moddi.s 704 B

123456789101112131415161718192021222324252627282930
  1. |moddi3 routine copyright (C) 2002, Kevin Kofler
  2. |WARNING: Division by 0 will be handled the same way as in the unsigned variant.
  3. | For my __umoddi3, this means:
  4. | A division by 0 will not cause an exception, but just crash in an
  5. | infinite loop!
  6. .data
  7. xdef __moddi3
  8. .even
  9. __moddi3:
  10. tst.b 12(%a7)
  11. bge.s .L__moddi3_denom_positive
  12. neg.l 16(%a7)
  13. negx.l 12(%a7)
  14. .L__moddi3_denom_positive:
  15. tst.b 4(%a7)
  16. blt.s .L__moddi3_numer_negative
  17. .L__moddi3_umoddi3:
  18. jbra __umoddi3
  19. .L__moddi3_numer_negative:
  20. neg.l 8(%a7)
  21. negx.l 4(%a7)
  22. lea.l (.L__moddi3_return_jump+2,%PC),%a0
  23. move.l (%a7)+,(%a0)
  24. bsr.s .L__moddi3_umoddi3
  25. neg.l %d1
  26. negx.l %d0
  27. .L__moddi3_return_jump:
  28. jmp.l 0:l