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