programming tools for Windows applications development
  Home  |   SwiftForth Archive  |   SwiftX Archive  |

Re: Binary question

From: Rick VanNorman <rvn_at_forth.com>
Date: Mon, 08 May 2000 08:53:36 -0700

>From: "Michael Kemper" <mikek_at_metretek.com>
>
>Rick,
>I was coding a crc algorithm and ran across this peculiarity. It may be
>normal operation, but seems inconsistant to me:
>
>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
>which is what I'd expect from both versions. Both versions bring the sign
>bit into the result, but the first rounds the result, which I wouldn't
>expect from the standard "/" word. Is this normal?

Mike,

My expectations are the same as yours, and I was very surprised to find
the results you cite. Here is the quote straight from Intel's pentium
instruction reference for the IDIV instruction:

<quote>

Non-integral results are truncated (chopped) towards 0. The sign of
the remainder is always the same as the sign of the dividend.
The absolute value of the remainder is always less than the
absolute value of the divisor. Overflow is indicated with
the #DE (divide error) exception rather than with the OF (overflow) flag.

</quote>

I use the IDIV instruction in / so it will (should) behave like this.
Consider if the "truncated (chopped) towards 0" is implemented in
hardware without consideration for the sign bit. This would produce
the exact result we are seeing.

I don't know what the correct answer is. Can anyone run this on
another 32-bit Forth and report the results?

Thanks,

Rick

.
Received on Mon May 08 2000 - 08:53:36 PDT

This archive was generated by hypermail 2.2.0 : Thu Nov 20 2008 - 03:04:28 PST