📄 trapentry.s
字号:
/* See COPYRIGHT for copyright information. */#include <inc/mmu.h>#include <inc/memlayout.h>#include <inc/trap.h>#################################################################### exceptions/interrupts###################################################################/* The TRAPHANDLER macro defines a globally-visible function for handling * a trap. It pushes a trap number onto the stack, then jumps to _alltraps. * Use TRAPHANDLER for traps where the CPU automatically pushes an error code. */ #define TRAPHANDLER(name, num) \ .globl name; /* define global symbol for 'name' */ \ .type name, @function; /* symbol type is function */ \ .align 2; /* align function definition */ \ name: /* function starts here */ \ pushl $(num); \ jmp _alltraps/* Use TRAPHANDLER_NOEC for traps where the CPU doesn't push an error code. * It pushes a 0 in place of the error code, so the trap frame has the same * format in either case. */#define TRAPHANDLER_NOEC(name, num) \ .globl name; \ .type name, @function; \ .align 2; \ name: \ pushl $0; \ pushl $(num); \ jmp _alltraps/* * Lab 3: Your code here for generating entry points for the different traps. */.text TRAPHANDLER_NOEC(te_divide, T_DIVIDE) TRAPHANDLER_NOEC(te_debug, T_DEBUG) TRAPHANDLER_NOEC(te_nmi, T_NMI) # no error code? TRAPHANDLER_NOEC(te_brkpt, T_BRKPT) TRAPHANDLER_NOEC(te_oflow, T_OFLOW) TRAPHANDLER_NOEC(te_bound, T_BOUND) TRAPHANDLER_NOEC(te_illop, T_ILLOP) TRAPHANDLER_NOEC(te_device, T_DEVICE) TRAPHANDLER(te_dblflt, T_DBLFLT) TRAPHANDLER(te_tss, T_TSS) TRAPHANDLER(te_segnp, T_SEGNP) TRAPHANDLER(te_stack, T_STACK) TRAPHANDLER(te_gpflt, T_GPFLT) TRAPHANDLER(te_pgflt, T_PGFLT) TRAPHANDLER_NOEC(te_fperr, T_FPERR) TRAPHANDLER_NOEC(te_align, T_ALIGN) TRAPHANDLER_NOEC(te_mchk, T_MCHK) TRAPHANDLER_NOEC(te_simderr, T_SIMDERR) TRAPHANDLER_NOEC(te_syscall, T_SYSCALL) TRAPHANDLER_NOEC(te_default, T_DEFAULT) /* * Lab 3: Your code here for _alltraps */ _alltraps: pushl %ds pushl %es pushal movl $GD_KD, %eax movw %ax, %ds movw %ax, %es pushl %esp call trap popl %esp popal popl %es popl %ds iret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -