Department of Electrical and Computer Engineering
The University of Texas at Austin
EE 306, Fall 2009
Problem Set 6
Solutions
Due: Not to be turned in
Yale N. Patt, Instructor
TAs: Aater Suleman, Chang Joo Lee, Ameya Chaudhari, Antonius Keddis, Arvind Chandrababu, Bhargavi
Narayanasetty, Eshar Bendor, Faruk Guvenilir, Marc Kellermann, RJ Harden
Note: This problem set is unusually long, and is not to be turned in. We have put it together and handed it out
to give you some challenging examples to help you prepare for the final exam.
•
(Adapted from 10.9) The input stream of a stack is a list of all the elements we pushed onto the stack,
in the order that we pushed them. The input stream from Excercise 10.8 from page 284 of the book
for example is ABCDEFGHIJKLM
The output stream is a list of all the elements that are popped off the stack in the order that they are
popped off.
a. If the input stream is ZYXWVUTSR, create a sequence of pushes and pops such that the output
stream is YXVUWZSRT.
Push Z
Push Y
Pop Y
Push X
Pop X
Push W
Push V
Pop V
Push U
Pop U
Pop W
Pop Z
Push T
Push S
Pop S
Push R
Pop R
Pop T
b. If the input stream is ZYXW, how many different output streams can be created.
14 different output streams.
•
Do Problem 6.16 on page 175 in the textbook.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
(Adapted from 10.6) Rewrite the PUSH and POP routines such that the stack on which they operate
holds elements that take up two memory locations each.
The problem assumes that each element of the value being pushed on the stack is 32bits.
For the PUSH, assume bits [15:0] of that value to be pushed are in R0 and bits [31:16] are in R1.
For the POP, bits [15:0] will be popped into R0 and bits [31:16] will be popped into R1.
Also assume the lower order bits of the number being pused or popped are located in the smaller
address in memroy. For example if the two memory locations to be used to store the number are
x2FFF and x2FFE, bits [15:0] will be stored in x2FFE and [31:16] will be stored in x2FFF.
PUSH:
ADD R6, R6, #2
STR R0, R6, #0
STR R1, R6, #1
POP:
LDR R0, R6, #0
LDR R1, R6, #1
ADD R6, R6, #2
•
Consider the following LC3 assembly language program. Assumming that the memory locations
DATA get filled before the program executes, what is the relationship between the final values at
DATA and the initial values at DATA?
.ORIG
x3000
LEA
R0, DATA
AND
R1, R1, #0
ADD
R1, R1, #9
LOOP1
ADD
R2, R0, #0
ADD
R3, R1, #0
LOOP2
JSR
SUB1
ADD
R4, R4, #0
BRzp
LABEL
JSR
SUB2
LABEL
ADD
R2, R2, #1
ADD
R3, R3, #1
BRp
LOOP2
ADD
R1, R1, #1
BRp
LOOP1
HALT
DATA
.BLKW
#10
SUB1
LDR
R5, R2, #0
NOT
R5, R5
ADD
R5, R5, #1
LDR
R6, R2, #1
ADD
R4, R5, R6
RET
SUB2
LDR
R4, R2, #0
LDR
R5, R2, #1
STR
R4, R2, #1
STR
R5, R2, #0
RET
.END
The final values at DATA will be sorted in ascending order.
•
During the initiation of the interrupt service routine, the N, Z, and P condition codes are saved on the
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '07
 Ambler
 SEPTA Regional Rail, Department of Electrical and Computer Engineering, Jaguar Racing, INMUX

Click to edit the document details