> quicklinks

ti-92

ti-89
linux
how-to's
about us
links
projects
members
archive

quick links


ontic

tie
ultrapascal
 

o









   

> how-to's > memory / tsr

>> how to program a "TSR"

i can't say TSR, but a lot of people know this word, so I'll use this. first of all, look at the following graphic, it shows you, how the TI92 memory is divided

to create a TSR routine, you have to copy your routine to this "Fixed memory area". So, now we have to find the fixed memory area. At the moment I don't know where the fixed memory area starts, but when you search the first space from the top, then it works (see MXMLib). The top depends from the memory size. The top at 128Kb calculators is at 0x1ffff and on 256Kb at 0x3ffff. To find out, how much memory the calculator has, you have to check the bit 0 from the I/O port 0x600001. After this, the routine has to find the first empty space, because there could be some stuff (Fargo kernel for example!).
The second difficulty is that the TSR routine won't be reallocated, so you have to use relative branches and a pointer to the variables. You'll see an example below

; FindFixedMemoryArea
; Input     d0 Size of the TSR routine
; Output    a0 Pointer to the area
FindFixedMemoryArea:
   movem.l  d0-d7/a1-a6,-(a7)

   btst.b   #0,($600001)        ; How much memory?
   beq      \TI_with_256_KB
   move.l   #$1ffff,a0
   bra      \FindArea
\TI_with_256_KB:
   move.l   #$3ffff,a0

\FindArea:                      ; Overread some stuff
   tst.l    -(a0)
   bne      \FindArea

   suba.w   d0,a0
   movem.l  (a7)+,d0-d7/a1-a6
   rts


Now, I'll show you a TSR routine (relative branches, variables, ...)
; my_TSR_Routine
TSR_Routine_Start:
; Variables for the TSR routine
TSR_STUFF_LONG   dc.l 0
TSR_STUFF_WORD   dc.w 0
my_TSR_Routine:
   movem.l  d0-d7/a0-a6,-(a7)
   lea      TSR_STUFF_LONG(PC),a0
   add.l    #1,TSR_STUFF_LONG-TSR_STUFF_LONG(a0)
   cmpi.l   #5,TSR_STUFF_LONG-TSR_STUFF_LONG(a0)
   beq      #EndOfLoop
   add.w    #1,TSR_STUFF_WORD-TSR_STUFF_LONG(a0)
EndOfLoop:
   movem.l  (a7)+,d0-d7/a0-a6
   rte
TSR_Routine_End:

; Installing of a TSR
   move.w   #TSR_Routine_End-TSR_Routine_Start,d0
   bsr      FindFixedMemoryArea
   lea      TSR_Routine_Start(PC),a1
   move.w   #TSR_Routine_End-TSR_Routine_Start-1,d0
CopyTSR:
   move.b   (a1)+,(a0)+
   dbra.w   d0,CopyTSR
   ; Install the TSR (hook the interrupt!)
   ; ...

I hope this will help you!

 

powered by ticalc.org, levante.de, xoom.com, listbot.com, fastcounter.com
last update on 12.12.1999