0% found this document useful (0 votes)
57 views8 pages

Objective:: Lab#5: Loop Instructions SSUET/QR/114

This document discusses loops in assembly language. It explains that a loop is a sequence of instructions that repeats a certain number of times. The LOOP instruction is used to implement a FOR loop by decrementing the CX register on each iteration until it reaches 0. The document provides examples of assembly code programs that use loops to print characters, strings, and names multiple times. It includes the source code, solutions, and output for 5 tasks involving writing programs with different looping behaviors.

Uploaded by

Faraz Abbas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views8 pages

Objective:: Lab#5: Loop Instructions SSUET/QR/114

This document discusses loops in assembly language. It explains that a loop is a sequence of instructions that repeats a certain number of times. The LOOP instruction is used to implement a FOR loop by decrementing the CX register on each iteration until it reaches 0. The document provides examples of assembly code programs that use loops to print characters, strings, and names multiple times. It includes the source code, solutions, and output for 5 tasks involving writing programs with different looping behaviors.

Uploaded by

Faraz Abbas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Lab#5: Loop Instructions SSUET/QR/114

LAB#5

Objective :

To understand the concepts of loop in assembly language

Theory
Loop

A loop is a sequence of instructions that is repeated. The number of times to repeat may be
known in advance, or it may depend on conditions i.e. it’s a count controlled loop.

KEYWORD: LOOP

A FOR loop is implemented using the LOOP instruction. The counter for the loop is the CX
register, which is initialized to loop_count, which is the number of times the loop is executed.
Execution of the LOOP instruction causes CX to be decremented automatically. If CX becomes
0,the next instruction after loop is done.

Sample Program:

SOURCE CODE:
Object:Title a program that prints a character 100 times.
.model small
.stack 100h
.code
main proc

mov ah, 02h ;display a character


mov cx, 100 ;number of times loop will execute
mov dl, ‘*’ ;ASCII code of character 0

print: ;loop starts from here


int 21h
loop print ;executes the FOR loop

mov ah, 4ch ;terminates the current process


int 21h
main endp
end main

CE-207: Microprocessor and Microcontroller 27


Lab#5: Loop Instructions SSUET/QR/114

LAB OBJECTIVES:

Task #01:Write a program to print ‘*’ 100 times using linefeed and carriage return.

SOLUTION:

CE-207: Microprocessor and Microcontroller 28


Lab#5: Loop Instructions SSUET/QR/114

OUTPUT:

Task#02:Write a program to print ASCII characters from A-Z and Z-A


SOLUTION:

OUTPUT:

CE-207: Microprocessor and Microcontroller 29


Lab#5: Loop Instructions SSUET/QR/114

SOLUTION:

OUTPUT:

Task#03: Write a program to print ASCII characters from a-z and z-a

CE-207: Microprocessor and Microcontroller 30


Lab#5: Loop Instructions SSUET/QR/114

SOLUTION:

OUTPUT:

CE-207: Microprocessor and Microcontroller 31


Lab#5: Loop Instructions SSUET/QR/114

SOLUTION:

OUTPUT:

Task#04: Write a program to print ASCII characters.

SOLUTION:

CE-207: Microprocessor and Microcontroller 32


Lab#5: Loop Instructions SSUET/QR/114

OUTPUT:

Task#05:Write a program to print your name 10 times using linefeed and carriage return.

SOLUTION:

CE-207: Microprocessor and Microcontroller 33


Lab#5: Loop Instructions SSUET/QR/114

OUTPUT:

CE-207: Microprocessor and Microcontroller 34

You might also like