Question: Please finish this code for computer architecture and assembly TITLE Program Template (main.asm) INCLUDE Irvine32.inc ; (insert symbol definitions here) MAX_VALUE = 100 NUM_ELEMENTS =

Please finish this code for computer architecture and assembly

Please finish this code for computer architecture and assembly TITLE Program Template

TITLE Program Template (main.asm)

INCLUDE Irvine32.inc

; (insert symbol definitions here) MAX_VALUE = 100 NUM_ELEMENTS = 8

.data

; (insert variables here - flush left) array dword NUM_ELEMENTS dup(0)

labelStart BYTE "Array at start:",0 labelGen BYTE "Array after generation",0 labelComplete BYTE "Array at end:",0

labelArray BYTE "Array: ",0

labelTotal BYTE "Total: ", 0 labelAverage BYTE "Average: ",0

total DWORD 0 average DWORD ?

spaceString BYTE " ",0

.code main PROC ; (insert executable instructions here -- indented) call randomize

call displayLine mov edx, offset labelStart call writeString call crlf ;

call displayAllArraysExam2

;;; your code here to generate data into array 'array' ;;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

;;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; display generated data call crlf

call displayLine mov edx, offset labelGen

call writeString call crlf

call displayAllArraysExam2

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; your code here to calculate results ;;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

;;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; display data after calculations

call crlf

call displayLine mov edx, offset labelComplete call writeString call crlf

call displayAllArraysExam2

exit main ENDP

; (insert additional procedures here)

; ----------------------------------------------------------------- ; ; displayAllArraysExam2 procedure displays all of the arrays ; ; input - node ; displayAllArraysExam2 PROC

; display arrays

mov EDI, offset array mov ECX, lengthOf array mov EDX, offset labelArray call displayArrayForExam2

call crlf

mov edx, offset labelTotal call writeString mov eax, total call writeDec call crlf

mov edx, offset labelAverage call writeString mov eax, average call writeDec call crlf

ret displayAllArraysExam2 ENDP

; ----------------------------------------------------------------- ; ; displayArrayForExam2 procedure ; ; assumes that the array is an array of DWORD ; ; input EDI - address of array to display ; ECX - length of array to display ; EDX - address of label to display ; displayArrayForExam2 PROC

call writeString displayArrayLoop: mov eax, [EDI] call padOnLeft call writeDec mov edx, offset spaceString call writeString add EDI, 4 Loop displayArrayLoop

call crlf ;

ret displayArrayForExam2 ENDP

displaySignedArrayForExam2 PROC

call writeString displayArrayLoop: mov eax, [EDI] call signedPadOnLeft call writeInt mov edx, offset spaceString call writeString add EDI, 4 Loop displayArrayLoop

call crlf ;

ret displaySignedArrayForExam2 ENDP

padOnLeft PROC uses edx

cmp eax, 1000 jae maxedOut

mov edx, offset spaceString call writestring

nextDigit100: cmp eax, 100 jae maxedOut

mov edx, offset spaceString call writestring

nextDigit10: cmp eax, 10 jae maxedOut

mov edx, offset spaceString call writestring

maxedOut: ret padOnLeft ENDP

signedPadOnLeft PROC uses edx

cmp eax, -100 jle maxedOut mov edx, offset spaceString ; display space call writestring

nextDigit10: cmp eax, -10 ; compare eax to -10 jle maxedOut ; if eax

;

maxedOut: ret signedPadOnLeft ENDP

; ============================================= ; displayLine procedure expects no parameters ; it displays a line ; displayLine PROC

MOV ecx, 40 MOV eax, '=' Line: call writeChar Loop Line

call crlf

ret displayLine ENDP

END main

- Declaring/Using variables/one dimensional arrays (BYTE, SBYTE, WORD, SWORD, DWORD, SDWORD) and storing data(results) into memory - using LENGTHOF - Declaring/Using Constants (like MAX_ROWS =5) - Possibly getting data from user and storing in memory (using Author's readint, readDec, readString) - most likely generate random data into an array (using Author's randomize, randomRange] - Calculations (ADD, SUB, MUL, iMUL, DIV, iDIV) - Displaying Data on screen (using Author's Writelnt, WriteDec, Writestring, CRLF) [ Output procedures will most likely be provided and you need to load the correct variables and/or arrays] [ [ macros will not be on the exam, but you are free to use them ] - Plain old loops (loading ECX with \# of iterations and using a label and LOOP) Write the code to calculate the following based on array - total of the elements from array into variable total - the average of the elements from array into variable average See the picture (below) for where to place your code. - Declaring/Using variables/one dimensional arrays (BYTE, SBYTE, WORD, SWORD, DWORD, SDWORD) and storing data(results) into memory - using LENGTHOF - Declaring/Using Constants (like MAX_ROWS =5) - Possibly getting data from user and storing in memory (using Author's readint, readDec, readString) - most likely generate random data into an array (using Author's randomize, randomRange] - Calculations (ADD, SUB, MUL, iMUL, DIV, iDIV) - Displaying Data on screen (using Author's Writelnt, WriteDec, Writestring, CRLF) [ Output procedures will most likely be provided and you need to load the correct variables and/or arrays] [ [ macros will not be on the exam, but you are free to use them ] - Plain old loops (loading ECX with \# of iterations and using a label and LOOP) Write the code to calculate the following based on array - total of the elements from array into variable total - the average of the elements from array into variable average See the picture (below) for where to place your code

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 Accounting Questions!

Q:

\f