and.s 494 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. .define .and
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. ! auxiliary size 'and'
  8. ! parameters:
  9. ! de: size
  10. ! stack: operands
  11. ! stack: result (out)
  12. .and:
  13. pop ix ! save return address
  14. ld h,d
  15. ld l,e
  16. add hl,sp
  17. ex de,hl
  18. add hl,de ! now hl is the base of second
  19. ld b,d ! operand. bc and de are base
  20. ld c,e ! of the first operand
  21. 1:
  22. dec hl
  23. dec de
  24. ld a,(de)
  25. and (hl)
  26. ld (hl),a
  27. xor a
  28. sbc hl,bc
  29. jr z,2f
  30. add hl,bc
  31. jr 1b
  32. 2:
  33. ld h,b
  34. ld l,c
  35. ld sp,hl
  36. jp (ix)