Question: PLEASE READ THE INSTRUCTION CAREFULLY AND TAKE A LOOK AT MY ANSWER AND FEEDBACK FROM THE PROFFESOR, I GOT 0 FOR IT AND NEED TO

PLEASE READ THE INSTRUCTION CAREFULLY AND TAKE A LOOK AT MY ANSWER AND FEEDBACK FROM THE PROFFESOR, I GOT 0 FOR IT AND NEED TO FIX IT ASAP.
MUST BE IN MASM(MICROSOFT MACRO ASSEMBLER)
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
--------------------------
here is my answer:
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,6,2,6,4
lower DWORD 4
upper DWORD 8
ArraySize DWORD 0
index DWORD 0
sum DWORD 0
qualifiedMembers DWORD 0
.code
main PROC
; Calculate ArraySize
mov eax, SIZEOF array
mov ebx, SIZEOF lower
div ebx
mov ArraySize, eax
; Loop through the array
mov ecx, ArraySize
mov esi, OFFSET array
mov index, 0
mov sum, 0
mov qualifiedMembers, 0
loop_start:
cmp index, ecx
jge loop_end
; Check if array[index] qualifies for inclusion
mov eax, [esi
index *4] ; Load array[index] into eax
cmp eax, lower
jl not_qualified
cmp eax, upper
jg not_qualified
; If qualified, add to sum and increment qualifiedMembers
add sum, eax
inc qualifiedMembers
not_qualified:
inc index
jmp loop_start
loop_end:
; Display results
mov edx, OFFSET qualifiedMembers
call WriteString
mov eax, qualifiedMembers
call WriteDec
call Crlf
mov edx, OFFSET sum
call WriteString
mov eax, sum
call WriteDec
call Crlf
exit
main ENDP
END main
FEEDBACK
This is an assembly language class. The directions tell you to replicate the algorithm using MASM.
4/30- the file you uploaded does not build - please check your file
Severity Code Description Project File Line Suppression State
Error A2008 syntax error : index Project C:\Users\hitche\Desktop\Project32_VS2019\AddTwo.asm 54
Error A2207 missing right parenthesis in expression Project C:\Users\hitche\Desktop\Project32_VS2019\AddTwo.asm 53
Error MSB3721 The command "ml.exe /c /nologo /Sg /Zi /Fo"Debug\AddTwo.obj" /Fl"Project.lst"/I "c:\Irvine"/W3/errorReport:prompt /TaAddTwo.asm" exited with code 1. Project C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\BuildCustomizations\masm.targets 70
PLEASE FIX MY CODE AND SHOW ME THE SCREENSHOT OF OUTPUT
PLEASE READ THE INSTRUCTION CAREFULLY AND TAKE A

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!