سؤال

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

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

  1. Whether the operand is m8, m16 or m32, the register used to address the memory location can be 8, 16 or 32 bits - all are valid afaik.

  2. To specify how many bits are to be read from memory, you need to use one of the size specifiers byte, word or dword before the address. For example:

idiv byte [bx] ; m8

idiv word [bx] ; m16

idiv dword [bx] ; m32

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top