[A83] Re: IY and the interrupts
[Prev][Next][Index][Thread]
[A83] Re: IY and the interrupts
> Van: David Phillips <david@acz.org>
>
> > Van: Joe Pemberton <dArkSk8eR@buffbody.com>
> >
> > I know the interrupt mode 1 manipulates flags a lot. In my program, I
> > want to use the IY register as an index register to search through an
> > array (I'm already using the IX register for the same purpose). So
> > when I change the value of IY, do I have to disable the interrupts?
> > And what value do I need to set IY to when I finish using it?
>
> Yes. And a simple look at the registers in the VTI debugger will tell
you
> what to set it to.
No! :-p
use these include files (you have to translate them a bit to TASM).
You can now use all regs ("normal", "shadow" and IY).
If you only want a routine that 'wraps' for IY, and need some
assistance for making it, just ask.
[intwrap83.asm]
; Ti83 interrupt 'wrapper' - by Henk Poley
;---------------------------------------------------------------------------
--
; The z88dk makes extensively use of the shadow registers (EXX and EX
AF,AF)
; The Ti83 system interrupt doesn't preserve (any of) these regs and
; could thus crash your program. The workaround is to use this interrupt
; all the time, it saves and restores the (shadow-)registers for the
; system interrupt.
; We need the system interrupt when scanning keys (in an easy way), also
; some (other) ROM calls make use of the system interrupt. if the
interrupt
; is then not running, the calculator would crash.
;---------------------------------------------------------------------------
--
defc intcount = $878A ; 1 byte needed
INCLUDE "#int83.asm" ; Put interrupt loader here
; HL = $8789
inc hl ; We need to intialize variables
ld (hl),0 ; by ourself.
;
jr jump_over ; Jump over the interrupt code
;-----------------
; Actual interrupt
;-----------------
.IntProcStart
push af ;
ld a,(intcount) ; Check if own interrupt has quited
bit 7,a ; correctly, then bit 7 is zero
jr nz,int_fix ; If not zero, fix stack...
push hl ;
push de ;
push bc ;
push iy ;
ld iy,_IY_TABLE ;
ld hl,intcount ; If a 'direct interrupt' occures
set 7,(hl) ; right after the TIOS-int, then
; we want bit 7 to be set...
.exit_interrupt ;
exx ; Swap to shadow registers.
ex af,af ; So the TIOS swaps back to the
; normal ones... (the ones we saved
; with push/pops)
rst $38 ;
di ; 'BIG' HOLE HERE... (TIOS does ei...)
di ;
ex af,af ;
exx ;
;
ld hl,intcount ; Interrupt returned correctly, so
res 7,(hl) ; we reset our error-condition...
;
pop iy ;
pop bc ;
pop de ;
pop hl ;
pop af ;
ei ;
ret ;
.int_fix ;
pop af ; Pop AF back
ex af,af ; Fix shadowregs back
exx ;
pop bc ; Pop the returnpoint of RST $38
; from the stack
jr exit_interrupt ; Continue with interrupt
.IntProcEnd
.jump_over
[int83.asm]
; Memory usage in statvars:
; -------------------------------------------
; $858F / $85FF - 113 bytes - free
; $8600 / $8700 - 256 bytes - IV table
; $8701 / $8786 - 134 bytes - free
; $8787 / $8789 - 3 bytes - JP IntProcStart
; $878A - 1 byte - intcount <--
; $878B / $87A2 - 24 bytes - free
; -------------------------------------------
; Ti83 interrupt loader - by Henk Poley
; Based upon several sources, uses statvars to put the IV-table and JP
;---------------------------------------------------------------------------
--
; You only need to have an interrupt marked with IntProcStart
; at the beginning, since on the Ti83, programs stay where
; they are untill you quit. (you need to enable IM2 yourself)
;---------------------------------------------------------------------------
--
im 1 ;
res 6,(iy+9) ; stats not valid
ld a,$86 ; locate vector table at $8600-$8700
ld i,a ;
ld bc,$0100 ; vector table is 256 bytes
ld h,a ;
ld l,c ; HL = $8600
ld d,a ;
ld e,b ; DE = $8601
inc a ; A = $87
ld (hl),a ; interrupt "program" located at 8787h
ldir ;
;
ld l,a ; HL = $8787
ld (hl),$C3 ; Put a JP IntProcStart at $8787
inc hl ;
ld (hl),IntProcStart&$FF ;
inc hl ;
ld (hl),IntProcStart/256 ;
; Registers by now:
; -------------------------------------------
; A = $87
; HL = $8789
; DE = $8701
; BC = $0000
; F = carry flag is preserved
; -------------------------------------------
; Memory usage in statvars:
; -------------------------------------------
; $858F / $85FF - 113 bytes - free
; $8600 / $8700 - 256 bytes - IV table
; $8701 / $8786 - 134 bytes - free
; $8787 / $8789 - 3 bytes - JP IntProcStart
; $878A / $87A2 - 25 bytes - free
; -------------------------------------------
; See the interrupt routines themselves for
; further info of memory usage.