probset6_sol - Department of Electrical and Computer...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
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 Ben-dor, 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.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
(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 32-bits. 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 LC-3 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
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 9

probset6_sol - Department of Electrical and Computer...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online