mulsi3.S 714 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ; SPDX-License-Identifier: GPL-2.0
  2. ;
  3. ; mulsi3 for H8/300H - based on Renesas SH implementation
  4. ;
  5. ; by Toshiyasu Morita
  6. ;
  7. ; Old code:
  8. ;
  9. ; 16b * 16b = 372 states (worst case)
  10. ; 32b * 32b = 724 states (worst case)
  11. ;
  12. ; New code:
  13. ;
  14. ; 16b * 16b = 48 states
  15. ; 16b * 32b = 72 states
  16. ; 32b * 32b = 92 states
  17. ;
  18. .global __mulsi3
  19. __mulsi3:
  20. mov.w r1,r2 ; ( 2 states) b * d
  21. mulxu r0,er2 ; (22 states)
  22. mov.w e0,r3 ; ( 2 states) a * d
  23. beq L_skip1 ; ( 4 states)
  24. mulxu r1,er3 ; (22 states)
  25. add.w r3,e2 ; ( 2 states)
  26. L_skip1:
  27. mov.w e1,r3 ; ( 2 states) c * b
  28. beq L_skip2 ; ( 4 states)
  29. mulxu r0,er3 ; (22 states)
  30. add.w r3,e2 ; ( 2 states)
  31. L_skip2:
  32. mov.l er2,er0 ; ( 2 states)
  33. rts ; (10 states)
  34. .end