' | $F6 DIV lhs := lhs / rhs
' | $F7 MOD lhs := lhs // rhs
OvrDIV abs rhs,rhs WC, WZ ' Sets C if was negative
IF_Z mov lhs,#0
IF_Z jmp #CommonReturn
muxc :signBit,#1
abs lhs,lhs WC ' Sets C if was negative
IF_C xor :signBit,#1
mov acc,#0
mov :count,#1
:ShlLoop and rhs,:k_4000_0000 WZ,NR
IF_Z shl rhs,#1
IF_Z add :count,#1
IF_Z jmp #:ShlLoop
:SubLoop shl acc,#1
cmps lhs,rhs WC, WZ, NR
IF_AE sub lhs,rhs
IF_AE or acc,#1
shr rhs,#1
djnz :count,#:SubLoop
' acc = result
' lhs = remainder
shr opc,#1 WC, NR
IF_NC mov lhs,acc ' DIV
' If sign bit was set we need to negate back
shr :signBit,#1 WC, NR
IF_C neg lhs,lhs
jmp #CommonReturn
:k_4000_0000 long $4000_0000
The multiply is 32x32=64 and can be easily cut-back to 32x32=32 and becomes much simpler ( remove lhs:top and acc:top ). It doesn't have deterministic timing.
If this is for your MP3 decoding it may be worthwhile looking at a lookup table for the
multiplication. It doesn't have to be 2^64 entries ( although that's the fastest ) but
could be done by 'quarter squares'. That reduces the size of lookup quite considerably
but I cannot remember by how much; 2^33 ?
I cannot remember the details but it involves turning "ab = a(b²-a²)/(b+a) + a²" into
"ab = qs(a+b) - qs(a-b)" or something like that; a+b would give the lookup table size
of 2^33 as above. qs(n) = n²/4
deSilva,
I have read your tutorial and I apologize for having not commented on how informative it is. In fact, I am in the process of rereading it now, and I shall keep it in favorites!
Maybe you could post a link to it in your signature. That way it will get publicity even when your wrtting about something totally unrelated!
Thanks, Bambino! And a good hint, as I MOSTLY write something totally unrelated
Though assembly code should not be overemphasized. Alas, the full wisdom of this forum is not easy to tap. Reading between some lines, I have the impression that even the much adversized work of our WIKI writers is hardly known. When I read in it from time to time I am always astonished about its comprehensive and to the point information. Great work there!
Comments
The multiply is 32x32=64 and can be easily cut-back to 32x32=32 and becomes much simpler ( remove lhs:top and acc:top ). It doesn't have deterministic timing.
Post Edited (hippy) : 1/10/2008 3:09:13 PM GMT
multiplication. It doesn't have to be 2^64 entries ( although that's the fastest ) but
could be done by 'quarter squares'. That reduces the size of lookup quite considerably
but I cannot remember by how much; 2^33 ?
I cannot remember the details but it involves turning "ab = a(b²-a²)/(b+a) + a²" into
"ab = qs(a+b) - qs(a-b)" or something like that; a+b would give the lookup table size
of 2^33 as above. qs(n) = n²/4
Added : details here ... mathworld.wolfram.com/QuarterSquaresRule.html
You might get some mileage out of dropping down to 16x16, even lower. Although you'll
lose quality at least you may be able to go forward.
Post Edited (hippy) : 1/10/2008 4:02:18 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Like so: http://forums.parallax.com/showthread.php?p=668559
See also: Lighting a candle v. cursing the dark.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Michael Park
PS, BTW, and FYI:
To search the forum, use search.parallax.com (do not use the Search button).
Check out the Propeller Wiki: propeller.wikispaces.com/
I have read your tutorial and I apologize for having not commented on how informative it is. In fact, I am in the process of rereading it now, and I shall keep it in favorites!
Maybe you could post a link to it in your signature. That way it will get publicity even when your wrtting about something totally unrelated!
Though assembly code should not be overemphasized. Alas, the full wisdom of this forum is not easy to tap. Reading between some lines, I have the impression that even the much adversized work of our WIKI writers is hardly known. When I read in it from time to time I am always astonished about its comprehensive and to the point information. Great work there!