adi.s 482 B

123456789101112131415161718192021222324252627
  1. .define Adi2
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. ! This subroutine adds two twobyte integers.
  8. ! The first operand is on the top of the stack, the second operand
  9. ! is in the AX registerpair.
  10. ! The result is returned in registerpair AX.
  11. Adi2:
  12. sta ARTH+1 ! second operand (highbyte)
  13. stx ARTH ! second operand (lowbyte)
  14. jsr Pop ! get first operand
  15. pha ! save A
  16. clc
  17. txa
  18. adc ARTH ! add lowbytes
  19. tax
  20. pla ! get A
  21. adc ARTH+1 ! add the highbytes
  22. rts