0% found this document useful (0 votes)
78 views7 pages

MPI Lab 10

This document describes a program to control a virtual traffic light system using an 8086 microprocessor. The traffic light system has 12 LEDs and can be controlled by writing different control words to port address 4. The control word format and some example control words are provided. The document also provides instructions on using the OUT instruction to load control words and the INT 15h BIOS wait function to add delays between control words. An example ALP is provided to initialize the traffic lights, output different control words with delays, and loop continuously.

Uploaded by

dihosid99
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)
78 views7 pages

MPI Lab 10

This document describes a program to control a virtual traffic light system using an 8086 microprocessor. The traffic light system has 12 LEDs and can be controlled by writing different control words to port address 4. The control word format and some example control words are provided. The document also provides instructions on using the OUT instruction to load control words and the INT 15h BIOS wait function to add delays between control words. An example ALP is provided to initialize the traffic lights, output different control words with delays, and loop continuously.

Uploaded by

dihosid99
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/ 7

Microprocessors and Interfaces: 2021-22

Lab 10
Program to Control Traffic Light System

By Dr. Sanjay Vidhyadharan


Traffic Light in Emulator

• A virtual traffic light system is available in EMU8086 with port address 4.

• It consists of 12 LEDs with an animation of car moving in direction


where green LED is activated.

• Control word can be provided using 8086 to change the signal color.

State of each LED

1: LED is turned on
0: LED is turned off

Control Word Format


Current Control Word

2
Control Words

F E D C B A 9 8 7 6 5 4 3 2 1 0
× × × × 1 0 0 0 0 1 1 0 0 0 0 1 Default
× × × × 0 0 1 0 0 1 0 0 1 0 0 1 All red
× × × × 0 0 1 1 0 0 0 0 1 1 0 0
× × × × 0 1 1 0 1 0 0 1 1 0 1 0
× × × × 1 0 0 0 0 1 1 0 0 0 0 1
× × × × 1 0 0 0 0 1 1 0 0 0 0 1
× × × × 0 1 0 0 1 1 0 1 0 0 1 1

×: Not used bits (should be replaced by 0).

3
Traffic Light in Emulator

▪ Port Address: 04H

▪ Instruction to include stepper motor in emulator:


#start=traffic_lights.exe#

▪ How to load the control word in traffic light?

Use OUT instruction. For out instruction select port 4.


Use AX register to store control word intermediately.

▪ How to maintain time gap between two control words?

Use int 15h, AH=86h for delay

4
int 15h, AH=86h

INT 15h / AH = 86h - BIOS wait function. input:


CX:DX = interval in microseconds return:
CF clear if successful (wait interval elapsed),
CF set on error or when wait function is already in progress.

• What should be the value of CX-DX register for wait time


of 2s between two control instructions?

Wait Time = 2 s = 2 × 106 µs


Hexadecimal Value = 1E8480
CX = 001Eh
DX = 8480h

5
ALP for Traffic Signal
#start=Traffic_Lights.exe# Initializes the virtual traffic signal
name "traffic"
mov ax, all_red Closes all traffic
out 4, ax

mov si, offset situation Offset calculation of CW and load in SI.


next: mov ax, [si] Loads the first data in AX and send it IO
out 4, ax
mov cx, xxxxh Use CX-DX register to provide wait instruction for 5s.
mov dx, xxxxh
mov ah, 86h BIOS Delay Function. Unit in µs. Content Format: CX-DX
int 15h
add si, 2 Increase SI for next data
cmp si, sit_end
jb next Check all situational data are emulated or not. If yes, then restart
mov si, offset situation else complete all the situational control words.
jmp next
situation dw xxxx_xxxx_xxxx_xxxxb
s1 dw xxxx_xxxx_xxxx_xxxxb
s2 dw xxxx_xxxx_xxxx_xxxxb Control world (16-bit format)
s3 dw xxxx_xxxx_xxxx_xxxxb
s4 dw xxxx_xxxx_xxxx_xxxxb
sit_end = $
all_red equ 0000_0010_0100_1001b 6
Thankyou

You might also like