ch07_complete

ch07_complete - F.7 Chapter 7 Solutions 7.1 0xA7FE 7.2...

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

View Full Document Right Arrow Icon
F.7 Chapter 7 Solutions 7.1 0xA7FE 7.2 0x23FF 7.3 Using an instruction as a label confuses the assembler because it treats the label as the opcode itself so the label AND will not be entered into the symbol table. Instead the assembler will give an error in the second pass. 7.4 The Symbol Table generated by the assembler is given below. Symbol Address Test x301F Finish x3027 Save3 x3029 Save2 x302A 7.5 (a) The program calculates the product of values at addresses M0 and M1. The product is stored at address RESULT. mem[RESULT] = mem[M0] * mem[M1] (b) x200C 7.6 Correction: Please correct the problem to read as follows. Also please look at the errata for a new problem 7.26. Our assembler has crashed and we need your help! Create a symbol table for the program shown below, and assemble the instructions at labels A, B and D. .ORIG x3000 AND R0, R0, #0 A LD R1, E AND R2, R1, #1 BRp C B ADD R1, R1, #-1 C ADD R0, R0, R1 ADD R1, R1, #-2 D BRp C ST R0, F TRAP x25 E .BLKW 1 F .BLKW 1 .END 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 You may assume another module deposits a positive value into E before the module executes. In Ffteen words or fewer, what does the above program do? Solution: The Symbol Table generated by the assembler is given below. Symbol Address A 0x3001 B 0x3004 C 0x3005 D 0x3007 E 0x300A ± 0x300B Assembly of instructions at A, B, and D: A: 0010001000001000 B: 0001001001111111 D: 0000001111111101 It calculates the sum of the odd numbers between the value in E and zero and stores the result in ±. 7.7 The assembly language program is: .ORIG x3000 AND R5, R5, #0 ADD R5, R5, #1 ;R5 will act as a mask to ;mask out the unneeded bit AND R1, R1, #0 ;zero out the result register AND R2, R2, #0 ;R2 will act as a counter LD R3, NegSixt MskLoop AND R4, R0, R5 ;mask off the bit BRz NotOne ;if bit is zero then don’t ;increment the result ADD R1, R1, #1 ;if bit is one increment ;the result NotOne ADD R5, R5, R5 ;shift the mask one bit left ADD R2, R2, #1 ;increment counter (tells us ;where we are in bit pattern) ADD R6, R2, R3 BRn MskLoop ;not done yet go back and ;check other bits HALT NegSixt .FILL #-16 .END
Background image of page 2
F.7.CHAPTER7SOLUTIONS 3 7.8 Register File: Register Value R0 0xA400 R1 0x23FF R2 0xE1FF R3 0xA401 R4 0x0000 R5 0x0000 R6 0x0000 R7 0x0000 7.9 The .END pseudo-op tells the assembler where the program ends. Any string that occurs after that will be disregarded and not processed by the assembler. It is different from HALT instruction in very fundamental aspects: 1. It is not an instruction, it can never be executed. 2. Therefore it does not stop the machine. 3. It is just a marker that helps the assembler to know where to stop assembling. 7.10 Add R3, R3, #30 contains an immediate value that is too large to be stored in the Add instruc- tion’s immediate value. This instruction cannot be translated by the assembler, thus the error is detected when the program is assembled, not run on the LC-3. 7.11
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.

This homework help was uploaded on 04/07/2008 for the course ECE 495K taught by Professor Vijaykumar during the Spring '08 term at Purdue.

Page1 / 14

ch07_complete - F.7 Chapter 7 Solutions 7.1 0xA7FE 7.2...

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