



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




4 problems, 5 pages Final Exam 12 December 2000
Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate the pages of the exam. For maximum credit, show your work. Good Luck!
Your Name ( please print ) ________________________________________________
1 2 3 4 total
4 problems, 5 pages Final Exam 12 December 2000
Problem 1 (1 part, 20 points) Instruction Formats
An ancient Egyptian hieroglyphic tablet has been found which may be the earliest record of an instruction set architecture (perhaps alien?). The example shown below has all fields shown with zeros. Do your best to interpret its meaning and answer the questions below.
000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 opcode dest. reg. source 1 reg. immediate value
What is the maximum number of opcodes?
What is the number of registers?
What is the range of the signed immediate value?
What is the instruction word size?
How many are bits needed to specify a branch if equal instruction in this format?
Problem 2 (1 part, 20 points) addition and subtraction
For each problem below, (a) compute the operations using the rules of addition and subtraction, (b) indicate whether an error occurs assuming all numbers are expressed using a five bit two’s complement representation, and (c) indicate whether an error occurs assuming all numbers are expressed using a five bit unsigned representation.
result
signed error? unsigned error?
4 problems, 5 pages Final Exam 12 December 2000
Problem 4 (5 parts, 40 points) Assembly Language Programming
Consider the following MIPS program subroutine. Assume all values are decimal unless otherwise stated. The instruction set handout is attached.
address label instruction 1000 fun: addi $1, $0, 4000 1004 add $2, $0, $ 1008 loop: lw $3, 0($1) 1012 lw $4, 1000($1) 1016 mul $3, $3, $ 1020 add $2, $2, $ 1024 addi $1, $1, 4 1028 slti $4, $1, 6500 1032 bne $4, $0, loop 1036 jr $
Part A (10 points) How many times is the loop body in this program fragment executed?
number of loop iterations:
Part B (5 points) What is the branch offset (in bytes) of the BNE instruction at address 1032.
branch offset (in bytes)
Part C (10 points) What is the purpose of register $2 (i.e., what is the significance of its value when the fragment completes)?
Part D (5 points) Write the assembly language instruction that calls this subroutine.
Part E (10 points) Write an instruction sequence that branches to label target: when register $5 is less than or equal to register $6. You can use register $7 for intermediate results.