×

Machine Instructions

What is a Digital Computer?

A computer that takes input in a binary form and produces output in binary form.

Machine Instructions

The question arises of what kind of input the computer takes or what kind of input’s required for the computer to work on. So inputs are two things Programs + data, programs are the Machine instructions, and to execute these instructions, data is required. The computer understands only binary form, all the instructions should be in the binary, but instruction cannot be written in binary directly by the user. The program is written in High-level language, and translated with the help of a compilation processor program. So with a language translator, the program is compiled into an equivalent program in binary form. This is called a low-level program or machine code, Byte code, object code.

Program (instructions) written in High-level language are called programming statements. Instructions are the statements which CPU understands, and the CPU understands only binary, so instructions are compiled into binary bits that are understandable by the CPU.

Machine Instructions

Definition of Instruction: A group of bits that instruct the computer to perform some operation. Binary bits statements instruct the computer to execute the program.

The general format of instruction

Instruction can contain two types of information.

Machine Instructions
  1. Operation – It denotes what kind of operation the instruction wants to perform. The first few bits will inform the CPU that this operation to be performed to execute this instruction. Operations like ADD, MUL, SUB, MOVE, STORE, LOAD etc. So, the starting part of the operation will indicate operation, and it is called Operation Code, or in short, it is called OpCode.
  2. Operands – It is the remaining part of the instruction that tells the CPU about the operand’s data on the basis of which an operation is executed.

For example: A CPU has 8 Bits instruction, 3 bits are for the opcode, and the remaining 5 bits are for operand information.

Maximum combination for opcode- 23 =8(0000, 0001, 0010, 0011…1111)

It means 8 distinct types of instruction CPU can support.

Let's take two instructions ADD R1, R2, R3 and ADD R1, R3, R5. Here both have ADD type instruction operands that may be different, but the instruction type is the same.

Note: One opcode denotes one single operation within the CPU. During designing CPU, number of opcodes are decided by architecture. The compiler generates distinct types of instructions that are generated by the CPU. 

Instruction Set Architecture (ISA)

The collection of all those types of instructions that the CPU can support is known as Instruction set architecture. For the above example, size of ISA is 8.

Types of Instruction (Based on Operations)

  • Data Transfer: MOV, LDA, IN, OUT, PUSH, XLAT, XCHG, POP, LEA
MOVMove byte or word to memory.
XLATTranslate byte using a look-up table
PUSHPush data/word into the stack
POPPop word out of the stack
INInput byte
OUTOutput word to port
LEALoad effective address
LDSLoad pointer using data segment
XCHGExchange byte/ word
  • Arithmetic and Logic: ADD, SUB, AND, OR
ADD, SUBAddition and Subtraction of byte
CMPCompare byte/ word
NEGNegate byte/word
INC, DECIncrement and Decrement
IMULInteger multiply
IDIVDivide Byte
CBWConvert byte to word
CWDConvert word to double word
  • Machine Control: EI, DI, PUSH, POP
 EIEnable instruction
DIDisable instruction
PUSHPut the word into the stack.
POPPut the word out of the stack.
  • Iterative: LOOP, LOOPE, LOOPZ
LOOPThe logic of Object-Oriented Programming
LOOPZLOOP While Zero
LOOPLOOP While Equal
  • Branch: JMP, CALL, RET, JZ, JNZ
JMPJump
CALLProduce call
RETReturn instruction
JZJump If Zero
JNZJump If Not Zero

Types of Instruction( Based on Operand information)

  • 4- Address Instruction
Machine Instructions

Within each instruction, maximum of 4- addresses can be specified.

The opcode is the mandatory part of the instruction; we have 4 addresses in which staring three addresses specify operands and last address specify the address of next instruction. The program counter is not present in CPU having 4- address instruction format. Nowadays, it is not used in computers due to disadvantages.

Disadvantage

  • Larger size instruction
  • Larger size program in memory
  • Relocation is not easy.
  • Instruction fetch takes more time.
  • 3- Address Instruction
Machine Instructions

The modern computer uses this 3- address instruction format. Within each instruction, maximum of 3- addresses can be specified.

The opcode is the mandatory part of the instruction; we have 3 addresses that specify operands, and the program counter is used in CPU. Intermediate code generation, 3- address code is generated because CPU can Implement 3- address code in terms of instruction directly, and CPU is also using 3- address instruction code. All those disadvantages in 4- address instruction is eliminated here.

  • 2- Address Instruction
Machine Instructions

Maximum 2 addresses can be specified within an instruction. One operand is used as source and destination. Both means instruction is taken from R2, and the result is copied to R2.

The disadvantage of 2-Address instruction

  • More number of instructions for a program as compare to 3-address instruction format. So it requires more memory.
  • 1- Address Instruction
Machine Instructions

Maximum 1 address can be specified within an instruction. Here apart from opcode, we have only one operand, but we also require a second operand to do the operation, so here second operand value comes from Accumulator. So, it is supported in Accumulator based architecture.

Disadvantage

  • It will have more instruction for a program than 2-address instruction because addresses and more operands are not specified.
  • Here, the number of instructions is reduced, only one operand is used, but we still have more instructions than 2 and 3 address instruction.
  • 0- Address Instruction
Machine Instructions

0-Adress instruction follows stack-based architecture. No addresses can be specified within instruction, and there is only one opcode. So two operands are implicitly taken from the stack. Therefore, 0- address instructions are implemented on stack-based architecture. It is not used in nowadays systems.

Note: If a CPU supports 3-address instruction, then it supports 2-1-0 address instruction also.

If a CPU support 2-address instruction, then it supports 1-0 address instruction also.

If a CPU support 1-address instruction, then it supports 0-address instruction also.

If a CPU supports 0-address instruction, it can only support 0 address instruction.


Related Topics

Instruction Pipelining and Pipeline Hazards

Instruction Pipelining and Pipeline Hazards To apply pipeline, the prerequisite is to perform the same processing over multiple inputs, then pipelining is important. So instruction execution is the best example for...

10 minutes read.

Addressing mode in 8085 microprocessor

What is a Microprocessor? Microprocessor is a unit which is able to perform arithmetic and logical operations and is built on a single chip. The 8085 microprocessor is built by Intel which...

4 minutes read.

Biconnectivity in a Graph

What is a Graph? A graph is a structure where values are stored at the vertex, and the relation between vertices is denoted by edges. In a graph, if there is only...

4 minutes read.

Ethernet Frame Format

What is Ethernet? As we know in computer networking, LAN (Local Area Network) is used to connect devices in limited geographical areas like schools or a building.LAN uses different topologies (arrangement...

3 minutes read.

Flag Register of 8086 Microprocessor

In this article, we are going to study about the one of the registers named flag registers of 8086 microprocessor. We are also going to know where and how to...

3 minutes read.

Advantages and Disadvantages of Flash Memory

What is Flash Memory? Electrically Erasable Programmable Read-Only Memory (EEPROM) and Erasable Programmable Read-Only Memory (EPROM) are used for flash memory (EEPROM). Although technically the word flash is used in the industry...

3 minutes read.

8085 Arithmetic Instructions

Arithmetic instructions are a type of instruction in a computer's instruction set that perform arithmetic operations on data. These operations can include addition, subtraction, multiplication, and division. Arithmetic instructions can...

4 minutes read.

Bipartite Graph

A graph is said to be bipartite if and only if we can divide all the vertices of a graph into two sets such that these sets are mutually exclusive...

4 minutes read.

Local Broadcast Address and loopback address

In computer networking, if you send the data from one source to another source or group of sources in the form of packets, then this is called casting. We can categorize...

3 minutes read.

Assembly Language Register

Assembly Language Register Assembly language was introduced during the late 1940s in the second generation. It is a low-level language that helps in communication between the user and the computer. It...

6 minutes read.

Computer Organization and Architecture Data Formats

Data Formats In the digital world, everything is based on digits. In every method, the calculation is processed on the digits, and most importantly, the computer only understands the binary language...

6 minutes read.

Addressing Modes

Introduction: Addressing Modes An instruction consists of two parts opcode and operands. Opcode tells the operation going to perform, and operand information is the address of the operand. The CPU interprets...

8 minutes read.

Types of Microprocessors

Introduction:Microprocessor is known as the computer processor. The IC or integrated Circuit makes the microprocessor. That is the brain of the computer machine.  The microprocessor is the Processor or CPU (Central...

3 minutes read.

Interfacing DAC with the 8051 Microcontroller

A wide range of applications calls for microcontrollers, including measuring and controlling physical quantities like temperature, pressure, speed, and distance. In these systems, the microcontroller creates digital output, but the controlling...

2 minutes read.

Micro-Operations

Micro-Operations If CPU wants to perform any operation, suppose execution of only one instruction or even break it down one particular execution phase (like fetch instruction, write back, decode, operand fetch...

9 minutes read.

Fixed and Floating-Point Number

Fixed and Floating-Point Number: In digital technology, data is stored in memory registers with binary bits 0’s and 1’s because the computer only understands binary language. When we enter data...

6 minutes read.

8086 Microprocessor Pin Configurations

8086 microprocessor is invented and developed by Intel in 1976. The 8086 Microprocessor is an enhanced version of the 8085 Microprocessor. There are 20 address lines and 16 data lines...

6 minutes read.

Data Transfer and Manipulation

What is Data Transfer? In computer architecture, data transfer refers to the movement of data between different components within a computer system. These components can include the central processing unit (CPU),...

6 minutes read.

Pipelining: Computer Organization and Architecture

Introduction to Pipelining Before learning pipeline, we have to understand about the Parallel processing. Parallel processing is the processing of data simultaneously. There are three techniques of parallel processing. Types of Processing: Vector ProcessingArray...

7 minutes read.

Basic Terminologies Related to COA

Some Basic Terminologies Related to COA Computer organization and architecture is the detailed study of the internal components of the computer with their functionality. It describes how components arranged together and...

7 minutes read.