Reputation: 11
The bootloader is one of the hello world projects that i have found that in internet: https://johv.dk/blog/bare-metal-assembly-tutorial.html
Before that I had tried to write some bootloader with nasm , fasm etc but none of them worked and just crash.
format pe64 efi
entry main
section '.text' executable readable
main:
;; Recall that RDX contains a pointer to the System Table when
;; our application is called. So rdx + 64 is the address of the
;; pointer to ConOut, and [rdx + 64] is the pointer itself.
mov rcx, [rdx + 64]
;; Now, RCX contains the ConOut pointer. Thus, the address of
;; the OutputString function is at rcx + 8. We'll move this
;; function into RAX:
mov rax, [rcx + 8]
;; We already have the ConOut pointer in RCX. Let's load the
;; string pointer into RDX:
mov rdx, string
;; Set up the shadow space. We just need to reserve 32 bytes
;; on the stack, which we do by manipulating the stack pointer:
sub rsp, 32
;; Now we can call the OutputText function, whose address is
;; in the RAX register:
call rax
;; Finally, we'll clean up the shadow space and then return:
add rsp, 32
jmp $
section '.data' readable writable
string du 'Hello, World!', 0xD, 0xA, 0
compile the hello world with FASM
fasm hello.asm hello.efi
I make FAT32 file system on usb and copy the executable file :
mkfs.vfat -F32 /dev/sdb
mount /dev/sdb /mnt
mkdir -p /mnt/EFI/BOOT
cp -r hello.efi /mnt/EFI/BOOT/BOOTx64.EFI
umount /mnt
I select USB flash drive in UEFI boot manager to be booted
Finally the result is crash and black screen when it goes to bootup USB. Even when i go to /BOOT/EFI/ in UEFI shell and try to execute BOOTx64.EFI, the result is crash.
Upvotes: 0
Views: 105