8085 Microprocessor Lab Guide
8085 Microprocessor Lab Guide
LAB 0
The basic components of the 8085 Microprocessor Development System board consist of
The circuit diagram for this system is as Appendix 1. The board is connected to the computer
through its serial port. Overall system operation is controlled by the monitor program which
resides in the EPROM.
This Development System has two different address maps; Memory Map and I/O Map. The
Development System can address up to 64K of memory devices and 255 addresses for I/O
devices.
Figure 1 shows the memory map for the Development System. The first 8K of memory space
0000H - 1FFFH is allocated for EPROM which contains the monitor program code for the
system. Whilst the memory space 2000H - 3FFFH is allocated for RAM which is used for user
program, data and stack (Default Setting). User can changed the setting to other memory address
by configuring the jumper (J16) on the board.
The Development Board is provided with two input and output devices; Programmable
Peripheral Interface (PPI) 8255 and Universal Synchronous Asynchronous Transmitter and
Page 1 of 53
Receiver (USART) 8251. Both devices have a unique address where it is decoded as isolated
I/O. Figure 2 shows the I/O map for the 8085 Development System.
2.1.First, build the virtual ROM, RAM and PPI to start the simulation process.
2.2.Click button “Add ROM” and enter the value of start address location for your ROM.
Type 0000H.
2.3.Click button “Add RAM” and enter the value of start address location for your RAM.
Type 2000H.
2.4.Click button “Add PPI” and enter the value of address location for your PPI. Type 80H.
2.5.Run the simulator at address location 2000H. (Because RAM is set at 2000H of start
address location).
Page 2 of 53
Go to “Edit>Preferences…”, on the option box, select Simulation and enter 2000H for
Starting Address.
Page 3 of 53
2.9.Go to “Tool>Simulate” click word “Simulate”.
Page 4 of 53
2.11 Write down the value in Registers from your observation in 2.10 in the table below.
8-bit Registers
A
Page 5 of 53
2.13 LED panel will appear. Then, right click on the LED panel. Select “Device@80>PA0”
Tick(√) on PA0.
2.14 Repeat the previous procedure 2.13 and Tick(√) PA1-PA7 for LED1-LED7.
2.16 Repeat the previous procedure 2.8 to procedure 2.10 and write down your observation
in the table below. Compare what’s happening between registers and LEDs .
8-bit Registers
Page 6 of 53
3.0 MY1 SIM85 SOFTWARE CONNECTING WITH 8085 DEVELOPMENT BOARD
8085 Development System communicates with the computer through its serial port (RS232).
In essence, the computer functions as dump terminal. Although any terminal software (e.g.
HyperTerminal on Windows, mini com on Linux, etc.) can be used to communicate with the
board, we will be using the feature provided by mysim85 Integrated Development
Environment (IDE) software. Notice the terminal panel on the lower right area of the IDE.
The RS232 port first needs to be configured for 9600 b/s, 8 data bit, 1 stop bit and none
parity. This is already set by default by mysim85 (Hint: Right-click on the panel to get a the
pop-up menu).
Page 7 of 53
The only thing we need to set is the assigned name for the serial port (COMxx), where xx is
an integer beginning from 1 (COM1 is usually reserved for hardware port). We will be using
a USB to serial adapter, which will be assigned randomly by the OS (check on the Device
Manager to confirm). To set the port, get the popup menu and use Port Select. The port
assignment at the lab may be different from what is shown here. If you cannot see any port
options, make sure the USB to serial adapter is connected and click Refresh.
A couple of options required for Windows platform is Local Echo and Win32 CRLF. Once
this is done, it should now be possible to Connect.
Page 8 of 53
Switch on the power supply for the 8085 Development System Board and you will find the
following menu as shown below appears in the terminal panel.
If the menu fails to appear on the terminal screen, press again the Reset button on the 8085
Development System. Make sure the power supply is already switched on. Contact the
technician in charge if any problem occurs.
Monitor Program provides basic operating system commands to enable interaction between
8085 Development System and the user. It is written using 8085 Assembly Language and
programmed into the EPROM 2764. The commands provided are as followed:
Page 9 of 53
Download user program code to 8085 Development System.
Substitute memory contents
Execute program
Display memory contents
Display and substitute register contents
This command is to download a file which contains user program code in Intel Hex format
from the computer to the memory location of 8085 Development System through its serial
port. Press ‘L’ and the following information appear.
8085>L
Download HEX file
Then right click on the Terminal Panel and select Send File
Page 10 of 53
Select the name of file to be sent (e.g. program1. hex).
When the process is done, the user codes is transferred to the memory of 8085 Development
System
The contents of memory (RAM) can be changed using this command. Type ‘S’ and the
following message is displayed.
8085 > S
Type memory location address
Type Q – quit
-
At the cursor position, type the address of memory location which the value is to be changed.
For example, the location 2000H - 2004H is to be changed. Enter address 2000 and the next
message will show address 2000 and the original value of the data. Enter new value; 00 and
the address will be increased to 2001. Enter new values if you wish to continue changing the
contents, and last of all finish the process with ‘Q’ command.
Page 11 of 53
00 ENTER NEW DATA
2001 - FF
01
2002 - FF
02
2003 - FF
Q
8085>
Confirm that all data is changed by using display memory contents command.
This command can be used after user code is downloaded using ‘L’ command. The function
of this command is to execute the program.
8085 > E
Type program address: 2000
Program running…
This command enables you to see the memory contents in the 8085 Development System.
Press ‘D’ at prompt ‘8055>’ and the following message is displayed.
8055>D
Enter the address of memory location that you wish to see. Ex. 2000 value is entered and
information of memory contents will be displayed as follows.
Page 12 of 53
Each row contains 2 byte representing the address of memory and this is followed by 16 byte
which represents data.
Address 00 01 02 03 04 05 06 07 08 09 1A 1B 1C 1D 1E 1F
2000 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
2010 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
Data
Press any key except ‘Q” enables another 128 byte to be displayed beginning with 2080H
address. To go back to ‘8085>’ prompt press ‘Q’.
This command enables you to check and modify the contents of register A, B, C, D, E, H, L,
SP and Flag in 8085 Development System. By typing ‘R’, the following message will appear.
8085>R
Display & Modify Register
Acc=00 Flags : S=0 Z=0 AC=0 P=0 CY=0
B=00 C=00 D=00 E=00 H=00 L=00 SPH=00 SPL=00
Modify Register : Y/N
Page 13 of 53
NMK 20103 Microprocessor Laboratory Module
LABORATORY 1
INTRODUCTION TO 8085 MICROPROCESSOR DEVELOPMENT SYSTEM BOARD
The circuit diagram for this system is as Appendix 1. The board is connected to the
computer through its serial port. Overall system operation is controlled by the monitor
program which resides in the EPROM.
The Development Board is provided with two input and output devices; Programmable
Peripheral Interface (PPI) 8255 and Universal Synchronous Asynchronous Transmitter and
Page 14 of 53
NMK 20103 Microprocessor Laboratory Module
Receiver (USART) 8251. Both devices have a unique address where it is decoded as
isolated I/O. Figure 2 shows the I/O map for the 8085 Development System.
10H RESERVED
20H RESERVED
2|Page
Page 15 of 53
NMK 20103 Microprocessor Laboratory Module
There are four registers that control the operations of the PPI and there are mapped to four
address locations in the 8085 Development System as shown below:
Port Address
Port A Register 80H
Port B Register 81H
Port C Register 82H
Control Register 83H
Table 1 shows the details of the signals involved in controlling the PPI.
A0 A1 CS RD=0 WR=0
The control register is used to configure the PPI into a variety of operation modes. There
are three basic modes:
We will only concentrate at mode 0. Further descriptions about mode 1 and 2 can be
referred to ‘Intel Microsystems Component Handbook’. Mode 0 provides for simple input
output operations with no handshaking. This means that data either to or from the port does
not depend on other signal for data transfer. Basically, to configure the PPI, a control word
must first be sent to the control register. Figure 4 summarized the control word format.
Page 16 of 53
NMK 20103 Microprocessor Laboratory Module
The input and output line are connected to a 24 screw type connector, J3, whose pin out is
given in Figure 5.
J3 PIN USE
1 Port A, Bit 0
2 Port A, Bit 1
3 Port A, Bit 2
4 Port A, Bit 3
5 Port A, Bit 4
6 Port A, Bit 5
7 Port A, Bit 6
8 Port A, Bit 7
9 Port B, Bit 0
10 Port B, Bit 1
11 Port B, Bit 2
12 Port B, Bit 3
13 Port B, Bit 4
14 Port B, Bit 5
15 Port B, Bit 6
16 Port B, Bit 7
17 Port C, Bit 0
18 Port C, Bit 1
19 Port C, Bit 2
20 Port C, Bit 3
21 Port C, Bit 4
22 Port C, Bit 5
23 Port C, Bit 6
24 Port C, Bit 7
The RS232 serial communications channel is implemented using a single chip 8251
Universal Synchronous / Asynchronous Receiver and Transmitter (USART). The chip
accepts data characters from microprocessor in parallel format and then converts them into
a continuous serial data. It also receives serial data and converts them into parallel data for
the CPU.
Page 17 of 53
NMK 20103 Microprocessor Laboratory Module
Before starting data transmission or reception, the 8251 must be initiated with a set of
control words generated by the CPU. These control words define the function of 8251. The
control words include
Mode instruction
Command instruction
Mode instruction has two different formats: one for asynchronous transmission and the other
for synchronous transmission. Since in this Development System asynchronous
transmission is established, more attention is given to asynchronous format. Bit
Configuration of Mode Instruction (Asynchronous) is shown in Figure 6.
Page 18 of 53
NMK 20103 Microprocessor Laboratory Module
The Command Instruction controls the actual operation of the 8251 by configuring the bit of
control register. The functions of command instruction are to enable transmit or receive,
reset error flag and configure modem control signal. Figure 7 below shows the bit
configuration of Command instruction format.
In some applications there is a need to test the status of the 8251 during its operation. The
user can read the status of 8251 using standard input operation. The bit configuration of
status format is shown in Figure 8.
Page 19 of 53
NMK 20103 Microprocessor Laboratory Module
8085 Development System communicates with the computer through its serial port (RS232).
In essence, the computer functions as dump terminal. Although any terminal software (e.g.
HyperTerminal on Windows, minicom on Linux, etc.) can be used to communicate with the
board, we will be using the feature provided by mysim85 Integrated Development
Environment (IDE) software. Notice the terminal panel on the lower right area of the IDE.
The RS232 port first needs to be configured for 9600 b/s, 8 data bit, 1 stop bit and none
parity. This is already set by default by mysim85 (Hint: Right-click on the panel to get a the
pop-up menu)
Page 20 of 53
NMK 20103 Microprocessor Laboratory Module
The only thing we need to set is the assigned name for the serial port (COMxx), where xx is
an integer beginning from 1 (COM1 is usually reserved for hardware port). We will be using
a USB to serial adapter, which will be assigned randomly by the OS (check on the Device
Manager to confirm). To set the port, get the popup menu and use Port Select. The port
assignment at the lab may be different from what is shown here. If you cannot see any port
options, make sure the USB to serial adapter is connected and click Refresh.
A couple of options required for Windows platform is Local Echo and Win32 CRLF. Once
this is done, it should now be possible to Connect.
Switch on the power supply for the 8085 Development System Board and you will find the
following menu as shown below appears in the terminal panel.
Page 21 of 53
NMK 20103 Microprocessor Laboratory Module
If the menu fails to appear on the terminal screen, press again the Reset button on the 8085
Development System. Make sure the power supply is already switched on. Contact the
technician in charge if any problem occurs.
Monitor Program provides basic operating system commands to enable interaction between
8085 Development System and the user. It is written using 8085 Assembly Language and
programmed into the EPROM 2764. The commands provided are as followed:
Download user program code to 8085 Development System.
Substitute memory contents
Execute program
Display memory contents
Display and substitute register contents
This command is to download a file which contains user program code in Intel Hex format
from the computer to the memory location of 8085 Development System through its serial
port. Press ‘L’ and the following information appear.
8085>L
Download HEX file
Then right click on the Terminal Panel and select Send File
Page 22 of 53
NMK 20103 Microprocessor Laboratory Module
When the process is done, the user codes is transferred to the memory of 8085
Development System
The contents of memory (RAM) can be changed using this command. Type ‘S’ and the
following message is displayed.
8085 > S
Type memory location address
Type Q – quit
-
At the cursor position, type the address of memory location which the value is to be
changed. For example, the location 2000H - 2004H is to be changed. Enter address 2000
and the next message will show address 2000 and the original value of the data. Enter new
value; 00 and the address will be increased to 2001. Enter new values if you wish to
continue changing the contents, and last of all finish the process with ‘Q’ command.
8085 >
Page 23 of 53
NMK 20103 Microprocessor Laboratory Module
Confirm that all data is changed by using display memory contents command.
This command can be used after user code is downloaded using ‘L’ command. The function
of this command is to execute the program.
8085 > E
Type program address: 2000
Program running…
This command enables you to see the memory contents in the 8085 Development System.
Press ‘D’ at prompt ‘KUKUM>’ and the following message is displayed.
8085> D
Enter the address of memory location that you wish to see. Ex. 2000 value is entered and
information of memory contents will be displayed as follows.
Page 24 of 53
NMK 20103 Microprocessor Laboratory Module
Each row contains 2 byte representing the address of memory and this is followed by 16
byte which represents data.
Press any key except ‘Q” enables another 128 byte to be displayed beginning with 2080H
address. To go back to ‘8085>’ prompt press ‘Q’.
This command enables you to check and modify the contents of register A, B, C, D, E, H, L,
SP and Flag in 8085 Development System. By typing ‘R’, the following message will appear.
8085>R
Page 25 of 53
NMK 20103 Microprocessor Laboratory Module
LABORATORY 2
INTRODUCTION TO ASSEMBLY LANGUAGE PROGRAMMING
1. OBJECTIVES
2. INTRODUCTION
Assembly Language is a low level language which is used to program microprocessor based
system so that it can function according to the user’s desire. Generally, a microprocessor
system executes instruction in the form of machine codes which is represented by logic 1
and 0. However, to write a program based on the machine codes will be very complicated
and takes a long time. So, assembly language is the solution to solve this problem. Each
program in an assembly language will be translated automatically to machine codes by
software named ‘assembler’.
Label (‘SUM’)
Mnemonic (‘ADI’)
Operand (‘12’ )
Comments (‘add the contents of Acc with 12’)
Notes: Please see the used of notation ‘:’ after label and also notation ‘;’ before comments.
A complete program may consist of instructions as above and every instruction is executed
sequentially. In this lab, you will be writing program in assembly language and using
assembler to produce machine codes. Refer to Appendix 4 for 8085 instruction set details.
Page 26 of 53
NMK 20103 Microprocessor Laboratory Module
Figure 1
Page 27 of 53
NMK 20103 Microprocessor Laboratory Module
Page 28 of 53
NMK 20103 Microprocessor Laboratory Module
Your program will be saved as <filename>.ASM (the extension will be added automatically).
This is to enable the Assembler to recognize the program as source file or source code.
Page 29 of 53
PGT201 Microprocessor Laboratory Module
When your program is completed, it must be translated to machine codes in the binary form
of 1 and 0 or assemble process.
You should see the result of this process in the Console Panel as shown below. This process
is actually done to check for any syntax error in your code. If the assembler detects any
errors, it will be shown here.
5|Page
Page 30 of 53
NMK 20103 Microprocessor Laboratory Module
In order to download the machine code to the 8085 development board, an Intel Hex
formatted file is required.
Sometimes, it is useful to have more information (code address and instruction binary code)
of the generated machine code. This is usually available in a Listing File.
Page 31 of 53
NMK 20103 Microprocessor Laboratory Module
Select Assembler and select for Create Listing File check box
Next re-run the assemble process in order to get a Listing File. The Listing File shows the
address and machine codes (opcode and operand) for each line of the instruction which has
been translated by MY1SIM85 Assembler. The Hex File contains machine codes information
in ASCII format. Further details can be referred to the lecture notes.
In this section, you will be shown how to transfer your code to 8085 Development System.
This can be done with the help of Monitor Program which resides in the system memory
(ROM). This monitor program controls the whole system operation by providing the following
facilities (as discussed in Lab 1 session).
Now you can transfer your machine codes (HEX file) to 8085 Development System. Switch
on the power supply for the 8085 Development System. From the main menu, select ‘L’
command to download your program code and execute it using ‘E’ command.
After the execution process, use ‘R’ command to check the register contents and check
memory location 2050H until 2052H by using ‘D’ command. Complete Table 1:
Page 32 of 53
NMK 20103 Microprocessor Laboratory Module
6. 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 ADD 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 an assembly language program to add two 3-digit BCD numbers at memory
location 3000H (MSB) to 3002H (LSB) and 3003H (MSB) to 3005H (LSB) and store the
result at memory location 3006H to 3008H.
8. 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.
9. 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.
10. 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.
Page 33 of 53
NMK 20103 Microprocessor Laboratory Module 3
LABORATORY 3
8085 DATA TRANSFER AND ARITHMATIC INSTRUCTIONS
EXERCISE
ORG 2000H
LXI SP,3FF0H
LXI B,1011H
LXI D,1213H
PUSH B
PUSH D
POP B
POP D
RST 1
END
Write this code and execute it. By referring the register contain in the board, Fill in the table below:
Register Data
B
C
D
E
SP
Page 34 of 53
NMK 20103 Microprocessor Laboratory Module 3
INR Reg.
The contents of the designated register or memory) are incremented by 1 and the result is stored in the same place. If
the operand is a memory location, its location is specified by the contents of the HL registers.
EXERCISE
ORG 2000H
LXI SP,3FF0H
MVI A, 1
MVI B, 3
MVI C, 2
ADD B
STA 3000H
MOV A, C
ADI 3
STA 3001H
MVI A, 0
INR A
INR A
INR A
STA 3002H
LXI H,0001H
INX H
INX H
INX H
MOV A, L
STA 3003H
RST 1
END
Write this code and execute it. By referring the Memory contain in the board, Fill in the table below:
Address Data
3000H
3001H
3002H
3003H
Page 35 of 53
NMK 20103 Microprocessor Laboratory Module 3
DCR Reg.
The contents of the designated register or memory) are decremented by 1 and the result is stored in the same place.
If the operand is a memory location, its location is specified by the contents of the HL registers.
EXERCISE
ORG 2000H
LXI SP,3FF0H
MVI A, 5
LXI B,0107H
SUB B
STA 3200H
MOV A, C
SUI 2
STA 3201H
MVI E,8
DCR E
DCR E
DCR E
MOV A,E
STA 3202H
LXI H,0009H
DCX H
DCX H
MOV A, L
STA 3203H
RST 1
END
Write this code and execute it. By referring the Memory contain in the board, Fill in the table below:
Address Data
3200H
3201H
3202H
3203H
Page 36 of 53
NMK 20103 Microprocessor Laboratory Module 3
TASK
1. 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.
2. Write a program that store 00H into memory location 2500H through 2510H.
3. 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.
4. 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.
5. Write a program to calculate the sum of a series of numbers. The length of the block is in memory location
2102H and the series itself begins in memory location 2103H. Store the sum in memory locations 2100H
and 2101H (MSB byte in 2101H).
6. Write a program to find the largest element in a block of data. The length of series is in memory location
2501H and the block itself begins in memory location 2502H. Store the largest value in memory locations
2500H. Assume that the numbers in the block are all 8-bit unsigned binary numbers.
7. Read one byte data from memory location 2200H. Determine the number of bit 1’s in the data and store the
result at memory location 2201H.
8. Write a program to multiply two 8-bit unsigned numbers. Store the result in memory locations 2A00H and
2A01H (MSB byte in 2A01H).
9. Write an 8085 assembly language program, which checks the number in memory location 2800H based on
the following algorithm.
Page 37 of 53
NMK 20103 Microprocessor Laboratory Module
LABORATORY 4
INTRODUCTION TO PROGRAMMABLE PERIPHERAL INTERFACE 8255
1. OBJECTIVES
The 8255 Programmable Peripheral Interface (PPI) is a general purpose interface device
which is widely used in microprocessor design. It contains three independent 8 bit ports
named Port A, B and C. Port A and B can be programmed as either input or output (all
eight line must be same), while port C is split into two 4 bit halves (Port C upper (PC4-
PC7) and Port C lower (PC0-PC3)) that can be separately programmed as input or
output.
A1 PPI 8255
Port B (8 Bit)
RD
WR Port C (8 Bit)
CS
There are four registers that control the operations of the PPI and they are mapped to
four address locations in the 8085 Development System as shown below:
Port Address
Port A Register 80H
Port B Register 81H
Port C Register 82H
Control Register 83H
Page 38 of 53
NMK 20103 Microprocessor Laboratory Module
The control register is used to configure the PPI into a variety of operation modes.
There are three basic modes:
We will only concentrate at mode 0. Further descriptions about mode 1 and 2 can be
referred to 8255 datasheet. Mode 0 provides for simple input output operations with no
handshaking. This means that data either to or from the port does not depends to other
signal for data transfer. Basically, to configure the PPI, a control word must first be sent
to the control register. Figure 1 summarized the control word format.
Therefore to enable these ports to function as input or output, the microprocessor needs
to configure the PPI by sending the control word as describe above to the control
register.
The following program is used to configure the PPI so that port A functions as input and
port B & C as output.
MVI A, 10010000B ; Control word setting where Port A= I/P and Port B & C=O/P.
OUT 83H ; send control word to 8255 control register.
When the control port is configured, the data can be sent to any of the output port using
OUT instruction. For example, if a data is to be sent to the Port B. The data must first be
loaded into the accumulator and OUT instruction is used as below.
MVI A, 55H
OUT 81H ; send data 55H to Port B.
Page 39 of 53
NMK 20103 Microprocessor Laboratory Module
To further understand the I/O concept, perform the following experiment. Connect eight
LEDs to Port A and eight switches to Port B. Configure Port A as output and Port B as
input. Write and test the following program:
ORG 2000H
LXI SP, 3FF0H
MVI A, 82H
OUT CTRLPORT
IN PORTB
OUT PORTA
RST 1
Before executing the program, set the switches to logic ‘1’ or ‘0’ as desired. Execute the
program and see what happen to the LED. Change the logic pattern of the switches.
Execute the program once again and see what happens to the LEDs.
Connect one LED to Port C0, write the following program and execute the program. Give
a short description about the program.
ORG 2000H
LXI SP, 3FF0H
MVI A, 80H
OUT CTRLPORT
MVI A, 0
REPEAT: CMA
OUT PORTC
CALL DELAY
JMP REPEAT
Page 40 of 53
NMK 20103 Microprocessor Laboratory Module
3. SOFTWARE DELAY
MVI C, 255
LOOP: DCR C
JNZ LOOP
This program forms a loop which will decrease the contents of register C by 1 until it
contents becomes 0. Any instructions after JNZ will be execute after register C equal to
zero. This loop will create a delay that can be used for certain microprocessor
application. The time delay is depended on instruction set which determine the T State
for each instruction. (Please refer to Appendix 3: 8080A/8085A INSTRUCTION SET
INDEX). The following example shows the calculation of the software delay routine.
Where
T state, Ts=1 / (0.5 x crystal frequency)
T state, Ts= 325 ns. Time delay, td=3574 x 325 ns = 1.16 ms.
(b)
DELAY: LXI B, m
LOOP: DCX B
MOV A, B
ORA C
JNZ LOOP
RET
Page 41 of 53
NMK 20103 Microprocessor Laboratory Module
Ts =10+ (m - 1) [6+4 + 4 + 7] + 6 + 4 + 4 + 10 + 10
Now write a program to make the LED blinked at rate of 500ms. Show the calculation to
determine the value of x1 and x2 or m for the delay routine. Check the signal frequency using
an oscilloscope.
DESIGN PROBLEM
1. Generate a square waveform output at PA0 and PA1. (Frequency 250 Hz & 500 Hz).
PC0
T=2ms
PC1
T=4ms
PC2
T=1ms
Page 42 of 53
NMK 20103 Microprocessor Laboratory Module
LABORATORY 5
EXERCISE ON INPUT / OUTPUT (I/O) INTERFACE
1. Figure 1 shows the connection between LED and switch using 8255 I/O port. Write a
program to make the LED blink when the switch is ON and stop blinking when the
switch is OFF.
5V
I/O
34 4 1 2
33 D0 PA0 3
32 D1 PA1 2 SW1
31 D2 PA2 1
30 D3 PA3 40 R
29 D4 PA4 39
28 D5 PA5 38
27 D6 PA6 37
D7 PA7
5 18
36 RD PB0 19
9 WR PB1 20
8 A0 PB2 21
35 A1 PB3 22 5V
6 RESET PB4 23
CS PB5 24
PB6 25
PB7 LED2 R4
14
PC0 15
PC1 16
PC2 17
PC3 13
PC4 12
PC5 11
PC6 10
PC7
8255
Figure 1
2. Figure 2 below shows the connection interface of two switches and two LED‟s with
Port B and Port C. Write a program based on the following table.
U5
34 4 1 2
33 D0 PA0 3 SW1
32 D1 PA1 2
31 D2 PA2 1 1 2
30 D3 PA3 40 SW2
29 D4 PA4 39
28 D5 PA5 38
27 D6 PA6 37 R1 R2
D7 PA7
5 18
36 RD PB0 19
9 WR PB1 20
8 A0 PB2 21
35 A1 PB3 22
6 RESET PB4 23
CS PB5 24
PB6 25 5V
PB7
14
PC0 15 LED1 R3
PC1 16
PC2 17
PC3 13
PC4 12
PC5 11 LED2 R4
PC6 10
PC7
8255
Figure 2
Page 43 of 53
NMK 20103 Microprocessor Laboratory Module
3. Figure 3 below shows the connection interface of four switches and LED with Port A
and Port C. The switches represent a 4-bit data input. Write a program to read 4 bit
data input from the switches and the value will be used to determine how many time
5V
the LED should blink.
1 2
SW1
I/O 1 2
34 4 SW2
33 D0 PA0 3 1 2
32 D1 PA1 2 SW3
31 D2 PA2 1 1 2
30 D3 PA3 40 SW4
29 D4 PA4 39
28 D5 PA5 38
27 D6 PA6 37 R1 R2 R3 R4
D7 PA7
5 18
36 RD PB0 19
9 WR PB1 20
8 A0 PB2 21
35 A1 PB3 22 5V
6 RESET PB4 23
CS PB5 24
PB6 25
PB7 LED2 R5
14
PC0 15
PC1 16
PC2 17
PC3 13
PC4 12
PC5 11
PC6 10
PC7
8255
Figure 3
4. Using eight LED and one switch, write a program to design a simple running light
system. The following table shows the operation of the system.
Switch LED„s
OFF (Logic “0”) STOP running
ON (Logic “1”) START running
Page 44 of 53
NMK 20103 Microprocessor Laboratory Module
LABORATORY 6
INTERFACING WITH SEVEN SEGMENT DISPLAY
1. OBJECTIVES
2. INTRODUCTION
In this lab session, you will interface the 8085 Microprocessor System with seven segment
display through its programmable I/O port 8255. Seven segment displays (as shown in
Figure 1) is often used in the digital electronic equipment to display information regarding
certain process.
dp
There are two types of seven segment display; common anode and common cathode. The
differences between these two displays are shown in Figure 2a and 2b. The internal
structure of the seven segment display consist of a group of Light Emitting Diode (LED)
Anode(+)
a b c d e f g dp
a b c d e f g dp
Cathode(-)
For common cathode, the segment will light up when logic ‘1’ (+V) is supplied and it will light
off when logic ‘0’ (OV) is supplied. While for common anode, logic ‘1’ will light off the
segment and logic ‘0’ will light up the segment. Therefore to display number ‘0’ on the
seven segment display, segment a, b, c, d, e and f must light up. For common cathode,
logic ‘1’ should be given to the related segment whereas in the case of common anode, logic
‘0’ should be given to the necessary segment. Based on the above explanation, complete
the Table 1 below:
Page 45 of 53
NMK 20103 Microprocessor Laboratory Module
The following diagram shows the interface for common cathode 7 segments in the I/O board.
The 7 segments is connected through 8 resistor (range from 100 to 1K ) in series to each
segment.
PA0
PA1
PA2
PA3
PA4
PA5
PA6
Make a connection for this seven segment display with microprocessor through
programmable I/O port 8255. Segment a - g is connected to Port A. Write and test the
following program.
ORG 2000H
LXI SP, 3FF0H
MVI A, 80H
OUT CTRLPORT
START: MVI B, 10
LXI D, TABLE
REPEAT: LDAX D
OUT PORTA
CALL DELAY
INX D
DCR B
JNZ REPEAT
JMP START
Page 46 of 53
NMK 20103 Microprocessor Laboratory Module
DELAY: PUSH B
LXI B, 65535
LOOP: DCX B
MOV A, B
ORA C
JNZ LOOP
POP B
RET
TABLE: DFB ___, ___, ___, ___, ___, ___, ___, ___, ___, ___
(Common cathode data pattern from Table 1)
1. In this part, you will be modifying the program you have written in Part A to design an
up/down counter. The decision whether to count up or down depends on the input
from a switch connected to another I/O port. If the switch is set at logic ‘1’, the
counter will count up. The counter will count down when the switch is set to logic ‘0’.
The block diagram is as follows:
8255
Address
Bus O/P
Port
Control
Bus
Data
Port Logic ‘0’
Bus
2. Write an 8085 assembly language program, which checks the number in memory
location 2800H based on the following algorithm.
Page 47 of 53
NMK 20103 Microprocessor Laboratory Module
LABORATORY 7
INTERRUPT
1. OBJECTIVE
2. INTRODUCTION
The 8085 microprocessor has five (5) interrupt source input. They are TRAP, RST7.5,
RST6.5, RST5.5 and INTR. TRAP is non maskable and the others are maskable. During
reset, all the maskable interrupt are disable, so the microprocessor only responds to TRAP.
For maskable interrupt to be effective, it must be enabled under program control.
Only three (3) of this interrupt can be used using our 8085 development system: RST7.5,
RST6.5 and RST5.5. The RST6.5 and RST5.5 are level sensitive while RST7.5 is rising
edge sensitive.
When the microprocessor is interrupted by the external device, it will respond to the
interruption by completing their current instruction, saving the program counter of the next
instruction to be executed onto the stack and then jumping to the following addresses based
on the type of interrupt request.
RST5.5 002CH
RST6.5 0034H
RST7.5 003CH
These addresses are located in the ROM space. For the 8085 development board that is
used in the laboratory, the interrupt address of RST5.5, RST6.5 and RST7.5 are redirect to
the new address location at RAM space using JMP instruction. Therefore, the users can
easily enter their code of JMP instruction to the interrupt service routine. The new addresses
are listed below.
RST5.5 3F2CH
RST6.5 3F34H
RST7.5 3F3CH
You can examine the contents of memory location 002CH, 0034H and 003CH using D
command (Display memory). Its contain three byte of instruction for each interrupt address.
The code is C3 which is representing the opcode of JMP instruction and followed by another
two byte of data represented the destination address.
Two program steps are required to enable the RST7.5, RST6.5, RST5.5 interrupts:
The SIM instruction is used to implement the masking process of the 8085 interrupts
RST7.5, RST6.5 and RST5.5. This instruction interprets the accumulator contents as
follows:
Page 48 of 53
NMK 20103 Microprocessor Laboratory Module
SOD – Serial Output Data: Bit D7 of Accumulator is latched into the SOD output
line and made available to serial peripheral if bit D6 = 1
SOE – Serial Output Enable: If this bit = 1, it enables the serial output. To
implement serial output, this bit needs to be enabled.
X – Don’t care
R7.5 – Reset RST7.5: If this bit = 1, RST7.5 flip-flop is reset. This is an additional
control to reset RST7.5.
MSE – Mask Set Enable: If this bit is high, it enables the function of bits D2, D1
and D0. This is a master control over all the interrupt masking bits. If this bit is
low, bits D2, D1 and D0 do not have any effect on the masks.
For example, the following instruction sequence enables RST6.5 and disables RST7.5 and
RST5.5:
MVI A, 00011001B
SIM
EI
3. EXERCISE
Connect the circuit as shown in Figure 1 and write the following program. Test the program
using the 8085 development system by pressing the pushbutton switch connected to
RST6.5.
8255
Address
Bus
PA0
LED
Control
Bus PB0
LED
Data
Bus RST6.5
SW PUSHBUTTON
Figure 1
Page 49 of 53
NMK 20103 Microprocessor Laboratory Module
ORG 2000H
LXI SP, 3FF0H
MVI A, 80H
OUT 83H
MVI A, 00011101B
SIM
; Main program
MAIN: EI
MVI A, 11111110B
OUT 80H
CALL DELAY
MVI A, 11111111B
OUT 80H
CALL DELAY
JMP MAIN
ORG 3F34H
JMP ISR65
END
Discuss your result. Connect another pushbutton switch to the RST5.5 pin. Modify your
existing program to make the LED blink 20 times when the pushbutton switch (RST 5.5) is
pressed.
Page 50 of 53
NMK 20103 Microprocessor Laboratory Module
LABORATORY 8
INTRODUCTION TO SERIAL I/O (SID AND SOD)
1. OBJECTIVE
2. INTRODUCTION
The 8085 Microprocessor have two line specially designed for serial data transmission and
reception. The two line are SID (Serial Input Data) and SOD (Serial Output Data). Data
transfer is controlled using two instructions, SIM (Set Interrupt Mask) and RIM (Read
Interrupt Mask). The RIM instruction, read the data from SID pin into Accumulator bit 7. Bit 0
to bit 6 Accumulator represent the interrupt status information in the 8085 system (Figure 1).
Figure 1
SIM instruction will transmit bit 7 in Accumulator through the SOD pin and bit 6 in
Accumulator (SOE - Serial Output Enable) must be set to logic „1‟ in order to enable the
transmission (Figure 2).
Figure 2
Serial data transmission through the SOD line is done by repeating the process of data
transmission from the Accumulator to the SOD pin. For example, to transmit serial 8 bits
data; the data will be transmit bit by bit through the SOD line using SIM instruction. The
same concept is applied for receiving data process where the bit by bit of data is received
through the SID pin. The method of transmission and reception of serial data in digital
system is usually referred to the standard or specific format such as RS232. Baud rate,
parity and stop bit must be considered as an important parameter for the process of
transmission and reception serial data.
Example below shows how to write a program for transmitting serial data to a PC terminal.
Data transmission is in asynchronous mode with 9600 baud rate, 8 bit data, none parity and
Page 51 of 53
NMK 20103 Microprocessor Laboratory Module
1 stop bit. Test the program using the 8085 system. Serial data transmission from the
microprocessor to PC terminal is done by using the transmit subroutine. The data sent to
the PC terminal should be in ASCII code format (Refer to Appendix 5).
baudtime: equ 18
baudtime1: equ 19
org 2000h
lxi sp,3ff0h
lxi h, message
next_char: mov a, m
cpi 0
jz exit
call transmit
inx h
jmp next_char
exit: rst 1
transmit: push h
push b
mov c,a ;4
mvi b,10 ;7
mvi a,01000000b ;7
sim ;4 ;send start bit = 0
tx_loop: mvi h,baudtime ;7
tx_loop1: dcr h ;4
jnz tx_loop1 ;7/10
mov a,c ;4
stc ;4
rar ;4
mov c,a ;4
rar ;4
ani 80h ;7
ori 01000000b ;7
sim ;4
dcr b ;4
jnz tx_loop ;7/10
pop b
pop h
ret ;10
Page 52 of 53
NMK 20103 Microprocessor Laboratory Module
3. EXERCISE
Write a program for receiving 10 data from a terminal (keyboard) and store the data to
memory location starting from 3000H address and then display the data to PC terminal.
Received subroutine below is for receiving serial data from the terminal.
received: push h
push b
mvi b,9 ;7
si1: rim ;4
ora a ;4
jm si1 ;7/10
mvi h,baudtime1/2 ;7
si2: dcr h ;4
jnz si2 ;7/10
si4: mvi h,baudtime1 ;7
si3: dcr h ;4
jnz si3 ;7/10
rim ;4
ral ;4
dcr b ;4
jz rx_exit ;7/10
mov a,c ;4
rar ;4
mov c,a ;4
jmp si4 ;10
rx_exit: mov a,c ;4
pop b
pop h
ret
Page 53 of 53