assemblyx86x86-64cpu-registersoperands

x86 assembly memory operands


Hello all I have a question relating to x86. In the Intel manual some instruction might take different types of memory operands. eg. IDIV r/m8 or IDIV r/m16 or IDIV r/m32 or IDIV r/m64 now they are all IDIV is there a possibility to know if the operand is m8, m16,m32 or m64? I was thinking if operand is m8 then it is addressed by an 8 bit register eg. ax if 32 then eax,esp... Is my assumption correct? Correct me if I'm wrong Any suggestions welcome Thanks


Solution

  • Yes, the register that is used as an operand resolves the ambiguity. (Note, however, that ax is a 16-bit register, not an 8-bit register -- that would be ah or al for the high or low byte, respectively.)

    If you're only referring to memory operands, you need to use a BYTE PTR, WORD PTR or DWORD PTR specifier to resolve the ambiguity, like this:

    mov dword ptr [eax], 0
    

    This example sets the 32-bit quantity ("double word") at the address contained in eax to 0.