Documente Academic
Documente Profesional
Documente Cultură
Instruction Format:
Addressing Modes:
The various formats of specifying the operands are called the Addressing Modes. The 8085
instruction set has the following addressing modes.
1. Immediate Addressing Mode.
2. Register Addressing Mode.
3. Direct Addressing Mode.
4. Indirect Addressing Mode.
1. Immediate Addressing Mode: Transferring the data into register. (Eg: MOV Rs, Data).
2. Register Addressing Mode: Transferring one register content into another register. (Eg:
MOV Rd, Rs).
3. Direct Addressing Mode: Reading/Writing data directly from Input / Output. (Eg: IN 8-bit
port Address).
Since the 8085 is an 8-bit device it can have up to 28 (256) instructions. However, the
8085 only uses 246 combinations that represent a total of 74 instructions. Most of the
instructions have more than one format.
These instructions can be grouped into five different groups:
1. Data Transfer (Copy) Operations.
2. Arithmetic Operations.
3. Logic Operations.
4. Branch Operations.
5. Machine Control Operations.
Arithmetic Operations:
These operations perform arithmetic operations such as addition, subtraction, increment and
decrement.
Logical Operations:
These instructions perform various logical operations such as logical AND, OR, Exclusive-OR,
Rotate, Compare and Complement with the contents of the accumulator.
Branching Operations:
The group of instructions such as Jump, Call, Return and Restart alters the sequence of program
execution either conditionally or unconditionally.
Load Accumulator
Copy the data byte into the accumulator from the
LDA 16-bit Address LDA 2034H
memory location specified by 16-bit address.
Load Accumulator Indirect
Copy the data byte into the accumulator from the
LDAX B/D Reg. Pair LDAX B
memory location indicated by a register pair.
Store Accumulator Direct
Copy the data byte from the accumulator into the
STA 16-bit Address STA 4350H
memory location specified by 16-bit address.
Store Accumulator Indirect
Copy the data byte from the accumulator into the
STAX Reg. Pair STAX B
memory location indicated by a register pair.
Load Register pair Immediate
Reg. Pair, 16-
LXI Load 16-bit data into a register pair LXI H, 2034H
bit data
Writing data to a Output device
8-bit (Port Send (write) data byte from accumulator to an
OUT OUT PORT1
Address) output device.
Reading data from an Input Device
8-bit (Port Accept (read) data byte from an input device and
IN IN PORT0
Address) place it in the accumulator.
Arithmetic Instruction Set:
ADI 8-bit Data Add 8-bit data to contents of accumulator ADI 45H
SUI 8-bit Data Subtract 8-bit data to contents of accumulator SUI 45H
Complement Accumulator
Jump Unconditionally
Jump Conditionally
JNC 16-bit Address Jump to 16-bit address on No Carry CY=0 JNC 2034H
JNZ 16-bit Address Jump to 16-bit address on No Zero flag Z=0 JNZ 2034H
JPE 16-bit Address Jump to 16-bit address on parity flag even P =1 JPE 2034H
JPO 16-bit Address Jump to 16-bit address on parity flag odd P =0 JPO 2034H
Call Unconditionally
Change the program sequence to the location of a
CALL 16-bit Address CALL 2034H
sub routine specified by the 16-bit address
Call Conditionally
CZ 16-bit Address Call a routine on 16-bit address on Zero flag Z=1 CZ 2034H
Call a routine on 16-bit address on No Zero flag
CNZ 16-bit Address CNZ 2034H
Z=0
Call a routine on 16-bit address on parity flag
CPE 16-bit Address CPE 2034H
even P =1
Call a routine on 16-bit address on parity flag odd
CPO 16-bit Address CPO 2034H
P =0
Return from a subroutine Unconditionally
Return from the calling program after completing
RET RET
the subroutine sequence.
Return from a subroutine Unconditionally
A microprocessor performs a task by reading and executing the set of instructions written in its
memory. This set of instructions, written in a sequence is called a program. Writing a program
is equivalent to giving specific commands to the microprocessor in a sequence to perform a task.
Steps:
Step 1: Read the problem carefully.
Step 2: Break it down into small steps.
Step 3: Represent these small steps in a possible sequence with a flowchart.
Step 4: Translate each block of flow chart into appropriate mnemonic instruction.
Step 5: Translate mnemonics into the machine code.
Step 6: Enter the machine code in memory and execute.
Step 7: Start troubleshooting.
Sample Program 1:
Problem Statement: Write a program to perform the following functions and verify the output.
1. Load register B with Number 37H.
2. Send the number to the output port.
Assembly Language Program:
Tasks to perform the operation: 1. Load register B with 37H.
2. Move the contents of register B to register A.
3. Send the number to the output port 01H.
4. End of program.
Assembly Language Code corresponding to each task:
MVI B, 37H Moves immediate data of 37H into register B.
MOV A, B Moves the contents of register B to Accumulator register A.
OUT, PORT1 this instruction sends the accumulator contents to output port.
HLT end of program (Do Nothing).
Sample Program 2:
Problem Statement: Write a program to perform the following functions and verify the output.
1. Load the number 8BH in register D.
2. Load the number 6FH in register C.
3. Increment the contents of register C by one.
4. Add the contents of registers C and D and display the sum at the output port1.
Assembly Language Code corresponding to each task:
MVI D, 8BH Moves immediate data of 8BH into register D.
MVI C, 6FH Moves immediate data of 6FH into register C.
INR C Increments the contents of register C by 1.
MOV A, C Moves the contents of register C into accumulator register A.
ADD D Adds the contents of register D to contents of accumulator register A.
OUT PORT1 this instruction sends the accumulator contents to output port.
HLT end of program (Do Nothing).
Sample Program 3:
Problem Statement: Write a program to perform the following functions and verify the output.
1. Load the number 30H in register B.
2. Load the number 39H in register C.
3. Subtract 39H from 30H.
4. Display the answer at output port1.
Assembly Language Code corresponding to each task:
MVI B, 30H Moves immediate data of 30H into register B.
MVI C, 39H Moves immediate data of 39H into register C.
MOV A, B Moves the contents of register B into accumulator register A.
SUB C subtracts the contents of register C from contents of accumulator
register A.
OUT PORT1 this instruction sends the accumulator contents to output port.
HLT end of program (Do Nothing).
Sample Program 4:
Problem Statement: Write a program to perform the following functions and verify the output.
Store the data byte 32H into memory location 4000H.
Assembly Language Code corresponding to each task:
MVI A, 32H Moves immediate data of 32H into accumulator register A.
STA 4000H copies the accumulator register contents to 4000H memory location.
HLT end of program (Do Nothing).
Sample Program 5:
Problem Statement: Write a program to perform the following functions and verify the output.
Exchange the contents of memory locations 2000H to 4000H
Assembly Language Code corresponding to each task:
LDA 2000H gets the contents in 2000H memory location into accumulator A.
MOV B, A stores the contents of accumulator register A into register B.
LDA 4000H gets the contents in 2000H memory location into accumulator A.
STA 2000H copies the accumulator register contents to 2000H memory location.
MOV A, B stores the contents of register B into accumulator register A.
STA 4000H copies the accumulator register contents to 4000H memory location.
HLT end of program (Do Nothing).
Sample Program 6:
Problem Statement: Write a program to perform the following functions and verify the output.
Find the 2's complement of the number stored at memory location 4200H and store the
complemented number at memory location 4300H.
Assembly Language Code corresponding to each task:
LDA 4200H gets the contents in 4200H memory location into accumulator A.
CMA complement the accumulator register A contents.
ADI 01H add the contents of accumulator register with immediate data 01H.
STA 4300H copies the accumulator register contents to 4300H memory location.
HLT end of program (Do Nothing).
Sample Program 7:
Problem Statement: Write a program to perform the following functions and verify the output.
Find the 1’s complement of the number stored at memory location 2200Hand store the
complemented number at memory location 2300H.
Assembly Language Code corresponding to each task:
LDA 2200H gets the contents in 2200H memory location into accumulator A.
CMA complement the accumulator register A contents.
STA 2300H store the accumulator register contents in 2300H memory location.
HLT terminate the program.
ADDRESSING MODES
Every instruction of a program has to operate on a data. The method of specifying the
data to be operated by the instruction is called Addressing.
The 8085 has the following 5 different types of addressing.
1. Immediate Addressing Mode
2. Direct Addressing Mode
3. Register Addressing Mode
4. Register Indirect Addressing Mode
5. Implied Addressing Mode
Immediate Addressing
In immediate addressing mode, the data is specified in the instruction itself. The data
will be apart of the program instruction. All instructions that have ‘I’ in their
mnemonics are of Immediate addressing type.
Eg.MVI B, 3EH- Move the data 3EH given in the instruction to B register.
Direct Addressing
In direct addressing mode, the address of the data is specified in the instruction. The data
will be in memory. In this addressing mode, the program instructions and data can be
stored in different memory blocks. This type of addressing can be identified by 16-bit
address present in the instruction.
Eg.LDA 1050H- Load the data available in memory location 1050H in accumulator.
Register Addressing
In register addressing mode, the instruction specifies the name of the register in which
the data is available. This type of addressing can be identified by register names (such
as ‘A’, ‘B’....) in the instruction.
Eg. MOV A, B -Move the content of B register to A register.
Register Indirect Addressing
In register indirect addressing mode, the instruction specifies the name of the register in
which the address of the data is available. Here the data will be in memory and the
address will be in the register pair. This type of addressing can be identified by letter
‘M’ present in the instruction.
Eg. MOV A, M - The memory data addressed by HL pair is moved to A register.
Implied Addressing
In implied addressing mode, the instruction itself specifies the type of operation and
location of data to be operated. This type of instruction does not have any address,
register name, immediate data specified along with it. Eg. CMA - Complement the
content of accumulator.