addsub.s 642 B

1234567891011121314151617181920212223242526272829303132
  1. .define Addsub
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. ! This subroutine is used by the fourbyte addition and subtraction
  8. ! routines.
  9. ! It puts the address of the second operand into
  10. ! the zeropage locations ADDR and ADDR+1
  11. ! The address of the first operand is put into
  12. ! zeropage locations ADDR+2 and ADDR+3.
  13. Addsub:
  14. clc
  15. lda SP+2
  16. sta ADDR ! address of second operand (lowbyte)
  17. adc #4
  18. sta SP+2
  19. sta ADDR+2 ! address of first operand (lowbyte)
  20. lda SP+1
  21. sta ADDR+1 ! address of second operand (highbyte)
  22. adc #0
  23. sta ADDR+3 ! address of first operand (highbyte)
  24. sta SP+1
  25. ldy #0
  26. ldx #0x0FC ! do it 4 times
  27. rts