dlyons@Apple.COM (David A. Lyons) (08/01/90)
In article <1990Jul31.184844.10094@laguna.ccsf.caltech.edu> toddpw@tybalt.caltech.edu (Todd P. Whitesel) writes: >A simpler way to test for emulation mode is > > clc > xce ;force native mode temporarily > php ;save the old e bit which is now in c > xce ;restore old e bit, carry is cleared > plp ;and get it back into the carry > bcc is_native > bcs is_emulation > >Unless I grossly misunderstand the stack effects of mode-switching, this >routine should work under ANY conditions. However, there could be side effects >if we are in emulation mode and the stack pointer is $100 -- namely, the >interrupt info clobbers the top of zero page. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ What? Yeah, if your stack pointer is $100 that's Not Good. If you just meant the stack = $1xx, that's no problem, because switching to NATIVE mode doesn't fiddle with the stack pointer. (If you were switching to emulation from native & the stack was not already in $01xx, *then* there would be problems.) -- David A. Lyons, Apple Computer, Inc. | DAL Systems Apple II Developer Technical Support | P.O. Box 875 America Online: Dave Lyons | Cupertino, CA 95015-0875 GEnie: D.LYONS2 or DAVE.LYONS CompuServe: 72177,3233 Internet/BITNET: dlyons@apple.com UUCP: ...!ames!apple!dlyons My opinions are my own, not Apple's.
toddpw@tybalt.caltech.edu (Todd P. Whitesel) (08/02/90)
dlyons@Apple.COM (David A. Lyons) writes: [ about some code I posted ] >What? Yeah, if your stack pointer is $100 that's Not Good. Actually, what I meant to point out was that in emulation mode the stack is supposed to wrap around (if that ever happens; I know the O/S tries to prevent it but it still can happen) and since the CPU just switched into native mode an interrupt would clobber the very top of zero page. >If you just meant the stack = $1xx, that's no problem, because switching to >NATIVE mode doesn't fiddle with the stack pointer. (If you were switching >to emulation from native & the stack was not already in $01xx, *then* there >would be problems.) This is all true; however my real point was that one should ALWAYS program for an interruptible environment. This means being careful about the stack & the P register flags -- and the second piece of code I posted neatly avoids all that because it doesn't do anything potentially dangerous. Todd Whitesel toddpw @ tybalt.caltech.edu