What did the 8086 (and 8088) do upon encountering an illegal instruction?Use of undocumented opcodesWhat conventions and language extensions did people use to program the 8086 and 80286?Why did the PDP-11 include a JMP instruction?What was the IBM PC cost saving for using the 8088 vs 8086?Did the Intel 8086/8088 not guarantee the value of SS:SP immediately after RESET?8086 pinout and address space limitHow to keep the instruction prefetcher filled upHow did the 8086 interface with the 8087 FPU coprocessor?SYNC and the 65CE02 instruction timingDid the IBM PC use the 8088's NMI line?Need circuit - manual step-by-step clock for 8086/8088
Are there any real life instances of aircraft aborting a landing to avoid a vehicle?
Joining matrices together
Did Bercow say he would have sent the EU extension-request letter himself, had Johnson not done so?
Why did quill pens persist until the early 19th century despite the capacity to make metal dip pens?
Why can't my custom camera body focus to far distances?
How to help my son improve without being discouraging?
Did the Byzantine Emperor Constantine XI will his titles to Ferdinand and Isabella of Spain?
Is exploit-free software possible?
Why is macOS limited to 1064 processes?
Why don't my appliances work when my tester shows voltage at the outlets?
Finding big cacti between Phoenix, Las Vegas, and Los Angeles
What would it take to slow down fermentation? (Specific: Wine / grape juice)
Can shadow pokémon be shiny?
Implementing simplified Jaipur board game
Uncooked peppers and garlic in olive oil fizzled when opened
What are the applications of the Mean Value Theorem?
What does this damaged inscription in a church say?
How to concatenate files found by the find command in bash
Why do some PCBs have the courtyard in the silkscreen layer?
Is velocity a valid measure of team and process improvement?
Right way to say I disagree with the design but ok I will do
Write a bot to play Grid Game
The falling broom handle
18-month-old kicked out of church nursery
What did the 8086 (and 8088) do upon encountering an illegal instruction?
Use of undocumented opcodesWhat conventions and language extensions did people use to program the 8086 and 80286?Why did the PDP-11 include a JMP instruction?What was the IBM PC cost saving for using the 8088 vs 8086?Did the Intel 8086/8088 not guarantee the value of SS:SP immediately after RESET?8086 pinout and address space limitHow to keep the instruction prefetcher filled upHow did the 8086 interface with the 8087 FPU coprocessor?SYNC and the 65CE02 instruction timingDid the IBM PC use the 8088's NMI line?Need circuit - manual step-by-step clock for 8086/8088
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
Preface: This question does in part intersect with Use of undocumented opcodes, but targets especially the 8086 instruction handling.
I was reading Tanenbaum's "Operating Systems, Design and Implementation" 3rd edition (The MINIX Book), where I encountered the following quote that surprised me:
For instance, the 8086 and 8088 processors do not support detection of illegal instruction operation codes, but this capability is available on the 286 and above, which trap on an attempt to execute an illegal opcode.
What did the 8086 and 8088 do when it an encountered an illegal instruction?
instruction-set 8086 8088
|
show 2 more comments
Preface: This question does in part intersect with Use of undocumented opcodes, but targets especially the 8086 instruction handling.
I was reading Tanenbaum's "Operating Systems, Design and Implementation" 3rd edition (The MINIX Book), where I encountered the following quote that surprised me:
For instance, the 8086 and 8088 processors do not support detection of illegal instruction operation codes, but this capability is available on the 286 and above, which trap on an attempt to execute an illegal opcode.
What did the 8086 and 8088 do when it an encountered an illegal instruction?
instruction-set 8086 8088
2
@StephenKitt I'd err on the side of not closing it if the questions themselves aren't identical; it's possible that there are answers to this one that wouldn't be answers to the others, and I know for sure that the other way around also applies.
– wizzwizz4♦
Jun 11 at 17:31
@StephenKitt Could you write up a Retrocomputing Meta question? You have a very good point, and I have a slightly-less-good rebuttal, but we really need to decide on this as a community.
– wizzwizz4♦
Jun 11 at 17:45
I keep wanting this question to be the lead line for a joke...
– Tim Holt
Jun 14 at 0:37
I just got it this for close review, and I have a hard time to decide. For one, it does tackle the issue for a specific CPU, while the other is more generic. But Stephen is as well right, both may trigger the same answers. But not due the way this one if phrased, but rather because the other is way to broad. Marking it as double would be good to target future readers toward the already given answers - better than copying. But then again, asking exactly for the 8086 is a question in its own right. No idea for a middle way, I vote leave open - maybe to incooperate the link into the question.
– Raffzahn
Jun 15 at 8:58
@StephenKitt After a bit rereading, I no longer see it as a duplicate, as the liked question is specific about undocumented opcodes and their usage in relation to documentes, while this is strictly about the 8086 and its handling.
– Raffzahn
Jun 15 at 9:30
|
show 2 more comments
Preface: This question does in part intersect with Use of undocumented opcodes, but targets especially the 8086 instruction handling.
I was reading Tanenbaum's "Operating Systems, Design and Implementation" 3rd edition (The MINIX Book), where I encountered the following quote that surprised me:
For instance, the 8086 and 8088 processors do not support detection of illegal instruction operation codes, but this capability is available on the 286 and above, which trap on an attempt to execute an illegal opcode.
What did the 8086 and 8088 do when it an encountered an illegal instruction?
instruction-set 8086 8088
Preface: This question does in part intersect with Use of undocumented opcodes, but targets especially the 8086 instruction handling.
I was reading Tanenbaum's "Operating Systems, Design and Implementation" 3rd edition (The MINIX Book), where I encountered the following quote that surprised me:
For instance, the 8086 and 8088 processors do not support detection of illegal instruction operation codes, but this capability is available on the 286 and above, which trap on an attempt to execute an illegal opcode.
What did the 8086 and 8088 do when it an encountered an illegal instruction?
instruction-set 8086 8088
instruction-set 8086 8088
edited Jun 15 at 9:29
Raffzahn
72.8k8 gold badges181 silver badges303 bronze badges
72.8k8 gold badges181 silver badges303 bronze badges
asked Jun 10 at 17:02
Joe DJoe D
3362 silver badges5 bronze badges
3362 silver badges5 bronze badges
2
@StephenKitt I'd err on the side of not closing it if the questions themselves aren't identical; it's possible that there are answers to this one that wouldn't be answers to the others, and I know for sure that the other way around also applies.
– wizzwizz4♦
Jun 11 at 17:31
@StephenKitt Could you write up a Retrocomputing Meta question? You have a very good point, and I have a slightly-less-good rebuttal, but we really need to decide on this as a community.
– wizzwizz4♦
Jun 11 at 17:45
I keep wanting this question to be the lead line for a joke...
– Tim Holt
Jun 14 at 0:37
I just got it this for close review, and I have a hard time to decide. For one, it does tackle the issue for a specific CPU, while the other is more generic. But Stephen is as well right, both may trigger the same answers. But not due the way this one if phrased, but rather because the other is way to broad. Marking it as double would be good to target future readers toward the already given answers - better than copying. But then again, asking exactly for the 8086 is a question in its own right. No idea for a middle way, I vote leave open - maybe to incooperate the link into the question.
– Raffzahn
Jun 15 at 8:58
@StephenKitt After a bit rereading, I no longer see it as a duplicate, as the liked question is specific about undocumented opcodes and their usage in relation to documentes, while this is strictly about the 8086 and its handling.
– Raffzahn
Jun 15 at 9:30
|
show 2 more comments
2
@StephenKitt I'd err on the side of not closing it if the questions themselves aren't identical; it's possible that there are answers to this one that wouldn't be answers to the others, and I know for sure that the other way around also applies.
– wizzwizz4♦
Jun 11 at 17:31
@StephenKitt Could you write up a Retrocomputing Meta question? You have a very good point, and I have a slightly-less-good rebuttal, but we really need to decide on this as a community.
– wizzwizz4♦
Jun 11 at 17:45
I keep wanting this question to be the lead line for a joke...
– Tim Holt
Jun 14 at 0:37
I just got it this for close review, and I have a hard time to decide. For one, it does tackle the issue for a specific CPU, while the other is more generic. But Stephen is as well right, both may trigger the same answers. But not due the way this one if phrased, but rather because the other is way to broad. Marking it as double would be good to target future readers toward the already given answers - better than copying. But then again, asking exactly for the 8086 is a question in its own right. No idea for a middle way, I vote leave open - maybe to incooperate the link into the question.
– Raffzahn
Jun 15 at 8:58
@StephenKitt After a bit rereading, I no longer see it as a duplicate, as the liked question is specific about undocumented opcodes and their usage in relation to documentes, while this is strictly about the 8086 and its handling.
– Raffzahn
Jun 15 at 9:30
2
2
@StephenKitt I'd err on the side of not closing it if the questions themselves aren't identical; it's possible that there are answers to this one that wouldn't be answers to the others, and I know for sure that the other way around also applies.
– wizzwizz4♦
Jun 11 at 17:31
@StephenKitt I'd err on the side of not closing it if the questions themselves aren't identical; it's possible that there are answers to this one that wouldn't be answers to the others, and I know for sure that the other way around also applies.
– wizzwizz4♦
Jun 11 at 17:31
@StephenKitt Could you write up a Retrocomputing Meta question? You have a very good point, and I have a slightly-less-good rebuttal, but we really need to decide on this as a community.
– wizzwizz4♦
Jun 11 at 17:45
@StephenKitt Could you write up a Retrocomputing Meta question? You have a very good point, and I have a slightly-less-good rebuttal, but we really need to decide on this as a community.
– wizzwizz4♦
Jun 11 at 17:45
I keep wanting this question to be the lead line for a joke...
– Tim Holt
Jun 14 at 0:37
I keep wanting this question to be the lead line for a joke...
– Tim Holt
Jun 14 at 0:37
I just got it this for close review, and I have a hard time to decide. For one, it does tackle the issue for a specific CPU, while the other is more generic. But Stephen is as well right, both may trigger the same answers. But not due the way this one if phrased, but rather because the other is way to broad. Marking it as double would be good to target future readers toward the already given answers - better than copying. But then again, asking exactly for the 8086 is a question in its own right. No idea for a middle way, I vote leave open - maybe to incooperate the link into the question.
– Raffzahn
Jun 15 at 8:58
I just got it this for close review, and I have a hard time to decide. For one, it does tackle the issue for a specific CPU, while the other is more generic. But Stephen is as well right, both may trigger the same answers. But not due the way this one if phrased, but rather because the other is way to broad. Marking it as double would be good to target future readers toward the already given answers - better than copying. But then again, asking exactly for the 8086 is a question in its own right. No idea for a middle way, I vote leave open - maybe to incooperate the link into the question.
– Raffzahn
Jun 15 at 8:58
@StephenKitt After a bit rereading, I no longer see it as a duplicate, as the liked question is specific about undocumented opcodes and their usage in relation to documentes, while this is strictly about the 8086 and its handling.
– Raffzahn
Jun 15 at 9:30
@StephenKitt After a bit rereading, I no longer see it as a duplicate, as the liked question is specific about undocumented opcodes and their usage in relation to documentes, while this is strictly about the 8086 and its handling.
– Raffzahn
Jun 15 at 9:30
|
show 2 more comments
4 Answers
4
active
oldest
votes
Illegal opcodes were just instructions that hadn't been fully defined by the chip designers – a little like Undefined Behaviour in C, but much more predictable. Many people called these "undocumented instructions", because they functioned just like ordinary instructions, on the particular versions of the particular chips on which they are found. There was no special handling to prevent these instructions from executing.
Most of them were just NOP
s (either because they weren't wired up to anything or because they did stuff like writing a register to itself) or duplicates of other instructions (because the instruction decoder ignored some bits when it didn't need to pay attention to them), but some of them were more interesting.
For instance, SALC
, which does:
if (carry flag set)
AL = 0xFF;
else
AL = 0x00;
This can be used as a translation layer between C code and certain assembly returning conventions. It is equivalent to SBB AL, AL
, except that it does not clobber flags.
For more information, see:
Stephen Kitt's answer to Use of undocumented opcodes.
supercat's answer to Use of undocumented opcodes, which has a good explanation of where they come from.- A related question on Stack Overflow
add a comment
|
It might be better to think about it this way:
On the 80186 and above, a new thing was defined called an "illegal instruction", and this new thing came with a new behavior -- a #UD
exception that was generated when one was encountered. Before the 80186/80286, there was no such thing as an illegal instruction, just undocumented ones.
Your question then becomes, "what did the 8086 and 8088 do when encountering undocumented instructions" and the answer is simply that the behavior was undocumented. Some of them appeared to do nothing (i.e. they produced the same apparent result as a NOP instruction), while others did odd things, or simply the same thing as another opcode.
Here's a WayBack link that may shed more light on the situation:
http://web.archive.org/web/20190321200321/http://www.os2museum.com/wp/undocumented-8086-opcodes-part-i/
2
I found that "POP CS" is useless kinda funny. I used it. It can be used to perform a long jmp instruction. It's most useful when moving your code's base. At the end of the base move you would do "POP CS" to jump to the next instruction in your code in the new location.
– Joshua
Jun 12 at 17:37
@Joshua The "pop cs" idiom was common in many dos viruses, for the reason you give.
– Hasse1987
Jun 13 at 23:17
add a comment
|
To understand this, you need a general idea of how processors work at the raw hardware level (or at least how they worked before the concept of microcode was developed).
Basically, as the processor would read the bytes of a single assembler language instruction, those bytes would be fed as an input to a network of logic gates called the instruction decoder; this network was designed to produce as output the signals to enable or disable various internal components of the processor according to what the instruction was supposed to do, so that the processor ends up doing the required operation.
As a result, if you viewed the instructions of older, simpler processors as bit patterns, you might notice certain groupings; for example, if the top three bits of the instructions would be set so, you might know that it must be a jump instruction of some type; other patterns might identify other general types of instructions.
The design team for a new processor architecture would develop a reasonable set of instructions, the various networks of logic gates to implement them, and the instruction decoder to manage them all. Back when the 8086 and 8088 processors were designed, it was not yet economically viable to add extra logic to the instruction decoder to exclude any "undocumented instructions", so any bit pattern fed into the instruction decoder would do something, but only the documented instructions would be guaranteed to exist and work the same also in the future members of the same processor family.
Sometimes the undocumented instructions actually ended up doing something useful, but relying on them was risky, as it might mean any program using a particular undocumented instructions might only run successfully that particular processor model. On a newer model, the previously undocumented instructions might actually been used for some new functionality, or they might have become completely useless as a result of a redesign of the instruction decoder.
With 80186 or above, using a number of logic gates to trap the undocumented instructions was economically feasible, and it became a compatibility feature: a program might prefer to use a new instruction available in newer processors only, but could provide a routine to emulate that instruction in software within an "illegal instruction" trap handler.
2
Those patterns in the instruction encoding are very obvious in MIPS, for example, which was designed so the bits of the instruction encoding could be used fairly directly as internal control signals. And it only has a few instruction formats (3-register ALU, or I-type with a 16-bit immediate, or J-type for unconditional jumps). It's word-oriented not byte-oriented. But basically all ISAs with fixed-width instructions have some opcode bits and some register-number bits in consistent locations across many instructions.
– Peter Cordes
Jun 14 at 4:02
For more about x86 opcode patterns, see Are x86 opcodes arbitrary? Also, 3-bit groups come up in some, so octal is apparently helpful.
– Peter Cordes
Jun 14 at 4:04
add a comment
|
Based on the other answers, the proper answer is: they do whatever the instructions bits tell them too.
Since apparently they aren't validated, they always do something, even if that something is nothing.
Same as trying to turn on a lamp on an illuminated room- you won't notice it is there and it is on.
EDIT: I had a question in the answer which I removed, which was "Another question you may ask is: if an instruction does not exist, how does the processor knows it length?", which was replied in the comments below.
1
You could ask your question as a new question — as it is, your answer is likely to be flagged as “not an answer” ;-).
– Stephen Kitt
Jun 12 at 15:12
1
It knows its length the same way it "knows" what the instruction does: the wiring causes it to increment the instruction register by however much it needs to.
– wizzwizz4♦
Jun 12 at 16:41
add a comment
|
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "648"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fretrocomputing.stackexchange.com%2fquestions%2f11327%2fwhat-did-the-8086-and-8088-do-upon-encountering-an-illegal-instruction%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Illegal opcodes were just instructions that hadn't been fully defined by the chip designers – a little like Undefined Behaviour in C, but much more predictable. Many people called these "undocumented instructions", because they functioned just like ordinary instructions, on the particular versions of the particular chips on which they are found. There was no special handling to prevent these instructions from executing.
Most of them were just NOP
s (either because they weren't wired up to anything or because they did stuff like writing a register to itself) or duplicates of other instructions (because the instruction decoder ignored some bits when it didn't need to pay attention to them), but some of them were more interesting.
For instance, SALC
, which does:
if (carry flag set)
AL = 0xFF;
else
AL = 0x00;
This can be used as a translation layer between C code and certain assembly returning conventions. It is equivalent to SBB AL, AL
, except that it does not clobber flags.
For more information, see:
Stephen Kitt's answer to Use of undocumented opcodes.
supercat's answer to Use of undocumented opcodes, which has a good explanation of where they come from.- A related question on Stack Overflow
add a comment
|
Illegal opcodes were just instructions that hadn't been fully defined by the chip designers – a little like Undefined Behaviour in C, but much more predictable. Many people called these "undocumented instructions", because they functioned just like ordinary instructions, on the particular versions of the particular chips on which they are found. There was no special handling to prevent these instructions from executing.
Most of them were just NOP
s (either because they weren't wired up to anything or because they did stuff like writing a register to itself) or duplicates of other instructions (because the instruction decoder ignored some bits when it didn't need to pay attention to them), but some of them were more interesting.
For instance, SALC
, which does:
if (carry flag set)
AL = 0xFF;
else
AL = 0x00;
This can be used as a translation layer between C code and certain assembly returning conventions. It is equivalent to SBB AL, AL
, except that it does not clobber flags.
For more information, see:
Stephen Kitt's answer to Use of undocumented opcodes.
supercat's answer to Use of undocumented opcodes, which has a good explanation of where they come from.- A related question on Stack Overflow
add a comment
|
Illegal opcodes were just instructions that hadn't been fully defined by the chip designers – a little like Undefined Behaviour in C, but much more predictable. Many people called these "undocumented instructions", because they functioned just like ordinary instructions, on the particular versions of the particular chips on which they are found. There was no special handling to prevent these instructions from executing.
Most of them were just NOP
s (either because they weren't wired up to anything or because they did stuff like writing a register to itself) or duplicates of other instructions (because the instruction decoder ignored some bits when it didn't need to pay attention to them), but some of them were more interesting.
For instance, SALC
, which does:
if (carry flag set)
AL = 0xFF;
else
AL = 0x00;
This can be used as a translation layer between C code and certain assembly returning conventions. It is equivalent to SBB AL, AL
, except that it does not clobber flags.
For more information, see:
Stephen Kitt's answer to Use of undocumented opcodes.
supercat's answer to Use of undocumented opcodes, which has a good explanation of where they come from.- A related question on Stack Overflow
Illegal opcodes were just instructions that hadn't been fully defined by the chip designers – a little like Undefined Behaviour in C, but much more predictable. Many people called these "undocumented instructions", because they functioned just like ordinary instructions, on the particular versions of the particular chips on which they are found. There was no special handling to prevent these instructions from executing.
Most of them were just NOP
s (either because they weren't wired up to anything or because they did stuff like writing a register to itself) or duplicates of other instructions (because the instruction decoder ignored some bits when it didn't need to pay attention to them), but some of them were more interesting.
For instance, SALC
, which does:
if (carry flag set)
AL = 0xFF;
else
AL = 0x00;
This can be used as a translation layer between C code and certain assembly returning conventions. It is equivalent to SBB AL, AL
, except that it does not clobber flags.
For more information, see:
Stephen Kitt's answer to Use of undocumented opcodes.
supercat's answer to Use of undocumented opcodes, which has a good explanation of where they come from.- A related question on Stack Overflow
edited Jun 11 at 1:39
Cody Gray
1,2016 silver badges21 bronze badges
1,2016 silver badges21 bronze badges
answered Jun 10 at 17:44
wizzwizz4♦wizzwizz4
9,7806 gold badges48 silver badges115 bronze badges
9,7806 gold badges48 silver badges115 bronze badges
add a comment
|
add a comment
|
It might be better to think about it this way:
On the 80186 and above, a new thing was defined called an "illegal instruction", and this new thing came with a new behavior -- a #UD
exception that was generated when one was encountered. Before the 80186/80286, there was no such thing as an illegal instruction, just undocumented ones.
Your question then becomes, "what did the 8086 and 8088 do when encountering undocumented instructions" and the answer is simply that the behavior was undocumented. Some of them appeared to do nothing (i.e. they produced the same apparent result as a NOP instruction), while others did odd things, or simply the same thing as another opcode.
Here's a WayBack link that may shed more light on the situation:
http://web.archive.org/web/20190321200321/http://www.os2museum.com/wp/undocumented-8086-opcodes-part-i/
2
I found that "POP CS" is useless kinda funny. I used it. It can be used to perform a long jmp instruction. It's most useful when moving your code's base. At the end of the base move you would do "POP CS" to jump to the next instruction in your code in the new location.
– Joshua
Jun 12 at 17:37
@Joshua The "pop cs" idiom was common in many dos viruses, for the reason you give.
– Hasse1987
Jun 13 at 23:17
add a comment
|
It might be better to think about it this way:
On the 80186 and above, a new thing was defined called an "illegal instruction", and this new thing came with a new behavior -- a #UD
exception that was generated when one was encountered. Before the 80186/80286, there was no such thing as an illegal instruction, just undocumented ones.
Your question then becomes, "what did the 8086 and 8088 do when encountering undocumented instructions" and the answer is simply that the behavior was undocumented. Some of them appeared to do nothing (i.e. they produced the same apparent result as a NOP instruction), while others did odd things, or simply the same thing as another opcode.
Here's a WayBack link that may shed more light on the situation:
http://web.archive.org/web/20190321200321/http://www.os2museum.com/wp/undocumented-8086-opcodes-part-i/
2
I found that "POP CS" is useless kinda funny. I used it. It can be used to perform a long jmp instruction. It's most useful when moving your code's base. At the end of the base move you would do "POP CS" to jump to the next instruction in your code in the new location.
– Joshua
Jun 12 at 17:37
@Joshua The "pop cs" idiom was common in many dos viruses, for the reason you give.
– Hasse1987
Jun 13 at 23:17
add a comment
|
It might be better to think about it this way:
On the 80186 and above, a new thing was defined called an "illegal instruction", and this new thing came with a new behavior -- a #UD
exception that was generated when one was encountered. Before the 80186/80286, there was no such thing as an illegal instruction, just undocumented ones.
Your question then becomes, "what did the 8086 and 8088 do when encountering undocumented instructions" and the answer is simply that the behavior was undocumented. Some of them appeared to do nothing (i.e. they produced the same apparent result as a NOP instruction), while others did odd things, or simply the same thing as another opcode.
Here's a WayBack link that may shed more light on the situation:
http://web.archive.org/web/20190321200321/http://www.os2museum.com/wp/undocumented-8086-opcodes-part-i/
It might be better to think about it this way:
On the 80186 and above, a new thing was defined called an "illegal instruction", and this new thing came with a new behavior -- a #UD
exception that was generated when one was encountered. Before the 80186/80286, there was no such thing as an illegal instruction, just undocumented ones.
Your question then becomes, "what did the 8086 and 8088 do when encountering undocumented instructions" and the answer is simply that the behavior was undocumented. Some of them appeared to do nothing (i.e. they produced the same apparent result as a NOP instruction), while others did odd things, or simply the same thing as another opcode.
Here's a WayBack link that may shed more light on the situation:
http://web.archive.org/web/20190321200321/http://www.os2museum.com/wp/undocumented-8086-opcodes-part-i/
edited Jun 11 at 17:21
Peter Cordes
1,4009 silver badges13 bronze badges
1,4009 silver badges13 bronze badges
answered Jun 10 at 17:49
Ken GoberKen Gober
9,7041 gold badge31 silver badges49 bronze badges
9,7041 gold badge31 silver badges49 bronze badges
2
I found that "POP CS" is useless kinda funny. I used it. It can be used to perform a long jmp instruction. It's most useful when moving your code's base. At the end of the base move you would do "POP CS" to jump to the next instruction in your code in the new location.
– Joshua
Jun 12 at 17:37
@Joshua The "pop cs" idiom was common in many dos viruses, for the reason you give.
– Hasse1987
Jun 13 at 23:17
add a comment
|
2
I found that "POP CS" is useless kinda funny. I used it. It can be used to perform a long jmp instruction. It's most useful when moving your code's base. At the end of the base move you would do "POP CS" to jump to the next instruction in your code in the new location.
– Joshua
Jun 12 at 17:37
@Joshua The "pop cs" idiom was common in many dos viruses, for the reason you give.
– Hasse1987
Jun 13 at 23:17
2
2
I found that "POP CS" is useless kinda funny. I used it. It can be used to perform a long jmp instruction. It's most useful when moving your code's base. At the end of the base move you would do "POP CS" to jump to the next instruction in your code in the new location.
– Joshua
Jun 12 at 17:37
I found that "POP CS" is useless kinda funny. I used it. It can be used to perform a long jmp instruction. It's most useful when moving your code's base. At the end of the base move you would do "POP CS" to jump to the next instruction in your code in the new location.
– Joshua
Jun 12 at 17:37
@Joshua The "pop cs" idiom was common in many dos viruses, for the reason you give.
– Hasse1987
Jun 13 at 23:17
@Joshua The "pop cs" idiom was common in many dos viruses, for the reason you give.
– Hasse1987
Jun 13 at 23:17
add a comment
|
To understand this, you need a general idea of how processors work at the raw hardware level (or at least how they worked before the concept of microcode was developed).
Basically, as the processor would read the bytes of a single assembler language instruction, those bytes would be fed as an input to a network of logic gates called the instruction decoder; this network was designed to produce as output the signals to enable or disable various internal components of the processor according to what the instruction was supposed to do, so that the processor ends up doing the required operation.
As a result, if you viewed the instructions of older, simpler processors as bit patterns, you might notice certain groupings; for example, if the top three bits of the instructions would be set so, you might know that it must be a jump instruction of some type; other patterns might identify other general types of instructions.
The design team for a new processor architecture would develop a reasonable set of instructions, the various networks of logic gates to implement them, and the instruction decoder to manage them all. Back when the 8086 and 8088 processors were designed, it was not yet economically viable to add extra logic to the instruction decoder to exclude any "undocumented instructions", so any bit pattern fed into the instruction decoder would do something, but only the documented instructions would be guaranteed to exist and work the same also in the future members of the same processor family.
Sometimes the undocumented instructions actually ended up doing something useful, but relying on them was risky, as it might mean any program using a particular undocumented instructions might only run successfully that particular processor model. On a newer model, the previously undocumented instructions might actually been used for some new functionality, or they might have become completely useless as a result of a redesign of the instruction decoder.
With 80186 or above, using a number of logic gates to trap the undocumented instructions was economically feasible, and it became a compatibility feature: a program might prefer to use a new instruction available in newer processors only, but could provide a routine to emulate that instruction in software within an "illegal instruction" trap handler.
2
Those patterns in the instruction encoding are very obvious in MIPS, for example, which was designed so the bits of the instruction encoding could be used fairly directly as internal control signals. And it only has a few instruction formats (3-register ALU, or I-type with a 16-bit immediate, or J-type for unconditional jumps). It's word-oriented not byte-oriented. But basically all ISAs with fixed-width instructions have some opcode bits and some register-number bits in consistent locations across many instructions.
– Peter Cordes
Jun 14 at 4:02
For more about x86 opcode patterns, see Are x86 opcodes arbitrary? Also, 3-bit groups come up in some, so octal is apparently helpful.
– Peter Cordes
Jun 14 at 4:04
add a comment
|
To understand this, you need a general idea of how processors work at the raw hardware level (or at least how they worked before the concept of microcode was developed).
Basically, as the processor would read the bytes of a single assembler language instruction, those bytes would be fed as an input to a network of logic gates called the instruction decoder; this network was designed to produce as output the signals to enable or disable various internal components of the processor according to what the instruction was supposed to do, so that the processor ends up doing the required operation.
As a result, if you viewed the instructions of older, simpler processors as bit patterns, you might notice certain groupings; for example, if the top three bits of the instructions would be set so, you might know that it must be a jump instruction of some type; other patterns might identify other general types of instructions.
The design team for a new processor architecture would develop a reasonable set of instructions, the various networks of logic gates to implement them, and the instruction decoder to manage them all. Back when the 8086 and 8088 processors were designed, it was not yet economically viable to add extra logic to the instruction decoder to exclude any "undocumented instructions", so any bit pattern fed into the instruction decoder would do something, but only the documented instructions would be guaranteed to exist and work the same also in the future members of the same processor family.
Sometimes the undocumented instructions actually ended up doing something useful, but relying on them was risky, as it might mean any program using a particular undocumented instructions might only run successfully that particular processor model. On a newer model, the previously undocumented instructions might actually been used for some new functionality, or they might have become completely useless as a result of a redesign of the instruction decoder.
With 80186 or above, using a number of logic gates to trap the undocumented instructions was economically feasible, and it became a compatibility feature: a program might prefer to use a new instruction available in newer processors only, but could provide a routine to emulate that instruction in software within an "illegal instruction" trap handler.
2
Those patterns in the instruction encoding are very obvious in MIPS, for example, which was designed so the bits of the instruction encoding could be used fairly directly as internal control signals. And it only has a few instruction formats (3-register ALU, or I-type with a 16-bit immediate, or J-type for unconditional jumps). It's word-oriented not byte-oriented. But basically all ISAs with fixed-width instructions have some opcode bits and some register-number bits in consistent locations across many instructions.
– Peter Cordes
Jun 14 at 4:02
For more about x86 opcode patterns, see Are x86 opcodes arbitrary? Also, 3-bit groups come up in some, so octal is apparently helpful.
– Peter Cordes
Jun 14 at 4:04
add a comment
|
To understand this, you need a general idea of how processors work at the raw hardware level (or at least how they worked before the concept of microcode was developed).
Basically, as the processor would read the bytes of a single assembler language instruction, those bytes would be fed as an input to a network of logic gates called the instruction decoder; this network was designed to produce as output the signals to enable or disable various internal components of the processor according to what the instruction was supposed to do, so that the processor ends up doing the required operation.
As a result, if you viewed the instructions of older, simpler processors as bit patterns, you might notice certain groupings; for example, if the top three bits of the instructions would be set so, you might know that it must be a jump instruction of some type; other patterns might identify other general types of instructions.
The design team for a new processor architecture would develop a reasonable set of instructions, the various networks of logic gates to implement them, and the instruction decoder to manage them all. Back when the 8086 and 8088 processors were designed, it was not yet economically viable to add extra logic to the instruction decoder to exclude any "undocumented instructions", so any bit pattern fed into the instruction decoder would do something, but only the documented instructions would be guaranteed to exist and work the same also in the future members of the same processor family.
Sometimes the undocumented instructions actually ended up doing something useful, but relying on them was risky, as it might mean any program using a particular undocumented instructions might only run successfully that particular processor model. On a newer model, the previously undocumented instructions might actually been used for some new functionality, or they might have become completely useless as a result of a redesign of the instruction decoder.
With 80186 or above, using a number of logic gates to trap the undocumented instructions was economically feasible, and it became a compatibility feature: a program might prefer to use a new instruction available in newer processors only, but could provide a routine to emulate that instruction in software within an "illegal instruction" trap handler.
To understand this, you need a general idea of how processors work at the raw hardware level (or at least how they worked before the concept of microcode was developed).
Basically, as the processor would read the bytes of a single assembler language instruction, those bytes would be fed as an input to a network of logic gates called the instruction decoder; this network was designed to produce as output the signals to enable or disable various internal components of the processor according to what the instruction was supposed to do, so that the processor ends up doing the required operation.
As a result, if you viewed the instructions of older, simpler processors as bit patterns, you might notice certain groupings; for example, if the top three bits of the instructions would be set so, you might know that it must be a jump instruction of some type; other patterns might identify other general types of instructions.
The design team for a new processor architecture would develop a reasonable set of instructions, the various networks of logic gates to implement them, and the instruction decoder to manage them all. Back when the 8086 and 8088 processors were designed, it was not yet economically viable to add extra logic to the instruction decoder to exclude any "undocumented instructions", so any bit pattern fed into the instruction decoder would do something, but only the documented instructions would be guaranteed to exist and work the same also in the future members of the same processor family.
Sometimes the undocumented instructions actually ended up doing something useful, but relying on them was risky, as it might mean any program using a particular undocumented instructions might only run successfully that particular processor model. On a newer model, the previously undocumented instructions might actually been used for some new functionality, or they might have become completely useless as a result of a redesign of the instruction decoder.
With 80186 or above, using a number of logic gates to trap the undocumented instructions was economically feasible, and it became a compatibility feature: a program might prefer to use a new instruction available in newer processors only, but could provide a routine to emulate that instruction in software within an "illegal instruction" trap handler.
answered Jun 13 at 14:44
telcoMtelcoM
4862 silver badges6 bronze badges
4862 silver badges6 bronze badges
2
Those patterns in the instruction encoding are very obvious in MIPS, for example, which was designed so the bits of the instruction encoding could be used fairly directly as internal control signals. And it only has a few instruction formats (3-register ALU, or I-type with a 16-bit immediate, or J-type for unconditional jumps). It's word-oriented not byte-oriented. But basically all ISAs with fixed-width instructions have some opcode bits and some register-number bits in consistent locations across many instructions.
– Peter Cordes
Jun 14 at 4:02
For more about x86 opcode patterns, see Are x86 opcodes arbitrary? Also, 3-bit groups come up in some, so octal is apparently helpful.
– Peter Cordes
Jun 14 at 4:04
add a comment
|
2
Those patterns in the instruction encoding are very obvious in MIPS, for example, which was designed so the bits of the instruction encoding could be used fairly directly as internal control signals. And it only has a few instruction formats (3-register ALU, or I-type with a 16-bit immediate, or J-type for unconditional jumps). It's word-oriented not byte-oriented. But basically all ISAs with fixed-width instructions have some opcode bits and some register-number bits in consistent locations across many instructions.
– Peter Cordes
Jun 14 at 4:02
For more about x86 opcode patterns, see Are x86 opcodes arbitrary? Also, 3-bit groups come up in some, so octal is apparently helpful.
– Peter Cordes
Jun 14 at 4:04
2
2
Those patterns in the instruction encoding are very obvious in MIPS, for example, which was designed so the bits of the instruction encoding could be used fairly directly as internal control signals. And it only has a few instruction formats (3-register ALU, or I-type with a 16-bit immediate, or J-type for unconditional jumps). It's word-oriented not byte-oriented. But basically all ISAs with fixed-width instructions have some opcode bits and some register-number bits in consistent locations across many instructions.
– Peter Cordes
Jun 14 at 4:02
Those patterns in the instruction encoding are very obvious in MIPS, for example, which was designed so the bits of the instruction encoding could be used fairly directly as internal control signals. And it only has a few instruction formats (3-register ALU, or I-type with a 16-bit immediate, or J-type for unconditional jumps). It's word-oriented not byte-oriented. But basically all ISAs with fixed-width instructions have some opcode bits and some register-number bits in consistent locations across many instructions.
– Peter Cordes
Jun 14 at 4:02
For more about x86 opcode patterns, see Are x86 opcodes arbitrary? Also, 3-bit groups come up in some, so octal is apparently helpful.
– Peter Cordes
Jun 14 at 4:04
For more about x86 opcode patterns, see Are x86 opcodes arbitrary? Also, 3-bit groups come up in some, so octal is apparently helpful.
– Peter Cordes
Jun 14 at 4:04
add a comment
|
Based on the other answers, the proper answer is: they do whatever the instructions bits tell them too.
Since apparently they aren't validated, they always do something, even if that something is nothing.
Same as trying to turn on a lamp on an illuminated room- you won't notice it is there and it is on.
EDIT: I had a question in the answer which I removed, which was "Another question you may ask is: if an instruction does not exist, how does the processor knows it length?", which was replied in the comments below.
1
You could ask your question as a new question — as it is, your answer is likely to be flagged as “not an answer” ;-).
– Stephen Kitt
Jun 12 at 15:12
1
It knows its length the same way it "knows" what the instruction does: the wiring causes it to increment the instruction register by however much it needs to.
– wizzwizz4♦
Jun 12 at 16:41
add a comment
|
Based on the other answers, the proper answer is: they do whatever the instructions bits tell them too.
Since apparently they aren't validated, they always do something, even if that something is nothing.
Same as trying to turn on a lamp on an illuminated room- you won't notice it is there and it is on.
EDIT: I had a question in the answer which I removed, which was "Another question you may ask is: if an instruction does not exist, how does the processor knows it length?", which was replied in the comments below.
1
You could ask your question as a new question — as it is, your answer is likely to be flagged as “not an answer” ;-).
– Stephen Kitt
Jun 12 at 15:12
1
It knows its length the same way it "knows" what the instruction does: the wiring causes it to increment the instruction register by however much it needs to.
– wizzwizz4♦
Jun 12 at 16:41
add a comment
|
Based on the other answers, the proper answer is: they do whatever the instructions bits tell them too.
Since apparently they aren't validated, they always do something, even if that something is nothing.
Same as trying to turn on a lamp on an illuminated room- you won't notice it is there and it is on.
EDIT: I had a question in the answer which I removed, which was "Another question you may ask is: if an instruction does not exist, how does the processor knows it length?", which was replied in the comments below.
Based on the other answers, the proper answer is: they do whatever the instructions bits tell them too.
Since apparently they aren't validated, they always do something, even if that something is nothing.
Same as trying to turn on a lamp on an illuminated room- you won't notice it is there and it is on.
EDIT: I had a question in the answer which I removed, which was "Another question you may ask is: if an instruction does not exist, how does the processor knows it length?", which was replied in the comments below.
edited Jul 1 at 8:57
answered Jun 12 at 15:03
pedropedro
11 bronze badge
11 bronze badge
1
You could ask your question as a new question — as it is, your answer is likely to be flagged as “not an answer” ;-).
– Stephen Kitt
Jun 12 at 15:12
1
It knows its length the same way it "knows" what the instruction does: the wiring causes it to increment the instruction register by however much it needs to.
– wizzwizz4♦
Jun 12 at 16:41
add a comment
|
1
You could ask your question as a new question — as it is, your answer is likely to be flagged as “not an answer” ;-).
– Stephen Kitt
Jun 12 at 15:12
1
It knows its length the same way it "knows" what the instruction does: the wiring causes it to increment the instruction register by however much it needs to.
– wizzwizz4♦
Jun 12 at 16:41
1
1
You could ask your question as a new question — as it is, your answer is likely to be flagged as “not an answer” ;-).
– Stephen Kitt
Jun 12 at 15:12
You could ask your question as a new question — as it is, your answer is likely to be flagged as “not an answer” ;-).
– Stephen Kitt
Jun 12 at 15:12
1
1
It knows its length the same way it "knows" what the instruction does: the wiring causes it to increment the instruction register by however much it needs to.
– wizzwizz4♦
Jun 12 at 16:41
It knows its length the same way it "knows" what the instruction does: the wiring causes it to increment the instruction register by however much it needs to.
– wizzwizz4♦
Jun 12 at 16:41
add a comment
|
Thanks for contributing an answer to Retrocomputing Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fretrocomputing.stackexchange.com%2fquestions%2f11327%2fwhat-did-the-8086-and-8088-do-upon-encountering-an-illegal-instruction%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
@StephenKitt I'd err on the side of not closing it if the questions themselves aren't identical; it's possible that there are answers to this one that wouldn't be answers to the others, and I know for sure that the other way around also applies.
– wizzwizz4♦
Jun 11 at 17:31
@StephenKitt Could you write up a Retrocomputing Meta question? You have a very good point, and I have a slightly-less-good rebuttal, but we really need to decide on this as a community.
– wizzwizz4♦
Jun 11 at 17:45
I keep wanting this question to be the lead line for a joke...
– Tim Holt
Jun 14 at 0:37
I just got it this for close review, and I have a hard time to decide. For one, it does tackle the issue for a specific CPU, while the other is more generic. But Stephen is as well right, both may trigger the same answers. But not due the way this one if phrased, but rather because the other is way to broad. Marking it as double would be good to target future readers toward the already given answers - better than copying. But then again, asking exactly for the 8086 is a question in its own right. No idea for a middle way, I vote leave open - maybe to incooperate the link into the question.
– Raffzahn
Jun 15 at 8:58
@StephenKitt After a bit rereading, I no longer see it as a duplicate, as the liked question is specific about undocumented opcodes and their usage in relation to documentes, while this is strictly about the 8086 and its handling.
– Raffzahn
Jun 15 at 9:30