pro.s 733 B

123456789101112131415161718192021222324252627282930313233
  1. .define Pro
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. ! This routine is called at the entry of a procedure.
  8. ! It saves the localbase of the invoking procedure, and sets the
  9. ! new localbase to the present value of the stackpointer.
  10. ! It then initializes the second localbase by subtracting
  11. ! BASE from the real one.
  12. Pro:
  13. ldx LB ! get localbase (lowbyte)
  14. lda LB+1 ! get localbase (highbyte)
  15. jsr Push ! push localbase onto the stack
  16. ldx SP+2 ! get stackpointer (lowbyte)
  17. lda SP+1 ! get stackpointer (highbyte)
  18. stx LB ! new localbase (lowbyte)
  19. sta LB+1 ! new localbse (highbyte)
  20. tay
  21. txa
  22. sec
  23. sbc #BASE
  24. sta LBl ! second localbase (lowbyte)
  25. tya
  26. sbc #0
  27. sta LBl+1 ! second localbase (highbyte)
  28. rts