Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

MIPS Exam 1 Solutions: Understanding MIPS Programs, Recursive Functions, and Concepts, Exams of Computer Architecture and Organization

Solutions to exam 1 of the cs232 course, focusing on understanding mips programs through a high-level function translation, writing a recursive function in mips assembly language, and answering short questions related to mips concepts such as abstraction, floating point numbers, and the 90/10 rule.

Typology: Exams

Pre 2010

Uploaded on 03/09/2009

koofers-user-gi5
koofers-user-gi5 🇺🇸

10 documents

1 / 5

Toggle sidebar

Related documents


Partial preview of the text

Download MIPS Exam 1 Solutions: Understanding MIPS Programs, Recursive Functions, and Concepts and more Exams Computer Architecture and Organization in PDF only on Docsity! 1 CS232 Exam 1 Solutions February 20, 2003 Name:  This exam has 5 pages, including this cover.  There are three questions, worth a total of 100 points.  The last page is a summary of the MIPS instruction set, which you may remove for your convenience.  No other written references or calculators are allowed.  Write clearly and show your work. State any assumptions you make.  You have 50 minutes. Budget your time, and good luck! 100Total 153 452 401 Your ScoreMaximumQuestion 2 Question 1: Understanding MIPS programs (40 points) func: li $v0, 0 li $t0, 0 L1: add $t1, $a0, $t0 lb $t2, 0($t1) beq $t2, $zero, L3 bne $t2, $a1, L2 add $v0, $v0, 1 L2: add $t0, $t0, 1 j L1 L3: jr $ra Part (a) Translate the function func above into a high-level language like C or Java. You should include a header that lists the types of any arguments and return values. Also, your code should be as concise as possible, without any gotos or pointers. We will not deduct points for syntax errors unless they are significant enough to alter the meaning of your code. (30 points) int func (char s[], char c) { int num = 0; for(int i=0;s[i] !=0;i++) { if(s[i] = = c) num++; } return num; } Part (b) Describe briefly, in English, what this function does. (10 points) Counts the number of occurrences of the second argument (a character) in the character array (first argument) and returns the count when it finds a zero in the array.
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved