Machine language
A systemcodes directly understandable bycomputer's CPUtermed this CPU's native or machine language. Although machine code may seem similarassembly language theyin fact two different typeslanguages. Assembly code consistsboth binary numberssimple words whereas machine codecomposed only oftwo binary digits 01. Every CPU has its own machine language, although thereconsiderable overlap between some. If CPU A understandsfull languageCPU B itsaid that AcompatibleB. CPU B may not be compatibleCPU A, as A may knowfew codes that B does not.The "words" ofmachine languagecalled instructions; eachthese givesbasic command toCPU. A programjustlong listinstructions thatexecuted byCPU. Older processors executed instructions one afterother, but newer superscalar processorscapableexecuting several instructions at once. Program flow may be influenced by special jump instructions that transfer executionan instruction other thanfollowing one. Conditional jumpstaken (execution continues at another address) or not (execution continues atnext instruction) depending on some condition.
Instructionssimplypattern bits -- different patterns corresponddifferent commands tomachine. The more readable rendition ofmachine languagecalled assembly language.
Some languages give all their instructionssame numberbits, whileinstruction length differsothers. Howpatternsorganised depends largely onspecific language. Commonmost isdivisionan instruction into fields,which one or more specifyexact operation (for example "add"). Other fields may givetype ofoperands, their location, or their value directly (operands containedan instructioncalled immediate).
Asspecific example, let us takelook atMIPS architecture. Its instructionsalways 32 bit long. The general typeinstructiongiven byop field,highest 6 bits. J-typeI-type instructionsfully specified by op. R-type instructions include an addtional field functdetermineexact operation. The fields usedthese types are:
6 5 5 5 5 6 bits [ op | rs | rt | rd |shamt| funct] R-type [ op | rs | rt | address/immediate] I-type [ op | target address ] J-typers, rt,rd indicate register operands; shamt givesshift amount; andaddress or immediate fields contain an operand directly.
For example addingregisters 12placingresultregister 6encoded:
[ op | rs | rt | rd |shamt| funct]
0 1 2 6 0 32 decimal
000000 00001 00010 00110 00000 100000 binary
Loadingvalue frommemory cell 68 cells afterone register 3 pointsinto register 8:
[ op | rs | rt | address/immediate] 35 3 8 68 decimal 100011 00011 01000 00000 00001 000100 binaryJumping toaddress 1025:
[ op | target address ]
2 1025 decimal
000010 00000 00000 00000 10000 000001 binary
See also
CISC, RISC, VLIW, Endianness.
