Im currently learning 8086 assembly at school, im using emu8086, i was playing around with some signed arithmetic and this occured.
if i use the SUB instruction to subtract 15(0FH) from -16(F0H) with the help of this code :
mov al,-16
sub al,15
i'll get-31 in 2s complement(E1H in hex), now the result isnt what im concerened about,im more concerned about the flags that were set after this operation, after this instruction the flags that were set were :
CF = 0
SF = 1
PF = 1
AF = 1
OF = 0
but if i do the subtraction operation with addition (ADD) instruction by typing the following code:
mov al,-16
add al,-15
i get the same result which is E1H but the flags that were set are different, the flags that were set after this arithmetic instruction are:
CF = 1
SF = 1
PF = 1
AF = 0
OF = 0(same with the sub instruction)
i understand why the flags are set because i did the arithmetic on paper myself,but what i dont understand is why the flags are different even though addition and subtraction are equivalent since if you want to subtract numbers, you can just add it this way : x-y= x+(-y) which in the end gives the same result.