0% found this document useful (0 votes)
44 views3 pages

LP 4

This document is a lab report summarizing an experiment on implementing loops in assembly language. The objectives were to learn how to use loops in assembly. The procedure involved using flags and branching instructions to execute code conditionally based on flag status, similar to if/else statements. The implementation showed a program to calculate a series sum using a loop. Testing showed the output was correct. Analysis discussed how conditional logic is achieved in assembly using branches, and how this experience deepened understanding of low-level programming and computer processing.

Uploaded by

sujon mridha
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)
44 views3 pages

LP 4

This document is a lab report summarizing an experiment on implementing loops in assembly language. The objectives were to learn how to use loops in assembly. The procedure involved using flags and branching instructions to execute code conditionally based on flag status, similar to if/else statements. The implementation showed a program to calculate a series sum using a loop. Testing showed the output was correct. Analysis discussed how conditional logic is achieved in assembly using branches, and how this experience deepened understanding of low-level programming and computer processing.

Uploaded by

sujon mridha
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/ 3

Green University of Bangladesh

Department of Computer Science and Engineering(CSE)


Faculty of Sciences and Engineering
Semester: (Fall, Year:2023), B.Sc. in CSE (Day)

LAB REPORT NO: 04


Course Title: Microprocessors & Microcontrollers Lab
Course Code: CSE-304 Section:212(D6)

Lab Experiment Name: Implementation of loop using assembly language.

Student Details

Name ID

1. Md Sujan 201002477

Lab Date : 24-11-2023


Submission Date : 01-12-2023
Course Teacher’s Name : Md. Nasif Osman Khansur

Lab Report Status


Marks: ………………………………… Signature:.....................
Comments:.............................................. Date:..............................
1. Title of The Lab Experiment
Implementation of loop using assembly language.
2. Objectives
To gather knowledge how to use loop in assembly language.

3. PROCEDURE / ANALYSIS / DESIGN


To execute conditional operations, CPU checks the state of flag registers. Flag registers basically
reflect what was the result of the last thing that CPU did. Decision is being made based on the
status of various flag registers. Based on the flag register we can execute a certain portion or can
execute different portion of our program. Just like if-else condition in high level language. This
jump can be either conditional or unconditional.Unconditional jump may take place by JMP
instruction. For conditional branching, CMP instruction can be used.
For conditional branching, various instructions are used other than JE. JNE/JNZ stands for Jump
not Equal or Jump Not Zero, JG/JNLE stands for Jump Greater or Jump Not Less/Equal, JGE/JNL
stands for Jump Greater/Equal or Jump Not Less etc.Follow your reference book for more
branching instructions. Table 1.shows different jump instructions that are used in assembly
language. It also depicts description of instructions and corresponding flag registers.

4. IMPLEMENTATION
Write a program for calculate the series of sum
;1+4+7+10 =?
.model small

.stack 100h

.data

ans dw ?

.code

main proc

mov ax,@data
mov ds,ax
mov cx,5
mov ax,0
mov bx,1
summation:
add ax,bx
add bx,3
mov ans,ax

loop summation

mov ah,2
mov dx,ans

int 21h

main endp

end main

5. TEST RESULT / OUTPUT

6. ANALYSIS AND DISCUSSION

In the realm of low-level programming, the implementation of conditional statements in assembly language
is a fundamental aspect. Conditional statements, such as "if-else" and "switch-case," are essential constructs
that enable the execution of specific code blocks based on certain conditions. In assembly language, these
statements are typically implemented using branch instructions, allowing the program to alter its flow based
on the evaluation of condition codes or flags.

During this experiment, the primary focus was on understanding and implementing conditional
statements in assembly language. This involved grasping the structure of conditional statements,
the usage of various comparison and branching instructions, and the overall impact on program
execution. Understanding the intricacies of assembly language is crucial as it directly interacts
with the hardware, providing a deeper insight into how computers process instructions at a
fundamental level.

7. SUMMARY:
In conclusion, the implementation of conditional statements using assembly language is an indispensable
skill for low-level programming. This experiment provided valuable insights into the mechanics of
conditional execution, the utilization of branching instructions, and their impact on program flow and
efficiency. Mastery of assembly language conditional statements enables programmers to create efficient
and optimized code that interacts closely with hardware.

You might also like