Answer To: Page 1 of 4 CSC 260 Assembly project Prof. Steve Ochani Due Date: Tuesday 12/18/19 11:30 AM Late...
Gaurav answered on Dec 18 2021
Project32_VS2017/.vs/Project/v14/.suo
Project32_VS2017/.vs/Project/v15/.suo
Project32_VS2017/.vs/Project/v15/Browse.VC.db
Project32_VS2017/.vs/Project/v15/Solution.VC.db
Project32_VS2017/AddTwo.asm
.386
.model flat,stdcall
.stack 4096
INCLUDELIB msvcrt.lib
printf PROTO C, :VARARG
scanf proto C, :VARARG
_getch proto C
ExitProcess proto, dwExitCode:dword
.data
array dword 5 dup (0)
array_size dword 5
prompt db "Please enter 5 Numbers : ", 0
fmt db "%d %d %d %d %d", 0
maxNumber db "The Maximum in given Array is %d", 10, 0
minNumber db "The Minimum in given Array is %d", 10, 0
AvgNumber db "The Average of given Array is %d.%d", 10, 0
.code
main proc
push offset prompt
call printf ; printf("Please enter 5 Numbers : ")
add esp, 4
push offset array + 16
push offset array + 12
push offset array + 8
push offset array + 4
push offset array + 0
push offset fmt
call scanf ; scanf("%d %d %d %d %d", array[0], array[1], array[2], array[3], array[4])
add esp, 24
push array_size
push offset array
call max ; max(array, array_size)
add esp, 8
push eax
push offset maxNumber
call printf ; printf("The Maximum in given Array is %d\n", max(array, array_size))
add esp, 8
push array_size
push offset array
call min ; min(array, array_size)
add esp, 8
push eax
push offset minNumber
call printf ; printf("The Minimum in given Array is %d\n", min(array, array_size))
add esp, 8
push array_size
push offset array
call avg ; avg(array, array_size)
add esp, 8
push edx
push eax
push offset avgNumber ; printf("The Average of given Array is %d.%d\n", quodient(eax), decimal(edx*2))
call printf
add esp, 8
call _getch ; to keep console open
invoke ExitProcess,0
main endp
max proc ; find the maximum number in the array
push ebp
mov ebp, esp ; update stack pointer
mov esi, [ebp + 8] ; array
mov ecx, [ebp + 12] ; array_size
sub esi, 4 ; compensate zero offset
mov eax, [esi + ecx * 4] ; last element
sub ecx, 1 ; before last element
maxLoop:
cmp eax, [esi + ecx * 4] ; if(current element < previous element)
jge maxSkip
mov eax, [esi + ecx * 4] ; then current element = previous element
maxSkip:
loop maxLoop ; while(array_size-- != 0)
mov esp, ebp ; restore stack
pop ebp
ret ; return
max endp
min proc ; find the minimum number in the array
push ebp
mov ebp, esp ; update stack pointer
mov esi, [ebp + 8] ; array
mov ecx, [ebp + 12] ; array_size
sub esi, 4 ; compensate zero offset
mov eax, [esi + ecx * 4] ; last element
sub ecx, 1 ; before last element
minLoop:
cmp eax, [esi + ecx * 4] ; if(current element > previous element)
jle minSkip
mov eax, [esi + ecx * 4] ; then current element = previous element
minSkip:
loop minLoop ; while(array_size-- != 0)
mov esp, ebp ; restore stack
pop ebp
ret ; return
min endp
avg proc ; finds the average of the given array
push ebp
mov ebp, esp ; update stack pointer
mov esi, [ebp + 8] ; array
mov ecx, [ebp + 12] ; array_size
sub esi, 4 ; compensate zero offset
mov eax, [esi + ecx * 4] ; last element
sub ecx, 1 ; before last element
avgLoop:
add eax, [esi + ecx * 4] ; current element += previous element
loop avgLoop ; while(array_size-- != 0)
mov ecx, [ebp + 12] ; array_size
mov edx, 0
idiv ecx ; sum of element / array_size
shl edx, 1 ; reminder * 2 since n = 5 multiply by 2 to give decimal points
mov esp, ebp ; restore stack
pop ebp
ret ; return
avg endp
end
Project32_VS2017/Debug/AddTwo.obj
Project32_VS2017/Debug/Project.Build.CppClean.log
c:\users\ganapathy\desktop\project32_vs2017\debug\project.ilk
c:\users\ganapathy\desktop\project32_vs2017\debug\project.exe
c:\users\ganapathy\desktop\project32_vs2017\debug\project.pdb
c:\users\ganapathy\desktop\project32_vs2017\debug\addtwo.obj
c:\users\ganapathy\desktop\project32_vs2017\debug\project.tlog\link.command.1.tlog
c:\users\ganapathy\desktop\project32_vs2017\debug\project.tlog\link.read.1.tlog
c:\users\ganapathy\desktop\project32_vs2017\debug\project.tlog\link.write.1.tlog
c:\users\ganapathy\desktop\project32_vs2017\debug\project.tlog\project.write.1u.tlog
Project32_VS2017/Debug/Project.exe
Project32_VS2017/Debug/Project.ilk
Project32_VS2017/Debug/Project.log
Assembling AddTwo.asm...
Project.vcxproj -> C:\Users\Ganapathy\Desktop\Project32_VS2017\Debug\Project.exe
Project.vcxproj -> C:\Users\Ganapathy\Desktop\Project32_VS2017\Debug\Project.pdb (Full PDB)
Project32_VS2017/Debug/Project.pdb
Project32_VS2017/Debug/Project.tlog/link.command.1.tlog
^C:\USERS\GANAPATHY\DESKTOP\PROJECT32_VS2017\DEBUG\ADDTWO.OBJ
/OUT:"C:\USERS\GANAPATHY\DESKTOP\PROJECT32_VS2017\DEBUG\PROJECT.EXE" /NOLOGO /LIBPATH:C:\MASM32\MACROS /LIBPATH:C:\MASM32\LIB /LIBPATH:C:\MASM32\INCLUDE USER32.LIB MASM32.LIB KERNEL32.LIB USER32.LIB GDI32.LIB WINSPOOL.LIB COMDLG32.LIB ADVAPI32.LIB SHELL32.LIB OLE32.LIB OLEAUT32.LIB UUID.LIB ODBC32.LIB ODBCCP32.LIB /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:\USERS\GANAPATHY\DESKTOP\PROJECT32_VS2017\DEBUG\PROJECT.PDB" /SUBSYSTEM:CONSOLE /TLBID:1 /ENTRY:"main" /DYNAMICBASE:NO /IMPLIB:"C:\USERS\GANAPATHY\DESKTOP\PROJECT32_VS2017\DEBUG\PROJECT.LIB" /MACHINE:X86 /SAFESEH:NO DEBUG\ADDTWO.OBJ
Project32_VS2017/Debug/Project.tlog/link.read.1.tlog
^C:\USERS\GANAPATHY\DESKTOP\PROJECT32_VS2017\DEBUG\ADDTWO.OBJ
C:\WINDOWS\GLOBALIZATION\SORTING\SORTDEFAULT.NLS
C:\MASM32\LIB\USER32.LIB
C:\MASM32\LIB\MASM32.LIB
C:\MASM32\LIB\KERNEL32.LIB
C:\MASM32\LIB\GDI32.LIB
C:\MASM32\LIB\WINSPOOL.LIB
C:\MASM32\LIB\COMDLG32.LIB
C:\MASM32\LIB\ADVAPI32.LIB
C:\MASM32\LIB\SHELL32.LIB
C:\MASM32\LIB\OLE32.LIB
C:\MASM32\LIB\OLEAUT32.LIB
C:\PROGRAM FILES (X86)\WINDOWS...