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

Assembly language CS 218 Please download the PDF file to see the data https://ww

ID: 639657 • Letter: A

Question

Assembly language CS 218

Please download the PDF file to see the data

https://www.dropbox.com/s/c5yu2odilwbxskz/asst04.pdf?dl=0


Purpose: Learn to use arithmetic instructions, control instructions, compare instructions, and
conditional jump instructions.
:
Assignment:
Write a simple assembly language program to find the minimum, middle value, maximum, sum, and
integer average of a list of numbers. Additionally, the program should also find the sum, count, and
integer average for the negative numbers. The program should also find the sum, count, and integer
average for the numbers that are evenly divisible by 3. Do not change the data types (double-words) as
defined below.
Declare the values:
lst dd 4224, 1116,
1542, 1240, 1677, 1635,
2420, 1820, 1246, 333
dd 2315, 215,
2726, 1140, 2565, 2871, 1614, 2418, 2513, 1422
dd 119,
1215, 1525,
712,
1441, 3622,
731,
1729,
1615, 2724
dd 1217, 224,
1580, 1147, 2324, 1425, 1816, 1262, 2718,
1192
dd 1435,
235, 2764, 1615,
1310, 1765, 1954, 967,
1515, 1556
dd 1342, 7321, 1556, 2727, 1227, 1927,
1382, 1465, 3955, 1435
dd 225,
2419,
2534,
1345,
2467, 1615, 1959, 1335, 2856, 2553
dd 1035,
1833, 1464, 1915, 1810,
1465, 1554, 267,
1615, 1656
dd 2192, 825,
1925, 2312, 1725, 2517,
1498, 677,
1475, 2034
dd 1223, 1883, 1173,
1350, 2415, 335,
1125, 1118, 1713, 3025
length dd 100
lstMin dd 0
lstMid dd 0
lstMax dd 0
lstSum dd 0
lstAve dd 0
negCnt dd 0
negSum dd 0
negAve dd 0
threeCnt dd 0
threeSum dd 0
threeAve dd 0
You may declare additional variables if needed. All data is signed. As such, the IDIV/IMUL would be
used (not DIV/MUL). The JG/JL/JGE/JLE must be used (as they are for signed data). You may
assume the first number in the list is evenly divisible by 3.
Note, for an odd number of items, the middle value is defined as the middle value. For an even number
of values, it is the integer average of the two middle values. The 'middle value' does not require the
numbers to be sorted.

Explanation / Answer

################## DATA SECTION ################## .data prompt: .asciiz " How many integer numbers?(5 integers,minimum)" result: .asciiz "The minimum integer is " ################## CODE SECTION ################## .text .globl main main: li $v0, 4 # system call code for Print String la $a0, prompt # load address of prompt into $a0 syscall # print the prompt message li $v0, 5 # system call code for Read Integer syscall # reads the value into $v0 blez $v0, end # branch to end if $v0 < = 0 li $t0, 0 # clear register $t0 to zero loop: add $t0, $t0, $v0 # sum of integers in register $t0 addi $v0, $v0, -1 # summing integers in reverse order bnez $v0, loop # branch to loop if $v0 is != zero li $v0, 4 # system call code for Print String la $a0, result # load address of message into $a0 syscall # print the string li $v0, 1 # system call code for Print Integer move $a0, $t0 # move value to be printed to $a0 syscall # print sum of integers b main # branch to main end: li $v0, 4 # system call code for Print String la $a0, # load address of msg. into $a0 syscall # print the string li $v0, 10 # terminate program run and syscall # return control to system