Machine Code
Machine code, also known as machine language, is the fundamental programming language that computers understand, classified as a first-generation programming language (1GL). It consists of binary digits (zeros and ones) that form instructions for the central processing unit (CPU), which is the core component of a computer responsible for executing these commands. Each CPU has its own specific machine code, meaning software must be tailored for different computer brands, like IBM or Apple.
Machine code is challenging for humans to read and write due to its lengthy sequences of binary digits that represent various operations and memory locations. Each instruction contains an opcode, which defines the operation, and an operand, which indicates where to perform the task. Although machine code allows for efficient execution of programs, it has limitations, including the potential for complex sequences and susceptibility to errors from minor changes.
While modern programmers typically use high-level programming languages, which are more human-readable and easier to work with, machine code remains vital for programming certain hardware components and debugging processes. Understanding machine code provides insight into how computers operate at their most fundamental level, despite the increasing abstraction of programming languages today.
Machine Code
Machine code, also known as machine language, is a type of language understood by computers. It is referred to as first-generation programming language (1GL), or the lowest level programming language of a computer. Low-level programming language is a type of vocabulary and set of grammatical rules used to instruct a computer to complete certain tasks.
![Screen shot of the output of the machine code monitor of a W65C816S single-board computer following execution of a short program (also illustrated). By BigDumbDinosaur, representing BCS Technology Limited (Own work) [CC BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0)], via Wikimedia Commons 87998920-106597.jpg](https://imageserver.ebscohost.com/img/embimages/ers/sp/embedded/87998920-106597.jpg?ephost1=dGJyMNHX8kSepq84xNvgOLCmsE2epq5Srqa4SK6WxWXS)
Machine code is made up of a long series of numbers: zeros and ones—known as binary digits, or bits. Groups of binary digits called instructions are translated into a command that could be understood by the central processing unit, or CPU, of a computer. The CPU, also called the processor, is the most important part of a computer. It can be thought of as the brain of the computer and is responsible for translating machine code. A CPU can understand and perform millions of instructions per second. Computers from different manufacturers, such as IBM's PC (personal computer) or Apple's Mac, have different CPUs and use different types of machine code, meaning separate machine code programs must be written to run on the different brands of computers.
Low-Level Programming Language
Machine code is written in binary digits (zeros and ones), which represent electric impulses; for example, off (zero) and on (one) states. The instructions are difficult for a human to understand because they are written in patterns of varying lengths that can be sixteen, twenty-four, thirty-two, or sixty-four digits long. Each CPU has its own machine code. The CPU translates instructions into commands that it can understand such as transferring files or storing data in RAM (random access memory).
The CPU is programmed to know which binary digits in a set of instructions tell it what to do. Each instruction consists of an opcode, or operator, and operand. The opcode refers to the first few digits of an instruction, and it signifies the operation to be performed by the computer. The rest of the digits in an instruction, or the operand, tell the computer the location where the task is to be performed. For example, in the instruction 00000100011100000000000100000010, the opcode 000001 tells the CPU to store the contents of the accumulator in a memory address. The operand 00011100000000000100000010 tells the CPU where to go to complete the task.
Assembly language, also known as assembler language, is a type of low-level programming language. It is known as second-generation programming language (2GL), which means it is a step up from machine code. It was written to help simplify machine code and speed up programming. It still contains long sequences of numbers and is very difficult for humans to read and write, but it does contain some characters. Just like with machine code, CPUs from different manufacturers have different assembly languages, meaning assembly language programs must be written to the specific type of computer.
Machine code runs very quickly and efficiently because the CPU executes the instructions. There are several downfalls, however. Instructions written in machine code can be very lengthy. Some simple tasks require more than ten separate instructions. One tiny change in machine code such as switching binary digits or leaving off one digit can affect the whole instruction sequence and cause errors. It also can cause the CPU to perform a different task altogether.
Computer programmers today typically do not write or read machine code or assembly language. Low-level programming language is difficult for humans to understand because of all the sequences of binary digits and characters required to direct a CPU to complete a task. High-level programming languages typically are used to write programs. However, low-level programming language is still used to program drivers, interfaces, and hardware devices. It also is used in a dump in some debugging programs used to find and correct errors. A dump shows the machine code from the program to help the user pinpoint errors.
High-Level Programming Language
High-level programming language is more like human language and easier to understand than machine code because it requires fewer characters to direct a CPU. It also uses characters and words rather than just binary digits. Some commands are very close to regular language. This makes high-level programming language either third -, fourth-, or fifth-generation programming language (3GL, 4GL, 5GL). The closer the language is to regular human language, the higher generation it is.
Regardless of the particular type of computer, any CPU can understand high-level programming language. However, it must be translated into machine code by a compiler or an interpreter for a CPU to understand it. Both compilers and interpreters are available for most high-level programming languages. Certain languages, however, are designed in a way that they must use either one or the other, but this is rare. Both types also are available for specific brands of computers.
The complier looks at all of the code from the high-level programming language and then collects and reorganizes it into instructions that could be understood by the CPU. Compilers are more commonly used than interpreters.
An interpreter analyzes and executes high-level programming language without looking at all of the code. An interpreter is faster at translating the language than a compiler, but the program produced by the compiler runs faster than the one produced by an interpreter.
Bibliography
"Assembly Language." Techopedia. Techopedia Inc. Web. 10 Mar. 2016. https://www.techopedia.com/definition/3903/assembly-language
Beal, Vangie. "Machine Language." Webopedia. QuinStreet Inc. Web. 10 Mar. 2016. http://www.webopedia.com/TERM/M/machine‗language.html
"Machine Code." Techopedia. Techopedia Inc. Web. 10 Mar. 2016. https://www.techopedia.com/definition/8179/machine-code-mc
"Machine Code (Machine Language)." TechTarget. TechTarget. Web. 10 Mar. 2016. http://whatis.techtarget.com/definition/machine-code-machine-language
"Machine Language vs High-Level Languages." Bright Hub Engineering. Bright Hub Inc. Web. 10 Mar. 2016. http://www.brighthubengineering.com/consumer-appliances-electronics/115635-machine-language-vs-high-level-languages/
"Programming Language Generations." TechTarget. TechTarget. Web. 10 Mar. 2016. http://whatis.techtarget.com/definition/programming-language-generations