User Tools

Site Tools


spo600:machine_language

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
spo600:machine_language [2024/01/12 21:18] – [Relationship to Assembly Language] chrisspo600:machine_language [2025/01/08 21:44] (current) chris
Line 1: Line 1:
 ====== Machine Language ====== ====== Machine Language ======
  
-//Machine language//, //machine code//, or //object code// is code that is directly executable by a CPU. It consist of a sequence of binary instructions encoded in a machine's [[Instruction Set Architecture]] (ISA) and is therefore very [[Portable|specific]] to a particular [[Computer Architecture|architecture]].+//Machine language//, //machine code//, or //object code// is code that is directly executable by a CPU. It consist of a sequence of binary instructions encoded for a machine's [[Instruction Set Architecture]] (ISA) and is therefore very [[Portable|specific]] to a particular [[Computer Architecture|architecture]].
  
 =====  General Format  ===== =====  General Format  =====
Line 9: Line 9:
 Many early computers encoded the [[Operation|operation]] and [[Addressing Mode|addressing mode]] as a distinct [[word#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. Many early computers encoded the [[Operation|operation]] and [[Addressing Mode|addressing mode]] as a distinct [[word#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 addressing mode, and still other bits specify the register(s) and other arguments.+Obviously, instructions are specific to a particular type of CPU, and the same opcode may mean very different things on different processors. For example, the opcode 0xA9 ($A9) means "Load Accumulator - Immediate" (LDA #) on a 6502, but the same opcode means "Test" (compare bits) on an x86 system. 
 +Other processors encode instructions as bit fields packed with a instruction word. For example, specific bits within an instruction word specify the operation, other bits specify the addressing mode, and still other bits specify the register(s) and other arguments.
  
 Thus, the length of each instruction may be variable (6502, x86_64) or fixed (ARM) -- a design decision which affects code density, execution speed, and [[Memory Prefetch|memory prefetch]] operations. Thus, the length of each instruction may be variable (6502, x86_64) or fixed (ARM) -- a design decision which affects code density, execution speed, and [[Memory Prefetch|memory prefetch]] operations.
Line 30: Line 31:
  
 Interpretation and compilation represent the two extreme cases of conversion to machine code. There are intermediate approaches between interpreting and compiling: 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 is not modelled after a physical machine. 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. +  *  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 is not modelled after a physical machine. 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. JavaPython, and [[https://webassembly.org/|Wasm]] all 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.+ 
 +  *  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, allowing certain advanced optimizations. JIT execution is typically faster than interpretation, but slower than traditional (pre-)compilation, because the compilation step occurs at run time.
  
spo600/machine_language.1705094328.txt.gz · Last modified: 2024/04/16 18:10 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki