Assignment 3 - James Stape CSE230 Tues Thurs 9:15-10:30...

Info icon This 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
Image of page 1

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

View Full Document Right 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) # return $v0 = N/A readData:
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern