twos complement and the CF (carry flag)
- From: "LuB" <lutherbaker@xxxxxxxxx>
- Date: 29 Jan 2007 08:32:30 -0800
I am a newbie ... self-studying Kip Irvine's 4th edition assembly
book. I may have mistyped an example program into my compiler - but
assuming not ...
I've got a basic handle on binary numbers and twos complement notation
- but I have a question about the CARRY FLAG.
Since the CF is really only relevant for unsigned operations ??? I
assume it looks at each transaction as though it were being carried
out on unsigned values.
So, since "sub" is implemented as adding the twos complement, why does
the CF=1 (carry flag get set to 1) when subtracting 90h from 80h and
not when adding 70h to 80h?
Aren't they the same from an unsigned perspective? Nothing gets
carried ... what is the CPU doing when subtracting 90h from 80h that
it knows to mark the CF=1?
80h + 70h = F0h, CF=0
that is
1000 0000 + 0111 0000 = 1111 0000
but
80h - 90h = F0h, CF=1
that is
90h => 1001 0000 => 0110 1111 + 0000 0001 => 0111 0000
so
80h - 90h = 80h + 70h = F0h.
Why does the CARRY FLAG = 1?
Thanks in advance,
-Luher
.
- Follow-Ups:
- Re: twos complement and the CF (carry flag)
- From: Herbert Kleebauer
- Re: twos complement and the CF (carry flag)
- Prev by Date: Problems posting to CLAX...
- Next by Date: Re: Problems posting to CLAX...
- Previous by thread: Problems posting to CLAX...
- Next by thread: Re: twos complement and the CF (carry flag)
- Index(es):
Relevant Pages
|