PA3 Answer Key Using the table that represents a small memory on page 111 in the book, answer questions 1-4: (Hint: See the book web page, which is linked off the syllabus, for answers to question 4.5 in the book) ------------------------------------------------------------------ 1) What binary value does location 4 contain? 0000 0000 0110 0101 ------------------------------------------------------------------ 2) Interpret location 6 as a 2's complement integer. 1111 1110 1101 0011 2's complement operation - 0000 0001 0010 1101 = - (256 + 32 + 8 + 4 + 1) = - 301 (checking: 301/2 = 150 r 1 150/2 = 75 r 0 75/2 = 37 r 1 37/2 = 18 r 1 18/2 = 9 r 0 9/2 = 4 r 1 4/2 = 2 r 0 2/2 = 1 r 0 1/2 = 0 r 1 ) ------------------------------------------------------------------ 3) Interpret locations 1 and 2 as an IEEE floating point number. Location 1 contains number [15:0] and location 2 contains number [31:16]. Do not translate to decimal fixed point. Instead just stop at the binary floating point representation. (for example, 1.1 x 2^(-3) ) 0110 1111 0000 0001 1111 0000 0010 0101 0 11011110 00000011111000000100101 1.00000011111000000100101 x 2^(222-127) 1.00000011111000000100101 x 2^(95) ------------------------------------------------------------------ 4) Interpret location 2 as an LC3 instruction. 0110 1111 0000 0001 0110 111 100 000001 LDR R7, R4, #1 ------------------------------------------------------------------ 5) Problem 4.8 from book. (NOTE: The students only have to copy "Problem 4.8 from book" into their README. That way you can tell if there numbering is off by one.) Suppose a 32-bit instruction takes the following format: OPCODE DR SR1 SR2 UNUSED If there are 225 opcodes and 120 registers, a) What is the minimum number of bits required to represent the OPCODE? 8 bits b) What is the minimum number of bits required to represent the Destination Register (DR)? 7 bits c) What is the maximum number of UNUSED bits in the instruction encoding? 32 - 8 - 7 - 7 - 7 = 3 bits ------------------------------------------------------------------ 6) Problem 4.14 from book. Describe the execution of the JMP instruction if R3 contains 0x369C (refer to Example 4.5). For this problem and the rest of the problems except for 13, use the book answer manuals to grade. ------------------------------------------------------------------ 7) Problem 5.2 from book. (addressability) ------------------------------------------------------------------ 8) Problem 5.4 from book. (Memory and PC relative) ------------------------------------------------------------------ 9) Problem 5.10 from book. (JMP versus JSR) ------------------------------------------------------------------ 10) Problem 5.13 from book. (How to do some stuff with limited LC3 instructions) ------------------------------------------------------------------ 11) Problem 5.14 from book. (Implementing OR in LC3) (Hint: What is the relationship between AND and OR?) ------------------------------------------------------------------ 12) Problem 5.24 from book. (LDR) ------------------------------------------------------------------ 13) If the condition codes have values N=0, Z=0, P=1 at the beginning of the execution of the following sequence of instructions, what will their values be at the end of the execution of the following sequence of LC-3 instructions? x3050 0000 0010 0000 0010 x3051 0101 0000 0010 0000 x3052 0000 1110 0000 0010 x3053 0101 0000 0010 0000 x3054 0001 0000 0011 1111 The resulting condition codes are N=1, Z=0, P=0. ------------------------------------------------------------------ 14) Problem 5.40 from book. ------------------------------------------------------------------ 15) Problem 6.14 from book. ------------------------------------------------------------------ 16) Problem 6.16 from book.