home | |||
links |
|
||
developer's mag main page article part 1 part 2 part 3 part 4 part 5 part 6 part 7 part 8 part 9 |
3 - Skeletal ViewIncluding any necessary register pushing and popping, a typical full function framework could look like this:push rp ; r8->stack & increment rptr to point to r9 push rp ; r9->stack & increment rptr push rp ; r10->stack... push rp ; r11->stack push rp ; r12->stack push rp ; r13->stack push rp ; r14->stack ldc -100 ; set aside local storage - we need 100 bytes add sp ; decrease stack pointer value mov t,sp ; and move it back ... do function's work ldc 100 ; reclaim our stack space add sp mov t,sp rptr r14 ; explicitly state the first reg to pop pop rp ; stack->r14, and rptr is decremented to point to r13 pop rp ; stack->r13, etc. pop rp ; ...and so on pop rp pop rp pop rp pop rpOf course, you can avoid the pushing and popping if you don't plan to overwrite any of these registers, and the amount of local space needed (here 100 bytes) will vary. Time to Return The side effects of rts are particularly interesting:
Previous Section Next Section |
||
Copyright © 2001-2006 ebmDevMag.com - Legal Notice |