3 ms·
Is an illegal opcode something that was intentionally added to the instruction set but was disabled by the manufacturer? Or is it a side effect of calling an u
by monkpit 3y ago
Is an illegal opcode something that was intentionally added to the instruction set but was disabled by the manufacturer?
Or is it a side effect of calling an undefined operation?
- zoky 3y agoIt can be both. Anything not officially defined in the spec is an illegal opcode. Intel had a couple of opcodes that were clearly supposed to have been functional, but didn’t make any sense to use—I believe one such opcode popped the code segment register, which would have effectively served as a “jump to random memory” instruction as it would run the next instruction per the IP register but in a totally different part of memory, so it didn’t make any sense to document it as there was no use for it. And they had at least one other instruction introduced as a copyright trap, which they obviously wouldn’t document. And there were a few more that were undocumented but were aliases of other instructions due to the way the 8086 handled bit masking.
- hota_mazi 3y agoYup, that's POP CS, 0x0f. Since it made no sense to use, it became the way 286 and later processors used to indicate multibyte opcodes. When a 286 is running the code, encountering a 0x0f means that the following opcode is multibyte, while on an 8088, all opcodes are single bytes.
- cesarb 3y ago> while on an 8088, all opcodes are single bytes. According to a recent article on undocumented 8086/8088 opcodes (https://www.righto.com/2023/07/undocumented-8086-instructions.html https://www.righto.com/2023/07/undocumented-8086-instruction...), there are some two-byte opcodes: "For most of the 8086 instructions, the first byte specifies the instruction. However, the 8086 has a few instructions where the second byte specifies the instruction: the reg field of the ModR/M byte provides an opcode extension that selects the instruction."
- daneel_w 3y agoThe latter. The instructions aren't disabled in the MOS 6502, but their function is unplanned and hence undocumented which is a better term.
- deleted 3y ago[deleted]