You are on page 1of 14

EKT 222

MICROPRESSOR SYSTEM

LAB 2 : FUNDAMENTALS OF 8085


INSTRUCTION SETS
EKT222 Microprocessor Systems

LAB 2:
Fundamentals of
8085 Instruction
Sets
Objectives:
1) Ability to create simple program instructions
2) Ability to translate between assembly code to machine code
3) Ability to execute and demonstrate the program instructions
4) Ability to analyze the 8085 register and memory map conditions

Equipments :
1. Computer station with Windows OS and MY1 8085 simulation
program
2. 8085 Instruction Sets (Detailed Description)
3. 8085 Instruction Sets (Summarized)

Introduction
The 8085 has 74 basic instructions and 246 total instructions.
The instruction set 8085 was defined by the manufacturer INTEL
CORPORATION. Each 8085 instruction has a one-byte (8-bit)
operation codes or opcode. With 8-bit binary opcode, a total of 256
different operation codes can be generated, each representing a
certain operation

Instruction Code Binary Hexadecimal


Code instruction #1 0000 0000 00 H
Code instruction #2 0000 0001 01 H
: : :
: : :
Code instruction
#255 1111 1110 FE H
Code instruction
#256 1111 1111 FF H
Example of instruction
codes :
MOV A,B 0111 1000 (78 H)
MOV B,A 0100 0111 (47 H)

In this, out of the possible 256 opcodes, 246 codes was developed
as 8085 instruction codes.

The size of the 8085 instruction can either be one-byte, two-


bytes or three bytes. The one-byte instruction only has the opcode
alone. The two-byte instruction will have an opcode, followed by an
8-bit address/data. The three-byte instruction will have an opcode,
followed by a 16-bit address/data (2-bytes address/data).
1
UniMAP
EKT222 Microprocessor Systems

These instruction codes or commonly called machine codes


will be stored in the memory and a sequence of these can be
fetched and executed by the 8085 microprocessor to perform a
certain task or program. A one-byte and two byte instruction is
simple to be stored, but storing a three-byte instruction code will
begin with the opcode followed by the 16-bit address/data starting
with the lower 8-bit address/data (lower byte) first and finally the
upper 8-bit address/data. The following display show the format of
the 8085 instructions

One-byte instruction opcode


:
7 0
byte data / address
Two-byte instruction opcode
:

7 0 7 0

Three-byte opcode
instruction :
low 8 data / address high 8 data / address

7 0 7 0 7
0
An example of a program to be stored in memory is given as follow :

0000
ORG H
2050
LDA H
INR A
2051
STA H
HLT

The machine code (hex code) for this operation will be stored
into the memory with the starting location at 0000H :

Memory Machine Code (Hex)


Assembly Code
Location Byte 1 Byte 2 Byte 3
ORG 0000H
LDA 2050H 0000 H 3A 50 20
INR A 0003 H 3C
STA 2051H 0004 H 32 51 20
HLT 0007 H 76
0008 H

The machine code can also be derived from the 8085


instruction set machine code reference.

2
UniMAP
EKT222 Microprocessor Systems

LABORATORY TASK
Lab1 Q3 review : Write the assembly code that will
a) Add together two data from memory locations 2200H and
2201H
b) Store the result in memory location 2202H

Solution 1 Solution 2
ORG 0000H ORG 0000H
LDA 2200H LXI H,2200H
MOV B,A MOV A,M
LDA 2201H INX H
ADD B ADD M
STA 2202H INX H
HLT MOV M,A
HLT

1. Without using the 8085 Simulator program , generate


the machine code with reference to the 8085 machine code
datasheet.

Memory Machine Code (Hex)


DDD/SS Solution 1 Assembly Code
Byte
S
B =000 Location Byte 1 Byte 2 3
C =001 ORG 0000H
D
=010 LDA 2200H 0000H 3A 00 22
M =110
E =011 MOV B,A ---01DD DSSS 0003H 47
H =100
L =101 LDA 2201H 0004H 3A 01 22
A =111 0007H 80
ADD B ---1000 0SSS
Reg.
STA 2202H 0008H 32 02 22
Pairs
BC=00 0000B 76
HL=10
HLT
DE=01
SP=11
Memory Machine Code (Hex)
Solution 2 Assembly Code
Byte
Location Byte 1 Byte 2 3
ORG 0000H
LXI H,2200H ---00RP 0001
0000H 21 00 22
data16

MOV A,M ---01DD D110 0003H 7E

INX H ---00RP 0011 0004H 23

ADD M 0005H 86

INX H 0006H 23

MOV M,A ---0111 0SSS 0007H 77

HLT 0008H 76
3
UniMAP
EKT222 Microprocessor Systems

2. Without using the 8085 Simulator program , generate


the machine code with reference to the 8085 machine code
datasheet.

Assembly Code

DDD/SS
ORG 0000H
S LXI SP,3FF0H ---00RP 0001
B =000
C =001 data16
D
=010
MVI A,05H ---00DD D110 data
M =110 MOV B,A ---01DD DSSS
E =011
H =100 MOV C,B
L =101
A =111 MOV D,C
Reg. MOV E,D
Pairs
BC=00 INR A ---00SS S100
HL=10
DE=01 STA 2050H ---32 addr
SP=11
INR A
LXI H,2051H ---00RP 0001
data16
MOV M,A ---0111 0SSS

LDA 2050H
INR A
INX H ---00RP 0011

MOV M,A
RST 1 ---11XX X111

HLT
Memory Machine Code (Hex)
Location Byte 1 Byte 2 Byte 3

0000H 31 FO 3F
0003H 3E 05
0005H 47
0006H 48
0007H 51
0008H 5A
0009H 3C
000AH 32 50 20
000DH 3C
000EH 21 51 20
0011H 77
0012H 3A 50 20
0015H 3C
0016H 23
0017H 77
0018H C7
0018 76

3. Using the 8085 Simulator program, generate the machine code


for Steps 1 and 2. Confirm your manual calculations with the ones
generated from the simulator.

4
UniMAP
EKT222 Microprocessor Systems

DISCUSSION
1. In Task 1, which solution requires bigger memory size?
Solution 1 requires 12 buyte while solution 2 requires only 9
bytes of memory. Therefore solution 1 requires bigger memory.
2. What can you observe regarding the assembly language
and the machine codes.
Assembly language is using mnemonic while machine codes are
in digital numeric.
3. In Task 2, explain the register conditions and also the
memories 2050H through 2052H when the program
counter reaches :
a. 0008H
B =05
C =05
D =05
E =F9
H =73
L =46
A =05
PC=0008

b. 0011H
1 B =05
2 C =05
3 D =05
4 E =F9
5 H =20
6 L =51
7 A =07
8 PC=0011

c. 0018H
1 B =05
2 C =05
3 D =05
4 E =05
5 H =20
6 L =52
7 A =07
8 PC=0018
4. What does the instruction RST 1 do? How do you derive the
machine code? What will happen if you change the number
1 to another number?
The instruction RST1 do restart the program at 0008H. If the
number 1 changed, the restart address will change to as per the
below table;
Instruction Restart Address
RST 0 0000H
RST 1 0008H
RST 2 0010H
RST 3 0018H
RST 4 0020H
RST 5 0028H
RST 6 0030H
RST 7 0038H
5
300
UniMAP
EKT222 Microprocessor Systems

EXERCISE

1. Using LDA and STA instructions, write a program that will transfer
five byte of memory from location 3000H through 3004H to
location 3200H through 3204H

2. Write a program to exchange the contents of HL register pair with


DE register pair using MOV instruction.

3. Write a program to swap lower 4 bit nibble with upper 4 bit nibble
of 8 bit data at memory location 2100H and place a result to
location 2101H.

4. Write a program using the ADI instruction to add the two


hexadecimal numbers 3AH and 48H and store the result in
memory location 2100H.

5. Write a program to subtract the number in the D register from


the number in the E register. Store the result in register C.

6. Write an assembly language program that AND, OR and XOR


together the contents of register B, C and E and place the result
into memory location 3000H, 3001H and 3002H.

7. Write a program that store 00H into memory location 2500H


through 2510H.

8. Write an assembly language program to add two 8-bit numbers,


the sum may be of 16-bits.

9. Write an 8085 assembly language program using minimum


number of instructions to add the 16 bit number in BC, DE & HL.
Store the 16 bit result in DE.

10. Develop a program in assembly that subtracts the number in


the DE register pair from the number in the HL register. Place the
result in BC register.

11. Sixteen bytes of data are stored in memory locations at 3150H


to 315FH. Write a program to transfer the entire block of data to
new memory locations starting at 3250H.

12. Write an 8085 assembly language program, which adds two


three-byte numbers. The first number is stored in memory
locations 3800H, 3801H & 3802H and the second number is
stored in memory location 3803H, 3804H & 3805H. Store the
answer in memory locations 3810H upwards.

13. Write an 8085 assembly language program, which checks the


number in memory location 2800H. If the number is an even
number, then put FF in memory location 2810H, otherwise put
00.
6
UniMAP
EKT222 Microprocessor Systems

14. Write a program to count the data byte in memory that equal
to 55H starting at memory location 2800H through 280FH. Place
the count value in B register.

15. Write an 8085 assembly language program to find the


smallest value between two number in memory location 2800H
and 2801. Store the value in memory location 3000H.

7
UniMAP
PDF to Word

You might also like