0% found this document useful (0 votes)
5 views

Assignment

The document outlines an assembly language lab assignment submitted by Tahreem Rafaqat, a BSCS student. It includes tasks to write code for finding the largest number in an array and converting a C++ code segment into assembly language instructions. The assignment emphasizes efficient coding practices and understanding of control flow in assembly language.

Uploaded by

223317
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)
5 views

Assignment

The document outlines an assembly language lab assignment submitted by Tahreem Rafaqat, a BSCS student. It includes tasks to write code for finding the largest number in an array and converting a C++ code segment into assembly language instructions. The assignment emphasizes efficient coding practices and understanding of control flow in assembly language.

Uploaded by

223317
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/ 5

Course: Assembly language lab

Submitted by Tahreem Rafaqat

Id No 223317

Program BSCS

Semester 5th Semester

Submitted to Ma am Mahnoor
1. Write an efficient code segment to find Largest Number in an array of 10 unsigned
words. Store the largest number in location named “result”.
This program scans through an array of 10 numbers to find the largest value:
1. Start by assuming the first number in the array is the largest.
2. Go through each number in the array one by one.
3. If a number is bigger than the current largest, update the largest number.
4. When all numbers are checked, save the largest value to a memory location called
result.
2. Convert the following C++ code to equivalent Assembly Language instructions. (All the
variables are unsigned 32 bit integers).
while(op1 <= op2)
{
if(op1 > x || op1 > y)
{
Z += 10;
}
else
{
Z -= 10;
}
op1++;
}

This program repeatedly compares op1 with op2 and updates Z based on certain
conditions:

1. Keep looping while op1 <= op2.


2. Inside the loop:
o If op1 is greater than either x or y, add 10 to Z.
o Otherwise, subtract 10 from Z.
3. After each check, increase op1 by 1.
4. Exit when op1 becomes greater than op2.

This is a straightforward translation of the C++ logic into MIPS assembly.

You might also like