Entry and Exit Code

The RS08 uses an overlapping system, rather than a stack, for memory allocation. The following listing illustrates correct entry and exit code use.

Listing: Entry and Exit Code Example


10: int f(int x) { 

0000 45 SHA 

0001 b700 STA __OVL_f_14__PSID_75300003 ------> entry code. Saves the 
SPC value. This only happens for non-leaf functions !

0003 42 SLA 

0004 b701 STA __OVL_f_14__PSID_75300003:1

11: g(&x);

0006 a600 LDA #__OVL_f_p0

0008 ad00 BSR PART_0_7(g)

12: return x;

000a 4e000f LDX __OVL_f_p1 --------> stores the return value

000d 4e000e MOV __OVL_f_p0,D[X]

0010 2f INCX 

0011 4e010e MOV __OVL_f_p0:1,D[X]

0014 b600 LDA __OVL_f_14__PSID_75300003 -----> restore SPC. This only 
happens for non-leaf functions !

0016 45 SHA 

0017 b601 LDA __OVL_f_14__PSID_75300003:1

0019 42 SLA 

13: }

001a be RTS