Homework 7 - In-class assignment
CS 345
Computer Organization
10 Points (2 points per problem)
Due Wednesday, Mar. 11, 2015 at midnight
You must submit a soft copy of this assignment and show all work!
You may work with a partner on this assignment.
If you work with a partner, submit only one copy of the assignment and include your partner's name on the assignment.
1. Compute the results of the following 8-bit binary
mathematical operations. Assume all numbers are in binary and
in two's complement format. Be sure to verify your results by
converting to decimal.
a) 00101000 + 00110111
b) 11100101 - 10011010
c) 11111111 + 00000000
d) 01101110 - 11111100
2. Write a MIPS function to print every third character in a
string. You may only pass in as parameters the address
of the string. Hint: you can find the end of a string by
counting all the characters up to the null character. The null
character has a value of zero. You do not have to write the
code for entire main function. You do, however, need to write
the code to call the function.
3. Write a MIPS function to compute the sum of the squares of all the
elements in an array. You may pass in as parameters the length
of the array and the array itself. Hint: this function will be
very similar to the Summation.asm program on the example code page.
4. Write a MIPS function called printRecursive that takes a
positive number as an argument and recursively prints the argument
and divides the result by two, printing the result in decreasing order
until the result is zero. For example, if we call
printRecursive(10), it should print 10, 5, 2, 0. Then, perform a stack
trace of the call printRecursive(5) using the code you wrote for this
problem. A stack trace should show how the stack is modified after each
recursive function call is made and after each value is returned.