Page 1 of 4 CSC 260 Assembly project Prof. Steve Ochani Due Date: Tuesday 12/18/19 11:30 AM Late submission will not be accepted Be sure to document any help sources such as websites or people, you...

1 answer below »
Page 1 of 4 CSC 260 Assembly project Prof. Steve Ochani Due Date: Tuesday 12/18/19 11:30 AM Late submission will not be accepted Be sure to document any help sources such as websites or people, you don’t have to credit my help! Submission Submit only the asm file to Moodle. Make sure it has your name and N number on top in comments. The program must work with Visual Studio 2017 setup like the one in B223 and B225. You may copy the \masm32 folder from a computer in either of those rooms. You may also download the zip file for it from https://stargate.ncc.edu/260/ The unzipped folder (masm32) must be at c:\ in order for the default project to find the files inside it. Make sure you don’t have a duplicate folder inside it, like c:\masm32\masm32. You will also need to install Visual Studio 2017 as well; the link for it was emailed. Note/hint: Plan this program out first before you start coding it. Page 2 of 4 This project is basically putting together things that were taught in class but DO NOT WAIT until the last day to start this. Code efficiency will count. Meaningful names of source file, vars, and procs will count as well. You will have to comment all important sections of your code except the standard code given in the addition example / template at https://stargate.ncc.edu/260/ (Project32_VS2017.zip) Comments don’t have to be for every line but anything significant. The comment should explain what the line of code is doing and if relevant why your line of code is doing what it is doing. The program will require the use of programmer defined procs. You can name them what you wish but they should have meaningful names. All procs should preserve values of any registers used in the proc except of course a register used to store the return value. For grade of 80: Your program will ask the user for 5 WORD numbers. They must be stored in an array of size 5. Page 3 of 4 This can be done in main proc. Call another proc to output the array, passing in the array and size. Call another proc, passing in the array and size, that will find the max number in that array and store result in register of your choice. This number will then be printed back in main. Call another proc, passing in the array and size, that will find the min number in that array and store result in register of your choice. This number will then be printed back in main. For grade of 100: Must do everything for grade of 80. In addition to above. Call another proc, passing in the array and size, that will find the average of that array and store result in register of your choice. This number will then be printed back in main. Carefully test this proc! For extra credit of 6 points on your final exam: Page 4 of 4 Must do everything for grade of 100 but instead of 5 WORD number array the program must use and support 5 REAL4 number array.
Answered Same DayDec 16, 2021

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
141 Votes
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...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here