View Single Post
Old 16 February 2018, 14:11   #155
Gorf
Registered User

 
Join Date: May 2017
Location: Munich/Bavaria
Posts: 1,137
Multiplication by a constant can be done very efficiently. So if you know by what factor you are going to multiply, you could use one of these tricks:

multiply d0 by 29:

Code:
move.l  d0, d1
lsl.l   #4, d0
sub.l   d1, d0
add.l   d0, d0
sub.l   d1, d0
multiply d0 by 625:

Code:
move.l  d0, d1
lsl.l   #2, d0
add.l   d1, d0
lsl.l   #3, d0
sub.l   d1, d0
lsl.l   #4, d0
add.l   d1, d0
multiply d0 by 156:

Code:
move.l  d0, d1
lsl.l   #2, d1
add.l   d1, d0
lsl.l   #5, d0
sub.l   d1, d0
Gorf is offline  
 
Page generated in 0.04290 seconds with 11 queries