0% found this document useful (0 votes)
7 views

Exercise-8(TIME)

The document outlines an exercise for a Microprocessors and Microcontroller Lab at Presidency University, Bengaluru, focusing on writing an Assembly Language Program (ALP) to read and display the current time. It discusses the concept of procedures in programming, highlighting their advantages such as simplification, reduced development time, and ease of debugging. Additionally, it provides a sample code and steps for executing Assembly Language programs using DOSBOX and MASM.

Uploaded by

houndclegane860
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Exercise-8(TIME)

The document outlines an exercise for a Microprocessors and Microcontroller Lab at Presidency University, Bengaluru, focusing on writing an Assembly Language Program (ALP) to read and display the current time. It discusses the concept of procedures in programming, highlighting their advantages such as simplification, reduced development time, and ease of debugging. Additionally, it provides a sample code and steps for executing Assembly Language programs using DOSBOX and MASM.

Uploaded by

houndclegane860
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

PRESIDENCY UNIVERISTY, BENGALURU

School of Engineering

Microprocessors and Microcontroller Lab


CSE 254

IV Semester 2018-19
Exercise-
8
Write an ALP to read the current time from the sys-
tem and display on screen
Exercise Descrip-
tion
While writing programs, it may be the case that a particular sequence of
instructions is used several times. To avoid writing the sequence of in-
structions again and again in the program, the same sequence can be
written as a separate subprogram called a procedure. Each time the se-
quence of instructions needs to be executed, CALL instruction can be
used. CALL instruction transfers the execution control to procedure. In
the procedure, a RET instruction is used at the end. This will cause the
execution to be transferred to caller program.
Often large programs are split into number of independent tasks which
can be easily designed and implemented. This is known as modular
programming.
Advantages:
1.Programming becomes simple.
2. Reduced development time – as each module can be imple-
mented by different persons.
3. Debugging of smaller programs and procedures is easy.4.
4. Reuse of procedures is possible.5.
5. A library of procedures can be created to use and distribute.
Exercise Description--- Con-
tinued
Defining procedures:
Assembler provides PROC and ENDP directives in order to define procedures.
The directive PROC indicates beginning of a procedure. Its general form is:
Procedure_name PROC [NEAR|FAR]
NEAR | FAR is optional and gives the types of procedure. If not used, assemble
r assumes the procedure as near procedure. All procedures are defined in code
segment. The dire-ctive ENDP indicates end of a procedure. Its general form is:
Procedure_name ENDP
For example:
Factorial PROC NEAR
……
……
……
Factorial ENDP
.model small currtime proc
.data mov ah,2ch
Msg db 10,13,'The current time is:' ;service number to read system time
hour db 2 dup(0),':' int 21h
min db 2 dup(0),':' mov al,ch
sec db 2 dup(0),'$'
aam
add ax,3030h ;For hours
.code
mov hour,ah
disp macro m1 mov hour+1, al
mov ah,09h mov al,cl
lea dx,m1 aam
int 21h add ax,3030h
endm mov min,ah ;For minutes
mov min+1,al
Mov ax,@data
mov al,dh
Mov ds,ax
aam
call currtime add ax,3030h ;For seconds
disp msg mov sec,ah
mov ah,4ch mov sec+1,al
int 21h ret
currtime endp
end
Steps to Execute Assembly Language programs
1) Install DOSBOX 0.74

2) Launch DOSBOX, By default it will be in Z drive <Z:\>


3) Change the drive to that, in which MASM is installed
mount c c:\masm
4) C:
5) C:\> Edit filename.asm
6) C:\> Masm filename.asm;
7) C:\> Link filename.obj;
8) Filename (Enter Key)
THANK YOU

You might also like