Docsity

ECE 2030 Fall 2000 Computer Engineering Final Exam, Exams of Computer Science

Partial preview of the text

Download ECE 2030 Fall 2000 Computer Engineering Final Exam and more Exams Computer Science in PDF only on Docsity!

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.

Assembly Language

  • 4 problems, 5 pages Final Exam 12 December
    • add add $1,$2,$3 $1 = $2 + $ instruction example meaning
    • subtract sub $1,$2,$3 $1 = $2 - $
    • add immediate addi $1,$2,100 $1 = $2 +
    • multiply mul $1,$2,$3 $1 = $2 * $
    • divide div $1,$2,$3 $1 = $2 / $
    • and and $1,$2,$3 $1 = $2 & $
    • or or $1,$2,$3 $1 = $2 | $
    • and immediate andi $1,$2,100 $1 = $2 &
    • or immediate ori $1,$2,100 $1 = $2 |
    • shift left logical sll $1,$2,5 $1 = $2 <<
    • shift right logical srl $1,$2,5 $1 = $2 >>
    • store word sw $1,100($2) memory [$2 + 100] = $ load word lw $1,100($2) $1 = memory [$2 + 100]
    • load upper immediate lui $1,100 $1 = 100 x
    • branch if equal beq $1,$2,100 if ($1 = $2), PC = PC + 4 +
    • branch if not equal bne $1,$2,100 if ($1 ≠ $2), PC = PC + 4 +
    • set if less than slt $1, $2, $3 if ($2 < $3), $1 = 1 else $1 =
    • set if less than immediate slti $1, $2, 100 if ($2 < 100), $1 = 1 else $1 =
    • jump j 10000 PC =
    • jump register jr $31 PC = $
    • jump and link jal 10000 $31 = PC + 4; PC =