Procedures

This is an example of making a procedure call, using caller-save to preserve registers. The only register being preserved is the X index register.

Calling Procedure Called Procedure
Push parameters on stack
Push X index register with pshx
jsr procedure
Use des to reserve space on stack for local variables
Use tsx to point X index register at base of new activation record
(get work done)
Use ins to get rid of locals
rts
pulx to retrieve old X index register
Use ins to remove parameters from stack

Access to parameters: calculate the offset from the x index register to the parameter, and use indexed addressing.