[A83] Re: Calculator power-off woes
[Prev][Next][Index][Thread]
[A83] Re: Calculator power-off woes
> turnoff:
> res pwrflag
> ex af,af'
> exx
> push af
> ld a,01h
> ei
> out (03h),a
> halt ; Don't you feel that this instruction shouldn't be in the interrupt routine?
> di
> pop af
> exx
> ex af,af'
>
What halt does is waiting for an interrupt to occur. However, since you
put it in the middle of your interrupt routine, no IT's will be accepted.
EI in itself isn't enough to reactivate them, you must acknowledge that
you handled the IT by outting some values to port 3 and returning from it
using RETI:
Interrupt:
ex af,af'
exx
... ; your IT routine
ld a,8
out (3),a
ld a,15
out (3),a
exx
ex af,af'
ei
reti
If you want to arrive at a halt after your IT, you can do some tricks
with the return address, like this:
HaltLabel:
halt
jp OldValue ; This will be overwritten
...
Interrupt:
ex af,af'
exx
... ; your IT routine
; Here we assume that you want to go into halt after returning:
pop hl
ld (HaltLabel+2),hl ; the address we'll jump to after the halt:
continuing execution
ld hl,HaltLabel
push hl ; so RETI will jump to HaltLabel
ld a,8
out (3),a
ld a,15
out (3),a
exx
ex af,af'
ei
reti
This is just an idea, the details are up to you.
PG
--
http://www.fastmail.fm - The way an email service should be
Follow-Ups:
References: