Re: A86: cphlde
[Prev][Next][Index][Thread]
Re: A86: cphlde
On Mon, 4 May 1998, Dux Gregis wrote:
> It doesn't matter what kind of numbers you're using: after you subtract,
> if de is greater than hl, the result is negative and the sign flag will
> be set.
Yes, it DOES matter what kind of numbers you're using. For example, $FF
is either -1 or 255, depending on whether or not you're using signed
math. Here are some 8-bit examples (I hope I did the math right):
hexadecimal signed decimal unsigned decimal
FE -2 254
-07 - 7 - 7
--- --- ----
F7 -9 247
In this case, the sign bit is set and the carry flag is clear.
hexadecimal signed decimal unsigned decimal
07 7 7
-FE --2 -254
--- --- ----
09 9 9
In this case, the sign bit is clear and the carry flag is set.
If your application uses signed numbers, you use the sign bit to determine
which operand is larger. If your application uses unsigned numbers, you
use the carry flag to determine which operand is larger.
--------
Dan Eble (mailto:eble@cis.ohio-state.edu)
(http://www.cis.ohio-state.edu/~eble)
"Behold, how great a matter a little fire kindleth!" -- James 3:5
Follow-Ups:
References: