the carry flag issue!
Posted
by Zia ur Rahman
on Stack Overflow
See other posts from Stack Overflow
or by Zia ur Rahman
Published on 2010-05-24T19:04:53Z
Indexed on
2010/05/24
19:21 UTC
Read the original article
Hit count: 566
assembly
|assemblyinfo
Suppose AX =FFFE and BX=1234
now if we write cmp ax,bx
(bx will be subtracted from ax and the approprite flages will be updated)
now the binary representation of the numbers in ax and bx is given by
AX = 1111 1111 1111 1110
BX= 0001 0010 0011 0100
As bx will be subtracted from ax so we have to negate bx (as Result= ax+(-bx))
so the negated bx (2's complement of bx ) is given by.
BX= 1110 1101 1100 1100
Now we add both ax and bx (as subtraction is implemented by addition in computer)
AX= 1111 1111 1111 1110
BX= 1110 1101 1100 1100
------------------------------------
1 1110 1101 1100 1010
Now as you can see the result is of 17 bits now the 17th bit should go into carry flage, but when i checked it the carry flag is 0 that is CF=0 why?
© Stack Overflow or respective owner