machine code program execution general concepts code translation compiler compiletime optimizing compiler intermediate representation ir execution runtime system runtime executable interpreter virtual machine types of code source code object code bytecode machine code microcode compilation strategies justintime jit tracing justintime aheadoftime aot transcompilation recompilation notable runtimes android runtime art common language runtime clr mono crt0 hhvm java virtual machine jvm objectivec v8 nodejs pypy zend engine notable compilers toolchains gnu compiler collection gcc llvm clang vte for code that is completely internal to some cpus and normally inaccessible to programmers see microcode machine language monitor in a w65c816s singleboard computer displaying code disassembly as well as processor register and memory dumps machine code is a computer program written in machine language instructions that can be executed directly by a computers central processing unit cpu each instruction causes the cpu to perform a very specific task such as a load a jump or an alu operation on a unit of data in a cpu register or memory machine code is a strictly numerical language which is intended to run as fast as possible and may be regarded as the lowestlevel representation of a compiled or assembled computer program or as a primitive and hardwaredependent programming language while it is possible to write programs directly in machine code it is tedious and error prone to manage individual bits and calculate numerical addresses and constants manually for this reason programs are very rarely written directly in machine code in modern contexts but may be done for low level debugging program patching and assembly language disassembly the overwhelming majority of practical programs today are written in higherlevel languages or assembly language the source code is then translated to executable machine code by utilities such as compilers assemblers and linkers with the important exception of interpreted programs which are not translated into machine code however the interpreter itself which may be seen as an executor or processor performing the instructions of the source code typically consists of directly executable machine code generated from assembly or highlevel language source code machine code is by definition the lowest level of programming detail visible to the programmer but internally many processors use microcode or optimise and transform machine code instructions into sequences of microops this is not generally considered to be a machine code per se instruction set instruction set every processor or processor family has its own instruction set instructions are patterns of bits that by physical design correspond to different commands to the machine thus the instruction set is specific to a class of processors using mostly the same architecture successor or derivative processor designs often include all the instructions of a predecessor and may add additional instructions occasionally a successor design will discontinue or alter the meaning of some instruction code typically because it is needed for new purposes affecting code compatibility to some extent even nearly completely compatible processors may show slightly different behavior for some instructions but this is rarely a problem systems may also differ in other details such as memory arrangement operating systems or peripheral devices because a program normally relies on such factors different systems will typically not run the same machine code even when the same type of processor is used a processors instruction set may have all instructions of the same length or it may have variablelength instructions how the patterns are organized varies strongly with the particular architecture and often also with the type of instruction most instructions have one or more opcode fields which specifies the basic instruction type such as arithmetic logical jump etc and the actual operation such as add or compare and other fields that may give the type of the operands the addressing modes the addressing offsets or index or the actual value itself such constant operands contained in an instruction are called immediates not all machines or individual instructions have explicit operands an accumulator machine has a combined left operand and result in an implicit accumulator for most arithmetic instructions other architectures such as 8086 and the x86family have accumulator versions of common instructions with the accumulator regarded as one of the general registers by longer instructions a stack machine has most or all of its operands on an implicit stack special purpose instructions also often lack explicit operands cpuid in the x86 architecture writes values into four implicit destination registers for instance this distinction between explicit and implicit operands is important in code generators especially in the register allocation and live range tracking parts a good code optimizer can track implicit as well as explicit operands which may allow more frequent constant propagation constant folding of registers a register assigned the result of a constant expression freed up by replacing it by that constant and other code enhancements programs a computer program is a list of instructions that can be executed by a central processing unit a programs execution is done in order for the cpu that is executing it to solve a specific problem and thus accomplish a specific result while simple processors are able to execute instructions one after another superscalar processors are capable of executing a variety of different instructions at once program flow may be influenced by special jump instructions that transfer execution to an instruction other than the numerically following one conditional jumps are taken execution continues at another address or not execution continues at the next instruction depending on some condition assembly languages assembly language a much more readable rendition of machine language called assembly language uses mnemonic codes to refer to machine code instructions rather than using the instructions numeric values directly for example on the zilog z80 processor the machine code 00000101 which causes the cpu to decrement the b processor register would be represented in assembly language as dec b example the mips architecture provides a specific example for a machine code whose instructions are always 32 bits long the general type of instruction is given by the op operation field the highest 6 bits jtype jump and itype immediate instructions are fully specified by op rtype register instructions include an additional field funct to determine the exact operation the fields used in these types are 6 5 5 5 5 6 bits rtype itype jtype rs rt and rd indicate register operands shamt gives a shift amount and the address or immediate fields contain an operand directly for example adding the registers 1 and 2 and placing the result in register 6 is encoded 0 1 2 6 0 32 decimal 000000 00001 00010 00110 00000 100000 binary load a value into register 8 taken from the memory cell 68 cells after the location listed in register 3 35 3 8 68 decimal 100011 00011 01000 00000 00001 000100 binary jumping to the address 1024 2 1024 decimal 000010 00000 00000 00000 10000 000000 binary relationship to microcode in some computer architectures the machine code is implemented by an even more fundamental underlying layer called microcode providing a common machine language interface across a line or family of different models of computer with widely different underlying dataflows this is done to facilitate porting of machine language programs between different models an example of this use is the ibm system360 family of computers and their successors with dataflow path widths of 8 bits to 64 bits and beyond they nevertheless present a common architecture at the machine language level across the entire line using microcode to implement an emulator enables the computer to present the architecture of an entirely different computer the system360 line used this to allow porting programs from earlier ibm machines to the new family of computers eg an ibm 140114401460 emulator on the ibm s360 model 40 relationship to bytecode machine code is generally different from bytecode also known as pcode which is either executed by an interpreter or itself compiled into machine code for faster direct execution an exception is when a processor is designed to use a particular bytecode directly as its machine code such as is the case with java processors machine code and assembly code are sometimes called native code when referring to platformdependent parts of language features or libraries storing in memory the harvard architecture is a computer architecture with physically separate storage and signal pathways for the code instructions and data today most processors implement such separate signal pathways for performance reasons but actually implement a modified harvard architecture so they can support tasks like loading an executable program from disk storage as data and then executing it harvard architecture is contrasted to the von neumann architecture where data and code are stored in the same memory which is read by the processor allowing the computer to execute commands from the point of view of a process the code space is the part of its address space where the code in execution is stored in multitasking systems this comprises the programs code segment and usually shared libraries in multithreading environment different threads of one process share code space along with data space which reduces the overhead of context switching considerably as compared to process switching readability by humans pamela samuelson wrote that machine code is so unreadable that the united states copyright office cannot identify whether a particular encoded program is an original work of authorship cognitive science professor douglas hofstadter has compared machine code to genetic code saying that looking at a program written in machine language is vaguely comparable to looking at a dna molecule atom by atom look up machine code in wiktionary the free dictionary assembly language endianness list of machine languages machine code monitor overhead code pcode machine pep7 reduced instruction set computing risc very long instruction word teaching machine code microprofessor mpfi notes and references hennessy john l patterson david a computer organization and design the hardwaresoftware interface morgan kaufmann publishers isbn155860281x tanenbaum andrew s structured computer organization prentice hall isbn0130204358 brookshear j glenn computer science an overview addison wesley isbn0321387015 vteapplication binary interface abiparts andconventions alignment calling convention call stack library static machine code memory segmentation name mangling object code opaque pointer positionindependent code relocation system call virtual method table related topics binary code compatibility foreign function interface language binding linker dynamic loader year 2038 problem vtetypes of programming languages actorbased array aspectoriented classbased concatenative concurrent dataflow declarative domainspecific dynamic esoteric eventdriven extensible functional imperative logic macro metaprogramming multiparadigm objectbased objectoriented pipeline procedural prototypebased reflective rulebased scripting stack based synchronous templating assembly compiled interpreted machine lowlevel highlevel very highlevel first generation second generation third generation fourth generation fifth generation nonenglishbased visual authority control gnd 40378275 