I am trying to do some low level programming using NASM. I know a fair amount of Assembly, and trying to compile what I think is perfectly sound code results in:
loader.s:8 : error: parser: instruction expected
What is wrong here? Here is my code:
global loader ; the entry symbol of the program
MAGIC_NUMBER equ 0x1BADB002 ; define the magic number constant
FLAGS equ 0x0 ; multiboot flags
CHECKSUM equ -MAGIC_NUMBER ; calculate the checksum
; (magic number + checksum + flags should equal 0)
KERNEL_STACK SIZE equ 4096 ; size of stack (4096 bytes or four kilobytes)
section .bss ; bss section for uninitialized values
align 4 ; the code must be aligned by 4 bytes
kernel_stack: ; label points to the beginnning of memory
resb KERNEL_STACK_SIZE ; reserve stack for the kernel
section .text ; the text section is where code is run
align 4 ; the code must be aligned by 4 bytes
dd MAGIC_NUMBER ; write the magic number to the machine code,
dd FLAGS ; the flags number,
dd CHECKSUM ; the checksum too
loader: ; the loader label, where the programstarts executing
mov eax, 0xCAFEBABE ; move the value 0xCAFEBABE to EAX
mov esp, kernel_stack + KERNEL_STACK_SIZE ;point kernel to top of stack
.loop:
jmp .loop ; loop forever (since this is a kernel, and it has to)