Machine code: Difference between revisions

Content deleted Content added
Removed paragraph from lead about early ISA limitations; expanded on tasks
skip
Line 8:
In [[computer programming]], '''machine code''' is [[computer program|computer code]] consisting of '''machine language''' [[instruction set architecture|instructions]], which are used to control a computer's [[central processing unit]] (CPU). For conventional [[binary number|binary computer]]s machine code is "the binary representation of a computer program which is actually read and interpreted by the computer. A program in machine code consists of a sequence of machine instructions (possibly interspersed with data)."<ref>{{cite book |last=Stallings |first=William |title=Computer Organization and Architecture 10th edition |date=2015 |page=776 |publisher=Pearson Prentice Hall |isbn=9789332570405}}</ref>
 
Each machine code instruction causes the CPU to perform a very specific task. A task may be to load a [[Word (computer architecture)|word]] from [[Random-access memory|memory]] to a [[Processor register|CPU register]]. A task may also be to [[jump instruction|jump]] or [[Addressing mode#skip|skip]] to an instruction that is not the next one. Instructions frequently execute an [[arithmetic logic unit]] (ALU) operation on one or more registers.
 
In general, each architecture family (e.g., [[x86]], [[ARM architecture family|ARM]]) has its own [[instruction set architecture]] (ISA), and hence its own specific machine code language. There are exceptions, such as the [[VAX]] architecture, which includes optional support of the [[PDP-11]] instruction set; the [[IA-64]] architecture, which includes optional support of the [[IA-32]] instruction set; and the [[PowerPC 600#PowerPC 615|PowerPC 615]] microprocessor, which can natively process both [[PowerPC]] and x86 instruction sets.
Line 28:
A [[computer program]] is a list of instructions that can be executed by a [[central processing unit]] (CPU). A program's execution is done in order for the CPU that is executing it to solve a problem and thus accomplish a result. While simple processors are able to execute instructions one after another, [[superscalar]] processors are able under certain circumstances (when the pipeline is full) of executing two or more instructions simultaneously. For example, the original [[Intel Pentium]] of 1993 can execute at most two instructions per clock cycle when its pipeline is full.
 
[[Program flow]] may be influenced by special 'jump' and 'skip' instructions that transfer execution to an address (and hence instruction) other than the next numerically sequential address. Whether these [[conditional jump]]s and skips occur is dependent upon a condition such as a value being greater than, less than, or equal to another value.
 
==Assembly languages==
Line 35:
A much more human-friendly rendition of machine language, named [[assembly language]], uses [[Assembly language#Opcode mnemonics and extended mnemonics|mnemonic code]]s to refer to machine code instructions, rather than using the instructions' numeric values directly, and uses [[Symbol table|symbolic names]] to refer to storage locations and sometimes [[Processor register|registers]].<ref name="Dourish_2004"/> For example, on the [[Zilog Z80]] processor, the machine code <code>00000101</code>, which causes the CPU to decrement the <code>B</code> [[general-purpose register]], would be represented in assembly language as <code>DEC B</code>.<ref name="Zaks_1982"/>
 
==ExampleExamples==
===IBM 709x===
The [[IBM 700/7000 series#Later scientific architecture (704/709/7090/7094)|IBM 704, 709, 704x and 709x]] had a Compare Accumulator with Storage (CAS) instruction that did a three way compare and conditionally skipped to NSI, NSI+1 or NSI+2, depending on the result.
 
===MIPS===
The [[MIPS architecture]] provides a specific example for a machine code whose instructions are always 32 bits long.<ref name="Harris_2007"/>{{Rp|299}} The general type of instruction is given by the ''op'' (operation) field, the highest 6 bits. J-type (jump) and I-type (immediate) instructions are fully specified by ''op''. R-type (register) instructions include an additional field ''funct'' to determine the exact operation. The fields used in these types are: