Professional Documents
Culture Documents
formats
Instruction formats
Computers may have instructions of several
different lengths containing varying number of
address
Three address instructions
Two address instructions
One address instructions
Zero address instructions
Three address instructions
Can be represented symbolically as,
ADD A , B , C
A,B,C are variables in which the variable names are
assigned to distinct locations in the memory
A and B are called source operands and C is called
as the destination operand
General three instruction format ,
Operation Source 1 , Source 2 , Destination
Two address instructions
Can be represented symbolically as,
ADD A , B
General two instruction format ,
Operation Source, Destination
One address instructions
Can be represented symbolically as,
ADD B , LOAD A , STORE B
General two instruction format ,
Operation Source
Zero address instructions
In these instructions , the locations of all operands are
defined implicitly
Such instructions are found in machines that store
operands in a structure called a pushdown stack
PUSH A , POP Y
Instruction types
Instructions must be capable of performing three
basic operations,
Data Movement
Data Processing
Program Sequencing and Control
Data Transfer Instructions
Load Instruction
This instruction copies the contents of memory location into the
accumulator or general purpose register
Eg:-
Load M - Copies the contents of memory location M into the
accumulator
Load M,Ri - Copies the contents of memory location M into Ri
(general purpose register)
Data Transfer Instructions
Store Instruction
This instruction copies the contents of accumulator or general
purpose register into memory location
Eg:-
Store M - Copies the contents of accumulator to memory M
Store Ri,M - Copies the contents of Ri into memory location M
Data Transfer Instructions
Move Instruction
This instruction places a copy of the contents of source into
destination
Eg:-
MOVE A,Ri - Same as Load A,Ri
MOVE Ri,A - Same as Store Ri,A
Arithmetic Instructions
Add Instruction
This instruction adds the contents of memory location or register
(source) and destination , and store result in the destination
Eg:-
Add M - Add the contents of memory location M to the
contents of the accumulator and place the sum
back into the accumulator
Add Ri,Rj - Add the contents of Ri to the contents of Rj and
store the sum into Rj
Add Ri,Rj,Rk - Add the contents of Ri,Rj and Rk, and store the
sum into Rk
Add #50,R1 - Add 50 into the contents of R1 and store and sum
in R1
Arithmetic Instructions
Increment Instruction
This instruction increments the contents of specified register by 1.
Eg:-
Increment R1 : R1 R1 + 1
Decrement Instruction
This instruction decrements the contents of specified register by 1
Eg:-
Decrement R2 : R2 R1 - 1
Arithmetic Instructions
Sub Instruction
This instruction subtracts the contents of memory location or
register (source) from destination and store the result into
destination.
Eg:-
Sub M : Subtracts the contents of memory location M from
the contents of accumulator and store the result back into the
accumulator
Sub Ri,Rj : Subtracts the contents of Ri from Rj and store the
result in Rj.
Arithmetic Instructions
Compare Instruction
Subtracts the contents of memory location or register (source) from
destination and sets the condition flags according to the result.
Eg:-
Compare M : Compares contents of memory location M
with the contents of the accumulator
Compare #50,R1 : Compares 50 with the contents of R1.
Clear Instruction
This instruction clears (makes contents equal to 0) specified
register.
Eg:- Clear R1 : R1 0
Arithmetic Instructions
Multiplication and Division Instructions
Eg:-
MUL R1,R0 ; R1 R1 X R0
DIV R1,R0 ; R1 R1 R0
Unfortunately , all processors do not provide these instructions .
On those processors MUL and DIV instruction are
implemented by performing basic operations such as add ,
subtract , shift and rotate repeatedly.
Logical Instructions
Logic instructions perform logic operations such as AND , OR
and NOT between registers or between memory and memory
location
1. NOT dst
The instruction complements all bits contained in the destination
operand , changing all Os to 1s and all 1s to Os.
NOT R1 : 1s complement
ADD R1,#1 : 2s complement
2. Negate R1
This instruction gives 2s complement of a number in R1 register
Logical Instructions
AND R0, #% 10001001
This instruction logically ANDs the contents of register R0 and the
given number in binary form.
OR R0, # $ 3E
This instruction logically ORs the contents of register R0 and the
given number in hexadecimal form.
Shift and Rotate Instructions
This instruction shift or rotates the bits of the operand right or left
by some specific number of bit positions.
Logical Shifts
LshiftL dst, count
LshiftR dst,count
The vacant positions are filled with zeroes.
Arithmetic Shift
Same as the above but the sign bit is repeated.
Shift and Rotate Instructions
Rotate Instructions
In shift instructions , the bits shifted out of the operand
are lost except for the retained bits
On the other hand, the rotate instructions preserve
the data during the rotate operations.
Program Sequencing and control Instructions
Branch Instructions
Branch Loop
BGTZ Loop
Call and return instructions
CALL SUB(2000)
RETURN
RISC Instructions
Reduced Instruction Set Computers or Computing
One Instruction per machine cycle
Instructions are not complicated
Simpler instruction formats
Simpler addressing modes