Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

UOZ – CS. Dept. Microprocessors Lab. 2020 – Lab.

Sheet #3

Using Loops in 8086 Assembly Language


Introduction:
In this lab experiment you will learn how to use loops to do repeated
tasks such as printing the same message or printing a specific character
on the screen multiple times to do such a task let’s begin with the code
listed below which prints the ( * ) character on the screen 10 times
spaced by space character.

The Code:
MODEL SMALL
.STACK 100H
.DATA

SPC EQU ' ' ; declare a constant SPC = ‘ ‘

.CODE

Start:

MOV CL,0AH ; CL = 10 in decimal

BACK:

MOV DL, '*'


MOV AH, 2 ; print one character in DL
INT 21H

MOV DL, SPC


MOV AH, 2 ; print space character
INT 21H

Instructors: Omar, Qaidar and Samyian


1
UOZ – CS. Dept. Microprocessors Lab. 2020 – Lab. Sheet #3

DEC CL
JNZ BACK

MOV AH,4CH
INT 21H

END Start

After completing the code save the code to prog4.asm file.

Assembling and Linking:

Instructors: Omar, Qaidar and Samyian


2
UOZ – CS. Dept. Microprocessors Lab. 2020 – Lab. Sheet #3

Running the program:

When you run the code, the output will be as shown below:

Questions:

1- Write an assembly program to fill the screen with star (*)


character.
2- Write an assembly program to print the following pattern on the
screen.

*
**
***
****
*****

3- Write an assembly program to print the following pattern on the


screen.

*****
****
***
**
*

Instructors: Omar, Qaidar and Samyian


3

You might also like