# ECE3055 SPIM Programming Assignment 1 # Name: YOUR NAME HERE. Spring 2003 # Section: YOUR SECTION HERE # Global Data Segment .data array1: .word 10,10,20,20,30,30,40,40,0 array2: .word 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,0 array3: .word 0 array4: .word 0xf, 0xf0, 0xf00, 0xf000, 0xf0000 .word 0xf00000, 0xf000000, 0xf0000000, 1, 0 array5: .word 0xf0, 0xf00, 0xf000, 0xf0000 .word 0xf00000, 0xf000000, 0xf0000000, 1, 0 Array1R: .asciiz "Results from array1\n" Array2R: .asciiz "Results from array2\n" Array3R: .asciiz "Results from array3\n" Array4R: .asciiz "Results from array4\n" Array5R: .asciiz "Results from array5\n" PressKey: .asciiz "Press any key to continue\n" AllDone: .asciiz "Exiting....\n" .text .globl main main: la $a0 array1 # Address of array1 jal Compute la $a0,Array1R li $v0,4 # Output string syscall code syscall jal PrintResults jal GetKey la $a0 array2 # Address of array2 jal Compute la $a0,Array2R li $v0,4 # Output string syscall code syscall jal PrintResults jal GetKey la $a0 array3 # Address of array3 jal Compute la $a0,Array3R li $v0,4 # Output string syscall code syscall jal PrintResults jal GetKey la $a0 array4 # Address of array4 jal Compute la $a0,Array4R li $v0,4 # Output string syscall code syscall jal PrintResults jal GetKey la $a0 array5 # Address of array5 jal Compute la $a0,Array5R li $v0,4 # Output string syscall code syscall jal PrintResults jal GetKey # Notify operating system program is done la $a0,AllDone # Address of all done prompt li $v0,4 # Output string syscall code syscall li $v0,10 # exit syscall # Subroutine GetKey # Wait for a user keystroke GetKey: la $a0,PressKey # Address of press key prompt li $v0,4 # Output string syscall code syscall # li $v0,12 # Read character li $v0,5 # Read integer syscall # Wait for user input jr $ra # Subroutine Compute # Compute the count, sum, average, min and max of values in an array # Entry: a0 = address of array # The array is of variable length, terminated with a 0 word # Compute: # YOUR CODE HERE jr $ra # Return # Subroutine PrintResults # This should print: # "Sum is xxx" # "Number entries is xxx" # "Average is xxx" # "Minimum is xxx" # "Maximum is xxx" PrintResults: # YOUR CODE HERE jr $ra