Assignment 3

Assignment 3 - # James Stape # CSE230 Tues. Thurs....

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 # James Stape # CSE230 Tues. Thurs. 9:15-10:30 # Program Assignment 1 Introduction into MIPS and SPIM .data .word 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20# numbers array .word 21# count name: .asciiz "James Stape\n" prompt1: .asciiz "Enter a number: " newline: .asciiz "\n" frontp: .asciiz " (" endp: .asciiz ")\n" endmessage: .asciiz "Thank you for running the program. Have a stupendous day!\n " .text .globl main #--------------------------------------------------------------------------- # Function main # Description: It will taken in numbers up to 20 into an array, find the average and place the values in order from least # to greatest. It will also find the difference between the average an the number and display that value # Parameters:$s0 = address of the array #$s1 = address of the count variable (pass by reference) # return N/A main:move $s7, $ra# saves this address lui $s0, 0x1001# Address of numbers array addi $s1, $s0, 80# Address of count # Action 1 li $v0, 4# loads the display function into the register la $a0, name# loads the variable name into the register syscall# displays the variable name # Action 2 move $a0, $s0# Move numbers array address into passing register move $a1, $s1# Move count address into passing register jal readData# jump to read function # Action 3 move $a0, $s0# Move numbers array address into passing register lw $a1, ($s1)# Move count value into passing register jal sort # Action 4 # move $a0, $s0# Move numbers array address into passing register
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Sheet1 Page 2 lw $a1, ($s1)# Move count value into passing register l jal average# jumps to the average function li $v0, 4# loads the display function into the register la $a0, newline# loads the variable name into the register syscall# displays the variable name mov.s $f12, $f0# places the return average value into a passing register value move $a0, $s0# Move numbers array address into passing register lw $a1, ($s1)# Move count value into passing register l jal print# jumps to the print function j li $v0, 4# loads the display function into the register la $a0, endmessage# loads the variable name into the register syscall# displays the variable name move $ra, $s7# Moves the return address back jr $ra #--------------------------------------------------------------------------- # Function readData # Description: It will read in the data from user and store it into memory of the array # Parameters:$a0 = address of the array #$a1 = address of the count variable (pass by reference)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

Assignment 3 - # James Stape # CSE230 Tues. Thurs....

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online