1. Department of Computer Science & Engineering
Course Title: Microprocessor &Assembly Language
Report On: Traffic-Lights-System-2
Report NO. 1
Submitted To:
Ahmed Al Marouf
Lecturer Daffodil International University
Submitted By:
M M Rayhan Parvez 143-15-4617
Tuhin Suad 143-15-4614
Jiya Uddin ahmed 143-15-4593
Asif Ahmed 143-15-4664
2. Fazle Karim 143-15-4492
Section: F
Submission Date: 5-4-2016
Traffic lights 2
1. ABSTRACT
On this paper we are going to discuss about
emu8086 example project the Traffic Lights 2 and
how it works. The aim of this project is to control
traffic system. The project is done by assembly
language which work on 8086 micro-processors. The
function of traffic lights is to provide sophisticated
control and coordination to ensure that traffic moves
as smoothly and safely as possible.
2. INTRODUCTION
Traffic signals are used to control the flow of
vehicles. In the recent years,the need of transportation
has gain immense importance for logistics as well as
for common human. This has given rise to the number
of vehicles on the road. Due to this reason, traffic jams
and road accidents are a common sight in any busy
city. Traffic Signals provide an easy,cheap, automatic
and justified solution to the road points where the
vehicles may turn to otherdirections e.g. roundabouts,
culverts, busy walk throughs etc.
Basic Idea The project we have chosen is an
8-lane traffic controller. The basic idea behind the
design is to avoid the collision of vehicles by
providing appropriate signals to different directions
for a limited time slot, after which the next waiting
drivers will be given same treatment. In This way a
cycle will be established which will control the traffic.
Control Signals The control signals are 3-
lights. Top light is Red(Stop), Middle light is
Yellow(Wait) Bottom light is Green(Go). States
of Traffic Flow There are 8-lanes and at most two
ways can be safely open. In this way a minimum of 4-
states are possible for which different vehicles will
pass through
2.1 WORKING PROCESS
In emu8086 We use some register and
segment to generate a code.We also use some built-in
default instruction to execute the desired output.
In here we use #start=Traffic_Lights.exe# for running
the whole code from c drive. The whole code is written
below with the comment of each line describe how the
code work as traffic light 2.
name "traffic2"; name the emulator ‘traffic2’
yellow_and_green equ 0000_0110b ;Assigns the
value 0000_0110b to the symbol yellow_and_green.
red equ 0000_0001b ;Assigns the value
0000_0110b to the symbol red.
3. yellow_and_red equ 0000_0011b ;Assigns the
value 0000_0110b to the symbol yellow and red.
green equ 0000_0100b ;Assigns the value
0000_0110b to the symbol green.
all_red equ 0010_0100_1001b ;Assigns the
value 0000_0110b to the symbol all_red.
start: ;label named start
nop ; do nothing
; 0,1,2
mov ax, green ;copy value of green symbol to ax
out 4, ax ;turn on green
mov ax, yellow_and_green ;copy value of
yellow_and_green symbol to ax
out 4, ax ;turn on yellow and green
mov ax,red ;copy value of red symbol to ax
out 4, ax ;turn on red
mov ax, yellow_and_red ;copy value of
yellow_and_red symbol to ax
out 4, ax ;turn on yellow and red
; 3,4,5
mov ax, green << 3 ;copy value of green symbol to
ax for 3,4,5 lights
out 4, ax ;turn on green
mov ax, yellow_and_green << 3 ;copy value of
yellow_and_green symbol to ax for 3,4,5 lights.
out 4, ax ;turn on yellow and green
mov ax,red << 3 ;copy value of red symbol to ax for
3,4,5 lights.
out 4, ax ;turn on red
mov ax, yellow_and_red << 3 ;copy value of
yellow_and_red symbol to ax for 3,4,5 lights
out 4, ax ;turn on yellow and red
; 6,7,8
mov ax, green << 6 ;copy value of green symbol to
ax for 6,7,8 lights
out 4, ax ;turn on green
mov ax, yellow_and_green << 6 ;copy value of
yellow_and_green symbol to ax for 6,7,8 lights
out 4, ax ;turn on yellow and green
mov ax,red << 6 ;copy value of red symbol to ax for
6,7,8 lights
out 4, ax ;turn on red
mov ax, yellow_and_red << 6 ;copy value of
yellow_and_red symbol to ax for 6,7,8 lights
out 4, ax ;turn on yellow and red
; 9,A,B
mov ax, green << 9 ;copy value of green symbol to
ax for 9,A,B lights
out 4, ax ;turn on green
mov ax, yellow_and_green << 9 ;copy value of
yellow_and_green symbol to ax for 9,A,B lights
out 4, ax ;turn on yellow and green
mov ax,red << 9 ;copy value of red symbol to ax for
9,A,B lights
out 4, ax ;turn on red
mov ax, yellow_and_red << 9 ;copy value of
yellow_and_red symbol to ax for 9,A,B lights
out 4, ax ;turn on yellow and red
; all
mov ax, all_red ;copy value of all_red symbol to ax
for all lights
out 4, ax ;turn on all red
mov ax, all_red << 1 ; all yellow
out 4, ax ;turn on all yellow
mov ax, all_red << 2 ; all green
out 4, ax ;turn on all green
jmp start ; jump to the start label
3.SYSTEM ARCHITECTURE
In this pro0ject we use a Traffic Light
Diagram and showing the functions of Traffic Light.
4. Fig1: Vehicles are going in Root1 when the Light is
Green.
Fig1: Vehicles are going in Root1 when the Light is
Green & Yellow.
Fig1: Vehicles are stop in Root1 when the Light is
Red.
Root1
Root3
Root2
Root4
5. Fig1: Vehicles are stop in all when the all Lights are
Red.
Fig1: Vehicles are stop in all when the all Lights are
Green.
4.CODE KEYWORDS (PROCEDURE
/MACROS/
FUNCTIONS/INSTRUCTION/LABEL)
Description of code keywords is given bellow: -
4.1 In " #start=Traffic_Lights.exe# " it runs an .exe
file of traffic lights 2 assembly code.
4.2 LABEL:
4.2.1 START:
In this label program start with copying the symbol of
green into the ax register. Then its moved out 4.
Similarly, Red & Green symbol copying in the register
then moved out. For every lights this process is
happening. At last all the similar lights fulfill the
condition. Again jump to the Start label. This process
is continuing until the program exit.
4.3 Instructions:(Describe Chronologically)
4.3.1 MOV: Copy operand2 to operand1.
The MOV instruction cannot:
set the value of the CS and IP registers.
copy value of one segment register to another
segment register.
copy immediate value to segment register
4.3.2 OUT: Output from AL or AX to port.
First operand is a port number. If required to access
port number over 255 - DX register should be used.
4.3.3 JMP: Unconditional Jump. Transfers control to
another part of the program. 4-byte address may be
entered in this form: 1234h:5678h, first value is a
segment second value is an offset.
Algorithm:
always jump
4.3.4 NOP: No Operation.
Algorithm:
Do nothing
6. Example:
; do nothing,3 times:
NOP
NOP
NOP
RET
C Z S O P A
unchanged
5. SPECIAL INSTRUCTION
In this project basically we don’t use many
instructions. Among them we use OUT instruction
specially because we use themfor port value.
5.1 OUT INSTRUCTION:
Operand:
im.byte,AL
im.byte,AX
DX,AL
DX, AX
Effect on Flags:
C Z S O P A
Unchanged
6. OUTCOME OF THE PRODUCT
Outcome of this project is knowing the basic of
Traffic light control and using the assembly
programming language syntax writing the logic of
Traffic light controlling and showit by a special
diagram.
7. WHAT’S NEW?
1. Use of graphical interface in assembly language.
2. Accessing .exe file using start instruction.
3. NOP instruction and its function
4.OUT instruction and its function
8. CONCLUSION
7. This is a program that maintain the traffic control. In
this project we compare different root vehicles
number. If the Light is Green of any root then that’s
root vehicles are running. If the Light is Red of any
root then that’s root vehicles are stop. If the Light is
Yellow ofany root then that’s root vehicles are waiting
for the next instructions.
REFERENCES
1. Google
2. Emu8086 Tutorial
3. Emu8086 Instruction Set
M M Rayhan Parvez
20%
Asif Ahmed
20%
Fazle Karim
20%
MD Tuhin Saud
20%
Jiya Uddin Ahmad
20%
CONTRIBUTION