com.s 440 B

1234567891011121314151617181920212223242526
  1. .define Com
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. ! This subroutine performs a one complement on
  8. ! a group of atmost 254 bytes (number in register Y).
  9. ! This group is on the top of the stack.
  10. Com:
  11. lda SP+1
  12. sta ADDR+1 ! address (highbyte) of first byte
  13. lda SP+2
  14. sta ADDR ! address (lowbyte) of first byte
  15. 1: dey
  16. lda (ADDR),y
  17. eor #0x0FF ! one complement
  18. sta (ADDR),y
  19. tya
  20. bne 1b ! do it n times
  21. rts