Activity05 Soln - ECSE-2660 Computer Architecture,...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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 Grading: There are 3 parts to this question: Pseudocode (10 pts), C program (10 pts), final answer (5 pts)....
View Full Document

This note was uploaded on 04/25/2010 for the course ECSE ecse-2340 taught by Professor Wozny during the Spring '09 term at Rensselaer Polytechnic Institute.

Page1 / 3

Activity05 Soln - ECSE-2660 Computer Architecture,...

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

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