Homework_2 - program Both you and your programming partner...

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 331: Computer Organization and Design Spring 200 8 Homework #2 Points: 5 (Pair programming assignment) Due: 5pm, Fri day, Feb. 8 , 200 8 Using SPIM write a program that sums up all the odd numbers or all the even numbers in 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 the ten integers from 1 to 10. The first three instructions starting from label ‘ main: ’ allow the user to input an integer. If this integer is zero, the program is to sum up all the even numbers in the data array. Otherwise, the program is to sum up all the odd numbers. The result should be stored in register $t1 and then printed out. Finish the assembly program shown below and submit, via ANGEL, the completed and tested
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: program. Both you and your programming partner should submit the program making sure to include in your comments who your partner is. (Hint: you can use instruction ‘ la $s0, item ’ to load the address of the first word of the array into register $s0.) .data .align 2 item: .word 1 .word 2 .word 3 .word 4 .word 5 .word 6 .word 7 .word 8 .word 9 .word 10 .align 0 str: .asciiz "The answer is " cr: .asciiz "\n" .text .align 2 .globl main main: ori $2, $0, 5 syscall move $t0, $2 ##### THIS SECTION OF THE CODE ##### IS TO BE COMPLETED BY YOU ##### AND YOUR PROGRAMMING PARTNER done: ori $2, $0, 4 la $4, str syscall ori $2, $0, 1 add $4, $t1, $0 syscall ori $2, $0, 4 la $4, cr syscall...
View Full 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