Lecture Introduction to computing systems (from bits & gates to C & beyond): Chapter 9 - Yale N. Patt, Sanjay J. Patel

Chapter 9 - TRAP routines. This chapter presents the following content: Privileged instructions, TRAP routines, subroutines, the complete mechanism, TRAP routines for handling I/O, TRAP routine for halting the computer, saving and restoring registers, the call/return mechanism, | Chapter 9 TRAP Routines Subroutines Privileged Instructions TRAP Routines Subroutines Used for Frequently executed code segments: written only once. Hides the implementation details. Passing of parameters and return values, in registers or memory. Is called from within a program; control is returned to the same point it was called from. Can be either Procedures, or Functions 9 - Jump to Sub - 1: JSR/JMP JSR/JMP: jump subroutine (direct) JSR: IR[11] = 1, and R7 (PC) . PC is saved in R7 JMP: IR[11] = 0, PC is not saved. PC PC[15:9] @ IR[8:0] 0 0 0 0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 JSR L x 0 0 pageoffset9 9 - Jump to Sub - 2: JSRR/JMPR JSRR/JMPR: jump subroutine (base + offset) JSRR: IR[11] = 1, and R7 (PC) . PC is saved in R7 JMPR: IR[11] = 0, PC is not saved. PC (BaseReg) + Zext(IR[5:0]) 0 0 0 0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 JSR L x 0 0 x x x index6 BaseReg 9 - Privileged Instructions There are several instructions that are best executed by a supervisor program (OS) rather than a user program: IO instructions Loading of memory mapping registers Resetting the clock Halt . instructions where one program can affect the behavior of another. Hardware enforces two modes of operation User Mode Privileged Mode (aka. supervisor, kernel, monitor mode) Only the supervisor program can execute privileged instructions. 9 - TRAP Instructions TRAP: A special instruction A subroutine call used to invoke a specific supervisor routine. It switches the execution to privileged mode, and reverts back to user mode when the routine completes. PC Mem[Zext(IR[7:0])] RET – return instruction Return the execution to the last calling point. PC (R7) 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 0 0 0 trapvector8 TRAP 9 - TRAP Example = x04A0 x300B R7 Service routine Address x300A System Control Block Or Interrupt Vector Table In LC-2 8 bits specify one of 256 locations (x0000 to x00FF) The location contains | Chapter 9 TRAP Routines Subroutines Privileged Instructions TRAP Routines Subroutines Used for Frequently executed code segments: written only once. Hides the implementation details. Passing of parameters and return values, in registers or memory. Is called from within a program; control is returned to the same point it was called from. Can be either Procedures, or Functions 9 - Jump to Sub - 1: JSR/JMP JSR/JMP: jump subroutine (direct) JSR: IR[11] = 1, and R7 (PC) . PC is saved in R7 JMP: IR[11] = 0, PC is not saved. PC PC[15:9] @ IR[8:0] 0 0 0 0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 JSR L x 0 0 pageoffset9 9 - Jump to Sub - 2: JSRR/JMPR JSRR/JMPR: jump subroutine (base + offset) JSRR: IR[11] = 1, and R7 (PC) . PC is saved in R7 JMPR: IR[11] = 0, PC is not saved. PC (BaseReg) + Zext(IR[5:0]) 0 0 0 0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 JSR L x 0 0 x x x index6 BaseReg 9 - Privileged Instructions There are several instructions that are best executed by a .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.