News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

questions about extended precision operations

Started by nam78, May 30, 2005, 01:44:56 AM

Previous topic - Next topic

nam78

Hello Randall,

Please help! I don't understand how the code on extended precision division where the divisor
is greater than 32 bits works.
First, it seems to me that the dividend's value can be any value and the sole purpose of this
variable is to hold the quotient's value.
Second, I don't know how the code right after the "then" clause can ever execute. Because on
first entry into the "if" loop, Remainder is zero and Divisor is always greater than zero, the CMP instruction will set the CF, and control is transferred out of the "if" loop to "dec(ecx)". Thus, Remainder is always zero.
Despite of all this, I compiled the code and it worked, to my surprise.

My second question is about the algorithm on extended precision unsigned decimal output. (A small complain: uns128 must change its name for the code to complile).
First,I don't know how the "RecursivePutu128" outputs the WHOLE number. Because it seems to me that when this procedure outputs the very first H.O digit of the decimal number, it encounters the "end RecursivePutu128" directive and control gets out of this procedure.
Second, I wonder how the var object Remainder can manage to hold ALL the remainder produced ater ALL recursive call. After all, it is only a byte object and does not store the byte value it receives after each division anywhere at all.

One final wonder. you wrote that, I quote,
   "CallProc(I);
   If you pass I by value,  CallProc does not change the value of I, regardless of
   what happens to the parameter inside CallProc. "
I don't think I can agree. Consider the algorithm on extended precision unsigned decimal output,
"DivideBy10" must change "b128's value", and in this case it reduces b128's value 10 times after
each recursive call to RecursivePutu128. Hence my doubt.

Thank you.