Propeller manual pasm division
![pilot0315](https://forums.parallax.com/uploads/userpics/394/n1NU2QCNW74FC.jpg)
in Propeller 1
I am having issues with this code example. I cannot get the remainder and' ing and shifting as Dave at parallax advised. If I divide an even number all is good. An odd number does not work and I get gobbelygook.
Here is their code: page 380 of the propeller manual
' Divide x[31..0] by y[15..0] (y[16] must be 0)
' on exit, quotient is in x[15..0] and remainder is in x[31..16]
'
divide shl y,#15 'get divisor into y[30..15]
mov t,#16 'ready for 16 quotient bits
:loop cmpsub x,y wc 'y =< x? Subtract it, quotient bit in c
rcl x,#1 'rotate c into quotient, shift dividend
djnz t,#:loop 'loop until done
divide_ret ret 'quotient in x[15..0],
'remainder in x[31..16]
Here is their code: page 380 of the propeller manual
' Divide x[31..0] by y[15..0] (y[16] must be 0)
' on exit, quotient is in x[15..0] and remainder is in x[31..16]
'
divide shl y,#15 'get divisor into y[30..15]
mov t,#16 'ready for 16 quotient bits
:loop cmpsub x,y wc 'y =< x? Subtract it, quotient bit in c
rcl x,#1 'rotate c into quotient, shift dividend
djnz t,#:loop 'loop until done
divide_ret ret 'quotient in x[15..0],
'remainder in x[31..16]
Comments
It looks like the links in your signature are broken (maybe because of the n-th forum upgrade?).
Anyway, as an example the Prop Tools (Index) link is currently:
...and might need to be instead:
Hope you take this as a friendly observation. Always have valued your code, comments, and commitment to the Prop!
-joe
thanks to both
Here is a modified version that works for me on a Quickstartboard:
Andy
Any hope the forum moderators could to a global search and replace for these "showthread.php?t=" things?
I'm not even sure who to reach out for matters like that...
Believe me, I would love to have that capability because I HATE broken links.
I will post a version of it soon.