From e29dc737adaf9ba9fb4b1a6e8b74ca1a9afb4a4c Mon Sep 17 00:00:00 2001 From: Joe Tretter Date: Fri, 29 Aug 2025 19:07:30 -0500 Subject: [PATCH] add simple boot loader example --- bootloader1/boot.asm | 21 +++++++++++++++++++++ bootloader1/compile.sh | 3 +++ 2 files changed, 24 insertions(+) create mode 100644 bootloader1/boot.asm create mode 100755 bootloader1/compile.sh diff --git a/bootloader1/boot.asm b/bootloader1/boot.asm new file mode 100644 index 0000000..57840c2 --- /dev/null +++ b/bootloader1/boot.asm @@ -0,0 +1,21 @@ +; boot.asm - prints 'A' and halts +BITS 16 ; 16-bit real mode +ORG 0x7C00 ; boot sector load address + +start: + mov ah, 0x0E ; teletype output BIOS function + mov al, 'A' ; character to print + mov bh, 0x00 ; page number 0 + mov bl, 0x07 ; text attribute (light grey on black) + int 0x10 ; BIOS video interrupt + + cli ; disable interrupts +hang: + hlt ; halt CPU + jmp hang ; infinite loop + +; fill the rest of the sector with zeros +times 510-($-$$) db 0 + +; boot signature (2 bytes) +dw 0xAA55 diff --git a/bootloader1/compile.sh b/bootloader1/compile.sh new file mode 100755 index 0000000..147f43c --- /dev/null +++ b/bootloader1/compile.sh @@ -0,0 +1,3 @@ +nasm -f bin boot.asm -o boot.bin +dd if=boot.bin of=floppy.img bs=512 count=1 conv=notrunc +qemu-system-x86_64 -fda floppy.img