Keep unknown flag bits, restore known flags on exit

git-svn-id: svn://svn.cc65.org/cc65/trunk@1901 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2003-01-15 17:19:12 +00:00
parent 2cb06ddf8e
commit 80a5fe182a

View File

@ -21,12 +21,21 @@ __sys: sta ptr1
lda (ptr1),y
sta jmpvec+1
; Get the flags, mask unnecessary bits and push them. Push a
; Remember the flags so we can restore them to a known state after calling the
; routine
php
; Get the flags, keep the state of bit 4 and 5 using the other flags from
; the flags value pased by the caller. Push the new flags and push A.
dey
lda (ptr1),y
and #%11001111 ; Mask out break and unused flag
pha
php
pla ; Current flags -> A
eor (ptr1),y
and #%00110000
eor (ptr1),y
pha ; Push new flags value
ldy #0
lda (ptr1),y
pha
@ -46,7 +55,7 @@ __sys: sta ptr1
plp
jsr jmpvec
; Back from the routine. Save the flags and a
; Back from the routine. Save the flags and A.
php
pha
@ -66,6 +75,10 @@ __sys: sta ptr1
pla
sta (ptr1),y
; Restore the old flags value
plp
; Done
rts