Halt and Catch Fire

From Infogalactic: the planetary knowledge core
Jump to: navigation, search

<templatestyles src="Module:Hatnote/styles.css"></templatestyles>

Lua error in package.lua at line 80: module 'strict' not found. In computer engineering, Halt and Catch Fire, known by the assembly mnemonic HCF, is a euphemism referring to a computer machine code instruction that causes the computer's central processing unit (CPU) to cease meaningful operation, typically requiring a restart of the computer. This originally referred to a fictitious instruction in IBM System/360 computers, but later computer developers who saw the joke created real versions of this instruction for some machines. In the case of real instructions the implication of this expression is that, whereas in most cases when a CPU executes an unintended instruction (a bug in the code) the computer may still be able to recover, but in the case of an HCF instruction there is, by definition, no way for the system to recover without a restart.

The expression "catch fire" in this context is normally facetious, rather than literal - referring to a total loss of CPU functionality during the current session, not physical damage.

Other euphemisms are often used such as "SDI" for "Self Destruct Immediate" and also for other joke operations, such as "CRN" for Convert to Roman Numerals.[1]

Assembly language mnemonics

In a computer's assembly language, mnemonics are used that are directly equivalent to machine code instructions. The mnemonics are frequently three letters long, such as ADD, CMP (to compare two numbers), and JMP (jump to a different location in the program). The HCF instruction was originally a fictitious assembly language instruction, said to be under development at IBM for use in their System/360 computers, along with many other amusing three-letter acronyms like XPR (Execute Programmer) and CAI (Corrupt Accounting Information).[2] The S/360 instruction set already included numerous non-obvious mnemonics like ZAP (Zero and Add Packed), EDMK (EDit and MarK), TRT (TRanslate and Test), and Read Backward (an I/O channel command),[3] and programmers began creating similarly cryptic, but fictitious, instructions in a humorous vein.[citation needed]

In modern CPUs

CPU designers sometimes incorporate one or more undocumented machine code instructions for testing purposes.[citation needed] These instructions are not intended to be executed during normal operation of the CPU; when they are actually executed by a program during normal operation, they can have unusual side-effects.[citation needed] The "Halt and Catch Fire" (HCF) instruction and mnemonic are sometimes appropriated by users who discover these instructions as a humorous way of expressing that the unintended execution of such an instruction causes the system to fail to perform its normal functions.[citation needed]

Motorola 6800

The Motorola 6800 microprocessor was the first for which an undocumented assembly mnemonic HCF became widely known. The operation codes (opcodes) — the portions of the machine language instructions that specify an operation to be performed — referred to by the mnemonic HCF are $9D and $DD and were reported in an article written by Gerry Wheeler in the December 1977 issue of BYTE magazine on undocumented opcodes.[4] Wheeler noted that Motorola reported 197 valid operation codes for the M6800 processor, and so inferred that with 256 possible 8 bit combinations, there must be 59 "invalid instructions." He goes on to describe the HCF as a "big surprise," and saying of the Catch Fire portion of the moniker, "Well, almost.":<templatestyles src="Template:Blockquote/styles.css" />

When this instruction is run the only way to see what it is doing is with an oscilloscope. From the user's point of view the machine halts and defies most attempts to get it restarted. Those persons with indicator lamps on the address bus will see that the processor begins to read all of the memory, sequentially, very quickly. In effect, the address bus turns into a 16 bit counter. However, the processor takes no notice of what it is reading… it just reads."[4]

The process is reviewed by David Agans, thus: "In the old days of the Motorola 6800 microprocessor, instruction code DD cause the processor to go into an endless loop, reading from each memory address in order. (Other engineers referred to this as the 'Halt and Catch Fire' (HCF) instruction, but we remembered the code by calling it the 'Drop Dead' instruction.) Drop Dead mode was wonderful for spotting hardware timing and address logic problems with a scope; all of the address and clock lines were nice, cycling square waves."[5]

That is, either opcode made the processor enter a mode, continuously performing memory read cycles from successive addresses with no intervening instruction fetches. Hence, the address bus effectively became a counter, allowing the operation of all address lines to be quickly verified. Once the processor entered this mode, it was not responsive to interrupts, so normal operation could only be restored by a reset (hence the "Drop Dead" and "Halt and Catch Fire" monikers). These references were thus to the unresponsive behavior of the CPU in this state, and not to any form of erratic behavior.[citation needed]

The mnemonic HCF is believed to be the first built-in self-test feature on a Motorola microprocessor.[6]

Intel x86

<templatestyles src="Module:Hatnote/styles.css"></templatestyles>

The Intel 8086 and subsequent processors in the x86 series had an HLT (halt) instruction, op code F4, which stopped instruction execution and placed the processor in a HALT state. An enabled interrupt, a debug exception, the BINIT signal, the INIT signal, or the RESET signal resumed execution, which meant the processor could always be restarted.[7] Some of the early Intel DX4 chips had a problem with the HLT instruction and could not be restarted after this instruction was used, which disabled the computer and turned HLT into more of an HCF instruction. The Linux kernel added a "no-hlt" option telling Linux to run an infinite loop instead of using HLT, which allowed users of these broken chips to use Linux.[8]

Many computers in the Intel Pentium line could be locked up by executing an invalid instruction (F00F C7C8), which caused the computer to lock up. This became known as the Pentium F00F bug. No compiler would create the instruction, but a malicious programmer could insert it into code to render an afflicted computer inoperable until the machine was power-cycled. Since its discovery, workarounds have been developed to prevent it from locking the computer, and the bug has been eliminated in subsequent Intel processors.[9][10]

Other CPUs

The 6502 has 12 different undocumented instructions which will freeze the CPU.[citation needed]

On the Z80, if you execute DI (disable interrupts) followed by HALT (wait for an interrupt), the CPU will stay frozen waiting for an interrupt that cannot happen. The similar processor found in the Game Boy contained a partial fix allowing it to recover from one HALT, but it would become frozen with two consecutive HALTs with interrupts disabled.[citation needed]

It should also be noted that the Z80 supports a non-maskable interrupt [11] [12] with /NMI being on Pin 17 of the original 40 pin DIP package. [13] [14] Since a non-maskable interrupt will regain control of the CPU even after executing the instruction sequence DI / HALT, that pair does not represent a true HCF, it will only result in a HCF condition if either the /NMI pin is connected directly to the +5V rail, making the generation of that signal impossible, or if the interrupt routine that services /NMI ends with a return, placing it back in the HALT state.

In early CPUs

One apocryphal story about the HCF instruction in an actual early CPU goes back to the late 1960s, when computers used magnetic core memory.[citation needed] The story goes that in order to speed up the core memory on their next model the engineers increased the read/write currents in the very fine wires that were threaded through the cores. This worked fine when the computer was executing normal programs, since memory accesses were spread throughout memory. However, the HALT instruction was implemented as a "Jump to self". This meant that the same core memory location was repeatedly accessed, and the very fine wires became so hot that they started to smoke — hence the instruction was labeled "Halt and Catch Fire".[15][better source needed]

See also

References

  1. Lua error in package.lua at line 80: module 'strict' not found.
  2. Lua error in package.lua at line 80: module 'strict' not found.
  3. Lua error in package.lua at line 80: module 'strict' not found.
  4. 4.0 4.1 Lua error in package.lua at line 80: module 'strict' not found.
  5. Lua error in package.lua at line 80: module 'strict' not found.
  6. Lua error in package.lua at line 80: module 'strict' not found. "HACOF thus became the first intentional built-in self-test feature on a Motorola microprocessor."
  7. Lua error in package.lua at line 80: module 'strict' not found.
  8. Lua error in package.lua at line 80: module 'strict' not found.
  9. Lua error in package.lua at line 80: module 'strict' not found.
  10. Lua error in package.lua at line 80: module 'strict' not found.
  11. http://www.smspower.org/Development/InterruptMechanism
  12. http://www.z80.info/interrup.htm
  13. http://www.cpu-world.com/info/Pinouts/Z80.html
  14. http://www.petervis.com/electronics/CPU_Processors/Zilog_Z80A/Z80A_CPU_Features.html
  15. http://catless.ncl.ac.uk/Risks/5.6.html#subj2.4 | RISKS Digest: Hardware vs Software Battles (from Usenet)[better source needed]

External links