Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "r/m8" mean when used in instruction encoding tables?

Tags:

x86

assembly

The ADD instruction documentation from this page has the following table with various encodings:

I believe that imm8 means an immediate value whose size is 8 bits (for example: BYTE 123).

And I believe that r32 means a register whose size is 32 bits (for example: EAX)

But what does r/m8 mean? Does it mean that I can use a register whose size is 8 bits (for example: AL]) or a memory location whose size is 8 bits (for example: BYTE [myvar])?

like image 412
user247763 Avatar asked Jul 14 '17 00:07

user247763


People also ask

What is R m16?

a one-byte operand that is either the contents of a byte register (AL, BL, CL, DL, AH, BH, CH, DH), or a byte from memory. r/m16: a word register or memory operand used for instructions whose operand-size attribute is 16 bits.

How are instructions encoded?

Encoding of instruction must include opcode, operands & addressing information. Encoding: represent entire instruction as a binary value. number of bytes needed depends on how much information must be encoded.

Which one is the register in encoded instruction?

The spare/register field contains either an opcode extension or the register code for another operand (see /r above). The r/m field encodes which register is used.

What SIB byte refers to?

Scaled indexed addressing mode uses the second byte (namely, SIB byte) that follows the MOD-REG-R/M byte in the instruction format. The MOD field still specifies the displacement size of zero, one, or four bytes.


1 Answers

That web page is a html conversion of the official intel documentation. You should read that instead, especially since it has a section 3.1.1.3 Instruction Column in the Opcode Summary Table which says:

r/m8 -- A byte operand that is either the contents of a byte general-purpose register (AL, CL, DL, BL, AH, CH, DH, BH, BPL, SPL, DIL and SIL) or a byte from memory. Byte registers R8L - R15L are available using REX.R in 64-bit mode.

So yes, it means what you said.

like image 66
Jester Avatar answered Oct 25 '22 21:10

Jester