[A83] Re: interrupt with shutdown
[Prev][Next][Index][Thread]
[A83] Re: interrupt with shutdown
A DI is good practice, because if your interrupt routine takes a long time
to run, another interrupt might be called before it's exited, and then it
will start again...going into a loop of sorts.
Michael Vincent
Detached Solutions - www.detacheds.com
Radical Software - www.radicalsoft.org
----- Original Message -----
From: "Tijl Coosemans" <tijl@ulyssis.org>
To: <assembly-83@lists.ticalc.org>
Sent: Sunday, December 09, 2001 7:16 AM
Subject: [A83] Re: interrupt with shutdown
>
> I just tested it out and a DI at the start of an interrupt routine is not
> necessary, at least not on the TI83-.
>
> I also changed a few things in your shutdown code. A short explanation...
>
> The apd counter should also be reset if you press 2nd+On.
>
> Then, what actually happens during the shutdown code is this. When you out
> 1 to port 3, that means you only enable on-key interrupts and disable all
> other sorts of interrupts, like the timer interrupt (the one at 120/130
> Hz). By outing 1 you also turn off the lcd. Then you enable interrupts
> (EI) and put the calc in low power mode waiting for an interrupt (HALT),
> which will be an on-key interrupt as since that's the only one we allowed.
> So when you turn the calc back on, an interrupt occurs and thus your
> interrupt routine is called. That interrupt returns to the address
> following the HALT, so that's the right place to put all sorts of things
> you want to do before giving all control back to the TIOS (e.g. display a
> welcome message). The RET after the HALT will return to the place where
> the original interrupt occured.
>
> Finally, at the end of your routine you had this code:
>
> 1: exx
> 2: ex af,af'
> 3: call $0038
> 4: ei
> 5: ret
>
> Lines 3,4,5 can be replaced by JP $0038, because the standard interrupt
> routine has an EI \ RET, so you don't have to repeat that. Then, you don't
> need to exchange the shadow registers, because the code at $0038
> immediately exchanges them back. All 5 lines can thus be replaced by:
>
> jp $003A
>
>
> Commented lines can be removed, others should remain.
>
>
> > From: "SUCKER from the old days" <sucker_pvn@hotmail.com>
> >
>
> [..code skipped..]
>
> > interrupt_start:
> > ;---------------
> >
>
> ; > di
>
> > ex af,af'
> > exx
> > ld a,($800A) ; check for apd
> > cp $11 ;
> > jr nc,resume ;
> > shutdown:
> > res shift2nd,(iy+shiftflags)
> > ld a,$74 ; reset apd counter
> > ld ($800A),a ;
>
> ; I'm not sure whether these two lines are necessary, but honestly I don't
> know.
> ; The docs say it turns the LCD ON and that's not what we want at this
> point.
>
> > ld a,8
> > out (3),a
>
> > ld a,1
> > out (3),a
>
> exx
> ex af,af'
>
> > ei
> > halt
>
>
> ; here you can put the code to ask a password.
>
> ret
>
> ; > ; here I forgot something
> ; > di
> ; > jr stop
>
> > resume:
> > bit shift2nd,(iy+shiftflags)
> > jr z,stop
> > in a,(3)
> > and 8
> > jr z,shutdown
> > stop:
>
> jp 003Ah
>
> ; > exx
> ; > ex af,af'
> ; > call $0038
> ; > ei
> ; > ret
>
> >
> >
> > ;------------
> > interrupt_end:
> >
> > text1: .db "Interrupt",0
> > text2: .db "Disabled",0
> > text3: .db "Enabled",0
> > prog: .db 6,"ZINT",0
> > current: .db 0
> > .end
> > END
>
>
>
>
References: