Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help, this is ASM project: COSC 2 4 2 5 - Project 2 Implement the following C + + code fragment in assembly language. Use

Help, this is ASM project: COSC 2425- Project 2
Implement the following C++ code fragment in assembly language. Use the block structured .IF and .WHILE directives. Assume that all variables are 32-bit integers.
int array[]={3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4,6,2,6,4};
int lower =4;
int upper =8;
int ArraySize = sizeof array / sizeof lower;
int index =0;
int sum =0;
while( index < ArraySize )
{
if( array[index]>= lower && array[index]<= upper )
{
sum += array[index];
}
index++;
}
Your assembly language program must also display as output the number of times a member of 'array' qualified for inclusion into the 'sum'(>= lower && <= upper) and what the final value of the variable 'sum' was. (Hint: you may have to add another variable.) You may use the author's procedures in the book's link library. Use only the procedures that have been covered in the textbook so far.
Sample output:
Qualified members: XX
Sum = XX. This is my work so far, and it's asking me to use irvine: .data
array WORD 3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4,6,2,6,9
lower DWORD 4
uppwe DWORD 8
index DWORD ?
sum DWORD ?
ArraySize=($-array)/4
index_Msg BYTE "Qualified Member: ",0
sum_Msg BYTE "Sum: ",0
.code
.text
global main
extern printif
.main
mov eax,0
mov ebx, ArraySize
mov ecx, lower
mov edx, upper
.loop
cmp eax, ebx
jge . done
mov esi, array
mov edi, [esi+eax*4]
cmp edi, ecx
jl .next
cmp edi, ecx
jl .next
add sum, edi
.next
inc eax
jmp .loop
.done
mov eax, 1
xor ebx, ebx
int 0x 80
.bss

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago