medin@noscvax.UUCP (Ted Medin) (10/30/85)
card and have come to the conclusion that the areg is not preserved for the interupt code. Specifically when I get an interupt the areg is always an 8 or 18 hex. This makes it very difficult to return to the interupted code with the regs restored. Can someone out there confirm this architecture failure on the ][+ ??????
tommie@psivax.UUCP (Tom Levin) (11/01/85)
In article <76@noscvax.UUCP> medin@nosc (Ted Medin) writes: >card and have come to the conclusion that the areg is not preserved >for the interupt code. Specifically when I get an interupt the areg is >always an 8 or 18 hex. This makes it very difficult to return to the >interupted code with the regs restored. > Can someone out there confirm this architecture failure on the ][+ ?????? First off, the word interrupt has 2 r's. Now then, although I don't exactly understand your problem as stated, I will give you my knowledge on 6502 interrupts. NO REGISTERS ARE SAVED FOR YOU!!! Yes, you must save all of the registers yourself and restore them after the "rti" (return from interrupt) command. I don't consider this an architecture failure. later... -- __________________________________________________________________________ Tom Levin {ttidca|sdcrdcf|logico|scgvaxd|bellcore}!psivax!tommie You've seen those car stickers that say "Baby on Board"??? _________ I want one that says: / \ / Psychotic \ / On \ \ Board / \___________/
zben@umd5.UUCP (11/05/85)
In article <829@psivax.UUCP> tommie@psivax.UUCP (Tom Levin) writes: >In article <76@noscvax.UUCP> medin@nosc (Ted Medin) writes: >>... card and have come to the conclusion that the areg is not preserved >>for the interupt code. Specifically when I get an interupt the areg is >>always an 8 or 18 hex. This makes it very difficult to return to the >>interupted code with the regs restored. >> Can someone out there confirm this architecture failure on the ][+ ?????? >... I will give you my knowledge on >6502 interrupts. NO REGISTERS ARE SAVED FOR YOU!!! Yes, you must >save all of the registers yourself and restore them after the "rti" >(return from interrupt) command. The apple monitor saves the ACC in location $45 and then uses the ACC to decide whether the interrupt was an IO interrupt (in which case it wants to jump to the user vector) or a BRKPT interrupt (in which case it wants to jump to the monitor break routine). ******* IT NEVER RESTORES THE ACCUMULATOR FROM THIS USAGE ******* That is where the 18 or 8 is coming from - its the top of the stack, left shifted by three bits. The end of the interrupt code should look like: ... ... LDA $45 RTI or else the mainline code's accumulator gets trashed... -- Ben Cranston ...{seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben zben@umd2.ARPA
owen@rtp47.UUCP (Karl M. Owen) (11/05/85)
>> [...] have come to the conclusion that the areg is not preserved >> for the interupt code. Specifically when I get an interupt the areg is >> always an 8 or 18 hex. This makes it very difficult to return to the >> interupted code with the regs restored. >> >> [Ted Medin] > > NO REGISTERS ARE SAVED FOR YOU!!! Yes, you must > save all of the registers yourself and restore them after the "rti" > (return from interrupt) command. > > [Tom Levin] Just a little bit more info (with the caveat that I'm working from memory): When you take an interrupt, the X and Y regs are preserved, and the A reg is stored at (I believe) $45. What I generally do is immediately grab the A reg from $45 and push it, followed by X and Y. As I recall, the pc and status word are already on the stack when your interrupt handler takes over. If you need more detailed info (like what order the hi & lo pc and status word are in), mail me or post and I'll look it up. Hope it helps, Karl -- Karl M. Owen Data General, RTP, NC ...!seismo!mcnc!rti-sel!rtp47!owen
davel@hpvcla.UUCP (davel) (11/06/85)
In a II+ the monitor code that "catches" the interrupt uses the areg to determine if the interrupt is hardware or a break insruction, as a result the areg gets trashed. The good news is that before the above test is made the areg is saved in location $45. The bad news is that the areg does not get restored from $45 on an RTI, you have to restore areg with an LDA before the RTI. My disclaimer: I am reciting this info from memory, and it has been a while, so some of the nitty-gritty details may be incorrect. Dave Lowe hp-pcd!hpvcla!davel
collinge@uvicctr.UUCP (Doug Collinge) (11/06/85)
>In article <76@noscvax.UUCP> medin@nosc (Ted Medin) writes: >>Specifically when I get an interupt the areg is >>always an 8 or 18 hex. This makes it very difficult to return to the >>interupted code with the regs restored. In article <829@psivax.UUCP> tommie@psivax.UUCP (Tom Levin) writes: >NO REGISTERS ARE SAVED FOR YOU!!! Yes, you must >save all of the registers yourself and restore them after the "rti" >(return from interrupt) command. I don't consider this an architecture >failure. One more time, and one more time only... The Apple ROM kindly decodes break instructions from IRQ interrupts for you. In the process it has to wreck the Areg. Since it is going to store all registers in hardcoded locations anyway if it was a BRK it saves the Areg in location $45 before wrecking it. Therefore the minimum Apple interrupt handler is: IRQ = * LDA $45 RTI If you want to save regs: LDA $45 PHA TYA PHA TXA PHA * Do what you will here. PLA TAX PLA TAY PLA RTI Pushing the Areg on the stack is necessary if you want a reentrant interrupt handler. -- Doug Collinge School of Music, University of Victoria, PO Box 1700, Victoria, B.C., Canada, V8W 2Y2 decvax!nrl-css!uvicctr!collinge decvax!uw-beaver!uvicctr!collinge ubc-vision!uvicctr!collinge