The whole flag thing is confusing the heck out of me. The definitions on the web seem really plain. I can't seem to get a really good applicable explanation to all this.
According to their definitions, - carry: indicates an unsigned integer overflow - overflow: indicates a signed integer overflow - zero: an operation produced zero - sign: operation produced a negative number
So how in the world are the following sentences true? - The following instructions will set the Sign flag: (The answer here is 252 not a negative number. So why is the sign flag set?)
mov al,0FEh
sub al,2
Adding 7Fh and 05h in an 8-bit register sets the Overflow flag.(The answer here is 132. It’s not above 255 so why is there an overflow?)
Adding 0FFh and 05h in an 8-bit register does not set the Overflow flag.(the answer is 300 so how is there not an overflow flag on? It’s above 256)
Adding 5 to 0FBh in an 8-bit register sets the Zero flag (The answer here is 256, not 0. I understand the 8 bit can only hold 255 but where does the “0” come from? I just don’t get it.)
Can someone please let me know what I'm doing wrong here and what the correct way to approach this is? Thanks.