At 09:06 AM 05/08/2000 -0700, you wrote:
>>If I do the following
>>$CEE1289A $100 / h.
>>>$FFCEE129
>>
>>but if I perform the following:
>>$CEE1289A 2/ 2/ 2/ 2/ 2/ 2/ 2/ 2/ h.
>>>$FFCEE128
>I don't know what the correct answer is. Can anyone run this on
>another 32-bit Forth and report the results?
>
>Thanks,
>
>Rick
Win32For:
$CEE1289A $100 / h. FFCEE128 ok
Gforth:
$CEE1289A $100 / hex u. FFCEE129 ok
It's getting interesting ;)
Win32For is in assembler; / uses /mod, and /mod is:
CODE /MOD ( n1 n2 -- rem quot )
pop ecx
mov eax, ecx
xor eax, ebx
jns short @@1
mov eax, ecx \ low order part to eax
mov ecx, edx \ save UP
cdq
idiv ebx
test edx, edx \ set zero flag
je short @@2
add edx, ebx \ add divisor to remainder
dec eax \ decrement quotient
jmp short @@2
@@1: mov eax, ecx \ low order part to eax
mov ecx, edx
cdq
idiv ebx
@@2: push edx
mov ebx, eax
mov edx, ecx \ restore UP
next c;
Gforth is in C, and / uses, as one would expect, the C division:
NAME("/")
{
DEF_CA
Cell n1;
Cell n2;
Cell n;
NEXT_P0;
n1 = (Cell) sp[1];
n2 = (Cell) TOS;
sp += 1;
{
n = n1/n2;
}
NEXT_P1;
TOS = (Cell)n;
NEXT_P2;
}
If you regard the numbers as signed, the Gforth/SwiftForth result is
correct. If they are unsigned, Win32For is correct.
$CEE1289A is -824104806
$FFCEE128 is -3219160
$FFCEE129 is -3219159
On a calculator:
-824104806 / 256 = -3219159.3984375
I don't know what the standard result should be.
Elko
-----------------------------------------------------------------------
I want to be a nothing-knower, Elko Tchernev
a little ant on any hill; etcher1_at_umbc.edu
for time is dead, the sun is over www.gl.umbc.edu/~etcher1
and there is nothing left to kill. tel/fax (410) 964 0593
.
Received on Mon May 08 2000 - 13:09:51 PDT
Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!
This archive was generated 09-Feb-2012. Archive updated nightly.