Chapter-3 Instruction Set and Programming of 8085 Part1 - 1-Introduction
Chapter-3 Instruction Set and Programming of 8085 Part1 - 1-Introduction
Compiler
Assembly
Compiler
Language
Assembler
Machine
Language
A statement in a high-
level language is
High-Level Language: A + B translated typically into
several machine-level
instructions
Control Instructions
Three-byte Instructions
Requires three memory locations
to perform an operation
E.g. JMP, CALL
8085 instructions
Instruction Set
It is the set of instructions that the microprocessor can understand.
Opcode
Known as Operation Code.
This required field contains the mnemonic operation code for the
8085 instruction.
Operand
The operand field identifies the data to be operated on by the
specified opcode.
Some instructions require no operands, while others require one or
two operands.
Opcode Operand
MVI D, 8BH
Addressing Modes
In an instruction, there my be one operand or two operands.
The various formats of specifying operands are called
addressing modes.
8085 instruction set has the following addressing modes
Immediate Addressing
Register Addressing
Direct Addressing
Indirect Addressing
The detailed examples in further slides
8085 instructions
General Terms
Control Instructions
Three-byte Instructions
Requires three memory locations
to perform an operation
E.g. JMP, CALL
One-byte Instruction
One-byte instruction
includes Opcode and Operand in the same byte.
In two-byte instruction,
1st Byte : Specifies Opcode
2nd Byte: Specifies Operand
Control Instructions
Three-byte Instructions
Requires three memory locations
to perform an operation
E.g. JMP, CALL
8085 Programming
Data Transfer Instructions
Data Transfer Instructions
Instructions copy data from source to destination.
While copying, the contents of source is not modified.
Data Transfer Instructions do not affect the flags.
MOV: Move data from source to destination
MVI R, Data • The 8-bit data is stored in the MVI B, 57H; B12
M, Data destination register or memory. MVI M, 12H ;
• If the operand is a memory M[HL]12
location, its location is specified
by the contents of the HL
registers.
• Two-byte instruction.
Example
Write an assembly language program to copy data (87 H) from
B register to D register.
Program
MVI B, 87H ; initialize B register with the value 87H
MOV D, B ; Copy value from B to D
HLT ; End of the program
LDA: Load Accumulator
Registers Memory
02 2000
A 0D
04 …
B C 0A ..
06 .
D E
0F 2049
H L 0D 2050
05 2051
03 2052
Example
Write an assembly language program to copy data (87 H) which
is available at memory location 2000H to D register.
Program
LDA 2000H ; Copy data into A
MOV D, A ; Copy value from A to D
HLT ; End of the program
LDAX: Load the accumulator indirect
LDAX B ; AM[BC]
Registers Memory
02 0001
A
04 0002
B 00 06 C 0A 0003
06 0004
D E
0F 0005
H L 0D 0006
05 0007
03 0008
Addressing Modes (Revised)
In an instruction, there my be one operand or two operands.
The various formats of specifying operands are called
addressing modes.
8085 instruction set has the following addressing modes
Immediate Addressing – MVI R, Data
Register Addressing – MOV Rd, Rs
Direct Addressing – LDA 2050H
Indirect Addressing - LDAX B
LXI: Load the immediate register pair
LXI H, 2034H A
Registers B
D
H 20 34 L
Example
Write an assembly language program to copy data (87 H) from
memory location 2000H to D register.
Program
LXI B, 2000H ; Copy 20H to B and 00H to C
LDAX B ; Copy data from ML specified by BC register into A
MOV D, A ; Copy value from A to D
HLT ; End of the program
STA: Store Accumulator
02 0001
04 0002
A 0D 0A 0003 Memory
06 0004
B 00 06 C 0F 0005
Registers
D E 04 0006
05 0007
H L 03 0008
OUT: Output from Accumulator to 8-bit port
Program
MVI B, 87H ; Initialize B
MOV A, B ; Copy value from B to A
OUT 01H ; Send data in A to output port
HLT ; End of the program
LHLD: Load H and L registers direct
Registers Memory
02 0001
A
04 0002
B C 0A 0003
06 0004
D E
0F 0005
H 05 0D L 0D 0006
05 0007
03 0008
SHLD: Store H and L registers direct
Memory
SHLD 0002H
0001
D3 0002
H A2 D3 L A2 0003
0004
XCHG: Exchange H and L with D and E
D A2 03 E D D3 08 E
H D3 08 L H A2 03 L
1 MOV Dst,Src Copy content 1 Byte
2 MVI (R/M), 8-bit Data Load 8-bit to Register/Memory 2 Byte
3 LDA 16-bit address Load Accumulator 3 Byte
4 LDAX Rp(B/D) Load the accumulator indirect 1 Byte
5 LXI Rp, 16-bit Data Load the register pair immediate 3 Byte
6 STA 16-bit address Store Accumulator 3 Byte
Data Transfer Instructions
Control Instructions
Three-byte Instructions
Requires three memory locations
to perform an operation
E.g. JMP, CALL
8085 Programming
Arithmetic Instructions
Arithmetic Instructions
1 Add register or memory, to the accumulator 1 Byte
ADD R/M
2 ADC R/M Add register to the accumulator with carry 1 Byte
3 ADI 8-bit data Add the immediate to the accumulator 2 Byte
4 ACI 8-bit data Add the immediate to the accumulator with carry 2 Byte
Arithmetic Instructions
ADI 8-bit • The 8-bit data (operand) is added ADI 03; A = A + 03h
data to the contents of the
accumulator and the result is
stored in the accumulator.
• All flags are modified to reflect
the result of the addition.
Example : Addition
Example : Addition
ADC: Add register to accumulator with carry
Instruction Description Example
Opcode Operand
ACI 8-bit • The 8-bit data (operand) and the ACI 03; A = A + 03h + CY
data Carry flag are added to the
contents of the accumulator and
the result is stored in the
accumulator.
• All flags are modified to reflect the
result of the addition.
DAD: Add register pair to H and L registers
DAD B
Registers
A
B 02 08 C
D E + 02 08
H 02 03 L 02 03
04 0B
04 0B
Arithmetic Instruction
Subtraction
8085 performs subtraction by using 2’s complement.
The subtraction can be performed by SUB/ SUI on 8-bit
data.
In any case, minuend (the number from which to subtract)
is in A.
If result after subtraction is 0, then Zero flag is set.
SUB: Subtract register/memory from
accumulator
Instruction Description Example
Opcode Operand
SBI 8-bit • The 8-bit data (operand) and the SBI 08h; A=A -
data borrow (CY) are subtracted from (08h+CY)
the contents of the accumulator
and the result is stored in the
accumulator.
INR: Increment register/memory by 1