First page Back Continue Last page Overview Graphics
Passing Parameters on the Stack
Accessing parameters in the called subroutine:
tsx ;address in sp to x
leax 2,x ;point to first argument
ldd 0,x ;read data word off the stack
ldaa 2,x ;read data byte off the stack
After the call instruction on the previous slide is executed, the stack pointer points to the high byte of the return address. To point to the first byte of data, we add two to the address pointed to by the stack pointer in order to get past the return address.