From 80a5fe182aa7af429e5a8c37e2553c36ae274e86 Mon Sep 17 00:00:00 2001 From: cuz Date: Wed, 15 Jan 2003 17:19:12 +0000 Subject: [PATCH] Keep unknown flag bits, restore known flags on exit git-svn-id: svn://svn.cc65.org/cc65/trunk@1901 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- libsrc/common/_sys.s | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/libsrc/common/_sys.s b/libsrc/common/_sys.s index 09856b9bf..0698ae42e 100644 --- a/libsrc/common/_sys.s +++ b/libsrc/common/_sys.s @@ -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 - dey - lda (ptr1),y - and #%11001111 ; Mask out break and unused flag - pha + 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 + 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