Texas Instruments TI89 Developer Guide - Page 68
Calling Flash-ROM-Resident Routines, Assembly Language Programming Overview
![]() |
UPC - 033317198566
View all Texas Instruments TI89 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 68 highlights
26 6.4. Chapter 6: Assembly Language Programming Overview Besides register A7, you can use the remaining registers as needed. But, if you intend to call OS-resident routines or mix subroutines written in assembly language and C, you should adhere to the Sierra C™ register usage conventions. Registers D0, D1, D2, A0, and A1 are scratch registers. You do not need to save scratch register contents before using them. C uses register A6 as the subroutine parameter and stack-based variables frame pointer. Save and restore D3 - D7 and A2 - A6 whenever you use them in subroutines. The following example saves registers D3 - D5 and A2 - A3. movem.l d3-d5/a2-a3,-(sp) ; the assembler recognizes SP as ; an alternative to A7 Restore register values before returning from subroutine with: movem.l (sp)+,d3-d5/a2-a3 For memory and speed efficiency, your subroutines should only save and restore the registers you use. If you use only scratch registers, then you do not need to save any registers. Use the link and unlk instructions with register A6 to access subroutine parameters and to allocate temporary local variables. Sierra C expects function values to be returned in registers. Integer values are returned in D0. Pointer values are returned in A0. Calling Flash-ROM-Resident Routines Memory address 0xC8 contains a pointer to a table of OS routines and data structures. File tiams.inc contains jump table offsets which let you call OS routines from assembly language. For example, to call OS routine kbhit to determine if a key has been pressed on the keyboard: .include . . . move.l . . . move.l jsr tst.w "tiams.inc" 0xC8,a2 kbhit(a2),a0 (a0) d0 ; a2 -> jump table ; get address of kbhit routine ; call kbhit() ; zero = no keypress, nonzero = key waiting TI-89 / TI-92 Plus Developer Guide Not for Distribution Beta Version January 26, 2001
![](/manual_guide/products/texas-instruments-ti89-developer-guide-95b636f/68.png)