Re: A86: interrupts
[Prev][Next][Index][Thread]
Re: A86: interrupts
Matt2000 wrote:
>
> >i see no reason for pushing & poping - there's nothing to be saved if
> >you disassemble the int handler. if you're using the built-in int
> >support then you CAN skip the calc's interrupt - at the end, do the
> >following:
> >
> >pop hl
> >exx
> >ex af,af'
> >reti
>
> I am trying to follow this discussion could someone elaborate on this? What
> is the difference between the built-in int and the calc's interrupt? Doing
> those four opcodes at the end would accomplish what, maybe restore all the
> registers before returning to the
> calling program? How to heck was that stack saved again? This is weird.
>
> -Matt
The interrupt itself is at 38h (I'm sure you knew that already :-) ;
what the interrupt does is load a checksum into $d2fd and then make a
call to $d2fe (the user interrupt routine). After it returns, somewhere
around 60h, it does alot of wacked out stuff with the ports. Whenever
you call, what you're actually doing is pushing the current program
counter to the stack and loading the program counter with the address
you pointed to (ex: call $d842). An rst instruction will also push pc
and in the same way; so will the interrupt. Now, when the user
interrupt executes, you have pc pushed onto the stack twice: the first
address on the stack is the one where the user routine was called from
the interrupt, the second one is the place of execution when the
interrupt occured. When you tell the cpu to pop hl, you are actually
popping pc into hl--the address to return to from the user routine--and
throwing it away. When the reti executes, a different address will be
loaded into the program counter: the original address from where 38h was
called. This way, you can still use the interrupt, but skip all the
stuff that the ROM does with the ports and thus speed up applications
using it.
Not a terrible explanation, I hope? :-)
References: