⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tp1_exception.asm

📁 小型操作系统,以VC为开发环境,需要boachs调试
💻 ASM
字号:
;/***************************************************************************
;**     File name   : tp1_exception.asm
;**     Author      : x.cheng
;**     Create date :
;**
;**	   Comment:
;**        contains the low-level code for most hardware faults.
;**        主要涉及对intel保留的中断int0-int16的处理(介个是异常)
;**
;**     Revisions:
;**     $Log: tp1_exception.asm,v $
;**     Revision 1.1  2005/08/04 08:32:12  x.cheng
;**     add into repositories
;**
;**
;***************************************************************************/

[bits 32]
SECTION	.text

%include "..\inc\def_int_exc.inc"	; //! Include common assembler header.

extern _DefaultExceptionHandler
align 4

COMMON_EXC:
	cld
	; // Saving segment registers; get rid of
	; // %gs and %fs registers because the kernel
	; // does not use them.
	push	ds
	push	es
	; // Saving general purpose registers.
	push	eax
	push	ecx
	push	edx
	push	ebx
	push	ebp
	push	esi
	push	edi
	; // Update segment registers with the kernel
	; // data segment.
	mov	eax, KERNEL_DATA
	mov	ds, ax
	mov	ds, ax
	; // Call the default handler;
	; //     void DefaultExceptionHandler(ts_ExceptionContext *pstContext);
	push	esp
	call	_DefaultExceptionHandler

Return_From_Exception:
	pop	esp
	; // Restore general purpose registers.
	pop	edi
	pop	esi
	pop	ebp
	pop	ebx
	pop	edx
	pop	ecx
	pop	eax
	; // Restore segment registers.
	pop	es
	pop	ds
	; // Skip the exception and error numbers.
	add	esp, 8
	; // Return from interrupt; restores %eip, %cs and
	; // eflags registers for 0-privileged tasks;
	; // for other tasks also %esp and %ss registers
	; // are restored.
	iret

; // --- Exception Handling Routines Declaration -----------------------//
; // refer to Volume 3 System Programming.pdf, page 146
;
EXCEPTION_ENTRY_NOCODE exc_DivideByZero,		0x00 		; // Division by Zero		fault
EXCEPTION_ENTRY_NOCODE exc_Debug,				0x01 		; // Debug Trap				fault/trap
EXCEPTION_ENTRY_NOCODE exc_Nmi,					0x02 		; // NMI Interrupt			interrupt
EXCEPTION_ENTRY_NOCODE exc_BreakPoint,			0x03 		; // Breakpoint Exception	trap
EXCEPTION_ENTRY_NOCODE exc_Overflow,			0x04 		; // Overflow				trap
EXCEPTION_ENTRY_NOCODE exc_BoundRangeExceeded,	0x05 		; // Bound Range Exceeded	fault
EXCEPTION_ENTRY_NOCODE exc_InvalidOpcode,		0x06 		; // Invalid Opcode			fault
EXCEPTION_ENTRY_NOCODE exc_DeviceNotExist,		0x07 		; // No Math				fault
; // EXCEPTION_ENTRY_CODE exc_DoubleFault, 0x08					; // Double Fault			abort
EXCEPTION_ENTRY_NOCODE exc_80x87OverRun,		0x09 		; // 80x87 OverRun			fault
EXCEPTION_ENTRY_CODE exc_InvalidTss,			0x0A 		; // Invalid TSS			fault
EXCEPTION_ENTRY_CODE exc_SegmentNotPresent,		0x0B 		; // Segment Not Present	fault
EXCEPTION_ENTRY_CODE exc_StackFault,			0x0C 		; // Stack Fault			fault
EXCEPTION_ENTRY_CODE exc_GeneralProtectFault,	0x0D 		; // General Protection		fault
EXCEPTION_ENTRY_CODE exc_PageFault,				0x0E 		; // Page Fault				fault
EXCEPTION_ENTRY_NOCODE exc_Reserved,			0x0F 		; // Intel Reserved
EXCEPTION_ENTRY_NOCODE exc_MathFault,			0x10		; // Math Fault				fault
EXCEPTION_ENTRY_CODE exc_AlignmentCheck,		0x11		; // Alignment Check		fault
EXCEPTION_ENTRY_NOCODE exc_MachineCheck,		0x12		; // Machine Check			abort
EXCEPTION_ENTRY_NOCODE exc_SimdExtensions,		0x13		; // Streaming SIMD extensions	fault

EXCEPTION_ENTRY_NOCODE exc_UnHandle,			0xFF 	; // Unhandled exception

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -