pub fn encode_instruction_16(
instr: &Instruction,
) -> Result<EncodedInstr, AsmError>Expand description
x86-16 (real mode) encoder.
In 16-bit mode the default operand size is 16 bits and the default
address size is 16 bits. The 0x66 prefix switches operand size to
32 bits, and 0x67 switches address size to 32 bits — the reverse
of 32-bit protected mode.
Implementation: reuse the 32-bit encoder (which handles push/pop/inc/dec
short forms, segment registers, etc.) and then toggle the 0x66 prefix:
- If
0x66is present → remove it (16-bit is now the default) - If
0x66is absent AND the instruction uses 32-bit GPRs → add it