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