Imagine it as a kind of analog clock. In a real clock the times "six fifty-five" (55) and "five to seven" (-5) are identical. It's just an issue of your definition, the clock itself doesn't know your definition and runs round and round and round... The same with the CPU. Look at the following "CPU-clock":
I've chosen a 4-bit-clock, but the principle is the same for every other group of bits (BYTE, WORD, DWORD etc.).
The carry flag will be set after the clock has jumped from 15 to 0. It is in this case a flag for unsigned overflow.
The overflow flag will be set after the clock has jumped from 7 to -8. It flags a signed overflow.
The sign flag flags a value which can be interpreted as a negative number.
The behavior of the flags is a little bit different, if you count downwards:
val2
is declared as aWORD
. Assuming this is for x86 (you haven't specified the CPU architecture), a word is 16 bits. So it's not a byte. Also, the value could be viewed as both signed and unsigned. Which way to choose to view it depends on the instructions you use. – Forebear