diff --git a/.gitignore b/.gitignore index 4a4eb43..2cf5651 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.o gamarjoba_munde/gamarjoba +baremetal_gamarjoba/baremetal_gamarjoba diff --git a/README.md b/README.md index b7ee307..af4ea34 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ low-level programming concerns. This repo contains the following executables: * `gamarjoba_munde` - x86-64 linux binary that prints the text "Gamarjoba, Munde" +* `baremetal_gamarjoba` - bare-metal x86 program run with QEMU # Useful links diff --git a/baremetal_gamarjoba.asm b/baremetal_gamarjoba/baremetal_gamarjoba.asm similarity index 82% rename from baremetal_gamarjoba.asm rename to baremetal_gamarjoba/baremetal_gamarjoba.asm index 8533442..df578f8 100644 --- a/baremetal_gamarjoba.asm +++ b/baremetal_gamarjoba/baremetal_gamarjoba.asm @@ -1,5 +1,5 @@ -%include "multiboot_header.asm" -%include "x86_vram.asm" +%include "../common/multiboot_header.asm" +%include "../common/x86_vram.asm" %define stack_size 0x1000 @@ -13,8 +13,11 @@ print_word db 'Hahaha',0 section .text +; Defined in include.c extern get_vram_offset extern c_entry + +; Defined in common/x86_vram_functions.asm global write_to_coord global boot @@ -52,4 +55,4 @@ halt: hlt jmp halt -%include "x86_vram_functions.asm" +%include "../common/x86_vram_functions.asm" diff --git a/include.c b/baremetal_gamarjoba/include.c similarity index 100% rename from include.c rename to baremetal_gamarjoba/include.c diff --git a/linker.ld b/common/linker.ld similarity index 100% rename from linker.ld rename to common/linker.ld diff --git a/multiboot_header.asm b/common/multiboot_header.asm similarity index 100% rename from multiboot_header.asm rename to common/multiboot_header.asm diff --git a/x86_vram.asm b/common/x86_vram.asm similarity index 94% rename from x86_vram.asm rename to common/x86_vram.asm index e8fce38..680c724 100644 --- a/x86_vram.asm +++ b/common/x86_vram.asm @@ -1,3 +1,5 @@ +%ifndef X86_VRAM_ASM +%define X86_VRAM_ASM ; x86 video stuff ; each character cell is a 16 bit word @@ -31,3 +33,4 @@ %define BG.GRAY 7 << 12 %define BG.BRIGHT 8 << 12 +%endif diff --git a/x86_vram_functions.asm b/common/x86_vram_functions.asm similarity index 100% rename from x86_vram_functions.asm rename to common/x86_vram_functions.asm diff --git a/justfile b/justfile index d505ac3..5826821 100644 --- a/justfile +++ b/justfile @@ -7,3 +7,16 @@ run_gamarjoba: build_gamarjoba build_gamarjoba: nasm -f elf64 -o gamarjoba_munde/gamarjoba.o gamarjoba_munde/gamarjoba.asm ld -o gamarjoba_munde/gamarjoba gamarjoba_munde/gamarjoba.o + +build_baremetal_gamarjoba: + #!/usr/bin/env bash + cd baremetal_gamarjoba + gcc -m32 -ffreestanding -o include.o -c include.c + nasm -f elf32 -i ../common baremetal_gamarjoba.asm + ld -m elf_i386 -nostdlib -T ../common/linker.ld baremetal_gamarjoba.o include.o -o baremetal_gamarjoba + + +run_baremetal_gamarjoba: build_baremetal_gamarjoba + #!/usr/bin/env bash + cd baremetal_gamarjoba + qemu-system-i386 -kernel baremetal_gamarjoba