AMD64 (aka x86-64 or x64) registers can be accessed 8, 16, 32 or 64 bits at a time. When reading a disassembly listing, what register operations are not straightforward?

For example, when an instruction accesses part of a register, how does it affect other parts?

What typical instructions or sequences of instructions used by optimizers might encode something that isn't obvious (e.g. xoring a register with itself to set it to zero)?

  • 1
    This question is far too broad. It will lead to a list of anecdotes rather than full answers. It should be far more focused, at the very least restricted to a particular topic and preferably to a particular compiler or platform (e.g. stack manipulations in Visual C++). Because there has already been one answer, I've proposed an edit that focuses on that answer's topic: register manipulations. Commented Mar 21, 2013 at 10:08
  • Thanks for the edit @Gilles. I knew the question was too broad when I asked it but I couldn't rephrase it in a way that still communicated what I wanted.
    – Modoc
    Commented Mar 21, 2013 at 11:39
  • I hope the question still approaches what you're interested it. I do encourage you to ask a separate question about stack manipulations with VC++, I'd have edited this question to focus on that but I thought it would me more useful to accommodate the existing answer. Commented Mar 21, 2013 at 13:03

1 Answer 1


Not really an optimization, but one gotcha that you must be aware of when coming from x86 is this:

Any operation on a 32-bit register zeroes out the top half of the 64-bit one

For example, the following:

mov eax, 3

Is actually equivalent to:

mov rax, 3

This also applies to the new registers r8-r15, e.g.:

inc r8d

also zeroes out the top half of r8.

However, the 8-bit and 16-bit portions of registers do not work like that, i.e. operations on them modify only that part of the register.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.