-2

Mostly asking about arithmetic operations.

Example:

Assume 32-bit hardware eax stores 0xff000000

If "sub al, 0x10" is called, do the higher bytes/bits change? Does it affect the whole register, or does it confine the operation to that subdivision?

Do other operations (add, sal, sar, etc.) have consistent whole/sub register interactions?

  • 3
    No, other bits are not affected. Yes, this is consistent except for 64 bit mode where 32 bit operations clear the top bits. – Jester Oct 11 '18 at 22:11
  • Kind of a duplicate of [Why do x86-64 instructions on 32-bit registers zero the upper part of the full 64-bit register?](https://stackoverflow.com/q/11177137). The question itself is the answer to this. Yeah, it actually quotes the part of the Intel manual that describes how writing to AX, AH, and AL work, so I'm going to close this as a dup. – Peter Cordes Oct 11 '18 at 23:54

1 Answers1

0

you can actually read the documentation in the Intel manuals where it is described that only the register parts that you addressed in your command will change.

Or you could perform a quick test on your own using a debugger (for example WinDbg Preview if you are using Windows).

As you can see from the figure below after executing sub al, 0x10 (via the trace t command), the eax register will be 0xff0000f0 (via the dump register command r). The flags are updated accordingly to the change of the specific lower part of the register (eg. carry from nc to cy).

Modification of al will not affect eax

Hope this helps. Regards, Ronald

Ronald Rink 'd-fens'
  • 1,289
  • 1
  • 10
  • 27