| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| Assembly Questions and Answers for Assembly here! |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Carry Flag
Hello CodeGurus.
I am reading "Assembly Language for Intel-Based Computers" by Kip R. Irvine. Section 4.2.6.2 is about the Carry Flag (CF). It says if we subtract an integer from a smaller integer, the CF will be set. This is true when I run, for example... Code:
.data val1 BYTE 1 val2 BYTE 2 .code mov al, val1 sub al, val2 ; CF = 1 SF = 1 Code:
Carry
0000 0001 1
1111 1110 -2
1111 1111 which is -1 in 2's complement form.
Thanks, Dave |
|
#2
|
|||
|
|||
|
Re: Carry Flag
Hi, Dave.
Your doing a 1+ ( NEG 2 ) operation on 'paper' which will only set the sign flag in computer flags terms, even though you get the exact same result as SUB 1, 2 I have written a little utility which gives you a visual look at what happens to registers and flags during logical and arithmatic operations. If you're interested, take a look at my cCalc program, attached. -Sevag K. |
|
#3
|
|||
|
|||
|
Re: Carry Flag
Let me clarify the previous post a little bit.
Rules for Binary Subtraction: 0 - 0 = 0 1 - 0 = 1 1 - 1 = 0 0 - 1 = 1 w/borrow 0000 0001 0000 0010 -------------- 1111 1111 |
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|