* The Midterm exam includes: Chapter 1,2,3, and Chapter 4 (Book: 4.1, 4.2 - Slides:to slide 40).
* If you don't have enough time to read book "Chapter 4", don't worry. Reading the Slides, and doing "assignment 4" are enough to cover last lecture.
* In the book, at the end of page 138 (pdf 109): Please correct the following sentence
"The Carry flag is exclusive ORed with the high bit of the result" ---> "The Carry out is exclusive ORed with the Carry in for the highest bit of the result"
Example:
mov al, 1
sub al, 128 ; al=1000 0001
In this example, the actual carry out= 0. However, the x86 processor invert this value and state the carry flag, then CF=1. Meanwhile, the Carry in of MSB=1 in the result of this operation.
Thus:
if it's Carry flag xor MSB: then 1 xor 1 =0 (Wrong)
if it's Carry out xor Carry In of MSB: then 0 xor 1= 1 (Correct)
How it comes?
0000 0001 0000 0001
-1000 0000 ->+0111 1111
+ 1
------------------------------------
1000 0001
CarryIn=1
CarryOut=0
Then CF=Inversion of CarryOut= 1
OF=CarryIn Xor Carryout=1
Add example:
0000 0001
+1111 1111
-----------------
0000 0000
CarryIn=1
CarryOut=1
Then CF=1, OF=0