I am taking an undergraduate class in assembly right now. I have some discrepancies with how the TA graded my assignment. I was only testing the status of the carry, zero, sign, and overflow flags.
Here is one of the status flag problems I got wrong:
mov ah, 255
mov al, -1
cmp ah, al
My Solutions: CF=0, ZF=1, SF=0, OF=0
His solutions: CF=0, ZF=0, SF=1, OF=1
Can someone please help me verify which is correct? I don't think mine are wrong but if they are can you explain what answer is correct?
Here's what I get running this on VC 2013 (caveat, 32 bit inline assembly in C++)
Before the 3 instructions, the flags are:
OV = 0 UP = 0 EI = 1 PL = 0 ZR = 0 AC = 0 PE = 0 CY = 0
After the 3 instructions
OV = 0 UP = 0 EI = 1 PL = 0 ZR = 1 AC = 0 PE = 1 CY = 0
Where the flags registers are as defined here
Interpreted as Parity Set, Carry not set, zero is set, sign is not set, overflow is not set.
Which seems to corroborate YOUR solution. The disassembly I get:
__asm {
mov ah, 255
00FC13CE mov ah,0FFh
mov al, -1
00FC13D0 mov al,0FFh
cmp ah, al
00FC13D2 cmp ah,al
}
My 8086 is terribly rusty, but FWIW:
mov
is done on the literals -1 (255) and 255 which wouldn't trigger overflow (no flags are set).255
and -1
in an 8 bit register.So I'm guessing the TA might have copy pasted the wrong answer somewhere?