diff --git a/boot.asm b/boot/boot.asm similarity index 72% rename from boot.asm rename to boot/boot.asm index da7b5cf..f463ae1 100644 --- a/boot.asm +++ b/boot/boot.asm @@ -1,3 +1,4 @@ +bits 16 org 0x7c00 halt: diff --git a/boot/util.asm b/boot/util.asm new file mode 100644 index 0000000..509f299 --- /dev/null +++ b/boot/util.asm @@ -0,0 +1,34 @@ +%define cr 0x0a +%define lf 0x0d +%define endl 0x0 + +; Reads a character +; out: +; al = asci character +; ah = scan code +read_char: + mov ah, 0 + int 0x16 + ret + +; Prints a character +; in: +; al = asci character to print +print_char: + mov ah, 0x0e + int 0x10 + ret + +; Prints a null terminated string +; in: +; si = null terminated string pointer +print_line: + .loop: + cmp byte [si], 0 + je .done + mov al, [si] + call print_char + inc si + jmp .loop + .done: + ret \ No newline at end of file diff --git a/makefile b/makefile index f182b6d..92be507 100644 --- a/makefile +++ b/makefile @@ -1,8 +1,8 @@ -boot.bin: boot.asm - nasm -o boot.bin boot.asm +boot/boot.bin: boot/boot.asm + nasm -o boot/boot.bin boot/boot.asm -run: boot.bin - qemu-system-x86_64 boot.bin +run: boot/boot.bin + qemu-system-x86_64 -drive file=boot/boot.bin,format=raw,index=0,media=disk clean: - rm boot.bin \ No newline at end of file + rm boot/boot.bin \ No newline at end of file