{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

homework2-fa2008 - CSE 331 Computer Organization and Design...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 331: Computer Organization and Design Fall 2008 Homework #2 Points: 10 (Pair programming assignment) Due: 11:55 PM, Thursday, Sept 11, 2008 Using SPIM, write a program that sums up the first or last n elements of a data array. As shown in the assembly code below, a 10-word data array is allocated in the data segment in memory; it contains ten integers. The first three instructions starting from label main: ask the user to input a 1 to indicate that the summation should start at the beginning of the array ( item ) and work forward, or a -1 to indicate that the summation should start at the end of the array ( last ) and work backwards. The next three instructions ask the user to input the integer n between 0 and 10. If the integer is 0, the program is to return 0; else, it should sum up the first or last n elements of the data array and return the sum. The result should be stored in register $t2 and then printed out. (Hint: you can use instruction la $s0, item to load the address of the first word of the array into register $s0.)
Image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
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