1. Slide 2. Slide Device registers needed to control disk drive o Do you want code that someone else has written controlling your disk drive? Maybe they accidentally write to some registers that tell the drive to format itself. o Solution: Let operating system code (presumably tested and robust!) to control the disk drive. When you write code that saves data to disk, do you read/write to the device registers? No, the OS does this for you. 3. Slide You already know how to USE traps. Now we will learn how they are implemented. What trap routines do we have available on the LC-3? o 20 (GETC), 21 (OUT), 22 (PUTS), 23 (IN), 25 (HALT) 4. Slide Show drawing of lower part of LC-3 memory (0000-00FF) 5. Slide Why Zero-extended? 6. Slide Show flow through diagram of the LC-3. 7. Slide 8. Slide Show trap vector table, trap code, polling for GETC (TRAP x20) 9. Slide Just example of how to use traps – You already know this! What would happen if we have data that we are using in R7 before we call a trap? 10. Slide Note that R1 is stored and loaded. Why? Why doesn’t the routine save R0? 11. Slide 12. Slide As an example, when you call TRAP x20 to get a character, you don’t expect data that you have stored in R1 (or R2-R7) to get trashed. o But you do expect what is in R0 to be trashed – it will contain the read-in character after 13. Slide 14. Slide Callee = the routine being called – Ex: Service Routine Caller = the code doing the actual calling – Ex: User code 15. Slide 16. Slide 17. Slide Lives in user space = not part of the operating system = code that you write 18. Slide 19. Slide 20. Slide 21. Slide 22. Slide 23. Slide 24. Slide 25. Slide 26. Slide Get groups to put solutions to FirstChar and CountChar on the board