Docsity

7 Problems in Final Exam - Introduction to Computing | E E 306, Exams of Electrical and Electronics Engineering

Toggle sidebar
bg1
Department of Electrical and Computer Engineering
The University of Texas at Austin
EE 306, Fall, 2008
Yale Patt, Instructor
TAs: Jeffrey Allan, Arvind Chandrababu, Eiman Ebrahimi, Aravind Jakkani, Khubaib,
Allison Korczynski, Pratyusha Nidamaluri, Zrinka Puljiz, Che-Chun Su, Christopher Wiley.
Final Exam, December 10, 2008
Name:
Problem 1 (20 points):
Problem 2 (15 points):
Problem 3 (10 points):
Problem 4 (15 points):
Problem 5 (15 points):
Problem 6 (20 points):
Problem 7 (20 points):
Total (115 points):
Note: Please be sure that your answers to all questions (and all supporting work that is required) are
contained in the space provided.
Note: Please be sure your name is written legibly on each sheet of the exam.
I will not cheat on this exam.
Signature
GOOD LUCK!
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download 7 Problems in Final Exam - Introduction to Computing | E E 306 and more Exams Electrical and Electronics Engineering in PDF only on Docsity!

Department of Electrical and Computer Engineering The University of Texas at Austin

EE 306, Fall, 2008 Yale Patt, Instructor TAs: Jeffrey Allan, Arvind Chandrababu, Eiman Ebrahimi, Aravind Jakkani, Khubaib, Allison Korczynski, Pratyusha Nidamaluri, Zrinka Puljiz, Che-Chun Su, Christopher Wiley. Final Exam, December 10, 2008

Name:

Problem 1 (20 points):

Problem 2 (15 points):

Problem 3 (10 points):

Problem 4 (15 points):

Problem 5 (15 points):

Problem 6 (20 points):

Problem 7 (20 points):

Total (115 points):

Note: Please be sure that your answers to all questions (and all supporting work that is required) are contained in the space provided.

Note: Please be sure your name is written legibly on each sheet of the exam.

I will not cheat on this exam.

Signature

GOOD LUCK!

Problem 1 (20 points)

Part a (5 points): A main program puts a value in R0, and then calls SUB. What does the subroutine SUB do? Please answer in ten words or fewer.

SUB ST R1, SaveR ADD R1,R0,R ADD R1,R1,R ADD R1,R1,R ADD R0,R0,R ADD R0,R0,R LD R1, SaveR RET SaveR1 .FILL x

Put answer here:

Part b (5 points): The MUX select line labeled ADDR1MUX in the LC-3 Data Path is controlled by the output of the OR-gate shown below. Complete the wiring of the inputs to the OR-gate and the second input to the AND gate, to achieve the correct signal for ADDR1MUX.

^ ADDR1MUX

0000 0001 0010 0011 0100 0101 0110 0111 1000

1011

1010

1001

1100 1101 1110 1111

4โˆ’toโˆ’16 decoder

IR Register:

Problem 2 (15 points):

Part a (7 points): In the circuit below, the two master-slave flip flops (MS0 and MS1) each initially contain the value 0. That is, Q1=0, Q0=0. Please fill in the values of Q1 and Q0 after the end of each clock cycle in the table below.

 CLK

MS

MS

S[1]

S[0]

Q

Q

Z[1:0]

Z[1]

Z[0]

After the end of clock cycle Q1 Q 1 2 3 4 5 6 7

Part b (8 points): The following program starts execution at x3000 and stops after executing the HALT instruction.

.ORIG x LD R0, Addr LEA R1, Addr LDI R2, Addr ADD R1,R1,#- STR R1,R0,#- STI R2,Addr HALT Addr1 .FILL x Addr2 .FILL x Addr3 .FILL x000A Addr4 .FILL x300A .END

Show the contents of R0 through R2 immediately after the ADD instruction in location x3003 executes.

Register Value R R R

Show the contents of memory locations Addr1 through Addr4 after the LC-3 halts.

Memory Address Label Value Addr Addr Addr Addr

Problem 4 (15 points): As you know, the LC-3 ADD instruction adds 16-bit 2โ€™s complement integers. If we wanted to add 32-bit 2โ€™s complement integers, we could do that with the program shown below. Note that the program requires calling subroutine X which stores into R0 the carry that results from adding R1 and R2.

Your job: Fill in the missing pieces of both the program and the subroutine X, as identified by the empty boxes. Each empty box corresponds to one instruction or the operands of one instruction. Note that a 32-bit operand requires two 16-bit memory locations. A 32-bit operand Y has Y[15:0] stored in address A, and Y[31:16] stored in address A+1.

.ORIG x LEA R3, NUM LEA R4, NUM LEA R5, RESULT LDR R1, R3, # LDR R2, R4, # ADD R0, R1, R STR R0, R5, #

LDR

LDR

ADD R0, R1, R

TRAP x

X ST R4, SAVER AND R0, R0, # AND R4, R1, R

BRn ADD R1, R1, #

BRn

ADD

BRn ADDING BRnzp EXIT ADDING ADD R4, R1, R BRn EXIT LABEL ADD R0, R0, # EXIT LD R4, SAVER RET

NUM1 .BLKW 2 NUM2 .BLKW 2 RESULT .BLKW 2 SAVER4 .BLKW 1

.END

Problem 5 (15 points): An Aggie was asked to write a program that will do the following operation ten times: Wait for keyboard input until someone types a character. Then, write that character to the screen. His solution is shown below.

Note that his main program calls the subroutine INPUT ten times. The subroutine INPUT waits for key- board input. After obtaining keyboard input, it calls the subroutine OUTPUT to output that character to the screen.

There are no assembly time errors in the program. However, there are three serious logical errors (the program does not work as intended). Describe them in the three boxes below. Please, no more than twenty words in each box.

.ORIG x

LD R1, SAVER LOOP ADD R1, R1, #- JSR INPUT BRp LOOP HALT

INPUT ST R7, SAVER

ST R1, SAVER

BWAIT LDI R1, KBSR

BRzp BWAIT LDI R1, KBDR JSR OUTPUT LD R1, SAVER LD R7, SAVER RET

OUTPUT ST R7, SAVER

ADD R7, R1,

STI R7, DDR

LD R7, SAVER

RET

SAVER1 .FILL x000A SAVER7 .FILL x KBSR .FILL xFE KBDR .FILL xFE DDR .FILL xFE

.END

Problem 7 (20 points): An LC-3 program starts execution at x3000. During the execution of the program, a snapshot of all 8 registers were taken at six different times as shown below: before the program executes, after execution of instruction 1, after execution of instruction 2, after execution of instruction 3, after execution of instruction 4, after execution of instruction 5, and after execution of instruction 6.

Registers Initial After 1st After 2nd After 3rd After 4th After 5th After 6th Value Instruction Instruction Instruction Instruction Instruction Instruction R0 x4006 x4050 x4050 x4050 x4050 x4050 x R1 x5009 x5009 x5009 x5009 x5009 x5009 x R2 x4008 x4008 x4008 x4008 x4008 x4008 xC R3 x4002 x8005 x8005 x8005 x

R4 x4003 x4003 x4003 x4003 x R5 x400D x400D x400D x400D x400D R6 x400C x400C x400C x400C x400C x400C x400C R7 x6001 x6001 x6001 x6001 x400E

Also, during the execution of the program, the PC trace, the MAR trace, and the MDR trace were also recorded as shown below. Note that a PC trace records the addresses of the instructions executed in sequence by the program.

PC Trace

x400D

x400E

MAR Trace MDR Trace xA

x

x

x

x400E x

Your job: Fill in the missing entries in the 3 tables above.