ch09_complete - F.9 Chapter 9 Solutions 9.1 The most...

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

View Full Document Right Arrow Icon
F.9 Chapter 9 Solutions 9.1 The most important advantage of doing I/O through a trap routine is the fact that it is not necessary for the programmer to know the gory low-level details of the speciFc hardware’s input/output mechanism. These details include: the hardware data registers for the input and output devices the hardware status registers for the input and output devices the asynchronous nature of the input relative to the executing program Besides, these details may change from computer to computer. The programmer would have to know these details for the computer she’s working on in order to be able to do input/output. Using a trap routine requires no hardware-speciFc knowledge on part of the programmer and saves time. 9.2 (a) The trap vector is 8 bits wide. 256 trap routines can be implemented in the LC-3. (b) After the TRAP routine is executed, program control must be passed back to the code that called the TRAP instruction. This is done by copying the value in R7 into the PC. The RET instruction provides this functionality. BRnzp does not restore the PC. (c) One. 9.3 (a) Some external mechanism is the only way to start the clock (hence, the computer) af- ter it is halted. The Halt service routine can never return after bit 15 of the machine control register is cleared because the clock has stopped, which means that instruction processing has stopped. (b) STI R0, MCR This instruction clears the most signiFcant bit of the machine control register, stopping the clock. (c) LD R1, SaveR1 (d) The RET of the HALT routine will bring program control back to the program that executed the HALT instruction. The PC will point to the address following the HALT instruction. 9.4 (a) 1111000000100001 (xf021) (b) x0430 (c) x0437 (d) HookemHorns 9.5 Note: This problem should be corrected to read as follows: .ORIG x3000 LEA R0, LABEL STR R1, R0, #3 TRAP x22 TRAP x25 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 LABEL .STRINGZ "FUNKY" LABEL2 .STRINGZ "HELLO WORLD" .END Answer: FUN 9.6 .ORIG x3000 LD R2, LOWER ; Load -A LD R3, ASCII ; Load ASCII difference LD R4, UPPER ; Load -Z AGAIN TRAP x23 ; Request keyboard input ADD R1, R2, R0
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.

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 University-West Lafayette.

Page1 / 8

ch09_complete - F.9 Chapter 9 Solutions 9.1 The most...

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