fbpx
Wikipedia

Illegal opcode

An illegal opcode, also called an unimplemented operation,[1] unintended opcode[2] or undocumented instruction, is an instruction to a CPU that is not mentioned in any official documentation released by the CPU's designer or manufacturer, which nevertheless has an effect. Illegal opcodes were common on older CPUs designed during the 1970s, such as the MOS Technology 6502, Intel 8086, and the Zilog Z80. On these older processors, many exist as a side effect of the wiring of transistors in the CPU, and usually combine functions of the CPU that were not intended to be combined. On old and modern processors, there are also instructions intentionally included in the processor by the manufacturer, but that are not documented in any official specification.

A human generated illegal instruction signal

The effect of many illegal opcodes, on many processors, is just a trap to an error handler. However, some processors that trap for most illegal opcodes do not do so for some illegal opcodes, and some other processors do not check for illegal opcodes, and, instead, perform an undocumented operation.

Overview edit

While most accidental illegal instructions have useless or even highly undesirable effects (such as crashing the computer), some can have useful functions in certain situations. Such instructions were sometimes exploited in computer games of the 1970s and 1980s to speed up certain time-critical sections. Another common use was in the ongoing battle between copy protection implementations and cracking. Here, they were a form of security through obscurity, and their secrecy usually did not last very long.

A danger associated with the use of illegal instructions was that, given the fact that the manufacturer does not guarantee their existence and function, they might disappear or behave differently with any change of the CPU internals or any new revision of the CPU, rendering programs that use them incompatible with the newer revisions. For example, a number of older Apple II games did not work correctly on the newer Apple IIc, because the latter used a newer CPU revision – 65C02 – that did away with illegal opcodes.

More recent CPUs, such as the 80186, 80286, 68000 and its descendants, do not have illegal opcodes that are widely known/used. Ideally, the CPU will behave in a well-defined way when it finds an unknown opcode in the instruction stream, such as triggering a certain exception or fault condition. The operating system's exception or fault handler will then usually terminate the application that caused the fault, unless the program had previously established its own exception/fault handler, in which case that handler would receive control. Another, less common way of handling illegal instructions is by defining them to do nothing except taking up time and space (equivalent to the CPU's official NOP instruction); this method is used by the TMS9900 and 65C02 processors, among others. Alternatively, unknown instructions can be emulated in software (e.g. LOADALL), or even "new" pseudo-instructions can be implemented. Some BIOSes, memory managers, and operating systems take advantage of this, for example, to let V86 tasks communicate with the underlying system, i.e. BOP (from "BIOS Operation") utilized by the Windows NTVDM.[3]

In spite of Intel's guarantee against such instructions, research using techniques such as fuzzing uncovered a vast number of undocumented instructions in x86 processors as late as 2018.[4] Some of these instructions are shared across processor manufacturers, indicating that Intel and AMD are both aware of the instruction and its purpose, despite it not appearing in any official specification. Other instructions are specific to manufacturers or specific product lines. The purpose of the majority of x86 undocumented instructions is unknown.

Today, the details of these instructions are mainly of interest for exact emulation of older systems.

See also edit

References edit

  1. ^ "1.2. Instruction Format". PDP-10 Reference Handbook: Programming with the PDP-10 Instruction Set (PDF). Vol. 1. Digital Equipment Corporation (DEC). 1969. p. 1-7. Retrieved 2022-05-13.
  2. ^ Åkesson, Linus (2013-03-31). "GCR decoding on the fly". from the original on 2017-03-21. Retrieved 2017-03-21.
  3. ^ Schulman, Andrew; Brown, Ralf D.; Maxey, David; Michels, Raymond J.; Kyle, Jim (1994) [November 1993]. Undocumented DOS: A programmer's guide to reserved MS-DOS functions and data structures - expanded to include MS-DOS 6, Novell DOS and Windows 3.1 (2 ed.). Reading, Massachusetts: Addison Wesley. ISBN 0-201-63287-X. (xviii+856+vi pages, 3.5-inch floppy) Errata:
  4. ^ Domas, Christopher. "Breaking the x86 Instruction Set". YouTube. Archived from the original on 2021-12-19. Retrieved 2018-01-03.

Further reading edit

  • Vardy, Adam (1996-09-27) [1995-08-22]. "Extra Instructions Of The 65XX Series CPU". from the original on 2021-08-28. Retrieved 2021-11-18. (NB. Illegal opcodes on the 6502.)
  • Steil, Michael (2008-07-29). "How MOS 6502 Illegal Opcodes really work". pagetable.com - Some Assembly Required. from the original on 2021-11-19. Retrieved 2021-11-18.
  • Young, Sean (2005-09-18) [1997]. "Z80 Documentation: The Undocumented Z80 Documented". 0.91. from the original on 2021-10-09. Retrieved 2021-11-18. (NB. Illegal opcodes on the Z80.)
  • Brown, Ralf D., ed. (2002-12-29) [2000-07-17, 1985]. "The x86 Interrupt List" (61 ed.). from the original on 2017-08-22. Retrieved 2011-10-14. (NB. Ralf Brown's Interrupt List's also contains some information about undocumented processor opcodes and processor bugs: OPCODES.LST by Alex V. Potemkin and 86BUGS.LST by Harald Feldmann.)

External links edit

  • Christian Ludloff's site sandpile.org also contains info on undocumented opcodes

illegal, opcode, this, article, multiple, issues, please, help, improve, discuss, these, issues, talk, page, learn, when, remove, these, template, messages, this, article, needs, additional, citations, verification, please, help, improve, this, article, adding. This article has multiple issues Please help improve it or discuss these issues on the talk page Learn how and when to remove these template messages This article needs additional citations for verification Please help improve this article by adding citations to reliable sources Unsourced material may be challenged and removed Find sources Illegal opcode news newspapers books scholar JSTOR December 2010 Learn how and when to remove this message This article includes a list of general references but it lacks sufficient corresponding inline citations Please help to improve this article by introducing more precise citations June 2020 Learn how and when to remove this message It has been suggested that this article should be split into articles titled Invalid opcode and Unintended opcode discuss December 2021 Learn how and when to remove this message An illegal opcode also called an unimplemented operation 1 unintended opcode 2 or undocumented instruction is an instruction to a CPU that is not mentioned in any official documentation released by the CPU s designer or manufacturer which nevertheless has an effect Illegal opcodes were common on older CPUs designed during the 1970s such as the MOS Technology 6502 Intel 8086 and the Zilog Z80 On these older processors many exist as a side effect of the wiring of transistors in the CPU and usually combine functions of the CPU that were not intended to be combined On old and modern processors there are also instructions intentionally included in the processor by the manufacturer but that are not documented in any official specification A human generated illegal instruction signal The effect of many illegal opcodes on many processors is just a trap to an error handler However some processors that trap for most illegal opcodes do not do so for some illegal opcodes and some other processors do not check for illegal opcodes and instead perform an undocumented operation Contents 1 Overview 2 See also 3 References 4 Further reading 5 External linksOverview editWhile most accidental illegal instructions have useless or even highly undesirable effects such as crashing the computer some can have useful functions in certain situations Such instructions were sometimes exploited in computer games of the 1970s and 1980s to speed up certain time critical sections Another common use was in the ongoing battle between copy protection implementations and cracking Here they were a form of security through obscurity and their secrecy usually did not last very long A danger associated with the use of illegal instructions was that given the fact that the manufacturer does not guarantee their existence and function they might disappear or behave differently with any change of the CPU internals or any new revision of the CPU rendering programs that use them incompatible with the newer revisions For example a number of older Apple II games did not work correctly on the newer Apple IIc because the latter used a newer CPU revision 65C02 that did away with illegal opcodes More recent CPUs such as the 80186 80286 68000 and its descendants do not have illegal opcodes that are widely known used Ideally the CPU will behave in a well defined way when it finds an unknown opcode in the instruction stream such as triggering a certain exception or fault condition The operating system s exception or fault handler will then usually terminate the application that caused the fault unless the program had previously established its own exception fault handler in which case that handler would receive control Another less common way of handling illegal instructions is by defining them to do nothing except taking up time and space equivalent to the CPU s official NOP instruction this method is used by the TMS9900 and 65C02 processors among others Alternatively unknown instructions can be emulated in software e g LOADALL or even new pseudo instructions can be implemented Some BIOSes memory managers and operating systems take advantage of this for example to let V86 tasks communicate with the underlying system i e BOP from BIOS Operation utilized by the Windows NTVDM 3 In spite of Intel s guarantee against such instructions research using techniques such as fuzzing uncovered a vast number of undocumented instructions in x86 processors as late as 2018 4 Some of these instructions are shared across processor manufacturers indicating that Intel and AMD are both aware of the instruction and its purpose despite it not appearing in any official specification Other instructions are specific to manufacturers or specific product lines The purpose of the majority of x86 undocumented instructions is unknown Today the details of these instructions are mainly of interest for exact emulation of older systems See also editBackdoor computing Don t care term Easter egg media Gadget machine instruction sequence Halt and Catch Fire computing Microcode Pentium F00F bug Synthetic programming Trap computing Undocumented featureReferences edit 1 2 Instruction Format PDP 10 Reference Handbook Programming with the PDP 10 Instruction Set PDF Vol 1 Digital Equipment Corporation DEC 1969 p 1 7 Retrieved 2022 05 13 Akesson Linus 2013 03 31 GCR decoding on the fly Archived from the original on 2017 03 21 Retrieved 2017 03 21 Schulman Andrew Brown Ralf D Maxey David Michels Raymond J Kyle Jim 1994 November 1993 Undocumented DOS A programmer s guide to reserved MS DOS functions and data structures expanded to include MS DOS 6 Novell DOS and Windows 3 1 2 ed Reading Massachusetts Addison Wesley ISBN 0 201 63287 X xviii 856 vi pages 3 5 inch floppy Errata 1 2 Domas Christopher Breaking the x86 Instruction Set YouTube Archived from the original on 2021 12 19 Retrieved 2018 01 03 Further reading editVardy Adam 1996 09 27 1995 08 22 Extra Instructions Of The 65XX Series CPU Archived from the original on 2021 08 28 Retrieved 2021 11 18 NB Illegal opcodes on the 6502 Steil Michael 2008 07 29 How MOS 6502 Illegal Opcodes really work pagetable com Some Assembly Required Archived from the original on 2021 11 19 Retrieved 2021 11 18 Young Sean 2005 09 18 1997 Z80 Documentation The Undocumented Z80 Documented 0 91 Archived from the original on 2021 10 09 Retrieved 2021 11 18 NB Illegal opcodes on the Z80 Brown Ralf D ed 2002 12 29 2000 07 17 1985 The x86 Interrupt List 61 ed Archived from the original on 2017 08 22 Retrieved 2011 10 14 3 4 5 6 7 8 9 NB Ralf Brown s Interrupt List s also contains some information about undocumented processor opcodes and processor bugs OPCODES LST by Alex V Potemkin and 86BUGS LST by Harald Feldmann External links editChristian Ludloff s site sandpile org also contains info on undocumented opcodes Retrieved from https en wikipedia org w index php title Illegal opcode amp oldid 1176286041, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.