mli2.s 365 B

12345678910111213141516171819202122232425262728293031323334
  1. .define .mli2
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. ! 16 bit multiply
  8. ! parameters:
  9. ! bc: multiplicand
  10. ! de: multiplier
  11. ! hl: result (out)
  12. ! multiplier (bc) is left unchanged
  13. ! no detection of overflow
  14. .mli2:
  15. ld hl,0
  16. ld a,16
  17. 0:
  18. bit 7,d
  19. jr z,1f
  20. add hl,bc
  21. 1:
  22. dec a
  23. jr z,2f
  24. ex de,hl
  25. add hl,hl
  26. ex de,hl
  27. add hl,hl
  28. jr 0b
  29. 2:
  30. ret