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.