{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Activity05 Soln

# Activity05 Soln - SOLUTIONS Activity#05 Activity 4.1(First...

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

ECSE-2660 Computer Architecture, Networks, & Operating Systems, Spring 2001 Page 1 of 3 SOLUTIONS Activity #05 Activity 4.1 (First hour) Learning to go from MIPS Assembler Pseudo code C Program a. (25 pts) Describe what the following MIPS code returns in the output register \$v0. Assume that \$a0 is used for the input and initially contains "n", a positive integer. First, start by creating a pseudo-code description, then a C/C++ program, and infer the program’s behavior from the C program. a0=n begin: addi \$t0, \$zero, 0 t0=0 addi \$t1, \$zero, 0 t1=0 addi \$t2, \$zero, 0 t2=0 loop: slt \$t3, \$a0, \$t2 bne \$t3, \$zero, finish if(a0 < t2 ) go to finish add \$t0, \$t0, \$t1 t0 = t0 + t1 addi \$t1, \$t1, 1 t1 = t1 + 1 addi \$t2, \$t2, 1 t2 = t2 +1 j loop goto loop finish: addi \$v0, \$t0, 0 v0 = t0 C program: A0 = n; T0=t1=t2 = 0; While (a0 !< t2) { T0 = t0 +t1; T1 = t1 +1; T2 = t2+1; } v0 = t0; This program calculates the sum 1 + 2 + ..... n Grading: There are 3 parts to this question: Pseudocode (10 pts), C program (10 pts), final answer (5 pts). For the 5 pt parts, give 2 pts for trying, and 5 for correct answer. For the 10-point parts, point out errors, and deduct one point for

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• 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.

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

• 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.

Dana University of Pennsylvania ‘17, Course Hero Intern

• 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.

Jill Tulane University ‘16, Course Hero Intern