hex0.S: print hello world as a test.

This commit is contained in:
Andrius Štikonas 2022-07-10 22:08:36 +01:00
parent 081a890e05
commit 9cb1d5b7f0
2 changed files with 23 additions and 11 deletions

View File

@ -3,7 +3,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later
cc = clang
cflags = -ffreestanding -MMD -mno-red-zone -std=c11 -target x86_64-unknown-windows
cflags = -ffreestanding -MMD -mno-red-zone -std=c11 -target x86_64-unknown-windows -masm=intel
ld = lld-link
lflags = -subsystem:efi_application -nodefaultlib -dll
@ -16,8 +16,8 @@ $(build)/%.o : %.S
$(cc) $(cflags) -c $< -o $@
$(build)/%.efi : $(build)/%.o
$(ld) $(lflags) -entry:efi_main $< -out:$@
$(ld) $(lflags) -entry:_start $< -out:$@
. PHONY : clean all
clean:
rm -f $(build)
rm -rf $(build)

View File

@ -2,13 +2,25 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later
.text
.globl efi_main
.global _start
.text
efi_main:
sub $16, %rsp
mov %rdx, 8(%rsp)
mov %rcx, (%rsp)
mov $42, %eax
add $16, %rsp
_start:
mov [ImageHandle], rcx # ImageHandle *image
mov [SystemTable], rdx # SystemTable *system
lea rdx, [hello] # arg2 = "Hello World"
mov rcx, [SystemTable] # system
mov rcx, [rcx+64] # arg1 = system->out
call [rcx+8]
Done:
mov rax, 0 # rax = 0
ret
.data
hello: .asciz "H\0e\0l\0l\0o\0 \0w\0o\0r\0l\0d\0!\0\n\0\r\0\0"
ImageHandle: .quad 0
SystemTable: .quad 0