0% found this document useful (0 votes)
12 views4 pages

LAB 6 Loops - While

This document outlines a lab exercise on implementing loop structures in 8086 Assembly Language, specifically focusing on a WHILE loop equivalent to print numbers 1 to 5. It includes the assembly code for the loop, demonstrating how high-level logic translates to low-level instructions. The lab also includes a task to convert the WHILE loop into a DO_WHILE loop and emphasizes understanding the syntax and functionality of loops in assembly programming.
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)
12 views4 pages

LAB 6 Loops - While

This document outlines a lab exercise on implementing loop structures in 8086 Assembly Language, specifically focusing on a WHILE loop equivalent to print numbers 1 to 5. It includes the assembly code for the loop, demonstrating how high-level logic translates to low-level instructions. The lab also includes a task to convert the WHILE loop into a DO_WHILE loop and emphasizes understanding the syntax and functionality of loops in assembly programming.
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/ 4

INSTITUTE OF MATHEMATICS AND COMPUTER SCIENCE

UNIVERSITY OF SINDH, JAMHSORO.

Subject: Computer Organization and Assembly Language Dated: 17/3/2025

INTRODUCTION
This lab determines implementing Loops structure in 8086 Assembly Language.

We will Implement WHILE loop equivalent.

This exercise clarifies how high-level conditional logic translates to low-level assembly
instructions, highlighting foundational decision-making techniques in processor-level
programming.

1. WHILE Loop Equivalent in 8086 Assembly

Objective: Print numbers 1 to 5 using a for loop equivalent.

For loop concept:

int i = 1;
while (i <= 5) {
print(i);
i++;
}

1
Course instructors:
Prof. Dr. Imtiaz Ali Korejo, Mr. Habibullah Nangraj.
INSTITUTE OF MATHEMATICS AND COMPUTER SCIENCE
UNIVERSITY OF SINDH, JAMHSORO.

Subject: Computer Organization and Assembly Language Dated: 17/3/2025

In Assembly:
.MODEL SMALL
.STACK 100H
.CODE

MAIN PROC

MOV BL, 1 ; Counter i = 1

WHILE_LOOP:

CMP BL, 6
JGE END_WHILE ; Exit if i >= 6

MOV AL, BL
CALL PRINT_NUM

INC BL ; i++

JMP WHILE_LOOP ; Repeat

END_WHILE:
MOV AH, 4CH
INT 21H

PRINT_NUM:
ADD AL, '0' ; 0 Equal to 30H
MOV DL, AL
MOV AH, 02H
INT 21H

RET

MAIN ENDP
END MAIN

2
Course instructors:
Prof. Dr. Imtiaz Ali Korejo, Mr. Habibullah Nangraj.
INSTITUTE OF MATHEMATICS AND COMPUTER SCIENCE
UNIVERSITY OF SINDH, JAMHSORO.

Subject: Computer Organization and Assembly Language Dated: 17/3/2025

Snapshot of program:

OUTPUT OF THE PROGRAM

We use CMP + JGE (JUMP IF GREATER OR EQUAL).

3
Course instructors:
Prof. Dr. Imtiaz Ali Korejo, Mr. Habibullah Nangraj.
INSTITUTE OF MATHEMATICS AND COMPUTER SCIENCE
UNIVERSITY OF SINDH, JAMHSORO.

Subject: Computer Organization and Assembly Language Dated: 17/3/2025

LAB TASKS

TASK 1. Covert the While loop into DO_WHILE (Print at least once).

CONCLUSION
This lab manual demonstrate the structure and uses of While Loop in assembly
programming using the 8086 microprocessor. By completing these exercises,
you will develop a solid understanding of While loop Syntax and working.

4
Course instructors:
Prof. Dr. Imtiaz Ali Korejo, Mr. Habibullah Nangraj.

You might also like