exg2.s 488 B

12345678910111213141516171819202122232425262728
  1. .define Exg2
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. ! This subroutine exchanges two words on top of the stack.
  8. ! The top word of the stack is really in the AX registerpair.
  9. ! So this word is exchanged with the top of the real stack.
  10. Exg2:
  11. pha ! save A
  12. txa
  13. pha ! save X
  14. jsr Pop ! get top real stack
  15. stx EXG
  16. sta EXG+1 ! save top of real stack
  17. pla ! get X
  18. tax
  19. pla ! get A
  20. jsr Push ! push on real stack
  21. ldx EXG ! get new X
  22. lda EXG+1 ! get new A
  23. rts