Home > Enterprise >  Was there ever 8 bit memory addressing in the original 16-bit x86?
Was there ever 8 bit memory addressing in the original 16-bit x86?

Time:10-19

In real mode and 32-bit protected mode, 16-bit addressing is used to reference memory via the modrm byte. This addressing is only supported in i386 instructions with use of legacy prefixes, and entirely unsupported in x86-64 instructions.

However, the modrm byte is also used by the 8-bit specific opcodes, which makes me question if 8-bit addressing was present in the original 16-bit x86 instruction set. Although an 8-bit address is very limited, it'd be entirely possible to encode such an instruction in the same style of 16-bit instructions with a different opcode.

For example, instead of

add (bx, si), ax

you'd have

add (bl, dh), al

It's hard to find any pre-i386 documentation, so I'm in the dark. Was this ever supported?

CodePudding user response:

Only via XLAT, which effectively does mov al, [bx al] (which is not encodeable as a mov).

Modern 16-bit real mode uses the same machine-code format as 8086, that's what it means to be backwards compatible. (With only very minor differences, like that there's now an instruction-length limit of 15 bytes, vs. 8086 would happily fetch an unlimited number of prefixes, even if that meant wrapping around IP within a 64k segment full of rep prefixes.)

NASM x86 16-bit addressing modes lists all the ModRM modes: they only include 16-bit registers.

add [bx si], al is encodeable, add [bl dh], al isn't.

PDFs of 8086 manuals are available if you want to check historical documents. Also, Stephen Morse, the primary architect of 8086's ISA, wrote a book "The 8086/8088 primer", which is now available for free on his web site: https://stevemorse.org/8086/.

Earlier ancestors of 8086, like 8080 which only has 8-bit registers, are not x86 CPUs.

  • Related