0% found this document useful (0 votes)
1K views53 pages

8085 Microprocessor Lab Guide

Uploaded by

Nur Aiman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views53 pages

8085 Microprocessor Lab Guide

Uploaded by

Nur Aiman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

v2023

LAB 0

INTRODUCTION TO MY1 SMI85 SOFTWARE AND 8085 MICROPROCESSOR


DEVELOPMENT BOARD

1.0 8085 MICROPROCESSOR DEVELOPMENT SYSTEMS

The basic components of the 8085 Microprocessor Development System board consist of

 8085 8-bit Intel Microprocessor


 8K Byte memory EPROM - 2764
 8K Byte memory RAM - 6264
 I/O Device - 8255
 Serial Communication (UART) – 8251
 Monitor Program

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.

1.1 Memory and I/O Map

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.

1.1.1 Memory Map

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.

Address Memory use


0000H-1FFFH ROM(8k x 8)
2000H-3FFFH RAM(8k x 8)
4000H-FFFFH RESERVED
Figure 1 : Memory Map

1.1.2 I/O Map

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.

Address I/O use


10H RESERVED
20H RESERVED
40H DATA REGISTER USART 8251
41H CONTROL/STATUS REGISTER USART 8251
80H PORT A 8255
81H PORT B 8255
82H PORT C 8255
83H CONTROL PORT 8255
90H-FFH NOT USED

2.0 MY1 SIM85 SIMULATOR

HOW TO OPERATE “MY1 SIM85” SIMULATOR USING VIRTUAL COMPONENT

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.

2.6.Then, the system is ready to use.


2.7.Write down the following code ;

2.8.Save the code and go to “Tool>assemble” click the word “Assemble”.

Page 3 of 53
2.9.Go to “Tool>Simulate” click word “Simulate”.

2.10 Click “Run” to observe the result.

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

2.12 Go to “System>Create devLED Panel”.

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.15 Write the following code ;

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.

3.1 Monitor Program Commands

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

3.1.1 Download user program code to 8085 System (‘L’ Command)

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

3.1.2 Substitute Memory Contents (‘S’ Command)

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.

Address Original data


2000 - FF

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.

3.1.3 Execute program (‘E’ 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…

3.1.4 Display memory content (‘D’ command)

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’.

3.1.5 Displaying and substituting register content (‘R’ command)

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

1. INTRODUCTION TO 8085 MICROPROCESSOR DEVELOPMENT SYSTEMS.


The basic components of the 8085 Microprocessor Development System board consist of
 8085 8-bit Intel Microprocessor
 8K Byte memory EPROM - 2764
 8K Byte memory RAM - 6264
 I/O Device - 8255
 Serial Communication (UART) – 8251
 Monitor Program

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.

1.1 Memory and I/O Map


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.

1.1.1 Memory Map


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.

Address Memory Use


0000H - 1FFFH EPROM (8K x 8)

2000H - 3FFFH RAM (8K x 8)

4000H - 5FFFH RESERVED

4000H - 5FFFH RESERVED

6000H - 7FFFH RESERVED

8000H - 9FFFH RESERVED

A000H - BFFFH RESERVED

C000H - DFFFH RESERVED

E000H - FFFFH RESERVED

Figure 1 : Memory Map

1.1.2 I/O Map

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.

Address I/O Use

10H RESERVED

20H RESERVED

40H Data Register USART 8251


41H Control/Status Register USART 8251
80H Port A 8255
81H Port B 8255
82H Port C 8255
82H Control Port 8255
90H
To NOT USED
FFH

Figure 2 : I/O Map

2. INPUT AND OUTPUT


Programmable Peripheral Interface (PPI) 8255 and Universal Synchronous Asynchronous
Transmitter and Receiver (USART) 8251 is an input and output device for the Development
System to communicate with the outside world.

2.1 Programmable Peripheral Interface 8255


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. Figure 3
shows the internal architecture and pin-out for the 8255 Programmable Peripheral Interface
(PPI).

Figure 3: PPI 8255

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.

Table 1 : Signals Controlling PPI.

A0 A1 CS RD=0 WR=0

0 0 0 Port A to Data bus Data bus to Port A

0 1 0 Port B to Data bus Data bus to Port B

1 0 0 Port C to Data bus Data bus to Port C

1 1 0 - Data bus to Control Register

The control register is used to configure the PPI into a variety of operation modes. There
are three basic modes:

 mode 0 : basic input/output


 mode 1 : strobe input/output
 mode 2 : bidirectional bus

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.

bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0


1 Port A and upper half of Port C Port B & lower half of Port C
MODE Port A Port C UPPER MODE Port B Port CLOWER

Mode Definition Control Byte: Indicate by bit b7=1.

Port A and upper half of Port C (Group A)


Bit b3 to bit b6 control the mode and direction of Group A

b6, b5 mode operation


0 0 mode 0
0 1 mode 1
1 0 mode 2

b4 Port A direction, 0=output, 1=input


b3 upper half of Port C direction, 0=output, 1=input

Port B and lower half of Port C (Group B)


Bit b0 to bit b2 control the mode and direction of Group B

b2 mode operation, 0=mod 0, 1=mod 1


b1 Port B direction, 0=output, 1=input
b0 lower half of Port C direction, 0=output, 1=input

Figure 4 : 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

Figure 5 : J3 Pin Connection

2.2 Universal Synchronous / Asynchronous Receiver and Transmitter (USART)


8251

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.

FUNCTIONAL BLOCK DIAGRAM

Page 17 of 53
NMK 20103 Microprocessor Laboratory Module

The 8251 functional configuration is programmed by software. Operation between the


USART 8251 and a CPU is executed by program control. Table 2 shows the operation and
the signals between a CPU and the USART.

Table 2 : Operation and Signals between CPU and USART

The addresses of 8251 in the Development System as shown below

Data Register (Input /output) 40H


Control/Status Register 41H

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.

Figure 6 : Bit Configuration of Mode Instruction (Asynchronous) Format

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.

Figure 7 : 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.

Figure 8 : Bit Configuration of Status Format

Page 19 of 53
NMK 20103 Microprocessor Laboratory Module

3. COMMUNICATION BETWEEN 8085 DEVELOPMENT SYSTEM AND HOST


COMPUTER (TERMINAL)

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.

3.1 Monitor Program Commands

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

3.1.1 Download user program code to 8085 System (‘L’ Command)

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

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

3.1.2 Substitute Memory Contents (‘S’ Command)

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.

Address Original data


Enter new data

8085 >

Page 23 of 53
NMK 20103 Microprocessor Laboratory Module

Confirm that all data is changed by using display memory contents command.

3.1.3 Execute program (‘E’ 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…

3.1.4 Display memory content (‘D’ command)

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.

Address 16 byte data

Data for 2000H Data for 200FH


address address

Press any key except ‘Q” enables another 128 byte to be displayed beginning with 2080H
address. To go back to ‘8085>’ prompt press ‘Q’.

3.1.5 Displaying and substituting register content (‘R’ command)

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 25 of 53
NMK 20103 Microprocessor Laboratory Module

LABORATORY 2
INTRODUCTION TO ASSEMBLY LANGUAGE PROGRAMMING

1. OBJECTIVES

1.1 To understand the assembly language programming and Assembler


1.2 To download user code (HEX File) to 8085 Development System.
1.3 To execute user program code.

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’.

The structure of an assembly language is very simple. Each instruction is written on a


separate line and the format of a line is shown as follows:

SUM: ADI 12 ; add the contents of Accumulator with 12

The example given above consists of four different fields.

 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

3. CREATING SOURCE CODE

Figure 1 below shows the main IDE interface for MY1SIM85.

Figure 1

Step 1: Select File > New

Page 27 of 53
NMK 20103 Microprocessor Laboratory Module

Step 2: Write your code in the opened window

Type in the following program example:

Lab 2 program example ;

ORG 2000H ; User code starting address

LXI SP,3FF0H ; Initialize stack pointer


MVI A,55H ; Copy immediate value 05H to accumulator (register A)
MOV B,A ; Copy the contents of Acc to register B
MOV C,B ; Copy the contents of register B to register C
MOV D,C ; Copy the contents of register C to register D
MOV E,D ; Copy the contents of register D to register E
INR A ; Increment the contents of Acc
STA 2050H ; Store the contents of Acc to memory location 2050H
INR A ; Increment the contents of Acc
LXI H,2051H ; Load register pair HL with value 2051H
MOV M,A ; Store the contents of Acc to memory
LDA 2050H ; Load acc with value from memory location 2050H
INR A ; Increment the contents of Acc
INX H ; Increment register pair HL
MOV M,A ; Store the contents of Acc to memory
RST 1
END

Page 28 of 53
NMK 20103 Microprocessor Laboratory Module

Step 3: Select File > Save As…

Step 4: Enter a filename for your program and click Save

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

4. ASSEMBLING SOURCE CODE

When your program is completed, it must be translated to machine codes in the binary form
of 1 and 0 or assemble process.

To assemble the source code, select Tool > Assemble

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.

To generate a Hex file, select Tool > Generate

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.

To generate a Listing File, select Edit > Preference

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.

5. DOWNLOADING HEX FILE (MACHINE CODE) TO 8085 DEVELOPMENT


SYSTEM AND RUNNING THE PROGRAM

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).

 Display and Modify register contents


 Display memory contents
 Modify memory contents
 Download user code (HEX file)
 Execute user code

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

Table 1 : Register / Memory Contents


Register/Memory Content
A
B
C
D
E
H
L
SP
2050H
2051H
2052H

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

STACK POINTER, PUSH AND POP INSTRUCTION

LXI SP, Add. Stack Pointer


A stack pointer is a small register that stores the address of the last program request in a stack. A stack is a
specialized buffer which stores data from the top down. As new requests come in, they "push down" the older ones.
The most recently entered request always resides at the top of the stack, and the program always takes requests from
the top.
A stack operates in a last-in/first-out sense (LI-FO). When a new data item is entered or "pushed" onto the top of a
stack, the stack pointer increments to the next physical memory address, and the new item is copied to that address.
When a data item is "popped" from the top of a stack, the item is copied from the address of the stack pointer, and
the stack pointer decrements to the next available item at the top of the stack.

PUSH Reg. Pair


The contents of the register pair designated in the operand are copied onto the stack in the following sequence. The
stack pointer register is decremented and the contents of the high order register (B, D, H, A) are copied into that
location. The stack pointer register is decremented again and the contents of the low-order register (C, E, L, flags)
are copied to that location.

POP Reg. Pair


The contents of the memory location pointed out by the stack pointer register are copied to the low-order register (C,
E, L, status flags) of the operand. The stack pointer is incremented by 1 and the contents of that memory location are
copied to the high-order register (B, D, H, A) of the operand. The stack pointer register is again incremented by 1.

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

ADD, ADI, INR, INX NSTRUCTION

ADD Reg. or Memory


The contents of the operand (register or memory) are added to the contents of the accumulator and the result is
stored in the accumulator. If the operand is a memory location, its location is specified by the contents of the HL
registers. All flags are modified to reflect the result of the addition.

ADI 8 bit data


The 8-bit data (operand) is 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.

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.

INX Reg. Pair


The contents of the designated register pair are incremented by 1 and the result is stored in the same place.

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

SUB, SUI, DCR, DCX NSTRUCTION

SUB Reg. or Memory


The contents of the operand (register or memory) are subtracted from the contents of the accumulator, and the result
is stored in the accumulator. If the operand is a memory location, its location is specified by the contents of the HL
registers. All flags are modified to reflect the result of the subtraction.

SUI 8 bit data


The 8-bit data (operand) is subtracted from the contents of the accumulator and the result is stored in the
accumulator. All flags are modified to reflect the result of the subtraction.

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.

DCX Reg. Pair


The contents of the designated register pair are decremented by 1 and the result is stored in the same place.

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.

If the number is less than 80H


Store 00H in memory location 2810H
Else if the number is equal to 80H
Store 7FH in memory location 2810H
Else if the number is more than 80H
Store FFH in memory location 2810H

Page 37 of 53
NMK 20103 Microprocessor Laboratory Module

LABORATORY 4
INTRODUCTION TO PROGRAMMABLE PERIPHERAL INTERFACE 8255

1. OBJECTIVES

1.1 To understand the Programmable Peripheral Interface 8255.


1.2 To use the 8255 in mode 0 (Basic I/O).
1.3 To perform simple interfacing with LED.
1.4 To write and understand the software delay routine.

2. INTRODUCTION TO PROGRAMMABLE PERIPHERAL INTERFACE 8255

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.

Data Bus (8 Bit)


Port A (8 Bit)
A0

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

Table 1 shows the details of signals involved in controlling the PPI.

Table 1 : Signals Controlling PPI


A0 A1 CS RD=0 WR=0
0 0 0 Port A to Data bus Data bus to Port A
0 1 0 Port B to Data bus Data bus to Port B
1 0 0 Port C to Data bus Data bus to Port C
1 1 0 - Data bus to Control Register

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:

 mode 0 : basic input/output


 mode 1 : strobe input/output
 mode 2 : bidirectional bus

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.

bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0


1 Port A and upper half of Port C Port B & lower half of Port C
MODE Port A Port C UPPER MODE Port B Port CLOWER

Mode Definition Control Byte. Indicate by bit b7=1.

Port A and upper half of Port C (Group A)


Bit b3 to bit b6 control the mode and direction of Group A

b6, b5 mode operation


0 0 mode 0
0 1 mode 1
1 0 mode 2

b4 Port A direction, 0=output, 1=input


b3 upper half of Port C direction, 0=output, 1=input

Port B and lower half of Port C (Group B)


Bit b0 to bit b2 control the mode and direction of Group B

b2 mode operation, 0=mod 0, 1=mod 1


b1 Port B direction, 0=output, 1=input
b0 lower half of Port C direction, 0=output, 1=input

Figure 1 : 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 read a data from Port A into the accumulator, IN instruction is used.

IN 80H (where 80H is the address of Port A)

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:

; Example of Lab 4 program 1


PORTA: EQU 80H
PORTB: EQU 81H
PORTC: EQU 82H
CTRLPORT: EQU 83H

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.

; Example of Lab 4 program 2


PORTA: EQU 80H
PORTB: EQU 81H
PORTC: EQU 82H
CTRLPORT: EQU 83H

ORG 2000H
LXI SP, 3FF0H
MVI A, 80H
OUT CTRLPORT
MVI A, 0
REPEAT: CMA
OUT PORTC
CALL DELAY
JMP REPEAT

DELAY: PUSH PSW


LXI B, 65535
LOOP: DCX B
MOV A, B
ORA C
JNZ LOOP
POP PSW
RET

Page 40 of 53
NMK 20103 Microprocessor Laboratory Module

3. SOFTWARE DELAY

The following program is given:

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.

MVI C, 255 ; 7 states


254 LOOP: DCR C ; 4 states
[ JNZ LOOP ; 7/10 states (10 states if condition is met or
; 7 states if the condition not met)

The total number of state,  Ts = 7 + 254(4 + 10) + 1(4 + 7) = 3574.

Where
T state, Ts=1 / (0.5 x crystal frequency)

For 6.144 MHz crystal,

T state, Ts= 325 ns. Time delay, td=3574 x 325 ns = 1.16 ms.

For longer delay, use the following subroutine;


(a)
DELAY: MVI B, x1
LOOP: MVI C, x2
LOOP1: DCR C
JNZ LOOP1
DCR B
JNZ LOOP
RET

(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

DELAY: MVI B, x1 ; 7 states


LOOP: MVI C, x2 ; 7 states
LOOP1: DCR C ; 4 states
JNZ LOOP1 ; 7/10 states
DCR B ; 4 states
JNZ LOOP ; 7/10 states
RET ; 10 states

The total number of state,

 Ts=7+ (x1 - 1)[ 7+(x2 – 1)(4+10) + (4 + 7) + 4 + 10 ] + [7+ (x2 – 1)(4+10) + (4 + 7) + 4 + 7+10]

DELAY: LXI B, m ; 10 states


LOOP: DCX B ; 6 states
MOV A, B ; 4 states
ORA C ; 4 states
JNZ LOOP ; 7/10 states
RET ; 10 states

 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).

2. Generate the following waveform at PC0, PC1 and PC2.

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.

SW2 SW1 LED2 LED1


OFF OFF OFF OFF
OFF ON OFF ON
ON OFF ON OFF
ON ON BLINK BLINK
5V

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

1.1 To perform interfacing with Seven Segment Display


1.2 To design the Up/Down Counter

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

Figure 1 : Seven Segment Display

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(-)

Figure 2a - Common Cathode Figure 2b - Common Anode

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

Table 1 : Common Anode and Common Cathode Logic Assignment

Common Anode Common Cathode


No g f e d c b a g f e d c b a
0 1 0 0 0 0 0 0 0 1 1 1 1 1 1
1
2
3
4
5
6
7
8
9

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.

PORTA: EQU 80H


PORTB: EQU 81H
PORTC: EQU 82H
CTRLPORT: EQU 83H

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)

3. DESIGNING THE UP/DOWN COUNTER

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

I/P Logic ‘1’

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.

If the number is less than 80H


Display ‘L’ on the 7 segment

Else if the number is equal to 80H


Display ‘=’ on the 7 segment

Else if the number is more than 80H


Display ‘H’ on the 7 segment

Page 47 of 53
NMK 20103 Microprocessor Laboratory Module

LABORATORY 7
INTERRUPT

1. OBJECTIVE

1.1 Understanding the interrupt structure in the 8085 microprocessor

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:

 Clearing the interrupt masks using SIM instruction.


 Enabling all interrupt using EI instruction

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 SOE X R7.5 MSE M7.5 M6.5 M5.5

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.

M7.5 – D2 = 0, RST7.5 is enabled


D2=1, RST7.5 is masked or disabled

M6.5 – D1 = 0, RST6.5 is enabled


D1=1, RST6.5 is masked or disabled

M5.5 – D0 = 0, RST5.5 is enabled


D0=1, RST5.5 is masked or disabled

Note: SOD and SOE are irrelevant for interrupt setting.

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

DELAY: LXI B, 65535


LOOP: DCX B
MOV A, B
ORA C
JNZ LOOP
RET

; Interrupt Service Routine RST6.5


ISR65: PUSH PSW
PUSH B
MVI D, 10
BLINK: MVI A, 11111110B
OUT 81H
CALL DELAY
MVI A, 11111111B
OUT 81H
CALL DELAY
DCR D
JNZ BLINK
POP B
POP PSW
EI
RET

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

1.1 To introduce Serial I/O (SID and SOD)

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

message: db 0dh,0ah, “Welcome to Microprocessor LAB”,0

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

You might also like