xor.s 540 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. .define .xor
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. ! Any size exclusive-or.
  8. ! Expects: size in de-registers
  9. ! operands on stack
  10. ! Yields: result on stack
  11. .xor: pop h
  12. shld .retadr
  13. mov h,b
  14. mov l,c
  15. shld .bcreg
  16. lxi h,0
  17. dad sp
  18. mov c,l
  19. mov b,h !now bc points to top of first operand
  20. dad d !and hl points to top of second operand
  21. push h !this will be the new stackpointer
  22. 1: ldax b
  23. xra m
  24. mov m,a
  25. inx h
  26. inx b
  27. dcx d
  28. mov a,e
  29. ora d
  30. jnz 1b
  31. pop h
  32. sphl
  33. lhld .bcreg
  34. mov b,h
  35. mov c,l
  36. lhld .retadr
  37. pchl