My name's David, I live in France and I'm very new registered in this place.
I used to own a Commodore 64 in the middle 80s and after at the start of 90s an Atari ST. So long long time ago (gosh I'm old).
I also used to exclusively play games on my good old Atari and now I feel like a late challenge to finally make something constructive.
I decided to start with the hardest : 68000 ASM
After a lot of weeks reading several docs I'm stuck with a problem : Fast muls and Divs.
I need your help
According to my doc a Muls is around 70 cycles to execute. Quite a lot. So I find (not me the author I read it somewhere) a solution using square tables.
So if I understood well the theory I wrote this portion of code making a signed a*b
Code: Select all
move.w d0,d2 ; 4
add.w d1,d0 ; 4 a+b
sub.w d1,d2 ; 4 a-b
add.w d0,d0 ; 4
add.w d2,d2 ; 4
move.w (a0,d0.w),d0 ; 14 (a+b)^2
sub.w (a0,d2.w),d0 ; 14 (a+b)^2-(a-b)^2
asr.w #2,d0 ; 10 /4
The problem is I can only muls two .BYTE to have a result in .W because the sqr table would be huge (?).
So for example if I want to muls two 12,4 numbers (12 bits integer, 4 bits decimal) I need to make two times this portion of code (+adding +swapping).
If I count well, it's a total of 58+58 cycles square tab method > 70 cycles of MULS instruction.
I have probably missed something as this square method meant faster. My math level is not very high so I request help
PS: Sorry, my english is weak.