What are machine instructions? Definition and examples

Machine instructions are machine code programs or commands. In other words, commands written in the machine code of a computer that it can recognize and subsequently execute.

Machine code or machine language refers to a computer programming language consisting of a string of ones and zeros, i.e., binary code. Computers can respond to machine code directly, i.e., without any direction or conversion.

Machine instructions make up the machine language program

One machine instruction consists of several bytes of memory. It tells the computer’s CPU to perform one machine operation. CPU stands for Central Processing Unit.

The CPU looks at machine instructions in the system’s main memory, one after another. For each machine instruction, it performs one machine operation.

The machine language program is the collection of all machine instructions in the main memory.

Machine Instructions 11234 Image 1
The computer’s control unit processes the machine instructions in a step-by-step manner.

Machine instructions – four main steps

There are four main steps in the machine instruction cycle:

Fetch: the processor fetches the instruction from the memory address. It stores the address in the PC (Program Counter) and IR (Instruction Register). The PC points to the next instruction at the end of the fetch operation.

Decode: the processor interprets and decodes the instruction. The instruction within the IR gets decoded.

Execute: the CPU’s Control Unit decodes the data as a sequence of control signals to the CPU’s relevant function units. These units perform the actions that the instruction ‘instructs.’

Store: the operation generates a result, which the processor stores in the main memory. Sometimes, it may send it to an output device.

According to chortle.ccsu.edu:

Each tiny electronic operation that a processor core can perform is called a machine operation. A processor (a ‘machine’) performs these one at a time, but billions of them in a second.”

Converting human instructions into machine instructions

Human programmers do not write programs as long strings of ones and zeros or sequences of binary digits. They use Python, BASIX, Ruby, Java, C++, or another programming language. We call these high-level programming languages.

High-level languages are more like the everyday written language that humans use, rather than binary number sequences. But computers don’t understand them.

Before a computer’s processor can execute the instructions in high-level languages, they must be translated into a binary code.

In the world of computer programming, there are two languages:

Human-readable language. In this case, humans can read and understand them, but machines cannot.

Machine-readable language. These appear as long strings of ones and zeros and tell the computer’s processor what to do. Humans cannot read the language, only machines (computers) can.

Compilers and interpreters

Most programming software has a piece of translating software that converts high-level languages into machine instructions. We call these translators compilers and interpreters. Compilers or interpreters translate the language.

A compiler translates a human-readable program into a machine-readable form before the program can run.

An interpreter translates a human-readable program, instruction by instruction, into an executive, machine-readable form. Then, it executes each instruction that it has translated before it moves onto the next one. Every time the program runs, it is translated.