ProbSet5_solution - Department of Electrical and Computer...

Info iconThis preview shows pages 1–4. 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 5 Due: 16 November, before class 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 Instructions: You are encouraged to work on the problem set in groups and turn in one problem set for the entire group. Remember to put all your names on the solution sheet. Also, remember to put the name of the TA and the time for the discussion section you would like the problem set turned back to you. Show your work. Please staple your Problem Sets BEFORE coming to class! Questions 1. Moved from Problem Set 4 (Adapted from 6.16) Shown below are the partial contents of memory locations x3000 to x3006. 15 0 x3000 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 x3001 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 x3002 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 x3003 1 1 1 1 0 0 0 0 0 0 1 0 0 0 0 1 x3004 1 1 1 1 0 0 0 0 0 0 1 0 0 1 0 1 x3005 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 x3006 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 The PC contains the value x3000, and the RUN button is pushed. As the program executes, we keep track of all values loaded into the MAR. Such a record is often referred to as an address trace. It is shown below.
Background image of page 1

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

View Full DocumentRight Arrow Icon
MAR Trace x3000 x3005 x3001 x3002 x3006 x4001 x3003 x0021 Your job: Fill in the missing bits in memory locations x3000 to x3006. 2. Assume that you have the following table in your program: MASKS .FILL x0001 .FILL x0002 .FILL x0004 .FILL x0008 .FILL x0010 .FILL x0020 .FILL x0040 .FILL x0080 .FILL x0100 .FILL x0200 .FILL x0400 .FILL x0800 .FILL x1000 .FILL x2000 .FILL x4000 .FILL x8000 a. Write a subroutine CLEAR in LC-3 assembly language that clears a bit in R0 using the table above . The index of the bit to clear is specified in R1 . R0 and R1 are inputs to the subroutine. Solution: CLEAR: ST R2, TEMP LEA R2, MASKS ADD R2,R1,R2 LDR R2,R2,#0 NOT R2,R2 AND R0,R2,R0 LD R2, TEMP RET TEMP: .BLKW #1 b. Write a similar subroutine SET that sets the specified bit instead of clearing it. Solution: SET: ST R2, TEMP
Background image of page 2
LEA R2, MASKS ADD R2,R1,R2 LDR R2,R2,#0 NOT R2,R2 NOT R0,R0 AND R0,R2,R0 NOT R0,R0 LD R2, TEMP RET TEMP: .BLKW #1 3. Jane Computer (Bob's adoring wife), not to be outdone by her husband, decided to rewrite the TRAP x22 handler at a different place in memory. Consider her implementation below. If a user writes a program that uses this TRAP handler to output an array of characters, how many times is the ADD instruction at the location with label A executed? Assume that the user only calls this "new"
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 8

ProbSet5_solution - Department of Electrical and Computer...

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

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