diff --git a/README.md b/README.md index faf0314..9c44520 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ A hobby OS written in Nim. * nim * nimble (* or use other nake install method) * clang -* nasm * grub2 * qemu diff --git a/kernel/arch/i386/boot.s b/kernel/arch/i386/boot.s index 21f0c4f..8da6d9e 100644 --- a/kernel/arch/i386/boot.s +++ b/kernel/arch/i386/boot.s @@ -1,31 +1,27 @@ -; http://wiki.osdev.org/Bare_Bones_with_NASM -MBALIGN equ 1<<0 ; align loaded modules on page boundaries -MEMINFO equ 1<<1 ; provide memory map -FLAGS equ MBALIGN | MEMINFO ; this is the Multiboot 'flag' field -MAGIC equ 0x1BADB002 ; 'magic number' lets bootloader find the header -CHECKSUM equ -(MAGIC + FLAGS) ; checksum of above, to prove we are multiboot +# http://wiki.osdev.org/Bare_Bones_with_NASM +.set MBALIGN, 1<<0 # align loaded modules on page boundaries +.set MEMINFO, 1<<1 # provide memory map +.set FLAGS, MBALIGN | MEMINFO # this is the Multiboot 'flag' field +.set MAGIC, 0x1BADB002 # 'magic number' lets bootloader find the header +.set CHECKSUM,-(MAGIC + FLAGS) # checksum of above, to prove we are multiboot -section .multiboot -align 4 - dd MAGIC - dd FLAGS - dd CHECKSUM +.section .multiboot +.align 4 +.long MAGIC +.long FLAGS +.long CHECKSUM -section .bss -align 16 +.section .bss stack_bottom: -resb 16384 ; 16 KiB +.skip 16384 # 16 KiB stack_top: -section .text -global _start:function (_start.end - _start) +.section .text +.global _start +.type _start, @function _start: - - mov esp, stack_top - - extern kernel_main + mov $stack_top, %esp call kernel_main - cli .hang: hlt jmp .hang diff --git a/nakefile.nim b/nakefile.nim index 1ef6f9a..c1e5197 100644 --- a/nakefile.nim +++ b/nakefile.nim @@ -17,7 +17,7 @@ task "clean", "Removes build files.": task "bootloader", "Builds the bootloader.": echo "Building bootloader." - direShell("nasm -felf32 kernel/arch/i386/boot.s -o boot.o") + direShell("clang -c --target=i386-pc-none-elf kernel/arch/i386/boot.s -o boot.o") echo "Done." task "build", "Builds the operating system.":