LAB 2: Fundamentals of 8085 Instruction Sets

advertisement
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
Code instruction #1
Code instruction #2
:
:
Code instruction #255
Code instruction #256
Binary
0000 0000
0000 0001
:
:
1111 1110
1111 1111
Hexadecimal
00 H
01 H
:
:
FE H
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
opcode
One-byte instruction :
7
0
byte data / address
opcode
Two-byte instruction :
7
0
low 8 data / address
opcode
Three-byte instruction :
7
0
7
0
7
0
high 8 data / address
0
7
An example of a program to be stored in memory is given as follow :
ORG
LDA
INR
STA
HLT
0000H
2050H
A
2051H
The machine code (hex code) for this operation will be stored into the memory with
the starting location at 0000H :
Assembly Code
ORG
LDA
INR
STA
HLT
0000H
2050H
A
2051H
Memory
Location
0000 H
0003 H
0004 H
0007 H
0008 H
Machine Code (Hex)
Byte 1 Byte 2 Byte 3
3A
3C
32
76
50
20
51
20
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
ORG
LDA
MOV
LDA
ADD
STA
HLT
Solution 1
0000H
2200H
B,A
2201H
B
2202H
ORG
LXI
MOV
INX
ADD
INX
MOV
HLT
Solution 2
0000H
H,2200H
A,M
H
M
H
M,A
1. Without using the 8085 Simulator program, generate the machine code with
reference to the 8085 machine code datasheet.
DDD/SSS
B =000
C =001
D =010
M =110
E =011
H =100
L =101
A =111
Solution 1 Assembly Code
Memory
Location
Machine Code (Hex)
Byte 1 Byte 2 Byte 3
ORG 0000H
Reg. Pairs
BC=00
HL=10
DE=01
SP=11
LDA
2200H
0000H
3A
MOV
B,A ---01DD DSSS
0003H
47
LDA
ADD
2201H
B ---1000 0SSS
0004H
3A
0007H
80
STA
2202H
0008H
32
0000B
76
HLT
Solution 2 Assembly Code
Memory
Location
00
22
01
22
02
22
Machine Code (Hex)
Byte 1 Byte 2 Byte 3
ORG 0000H
LXI
H,2200H ---00RP 0001 data16
0000H
21
MOV A,M
---01DD D110
0003H
7E
INX
H
---00RP 0011
0004H
23
ADD
M
0005H
86
INX
H
0006H
23
0007H
77
0008H
76
MOV M,A
HLT
---0111 0SSS
00
22
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
Memory
Location
Machine Code (Hex)
Byte 1 Byte 2 Byte 3
ORG 0000H
DDD/SSS
B =000
C =001
D =010
M =110
E =011
H =100
L =101
A =111
Reg. Pairs
BC=00
HL=10
DE=01
SP=11
LXI SP,3FF0H ---00RP 0001 data16
0000H
31
FO
MVI A,05H
---00DD D110 data
0003H
3E
05
MOV B,A
---01DD DSSS
0005H
47
MOV C,B
0006H
48
MOV D,C
0007H
51
MOV E,D
0008H
5A
0009H
3C
STA 2050H ---32 addr
000AH
32
INR A
000DH
3C
LXI H,2051H ---00RP 0001 data16
000EH
21
MOV M,A
0011H
77
LDA 2050H
0012H
3A
INR A
0015H
3C
0016H
23
0017H
77
0018H
C7
0018
76
INR
A
INX H
---00SS S100
---0111 0SSS
---00RP 0011
MOV M,A
RST 1
HLT
---11XX X111
3F
50
20
51
20
50
20
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
B =05
C =05
D =05
E =F9
H =20
L =51
A =07
PC=0011
c. 0018H
B =05
C =05
D =05
E =05
H =20
L =52
A =07
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
RST 1
RST 2
RST 3
RST 4
RST 5
RST 6
RST 7
0000H
0008H
0010H
0018H
0020H
0028H
0030H
0038H
5
UniMAP
300
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
Download