Вы находитесь на странице: 1из 8

Microprocessor project

Topic : timer

Submitted by:
Samiksha kaushik (14105001)
Priya soni (14105035)
Tejinder kaur (14105041)
Srishti bali (14105046)
Priya (14105053)
Submitted to:
Prof. neha bhullar

AIM :
To write an assembly language program in emulator EMU8086 to implement
a timer(stopwatch).

INTRODUCTION

A timer is a specialized type of clock for measuring time interval. A device


which counts upward from zero to a specified time interval for measuring
elapsed time is often called a stop watch. And a device which counts down
from a specified time interval is more usually called a countdown timer.
By emulating the assembly language program of timer in EMU8086, it comes
under the category of software timers. These type of timers are not
devices or parts of devices; they exist only in lines of code. They rely on the
accuracy of clock oscillator usually built into a hardware device that runs the
software.

Theory:
Following assembly language program is used to implement the timer.
count db
10
c1

db

'a'

msg db "Thank You for using!!..."


msg_size = $ - msg
mov

ax, cs

mov

ds, ax

mov

es, ax

call video_mode
call set_screen
next_char:
cmp
jz

count, 0
stop

mov

al, c1

mov

ah, 0eh

int

10h

inc

c1

dec
count
mov
cx, 0fh
mov

dx, 4240h

mov

ah, 86h

int
jmp

15h
next_char

stop:
mov al, 1
mov bh, 0
mov bl, 0010_1111b
mov cx, msg_size
mov dl, 4
mov dh, 15
mov bp, offset
mov ah, 13h
int 10h
mov ah, 0
int 16h
int 19h
video_mode proc
mov

ah,

mov

al, 3

int

10h

ret
video_mode endp
set_screen proc

push

ax

push

ds

push

bx

push

cx

push

di

mov

ax, 40h

mov

ds, ax

mov

ah, 06h

mov

al, 0

mov

bh, 1110_0100b

mov

ch, 0

mov

cl, 0

mov

di, 84h

mov

dh, [di]

mov

di, 4ah

mov

dl, [di]

dec

dl

int

10h

mov

bh, 0

mov

dl, 5

mov

dh, 5

mov

ah, 02

int

10h

pop

di

pop

cx

pop

bx

pop

ds

pop

ax

ret
set_screen endp
end
EXPLANATION:
The explanation of the program is as follows:
This program makes use of timer function (int 15h/ 86h ), and to witness this
delay the code prints some characters with one second delay.
Firstly all the segments are initialized with same address. Then the procedure
namely, video_mode is called by the main program. The function code
AH=00h, under int 10h instruction is used to set video mode. The value in AL
decides the current screen resolution. For example, if Al=3 , it sets text
mode 80 x 25, 16 colours , 8 pages
Or if AL=0, it sets text mode 40 x 25, 16 grey and so on.
Now, the main program calls the procedure by the name of set_screen.
Firstly, the PUSH instruction pushes the content of all the registers on to the
stack. To, access the screen parameters data segment register is initialized
with 40h. Then, AH=06h under int 10h is used to scroll up the window. The
content of AL decides the number of lines to be scrolled.
Al=0 is used for scrolling all lines. The 8 bit value in BH determines the
BIOS colour attributes, in which the lower 4 bits are for character colour and
the higher 4 bits for background colour. Eg. 1110_0010 signifies yellow for
background and red for text. The contents of CH and CL are for Upper row
number and Left column number respectively. Similarly , values in DH and DL
stand for Lower row number and Right column number.
To set CURSOR position AH=02h under int10h is used, where BH represents
the current page number, DL and DH represents the column and row number
respectively. Finally, the content stored on the stack is retrieved using the
POP instruction.
The instruction AH=0eh under int 10h is used to print a character, which is
stored in AL.
To introduce the delay of one second, AH=86h under int 15h is used. Here,
the time interval is in microseconds whose lower word is in dx and higher
word is in cx.
These instructions are repeated the required number of times as specified in
count using branching instructions.

Finally, after the implementation of timer a message a printed using


int10h/13h function. Here, AL = write mode,
BH= page number,
BL= colour,
CX=string length
DL= column no.
DH= row number,
BP = offset of string
AH=0 in int 16h waits in the idle state till it reads any character, and int 19h
is used to reboot.

FLOW chart:

segment registers initialisation

Call procedure video_mode

call procedure set_screen

print character on the screen using int


10h/0eh
introduce a delay of one second using int
15h/ 86h

repeat these instructions till count becomes zero

print message indicating the end of timer

wait for input from user and reboot the system

Apllications:
The timer can be used in a microwave oven to monitor time in
cooking and to alert the cook/user.
Timer applications can be used in various games.
And they can be used as stopwatch.
It can be used in almost all electronic devices like washing
machine, etc., whose operation is time dependent.

REFERENCES:
Int 10h in Wikipedia
www.computing.net
www.techsupportforum.com
Stanislaves.org
www.ctyme.com

Stackoverflow.com

Вам также может понравиться