efi64.asm
来自「EFI BIOS是Intel提出的下一代的BIOS标准。这里上传的Edk源代码是」· 汇编 代码 · 共 788 行 · 第 1/2 页
ASM
788 行
PrintTheString:
call PrintString
mov esi, offset String2
call PrintString
db 48h
mov eax, [ebp+19*8] ; CS
call PrintQword
mov al, ':'
mov byte ptr [edi], al
add edi, 2
db 48h
mov eax, [ebp+18*8] ; RIP
call PrintQword
mov esi, offset String3
call PrintString
mov edi, 0b8140h
mov esi, offset StringRax ; rax
call PrintString
db 48h
mov eax, [ebp+15*8]
call PrintQword
mov esi, offset StringRcx ; rcx
call PrintString
db 48h
mov eax, [ebp+14*8]
call PrintQword
mov esi, offset StringRdx ; rdx
call PrintString
db 48h
mov eax, [ebp+13*8]
call PrintQword
mov edi, 0b81e0h
mov esi, offset StringRbx ; rbx
call PrintString
db 48h
mov eax, [ebp+12*8]
call PrintQword
mov esi, offset StringRsp ; rsp
call PrintString
db 48h
mov eax, [ebp+21*8]
call PrintQword
mov esi, offset StringRbp ; rbp
call PrintString
db 48h
mov eax, [ebp+10*8]
call PrintQword
mov edi, 0b8280h
mov esi, offset StringRsi ; rsi
call PrintString
db 48h
mov eax, [ebp+9*8]
call PrintQword
mov esi, offset StringRdi ; rdi
call PrintString
db 48h
mov eax, [ebp+8*8]
call PrintQword
mov esi, offset StringEcode ; error code
call PrintString
db 48h
mov eax, [ebp+17*8]
call PrintQword
mov edi, 0b8320h
mov esi, offset StringR8 ; r8
call PrintString
db 48h
mov eax, [ebp+7*8]
call PrintQword
mov esi, offset StringR9 ; r9
call PrintString
db 48h
mov eax, [ebp+6*8]
call PrintQword
mov esi, offset StringR10 ; r10
call PrintString
db 48h
mov eax, [ebp+5*8]
call PrintQword
mov edi, 0b83c0h
mov esi, offset StringR11 ; r11
call PrintString
db 48h
mov eax, [ebp+4*8]
call PrintQword
mov esi, offset StringR12 ; r12
call PrintString
db 48h
mov eax, [ebp+3*8]
call PrintQword
mov esi, offset StringR13 ; r13
call PrintString
db 48h
mov eax, [ebp+2*8]
call PrintQword
mov edi, 0b8460h
mov esi, offset StringR14 ; r14
call PrintString
db 48h
mov eax, [ebp+1*8]
call PrintQword
mov esi, offset StringR15 ; r15
call PrintString
db 48h
mov eax, [ebp+0*8]
call PrintQword
mov esi, offset StringSs ; ss
call PrintString
db 48h
mov eax, [ebp+22*8]
call PrintQword
mov edi, 0b8500h
mov esi, offset StringRflags ; rflags
call PrintString
db 48h
mov eax, [ebp+20*8]
call PrintQword
mov edi, 0b8640h
mov esi, ebp
add esi, 23*8
mov ecx, 4
OuterLoop:
push ecx
mov ecx, 4
db 48h
mov edx, edi
InnerLoop:
db 48h
mov eax, [esi]
call PrintQword
add esi, 8
mov al, ' '
mov [edi], al
add edi, 2
loop InnerLoop
pop ecx
add edx, 0a0h
mov edi, edx
loop OuterLoop
mov edi, 0b8960h
db 48h
mov eax, [ebp+18*8] ; RIP
sub eax, 8 * 8
db 48h
mov esi, eax ; esi = rip - 8 QWORD linear (total 16 QWORD)
mov ecx, 4
OuterLoop1:
push ecx
mov ecx, 4
mov edx, edi
InnerLoop1:
db 48h
mov eax, [esi]
call PrintQword
add esi, 8
mov al, ' '
mov [edi], al
add edi, 2
loop InnerLoop1
pop ecx
add edx, 0a0h
mov edi, edx
loop OuterLoop1
wbinvd
@@:
jmp @b
;
; return
;
mov esp, ebp
; mov rsp, rbp
db 41h
db 5fh
; pop r15
db 41h
db 5eh
; pop r14
db 41h
db 5dh
; pop r13
db 41h
db 5ch
; pop r12
db 41h
db 5bh
; pop r11
db 41h
db 5ah
; pop r10
db 41h
db 59h
; pop r9
db 41h
db 58h
; pop r8
pop edi
pop esi
pop ebp
pop eax ; esp
pop ebx
pop edx
pop ecx
pop eax
db 48h
db 83h
db 0c4h
db 10h
; add esp, 16 ; error code and INT number
db 48h
db 0cfh
; iretq
PrintString:
push eax
@@:
mov al, byte ptr [esi]
cmp al, 0
je @f
mov byte ptr [edi], al
db 0ffh
db 0c6h
; inc esi
add edi, 2
jmp @b
@@:
pop eax
ret
;; RAX contains qword to print
;; RDI contains memory location (screen location) to print it to
PrintQword:
push ecx
push ebx
push eax
db 48h
db 0c7h
db 0c1h
dd 16
; mov rcx, 16
looptop:
db 48h
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
A2C:
and al, 0fh
add al, '0'
cmp al, '9'
jle @f
add al, 7
@@:
ret
String1 db "*** INT ",0
Int0String db "00h Divide by 0 -",0
Int1String db "01h Debug exception -",0
Int2String db "02h NMI -",0
Int3String db "03h Breakpoint -",0
Int4String db "04h Overflow -",0
Int5String db "05h Bound -",0
Int6String db "06h Invalid opcode -",0
Int7String db "07h Device not available -",0
Int8String db "08h Double fault -",0
Int9String db "09h Coprocessor seg overrun (reserved) -",0
Int10String db "0Ah Invalid TSS -",0
Int11String db "0Bh Segment not present -",0
Int12String db "0Ch Stack fault -",0
Int13String db "0Dh General protection fault -",0
Int14String db "0Eh Page fault -",0
Int15String db "0Fh (Intel reserved) -",0
Int16String db "10h Floating point error -",0
Int17String db "11h Alignment check -",0
Int18String db "12h Machine check -",0
Int19String db "13h SIMD Floating-Point Exception -",0
IntUnknownString db "??h Unknown interrupt -",0
StringTable dq 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, offset Int19String
String2 db " HALT!! *** (",0
String3 db ")",0
StringRax db "RAX=",0
StringRcx db " RCX=",0
StringRdx db " RDX=",0
StringRbx db "RBX=",0
StringRsp db " RSP=",0
StringRbp db " RBP=",0
StringRsi db "RSI=",0
StringRdi db " RDI=",0
StringEcode db " ECODE=",0
StringR8 db "R8 =",0
StringR9 db " R9 =",0
StringR10 db " R10=",0
StringR11 db "R11=",0
StringR12 db " R12=",0
StringR13 db " R13=",0
StringR14 db "R14=",0
StringR15 db " R15=",0
StringSs db " SS =",0
StringRflags db "RFLAGS=",0
Idtr df 0
df 0
org 21ffeh
BlockSignature:
dw 0aa55h
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?