sbi4.s 499 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. .define .sbi4
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. ! Subtract two 32 bits signed or unsigned integers.
  8. ! Expects operands on stack
  9. ! Yields result on stack
  10. .sbi4:
  11. pop h
  12. shld .retadr
  13. mov h,b
  14. mov l,c
  15. shld .bcreg
  16. lxi h,0
  17. dad sp !now hl points to the first operand
  18. mov d,h
  19. mov e,l
  20. inx d
  21. inx d
  22. inx d
  23. inx d !and de points to the second.
  24. mvi b,4
  25. xra a
  26. 1: ldax d
  27. sbb m
  28. stax d
  29. inx d
  30. inx h
  31. dcr b
  32. jnz 1b
  33. sphl
  34. lhld .bcreg
  35. mov b,h
  36. mov c,l
  37. lhld .retadr
  38. pchl