Chapter 6: Assembly Language Programming Overview
Arguments are passed to OS-resident routines on the hardware stack. Use the C
declaration of an OS routine to determine the type and order of arguments
required by the routine. Arguments are pushed onto the hardware stack in
right-to-left order described by the routine's C prototype declaration.
For example, the program would call memcmp to compare two byte arrays. The
C prototype for memcmp is:
int memcmp(const void *s1, const void *s2, size_t count);
The Assembly language call is:
; if (memcmp(ID, myid, sizeof(myid)) == 0)
When you look at OS routine C prototypes, keep in mind the size and range of C
data types. In particular, note that int is two bytes in the AMS.
Type
char
unsigned char
short
unsigned short
int
unsigned int
long
unsigned long
pointer
6.5.
Subroutine Linkage
Use
link
to free stack space before returning from the subroutine. Use the
instruction to save and restore registers.
Example: subroutine linkage for subroutine mySubr with eight bytes of local
variables and two parameters.
TI-89 / TI-92 Plus Developer Guide
move.l
#5,-(sp)
pea
myid(a6)
pea
id(a6)
move.l
memcmp(a2),a0
jsr
(a0)
add.w
#12,sp
tst.w
d0
bne
notTheSame
Size (bytes)
1
1
2
2
2
2
4
4
4
Table 6.1: AMS C Data Types
to allocate space from the hardware stack for local variables. Use
Not for Distribution
; push size of myid
; push address of myid
; push address of ID
; get address of memcmp
; call memcmp
; pop arguments from stack
; test result from memcmp
; not equal --->
Range
L128
. . .
127
0
. . .
255
L32768
. . .
32767
0
. . .
65535
L32768
. . .
32767
0
. . .
65535
L2147483648
. . .
2147483647
0
. . .
4294967295
0
. . .
0xFFFFFFFF
27
unlk
movem.l
Beta Version January 26, 2001