0

I start to learn x86 64bit programming and I'm confused about a thing.

I know that numbers on 8 bits can have values in the range -128 to 127 for signed numbers and 0 to 255 for unsigned numbers, and numbers of 16 bits can have values in the range -32768 to 32767

Now my question: Let's say I have a register AX which is a 16bits register and AH which is 8 bits register. Now, what values should AX take such that the instruction neg AL to set the overflow flag to be 1 ? a) 8000h b)255 c)7FFFh d)0 e)FFFF f) -127

I know that I can put in AX register numbers between -32768 and 32767 but how AL register is modifying when I put a numbers in AX? For example, I write mov ax,-127 which is fine, how AL is modifying?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
DaniVaja
  • 211
  • 1
  • 7
  • 4
    `AL` is the low 8 bits of `AX`, and `AH` is the top 8 bits. `mov ax, -127` loads `0xff81` so `AL=0x81`. `NEG` will only set `OF` if `AL=-128=0x80` which means you can load `AX` with values of the form `0x??80` – Jester Feb 11 '21 at 13:41
  • None of the listed values matches that. You can verify with a debugger. – Jester Feb 11 '21 at 13:47
  • Did you mean `neg ah`, since you mentioned AH earlier in the sentence? – Peter Cordes Feb 11 '21 at 21:26

0 Answers0