flat assembler
Message board for the users of flat assembler.
Index
> Tutorials and Examples > Newbie - Overflow Flag |
Author |
|
Tomasz Grysztar 02 Nov 2019, 18:51
As a fortunate coincidence, you can find this topic discussed in two of my recent videos.
I explained the basic ideas of the signed encoding and SF/OF in the part 6 of my ongoing x86 tutorial. And then I also started a new semi-advanced mini-series about using 2-adic numbers to explain these things in detail. There I derive some actual formulas for the value of OF after addition/subtraction operation. |
|||
02 Nov 2019, 18:51 |
|
SC0U7 02 Nov 2019, 19:50
Thank you Tomasz but if i am right then the reason why is Overflow flag set in 8bit register is fact the 128 in complement method not exist ? the last bit make a error for computer 8bit register then set OF. because for make OF on Zero it must be in range −128 and 127 right? Cuz my AL register cannot hold 128 then it only change it on EAX last byte 000DFF80 like 80 iam right? Thanks
|
|||
02 Nov 2019, 19:50 |
|
Tomasz Grysztar 02 Nov 2019, 19:58
In signed interpretation the highest bit is the sign bit. In this case you add two numbers that have the sign bit 0, so they are positive numbers, but the result has the highest bit 1 and therefore would be interpreted as negative number, even though the result of adding two positive numbers should also be positive. This discrepancy is an indication that an overflow occurred - the result of addition was too large to be correctly encoded as a positive number in 8 bits with sign bit.
|
|||
02 Nov 2019, 19:58 |
|
SC0U7 02 Nov 2019, 20:10
so when i try this
mov al,7fh mov cl,-1h add al,cl The Overflow Flag will be not set |
|||
02 Nov 2019, 20:10 |
|
Tomasz Grysztar 02 Nov 2019, 20:14
Yes. You can also see a similar example (-1 + 3) analyzed near the end of my aforementioned 2-adic video.
|
|||
02 Nov 2019, 20:14 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.