32-bit registers in addressing modes in 64-bit assembly not allowed?

153 Views Asked by At

What is wrong with the following instruction:

movb $0xF, (%ebx)

The answer states that %ebx cannot be used as an address register. I am new to assembly so can someone explain what this means?

If the instruction was movb $0xF, (%rbx) would that have been valid? Also what exactly is an address register? Lastly, does writing brackets around a register directly refer to the memory location the register is pointing to?

1

There are 1 best solutions below

1
Margaret Bloom On

There's nothing wrong with movb $0xf, (%ebx)1.

Even in 64-bit mode it's fine per sè. Surely x32 programs won't mind using it and r/e/bx can be certainly used as a base register (in fact bx is one of the few original registers that could act as a base in 16-bit mode).

My advice is to find a better source for learning.


1 which is correctly assembled as 67 C6 03 0F in 64-bit and 16-bit mode and without the address-size override byte (67) in 32-bit mode.