Professional Documents
Culture Documents
Microprocessors & Microcontrollers
Microprocessors & Microcontrollers
Microprocessors & Microcontrollers
Microcontrollers
Lecture 5
24/01/2022
Classification of Instruction Set
• Data Transfer Instruction
• Arithmetic Instruction
• Logical Instruction
• Branching Instruction
• Control Instruction
Arithmetic Instruction
Operation A=A+R
Machine Cycle OP
No. of bytes 1 byte
Flags All the flags are modified
Addressing mode Register Addressing mode
T-states 4
Arithmetic Instruction
Suppose before the execution of the instruction ADD E
A = 10101111
E = 10110101
CY = 0 , S = 1, Z = 0 and P = 1
then after the execution of the instruction ADD E we get the following
result:
A=10101111
E=10110101
_____________________________
A=101100100
CY
The flags will be affected as;
CY = 1, S = 0 , Z = 0 and P = 0
Arithmetic Instruction
ADD M
Operation A=A+M
Machine Cycle OP +MR
No. of bytes 1 byte
Flags All the flags are modified
Addressing mode Indirect Addressing mode
T-states 4+3 =7
Arithmetic Instruction
ADC R
Operation A=A+R+CY
Machine Cycle OP
No. of bytes 1 byte
Flags All the flags are modified
Addressing mode Register Addressing mode
T-states 4
Arithmetic Instruction
Suppose before the execution of the instruction ADC D
A = 10101001
D = 10111101
CY = 1, S = 1, Z = 0 and P = 1
then after the execution of the instruction ADD D we get the following
result:
CY = 1
A=10101001
D=10111101
_____________________________
A=1 01100111
CY
All flags will be affected.
Arithmetic Instruction
ADC M
Operation A=A+M+CY
Machine Cycle OP + MR
No. of bytes 1 byte
Flags All the flags are modified
Addressing mode Indirect Addressing mode
T-states 4 +3 =7
Arithmetic Instruction
ADI Data
Operation A=A+Data
Machine Cycle OP + MR
No. of bytes 2 byte
Flags All the flags are modified
Addressing mode Immediate Addressing mode
T-states 4 +3 =7
Arithmetic Instruction
ACI Data
(Adds immediately the data with Carry)
Operation A=A+Data +CY
Machine Cycle OP + MR
No. of bytes 2 byte
Flags All the flags are modified
Addressing mode Immediate Addressing mode
T-states 4 +3 =7
Arithmetic Instruction
DAD Rp
(Double Add )
Operation HL -- HL + Rp
Machine Cycle OP + BI + BI
No. of bytes 1 byte
Flags Only the carry flag is affected, No
other flags are modified to reflect
the result of operation
Addressing mode Register Addressing mode
T-states 4 +3 + 3 =10
Operation A=A-R
Machine Cycle OP
No. of bytes 1 byte
Flags All the flags are modified to reflect
the result of subtraction
Addressing mode Register Addressing mode
T-states 4
Arithmetic Instruction
Suppose before the execution of the instruction SUBD
A = 10101111, D = 10110101, CY = 0 , S = 1, Z = 0 and P =
1
then after the execution of the instruction SUBD we get
the following result:
A=10101111
D=10110101
_____________________________
A=111111010
CY
Arithmetic Instruction
SUB M
Operation A=A-M
Machine Cycle OP + MR
No. of bytes 1 byte
Flags All the flags are modified to reflect
the result of subtraction
Addressing mode Indirect Addressing mode
T-states 4 +3 =7
Arithmetic Instruction
SBB R
(Subtract register and borrow flag from accumulator)
Operation A=A-R-CY
Machine Cycle OP
No. of bytes 1 byte
Flags All the flags are modified to reflect
the result of subtraction
Addressing mode Register Addressing mode
T-states 4
Arithmetic Instruction
Suppose before the execution of the instruction SBB H
A = 10101111, H = 10110101, CY = 0 , S = 1, Z = 0 and P =
1
then after the execution of the instruction SBB H we get
the following result:
A=10101111
H=10110101
CY = 1
____________________________
A=111111001
CY
Arithmetic Instruction
SUI Data
Operation A=A-M-CY
Machine Cycle OP + MR
No. of bytes 1 byte
Flags All the flags are modified to reflect
the result of subtraction
Addressing mode Indirect Addressing mode
T-states 4 +3 =7
Arithmetic Instruction
SBI Data
(Subtract immediate 8-bit data and borrow flag from accumulator)
If the value of the low order 4 bits B3-B0 in the accumulator is greater
than 9 or if AC flag is set, then the instruction adds 6 to the low order 4
bits of the accumulator.
If the value of the high order 4 bits B7-B4 in accumulator is greater than 9
or if the carry flag is set, then the instruction add 6 to the high order 4 bits
of the accumulator.
Arithmetic Instruction
• The DAA instruction is used with the add instructions eg. ADD, ADI etc. to
perform addition of a number in BCD. The add instruction add the two
BCD numbers in hexadecimal form and the DAA instruction converts this
hexadecimal result to BCD format.
• Eg. MVI A, 12H
ADI 39 H
DAA
A= 0001 0010
Data= 0011 1001
1st = 0100 1011
Arithmetic Instruction
1st = 0100 1011
DAA(LSB) = + 0110
= 0101 0001 (51)
A = 0 0 0 1 1 0 0 1 CY = 1
M2500 = 0 0 1 1 0 1 1 1
__________________________
A= 00010001 CY = 0
Logical Instruction
ANI Data
Operation A=A AND data
Machine Cycle OP +MR
No. of bytes 2 byte
Flags S,Z and P reflect the result of
operation and CY flag is reset ad
AC flag is set
Addressing mode Immediate Addressing mode
T-states 4 +3 =7
Logical Instruction
If A = AB H and CY = 1 before the execution of ANI 06 H,
Then after the execution of this instruction we have:
A = 1 0 1 0 1 0 1 1 CY = 1
data = 0 0 0 0 0 1 1 0
__________________________
A = 0 0 0 0 0 0 1 0 CY = 0
Logical Instruction
ORA R
Operation A=A OR R
Machine Cycle OP
No. of bytes 1 byte
Flags S,Z and P reflect the result of
operation and CY and AC flag are
reset
Addressing mode Register Addressing mode
T-states 4
Logical Instruction
Before the execution of the instruction ORA B
Let A = 73 H B = C3 H CY = 1
Then after the instruction is executed we get:
A = 0 1 1 1 0 0 1 1 CY = 1
B=11000011
__________________________
A = 1 1 1 1 0 0 1 1 CY = 0
Logical Instruction
ORA M
Operation A=A OR M
Machine Cycle OP + MR
No. of bytes 1 byte
Flags S,Z and P reflect the result of
operation and CY and AC flag are
reset
Addressing mode Indirect Addressing mode
T-states 4 +3
Logical Instruction
Let A = 19 H H = 21 H L = 00 H
M 2100 = 37 H and CY = 1 before the execution of the instruction
ORA M. Then after the instruction is executed we get:
A = 0 0 0 1 1 0 0 1 CY = 1
M 2100 = 0 0 1 1 0 1 1 1
__________________________
A = 0 0 1 1 1 1 1 1 CY = 0
Logical Instruction
ORI Data
Operation A=A OR Data
Machine Cycle OP + MR
No. of bytes 2 byte
Flags S,Z and P reflect the result of
operation and CY and AC flag are
reset
Addressing mode Immediate Addressing mode
T-states 4 +3
Logical Instruction
If A = AB H and CY = 1 before the execution of ORI 16 H, then
after the execution of this instruction we have:
A = 1 0 1 0 1 0 1 1 CY = 1
data = 0 0 0 1 0 1 1 0
__________________________
A=10111111 CY = 0
Logical Instruction
XRA R
Operation A=A EX-OR R
Machine Cycle OP
No. of bytes 1 byte
Flags S,Z and P reflect the result of
operation and CY and AC flag are
reset
Addressing mode Register Addressing mode
T-states 4
Logical Instruction
Let A = 73 H D = C3 H, CY = 1 before the execution of the
instruction XRA D. Then after the instruction is executed we get:
A=01110011 CY = 1
D=11000011
__________________________
A=10110000 CY = 0
Logical Instruction
XRA M
Operation A=A EX-OR M
Machine Cycle OP +MR
No. of bytes 1 byte
Flags S,Z and P reflect the result of
operation and CY and AC flag are
reset i.e =0
Addressing mode Indirect Addressing mode
T-states 4 +3 =7
Logical Instruction
XRI Data
Operation A=A EX-OR M
Machine Cycle OP +MR
No. of bytes 2 byte
Flags S,Z and P reflect the result of
operation and CY and AC flag are
reset i.e =0
Addressing mode Immediate Addressing mode
T-states 4 +3 =7
Logical Instruction
CMA
Operation A= complement (A)
Machine Cycle OP
No. of bytes 1 byte
Flags No flags are modified
Addressing mode Implied Addressing mode
T-states 4