Jump to: navigation, search

Machine Language

3,381 bytes added, 11:52, 14 December 2013
no edit summary
[[Category:SPO600]]{{Chris Tyler Draft}}Machine language or machine code is code that is directly executable by a CPU. It consist of a number sequence of binary instructions encoded in a machine's [[Instruction Set Architecture]] (ISA) and is therefore very specific to a particular [[Computer Architecture|architecture]].
== General Format ==
== Resources ==Machine code consists of a series of instructions, each of which specifies an operation and zero or more arguments. Each argument may indicate a [[Register]], a [[Memory Address]], or an [[Immediate Value]].
* Wikipedia background articlesMany early computers encoded the [[Operation|operation]] and [[Addressing Mode|addressing mode]] as a distinct [[Byte|byte]] or [[Word|word]] called an [[OpCode|opcode]], followed by zero or more additional bytes for the arguments, where the number of additional bytes is implied by the opcode. ** Other processors encode instructions as bit values packed with a instruction field. For example, specific bits within an instruction word specify the operation, other bits specify the [[:fedora:Machine Addressing mode|addressing mode]], and still other bits specify the register(s). Thus, the length of each instruction may be variable (6502, x86_64) or fixed (ARM) -- a design decision which affects codedensity, execution speed, and [[Memory Prefetch|memory prefetch]] operations. == Assembly Language == Machine Codelanguage is very hard to write and read, although it can be hand-coded on simple processors (it was not uncommon for 6502 programmers to memorize the complete instruction set, for example). It is particularly difficult to write and read when the ISA uses bit-packing. [[Assembly language]] is closely related to machine language, but uses a [[Symbolic|symbolic]]representation of instructions and memory locations and is therefore easier to write and read.** == Relationship to Other Languages == Since machine language is the only type of code which can be directly executed by a CPU, all other languages are ultimately converted into machine language in some way. '''Interpreted languages''', such as bash, are not converted into machine code, but blocks of machine code within the interpreter are selectively invoked to perform the operations stated in the program or script. '''Compiled languages''', such as C, are converted into machine language instructions by the [[Compiler|compiler]]. The machine language code is stored in a separate [[wp:Instruction setObject file|Instruction Set Architectureobject file]]for later execution. Interpretation and compilation represent the two extreme cases of conversion to machine code. There are intermediate approaches between interpreting and compiling:* Bytecode compilers and interpreters compile source code into a "bytecode" which is like an architecture-independent machine code. The instructions in the bytecode are effectively instructions for a virtual machine that doesn't exist. Therefore, they cannot be directly executed by any CPU, but they can be interpreted much more quickly than the original source code because they have already been partially processed. Java and Python both utilize bytecode in the most common implementations.* Just-in-time (JIT) interpreters/compilers take source code or bytecode and compile it into machine code on-the-fly. This has three advantages over traditional compilation: (1) the distributed software can be in an architecture-neutral form, (2) any portion of the code which will not be executed is not compiled, and (3) more information is available to the compiler about the execution environment when the compilation is being performed. JIT execution is typically faster than interpretation, but slower than traditional (pre-)compilation, because the compilation step occurs at run time.

Navigation menu