-
Notifications
You must be signed in to change notification settings - Fork 2
/
HelloWorld.asm
98 lines (71 loc) · 1.5 KB
/
HelloWorld.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
;
; HelloWorld.asm
; 2015 Szymon Kłos
;
format pe dll efi
entry main
section '.text' code executable readable
include 'efi.inc'
main:
push ebp
mov ebp, esp
; get args ( ImageHandle and SystemTable pointer )
mov ecx, [ebp+8]
mov [ImageHandle], ecx
mov edx, [ebp+12]
mov [SystemTable], edx
; checking the signature
mov eax, EFI_SYSTEM_TABLE.Hdr
add edx, eax
mov eax, EFI_TABLE_HEADER.Signature
add edx, eax
mov ecx, [edx]
mov eax, EFI_SYSTEM_TABLE_SIGNATURE
cmp eax, ecx
jne error
mov ecx, [edx + 4]
mov eax, EFI_SYSTEM_TABLE_SIGNATURE2
cmp eax, ecx
jne error
clear:
mov eax, EFI_SYSTEM_TABLE.ConOut
mov ecx, [SystemTable]
add ecx, eax
mov ecx, [ecx]
mov edx, ecx
mov eax, SIMPLE_TEXT_OUTPUT_INTERFACE.ClearScreen
add edx, eax
push ecx ; [arg] SystemTable.ConOut
mov edx, [edx]
call edx
add esp, 4
print_text:
mov eax, EFI_SYSTEM_TABLE.ConOut
mov ecx, [SystemTable]
add ecx, eax
mov ecx, [ecx]
mov edx, ecx
mov eax, SIMPLE_TEXT_OUTPUT_INTERFACE.OutputString
add edx, eax
lea eax, [text]
push eax ; [arg] text
push ecx ; [arg] SystemTable.ConOut
mov edx, [edx]
call edx
add esp, 8
inf_loop:
nop
jmp inf_loop ; infinite loop
success:
mov eax, EFI_SUCCESS
pop ebp
retn
error:
mov eax, 1
pop ebp
retn
section '.data' data readable writeable
ImageHandle dd ?
SystemTable dd ?
text du 'Hello World',13,10,0
section '.reloc' fixups data discardable