efi32.asm
来自「Next BIOS Source code : Extensible Firmw」· 汇编 代码 · 共 540 行 · 第 1/2 页
ASM
540 行
JmpCommonIdtEntry
commonIdtEntry:
pushad
mov ebp, esp
;;
;; At this point the stack looks like this:
;;
;; eflags
;; Calling CS
;; Calling EIP
;; Error code or 0
;; Int num or 0ffh for unknown int num
;; eax
;; ecx
;; edx
;; ebx
;; esp
;; ebp
;; esi
;; edi <------- ESP, EBP
;;
call ClearScreen
mov esi, offset String1
call PrintString
mov eax, [ebp + 32] ;; move Int number into EAX
cmp eax, 18
ja PrintDefaultString
PrintExceptionString:
shl eax, 2 ;; multiply by 4 to get offset from StringTable to actual string address
add eax, offset StringTable
mov esi, [eax]
jmp PrintTheString
PrintDefaultString:
mov esi, offset IntUnknownString
PrintTheString:
call PrintString
mov esi, offset String2
call PrintString
mov eax, [ebp+44]
call PrintDword
mov al, ':'
mov byte ptr [edi], al
add edi, 2
mov eax, [ebp+40]
call PrintDword
mov esi, offset String3
call PrintString
mov edi, 0b8140h
mov esi, offset StringEax ; eax
call PrintString
mov eax, [ebp+28]
call PrintDword
mov esi, offset StringEbx ; ebx
call PrintString
mov eax, [ebp+16]
call PrintDword
mov esi, offset StringEcx ; ecx
call PrintString
mov eax, [ebp+24]
call PrintDword
mov esi, offset StringEdx ; edx
call PrintString
mov eax, [ebp+20]
call PrintDword
mov edi, 0b81e0h
mov esi, offset StringEsp ; esp
call PrintString
mov eax, [ebp+12]
call PrintDword
mov esi, offset StringEbp ; ebp
call PrintString
mov eax, [ebp+8]
call PrintDword
mov esi, offset StringEsi ; esi
call PrintString
mov eax, [ebp+4]
call PrintDword
mov esi, offset StringEdi ; edi
call PrintString
mov eax, [ebp]
call PrintDword
mov esi, offset StringEflags ; eflags
call PrintString
mov eax, [ebp+48]
call PrintDword
mov edi, 0b8320h
mov esi, ebp
add esi, 52
mov ecx, 8
OuterLoop:
push ecx
mov ecx, 8
mov edx, edi
InnerLoop:
mov eax, [esi]
call PrintDword
add esi, 4
mov al, ' '
mov [edi], al
add edi, 2
loop InnerLoop
pop ecx
add edx, 0a0h
mov edi, edx
loop OuterLoop
mov edi, 0b8960h
mov eax, [ebp+44]
shl eax, 4
add eax, [ebp+40]
sub eax, 16
mov esi, eax ; esi = cs:ip - 16 linear
mov ecx, 8
OuterLoop1:
push ecx
mov ecx, 8
mov edx, edi
InnerLoop1:
mov eax, [esi]
call PrintDword
add esi, 4
mov al, ' '
mov [edi], al
add edi, 2
loop InnerLoop1
pop ecx
add edx, 0a0h
mov edi, edx
loop OuterLoop1
wbinvd
@@:
jmp @b
PrintString:
push eax
@@:
mov al, byte ptr [esi]
cmp al, 0
je @f
mov byte ptr [edi], al
inc esi
add edi, 2
jmp @b
@@:
pop eax
ret
;; EAX contains dword to print
;; EDI contains memory location (screen location) to print it to
PrintDword:
push ecx
push ebx
push eax
mov ecx, 8
looptop:
rol eax, 4
mov bl, al
and bl, 0fh
add bl, '0'
cmp bl, '9'
jle @f
add bl, 7
@@:
mov byte ptr [edi], bl
add edi, 2
loop looptop
wbinvd
pop eax
pop ebx
pop ecx
ret
ClearScreen:
push eax
push ecx
mov al, ' '
mov ah, 0ch
mov edi, 0b8000h
mov ecx, 80 * 24
@@:
mov word ptr [edi], ax
add edi, 2
loop @b
mov edi, 0b8000h
pop ecx
pop eax
ret
String1 db "*** INT ",0
Int0String db "0 Divide by 0 -",0
Int1String db "1 Debug exception -",0
Int2String db "2 NMI -",0
Int3String db "3 Breakpoint -",0
Int4String db "4 Overflow -",0
Int5String db "5 Bound -",0
Int6String db "6 Invalid opcode -",0
Int7String db "7 device not available -",0
Int8String db "8 double fault -",0
Int9String db "9 coprocessor seg overrun (reserved) -",0
Int10String db "10 Invalid TSS -",0
Int11String db "11 Segment not present -",0
Int12String db "12 Stack fault -",0
Int13String db "13 General protection fault -",0
Int14String db "14 Page fault -",0
Int15String db "15 (intel reserved) -",0
Int16String db "16 Floating point error -",0
Int17String db "17 Alignment check -",0
Int18String db "18 Machine check -",0
IntUnknownString db "?? Unknown interrupt - ",0
StringTable dd offset Int0String, offset Int1String, offset Int2String, offset Int3String,
offset Int4String, offset Int5String, offset Int6String, offset Int7String,
offset Int8String, offset Int9String, offset Int10String, offset Int11String,
offset Int12String, offset Int13String, offset Int14String, offset Int15String,
offset Int16String, offset Int17String, offset Int18String
String2 db " HALT!! *** ( ",0
String3 db " )",0
StringEax db "EAX=",0
StringEbx db " EBX=",0
StringEcx db " ECX=",0
StringEdx db " EDX=",0
StringEsp db "ESP=",0
StringEbp db " EBP=",0
StringEsi db " ESI=",0
StringEdi db " EDI=",0
StringEflags db " EFLAGS=",0
Idtr df 0
org 21ffeh
BlockSignature:
dw 0aa55h
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?