Path: utzoo!attcan!uunet!cs.utexas.edu!sdd.hp.com!usc!apple!agate!eos!data.nas.nasa.gov!mustang!nntp-server.caltech.edu!toddpw From: toddpw@nntp-server.caltech.edu (Todd P. Whitesel) Newsgroups: comp.sys.apple2 Subject: Re: relocatable code Message-ID: <1990Nov12.061128.4986@nntp-server.caltech.edu> Date: 12 Nov 90 06:11:28 GMT References: <90315.194340ART100@psuvm.psu.edu> Organization: California Institute of Technology, Pasadena Lines: 28 Apple has guaranteed that there will be an RTS at $ff58 in the ROMs. This routine does not need to be fixed and can find its own address: php sei jsr $ff58 tsx ldy $100,x dex lda $100,x plp now A has the hi byte and Y has the low byte of the address of the $ff in the jsr $ff58 (i.e. the address of the tsx, minus one). The php/sei and plp business is necessary to insure that: a) the return address is not overwritten by an interrupt occurence b) the interrupt state is restored to its previous value afterwards If you don't want to even rely on the ROMs then you can always store a $60 somewhere and JSR to it instead. If you're really paranoid, save the value at some location ($400?) on the stack and put a $60 there just before you jsr to it, and restore the value just before the plp instruction. Only NMI's, Resets, or your code being run from that location could conceivably break that. Todd Whitesel toddpw @ tybalt.caltech.edu