1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-23 19:29:37 +00:00

optimized the sei/cli pairing a bit.

This commit is contained in:
Marco van den Heuvel 2015-12-02 00:14:56 -08:00
parent 2e2f19ba79
commit 83c63a65c3
2 changed files with 28 additions and 30 deletions

View File

@ -64,7 +64,6 @@ window: .res 256 ; Memory "window"
; ;
INSTALL: INSTALL:
sei
ldx #0 ldx #0
stx ptr1 stx ptr1
ldx #$80 ldx #$80
@ -74,20 +73,22 @@ INSTALL:
stx STAVEC stx STAVEC
ldy #0 ldy #0
ldx #MMU_CFG_EXT_FROM ldx #MMU_CFG_EXT_FROM
sei
jsr FETCH jsr FETCH
tax tax
inx inx
txa txa
sta tmp1 sta tmp1
ldx #MMU_CFG_EXT_FROM ldx #MMU_CFG_EXT_FROM
sei
jsr STASH jsr STASH
ldx #MMU_CFG_EXT_FROM ldx #MMU_CFG_EXT_FROM
jsr FETCH jsr FETCH
cli
cmp tmp1 cmp tmp1
beq @ram_present beq @ram_present
lda #<EM_ERR_NO_DEVICE lda #<EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #>EM_ERR_NO_DEVICE
cli
rts rts
@ram_present: @ram_present:
@ -96,7 +97,6 @@ INSTALL:
stx curpage+1 ; Invalidate the current page stx curpage+1 ; Invalidate the current page
inx inx
txa ; A = X = EM_ERR_OK txa ; A = X = EM_ERR_OK
cli
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
@ -123,8 +123,7 @@ PAGECOUNT:
; by the driver. ; by the driver.
; ;
MAP: sei MAP: sta curpage
sta curpage
stx curpage+1 ; Remember the new page stx curpage+1 ; Remember the new page
clc clc
@ -135,6 +134,7 @@ MAP: sei
lda #<ptr1 lda #<ptr1
sta FETVEC sta FETVEC
sei
; Transfer one page ; Transfer one page
@ -146,9 +146,9 @@ MAP: sei
; Return the memory window ; Return the memory window
cli
lda #<window lda #<window
ldx #>window ; Return the window address ldx #>window ; Return the window address
cli
rts rts
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
@ -163,8 +163,7 @@ USE: sta curpage
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
; COMMIT: Commit changes in the memory window to extended storage. ; COMMIT: Commit changes in the memory window to extended storage.
COMMIT: sei COMMIT: lda curpage ; Get the current page
lda curpage ; Get the current page
ldx curpage+1 ldx curpage+1
bmi done ; Jump if no page mapped bmi done ; Jump if no page mapped
@ -176,6 +175,7 @@ COMMIT: sei
lda #<ptr1 lda #<ptr1
sta STAVEC sta STAVEC
sei
; Transfer one page. Y must be zero on entry ; Transfer one page. Y must be zero on entry
@ -184,11 +184,11 @@ COMMIT: sei
jsr STASH jsr STASH
iny iny
bne @L1 bne @L1
cli
; Done ; Done
done: cli done: rts
rts
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
; COPYFROM: Copy from extended into linear memory. A pointer to a structure ; COPYFROM: Copy from extended into linear memory. A pointer to a structure
@ -197,7 +197,6 @@ done: cli
; ;
COPYFROM: COPYFROM:
sei
sta ptr3 sta ptr3
stx ptr3+1 ; Save the passed em_copy pointer stx ptr3+1 ; Save the passed em_copy pointer
@ -228,6 +227,7 @@ COPYFROM:
; Copy full pages ; Copy full pages
ldy #$00 ldy #$00
sei
@L1: ldx #MMU_CFG_EXT_FROM @L1: ldx #MMU_CFG_EXT_FROM
jsr FETCH jsr FETCH
sta (ptr2),y sta (ptr2),y
@ -252,7 +252,6 @@ COPYFROM:
iny iny
dec tmp1 dec tmp1
bne @L3 bne @L3
; Done ; Done
@L4: cli @L4: cli
@ -264,8 +263,7 @@ COPYFROM:
; The function must not return anything. ; The function must not return anything.
; ;
COPYTO: sei COPYTO: sta ptr3
sta ptr3
stx ptr3+1 ; Save the passed em_copy pointer stx ptr3+1 ; Save the passed em_copy pointer
ldy #EM_COPY::OFFS ldy #EM_COPY::OFFS
@ -294,6 +292,7 @@ COPYTO: sei
; Copy full pages ; Copy full pages
sei
ldy #$00 ldy #$00
@L1: lda (ptr2),y @L1: lda (ptr2),y
ldx #MMU_CFG_EXT_FROM ldx #MMU_CFG_EXT_FROM

View File

@ -1,5 +1,5 @@
; ;
; Extended memory driver for the C128 Internal Function RAM. Driver works ; Extended memory driver for the C128 External Function RAM. Driver works
; without problems when statically linked. ; without problems when statically linked.
; ;
; Marco van den Heuvel, 2015-11-30 ; Marco van den Heuvel, 2015-11-30
@ -18,7 +18,7 @@
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
; Header. Includes jump table ; Header. Includes jump table
module_header _c128_ifnram_emd module_header _c128_efnram_emd
; Driver signature ; Driver signature
@ -64,7 +64,6 @@ window: .res 256 ; Memory "window"
; ;
INSTALL: INSTALL:
sei
ldx #0 ldx #0
stx ptr1 stx ptr1
ldx #$80 ldx #$80
@ -74,20 +73,22 @@ INSTALL:
stx STAVEC stx STAVEC
ldy #0 ldy #0
ldx #MMU_CFG_INT_FROM ldx #MMU_CFG_INT_FROM
sei
jsr FETCH jsr FETCH
tax tax
inx inx
txa txa
sta tmp1 sta tmp1
ldx #MMU_CFG_INT_FROM ldx #MMU_CFG_INT_FROM
sei
jsr STASH jsr STASH
ldx #MMU_CFG_INT_FROM ldx #MMU_CFG_INT_FROM
jsr FETCH jsr FETCH
cli
cmp tmp1 cmp tmp1
beq @ram_present beq @ram_present
lda #<EM_ERR_NO_DEVICE lda #<EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #>EM_ERR_NO_DEVICE
cli
rts rts
@ram_present: @ram_present:
@ -96,7 +97,6 @@ INSTALL:
stx curpage+1 ; Invalidate the current page stx curpage+1 ; Invalidate the current page
inx inx
txa ; A = X = EM_ERR_OK txa ; A = X = EM_ERR_OK
cli
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
@ -123,8 +123,7 @@ PAGECOUNT:
; by the driver. ; by the driver.
; ;
MAP: sei MAP: sta curpage
sta curpage
stx curpage+1 ; Remember the new page stx curpage+1 ; Remember the new page
clc clc
@ -135,6 +134,7 @@ MAP: sei
lda #<ptr1 lda #<ptr1
sta FETVEC sta FETVEC
sei
; Transfer one page ; Transfer one page
@ -146,9 +146,9 @@ MAP: sei
; Return the memory window ; Return the memory window
cli
lda #<window lda #<window
ldx #>window ; Return the window address ldx #>window ; Return the window address
cli
rts rts
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
@ -163,8 +163,7 @@ USE: sta curpage
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
; COMMIT: Commit changes in the memory window to extended storage. ; COMMIT: Commit changes in the memory window to extended storage.
COMMIT: sei COMMIT: lda curpage ; Get the current page
lda curpage ; Get the current page
ldx curpage+1 ldx curpage+1
bmi done ; Jump if no page mapped bmi done ; Jump if no page mapped
@ -176,6 +175,7 @@ COMMIT: sei
lda #<ptr1 lda #<ptr1
sta STAVEC sta STAVEC
sei
; Transfer one page. Y must be zero on entry ; Transfer one page. Y must be zero on entry
@ -184,11 +184,11 @@ COMMIT: sei
jsr STASH jsr STASH
iny iny
bne @L1 bne @L1
cli
; Done ; Done
done: cli done: rts
rts
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
; COPYFROM: Copy from extended into linear memory. A pointer to a structure ; COPYFROM: Copy from extended into linear memory. A pointer to a structure
@ -197,7 +197,6 @@ done: cli
; ;
COPYFROM: COPYFROM:
sei
sta ptr3 sta ptr3
stx ptr3+1 ; Save the passed em_copy pointer stx ptr3+1 ; Save the passed em_copy pointer
@ -228,6 +227,7 @@ COPYFROM:
; Copy full pages ; Copy full pages
ldy #$00 ldy #$00
sei
@L1: ldx #MMU_CFG_INT_FROM @L1: ldx #MMU_CFG_INT_FROM
jsr FETCH jsr FETCH
sta (ptr2),y sta (ptr2),y
@ -252,7 +252,6 @@ COPYFROM:
iny iny
dec tmp1 dec tmp1
bne @L3 bne @L3
; Done ; Done
@L4: cli @L4: cli
@ -264,8 +263,7 @@ COPYFROM:
; The function must not return anything. ; The function must not return anything.
; ;
COPYTO: sei COPYTO: sta ptr3
sta ptr3
stx ptr3+1 ; Save the passed em_copy pointer stx ptr3+1 ; Save the passed em_copy pointer
ldy #EM_COPY::OFFS ldy #EM_COPY::OFFS
@ -294,6 +292,7 @@ COPYTO: sei
; Copy full pages ; Copy full pages
sei
ldy #$00 ldy #$00
@L1: lda (ptr2),y @L1: lda (ptr2),y
ldx #MMU_CFG_INT_FROM ldx #MMU_CFG_INT_FROM