Opcode prefix
In computing, an opcode prefix is a numeric value that alters the function of a following opcode.[1] On some instruction set architectures multiple opcode prefixes are allowed sequentially, with all combining to alter the subsequent opcode. The opcode prefix is a portion of a larger machine language instruction that specifies the operation to be performed.[2] In addition to the opcode, some instructions specify the operands the operation will act upon. Opcode prefixes may alter the number, size, or addressing mode of the operands. RISC processors do not use opcode prefixes. Types of prefixesOpcode prefixes generally fall into two categories:
Example opcode prefixesThe following is not intended to be an exhaustive list of opcode prefixes but instead shows how opcode prefixes have been used in various CPU instruction set architectures. MicrocontrollerThe National Semiconductor COP400 is an 4-bit microcontroller family introduced in 1977. It has 255 single-byte opcodes. It uses a 33H opcode prefix to enable an alternate set of 187 opcodes.[3] The National Semiconductor COP8 is an 8-bit microcontroller introduced in 1988. COP8 is an enhancement to National's earlier COP400. It uses an opcode prefix to alter its operands. Normally, absolute RAM addressing is only directly encoded for just four instructions: 8-bit microprocessorThe Zilog Z80 is an 8-bit microprocessor that was launched in 1976. It was designed to be backward software-compatible with the Intel 8080. It uses opcode prefixes to both alter its operands and to extend its instruction set. In order to access operands in its new IX and IY registers, 0xDD or 0xFE is prefixed to the old 8080 instructions, allowing those instructions to substitute IX or IY, respectively, for HL. In cases where (HL) is used, (IX+disp) and (IY+disp) addressing modes are substituted. 0xCB and 0xED enable new instructions not found on the 8080. Prefixes can be combined: The 0xDD or 0xFE IX/IY prefixes can prefix any 0xCB prefixed instruction that uses HL.[5] 16-bit microprocessorThe Intel 8086 and 8088 have three types of prefixes, all which can be combined[note 1] to alter some subsequent instructions.[6] Segment override: Normally the data segment (DS) is used for most data accesses and the stack segment (SS) is used for any accesses involving BP or SP. One-byte segment override prefixes are provided to substitute ES, CS, SS, or DS. Repeat: String instructions Lock: The 64-bit microprocessorAMD64 or x86-64 is a 64-bit extension of the x86 instruction set. It was announced in 1999 and first available in the AMD Opteron family in 2003. It introduced a REX opcode prefix that provides additional space for encoding 64-bit addressing modes and the additional eight integer registers present in the x86-64 architecture.[7][8] References
Notes
|