Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

COSC 2425 - Project 2 Part 1 Implement the following C++ code fragment in assemb

ID: 3572392 • Letter: C

Question

COSC 2425 - Project 2 Part 1 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}; int lower = 3; 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 ' and what the final value of the variable ' sum ' was. (Hint: you may have to add another variable.) Feel free to use the author's procedures in the book's link library. Use only the procedures that were introduced in chapter 5. Part 2 Write an assembly language program that asks the user to enter an integer dollar amount between 1 and 5,000. Your program should display the corresponding class description using the following table. Write the program so that it executes until the user inputs some value that you determine to be the "sentinel value". Your program must guard against and provide user messages for input values that are outside the valid range. Donation Amount (dollars) Class of Donation

$4,000 to $5,000 Platinum

$3,000 to $3,999 Gold

$2,000 to $2,999 Silver

$1,000 to $1,999Bronze

$1 to $999 Copper

Explanation / Answer

Answer:

TITLE Project 2
INCLUDE Irvine32.inc
.data
Array DWORD 3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4
lower DWORD 3
upper DWORD 8
ArraySize = ($ - Array) / TYPE array
index DWORD 0
sum DWORD 0
.code
main PROC
mov eax, 0 ; sum
mov edx, lower
mov esi, 0 ; index
mov ebx, upper
mov ecx, ArraySize
L1: cmp esi,ecx
jl L2
jmp L5
L2: cmp array[esi], edx
cmp array[esi], ebx
jg L3
jmp L4
L3: add eax, array[esi]
L4: inc esi
jmp L1
L5: mov sum,eax
call array
call sum
exit
main ENDP
END main