GO-V.ORG
As seen in

ModR/M

The ModR/M byte is an important part of instruction encoding for the x86 instruction set.[src]

The ModR/M byte is an important part of instruction encoding for the x86 instruction set.[src] ==Description== Opcodes in x86 are generally one-byte, though two-byte instructions and prefixes exist.[src] ModR/M is a byte that, if required, follows the opcode and specifies zero, one, or two operands for the instruction.[src] The format is: The "reg" field, if specifying an operand, encodes the three least-significant bits of a register index.[src] Which register (general purpose, AVX, etc.) depends on the instruction being executed.[src] Instructions which take only one operand typically do not use this field, but instead repurpose the bits as an "opcode extension", allowing eight instructions to share a single opcode byte.[src] In opcode listings, these are specified by following the opcode with a slash ( ) and a digit 0–7.[src] For example, the opcode for byte increment is , while for byte decrement it is .[src] The "mod" field specifies the addressing mode for the register/memory ("r/m") operand.[src] If the "mod" field is 11 2 , the "r/m" field encodes a register in the same manner as the "reg" field.[src] However, if the "mod" field is anything else ( 00 2 , 01 2 , or 10 2 ), the "r/m" field specifies an addressing mode.[src] The interpretation of these five bits differs between 16- and 32-/64-bit addressing modes.[src] In 16-bit mode, the eight possible values of the "r/m" field specify a base register as follows: 000: [BX + SI + disp] 001: [BX + DI + disp] 010: [BP + SI + disp] 011: [BP + DI + disp] 100: [SI + disp] 101: [DI + disp] 110: [BP + disp] 111: [BX + disp] where "disp" is the displacement specified by the "mod" bits.[src] As a special exception, the combination , which would normally specify , instead specifies a 16-bit address [disp16] with no register base at all.[src] To address , one must use a 1-byte displacement ("disp8") form with a displacement of 0.[src] This results in the full set of combinations: In 32-bit mode, there are many differences.[src] First, the MOD=10 case specifies a 32-bit displacement (disp32).[src] Second, the R/M field specifies only a single base register, using the same encoding as the REG field.[src] There are two exceptions: Like in 16-bit mode, the [EBP + disp0] encoding is usurped for a bare disp32.[src] The [EBP+0] address must use the [EBP+disp8] encoding with disp8 set to 0.[src] Note, however, that in 32-bit mode, the encoding for this is MOD=00 R/M=101.[src] The encoding MOD≠11 R/M=100 does not specify [ESP] as a base as one would expect, but instead specifies an is present, and the resultant SCALE*INDEX+BASE value should be used to compute the address.[src] The combination MOD=00 R/M=100, which specifies a SIB byte with no displacement, has a similar special case if the base register is coded as 101 (EBP).[src] In that case, the base register is omitted but a word displacement is used, producing a [SCALE*INDEX+disp32] addressing mode.[src] ==SIB byte== The SIB byte is an optional post-opcode byte in x86 assembly on the i386 and later, used for complex addressing.[src] If present, it appears immediately after the ModR/M byte, before any displacements.[src] SIB bytes are formatted similarly to ModR/M bytes, and take the form of , where the SCALE is 1, 2, 4, or 8.[src] BASE and INDEX each encode a register.[src] The displacement is a constant offset, whose size is given by the MOD field as usual, which encoded after the SIB byte and added to the final address.[src] The general format is as follows: However, there are two exceptions: An INDEX of ESP is forbidden.[src] The encoding INDEX=100 denotes a zero index irrespective of the SCALE field.[src] Normally, an addressing mode without an index would simply use a bare ModR/M byte without a SIB byte at all, but this is necessary to encode an ESP-relative address ( [esp] / [esp+disp8/32] ).[src] When MOD=00 , a BASE of 101 which would specify EBP with zero displacement, instead specifies no base register and a 32-bit displacement.[src] If EBP with zero displacement is desired, it must be encoded using an 8-bit displacement value of 0.[src] This is analogous to the treatment of the case.[src] In 64-bit mode, is reassigned to encode RIP-relative addresses ( [rip+disp32] ), so an absolute address ( [disp32] ) must be encoded using a SIB byte with both of those exceptions.[src] If BASE=101 , the M bit in the REX prefix doesn't affect RIP-relative addressing since RIP-relative address calculation produces a 64-bit address.[src] For all the instructions that use VSIB, MIB or SIBMEM addressing, the SIB byte is mandatory - instruction encodings without the SIB byte will cause #UD (invalid instruction exception).[src] For VSIB addressing, the INDEX=100 case is not treated specially (it will cause xmm4/ymm4/zmm4 to be used as index register); other than that, the INDEX=100 and the special cases work for VSIB/MIB/SIBMEM addressing in the same way as for regular SIB addressing.[src] ==64-bit changes== AMD's 64-bit extension to the original instruction set make relatively few changes to 32-bit addressing, with the most significant being that in long mode, 64-bit addressing is the default.[src] 64-bit registers (RAX, RBX, RCX, etc.) are used rather than 32-bit registers for address computation.[src] The displacement is not widened to 64 bits; continues to specify a 32-bit displacement, which is sign-extended to 64 bits.[src] It may be changed with the address size override prefix , which changes to 32-bit addressing for the following instruction.[src] The second major addition is the REX prefix.[src] In long mode, opcodes whose highest four bits are 0100 (decimal 4) are a REX prefix, which provide an additional bit for each register field of the following instruction, doubling the number of available processor registers from eight to sixteen.[src] Specifically, the four low-order bits are: W: If set, the operation is performed on 64-bit operands.[src] R: Extends the REG field to 4 bits.[src] X: Extends the INDEX field of the SIB byte (if present) to 4 bits.[src] B: Extends the R/M field (or the SIB byte's BASE if ) to 4 bits.[src] There is one additional effect of a REX prefix: a REX prefix changes how byte registers are addressed.[src] Without a prefix, the available byte registers are AL/CL/DL/BL, then AH/CH/DH/BH.[src] When a REX prefix is present, even a REX prefix of , byte instructions consistently address the low byte of the corresponding word registers, so the available byte become AL/CL/DL/BL/SPL/BPL/SIL/DIL.[src] The third significant change is RIP-relative addressing.[src] The encoding, which specifies an absolute 32-bit address (with no base register) in 32-bit mode, specifies [RIP+disp32] in long mode.[src] With an address-size override prefix, this becomes [EIP+disp32] .[src] The absolute [disp32] mode may be obtained by using to force use of a SIB byte, followed by a SIB byte with BASE=101 and INDEX=100 .[src] For the special-case addressing encodings R/M=100 (to force a SIB byte), (substitute RIP+disp32), and (substitute disp32), the REX.B prefix is not considered.[src] These special-case encodings apply to registers R12 (binary 1100) and R13 (binary 1101) as well, and the same slightly longer encodings must be used.[src] This is because these exceptions change the encoded instruction size, so they must be decoded very quickly so that the following instruction may be located.[src] The special case where INDEX=100 suppresses the index register since scaling RSP is forbidden.[src] However, it does respect the REX.X bit, so it is possible to scale R12.[src] This is for two reasons: There is no alternative way to encode indexing with R12, so this would be a serious limitation, and The exception changes the computed address but not the encoded instruction size, so there is more time in the instruction pipeline to resolve the special case.[src] ==See also== x86 instruction listings ==Notes== ==References==[src]

64 sentences · 64 cited inline · 0 references stored

References

No reference rows published for this article.

Cite this article

MLA

"ModR/M." encyclopegia.org, 2026, https://encyclopegia.org/wiki/modr-m. Accessed 04 December 2026.

Chicago

"ModR/M." encyclopegia.org. Accessed December 4, 2026. https://encyclopegia.org/wiki/modr-m.

APA

encyclopegia.org. (2026). ModR/M. Retrieved December 4, 2026, from https://encyclopegia.org/wiki/modr-m

Accessed December 4, 2026 · CC BY-SA 4.0 · citation page · JSON

CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1345505237 · 0.5 · snapshot enwiki-001345505237

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools
  • Careers — open roles: frontier engineers and sales partners
  • Index — every corpus, paper and record
  • Estate guide — what a public data estate is
  • Founder — Lois-Kleinner Alpasan
  • Records — DOIs and external deposits
  • Documents — one-pagers, PDFs and QR codes
  • Brand kit — logos and share images
  • Papers — plain-language briefs with citations
  • Browser — search engine, PWA and bookmarklet
  • Anticloud — the operator and its projects

As seen in Business Insider · 336 outlets · evidence DOIs · plain-language papers

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.