xor.s 710 B

1234567891011121314151617181920212223242526272829303132333435
  1. .define Xor
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. ! This subroutine performs the exclusive or on two groups of bytes.
  8. ! The groups consists of atmost 254 bytes.
  9. ! The result is on top of the stack.
  10. Xor:
  11. lda SP+1
  12. sta ADDR+1 ! address of first group (lowbyte)
  13. lda SP+2
  14. sta ADDR ! address of first group (highbyte)
  15. clc
  16. tya
  17. adc SP+2
  18. sta SP+2 ! new stackpointer (lowbyte)
  19. sta ADDR+2 ! address of second group (lowbyte)
  20. lda #0
  21. adc SP+1
  22. sta SP+1 ! new stackpointer (highbyte)
  23. sta ADDR+3 ! address of second group (highbyte)
  24. 1: dey
  25. lda (ADDR),y ! get byte first group
  26. eor (ADDR+2),y ! exclusive or with byte second group
  27. sta (ADDR+2),y ! restore result
  28. tya
  29. bne 1b
  30. rts