Page 1 of 1

OSDever Kernel Error with NASM

Posted: Sun May 29, 2011 5:25 pm
by ChosenOreo
I followed the kernel tutorial at http://www.osdever.net/bkerndev/Docs/basickernel.htm, and I recieved the two errors:

Code: Select all

start.asm:20: error: symbol 'MULTIBOOT_HEADER_MAGIC' undefined
start.asm:24: error: symbol 'MULTIBOOT_HEADER_MAGIC' undefined
My Assembly code is as follows:

Code: Select all

; This is the kernel's entry point. We could either call main here,
; or we can use this to setup the stack or other nice stuff, like
; perhaps setting up the GDT and segments. Please note that interrupts
; are disabled at this point: More on interrupts later!
[BITS 32]
global start
start:
    mov esp, sys_stack     ; This points the stack to our new stack area
    jmp stublet

; This part MUST be 4byte aligned, so we solve that issue using 'ALIGN 4'
ALIGN 4
mboot:
    ; Multiboot macros to make a few lines later more readable
    MULTIBOOT_PAGE_ALIGN	equ 1<<0
    MULTIBOOT_MEMORY_INFO	equ 1<<1
    MULTIBOOT_AOUT_KLUDGE	equ 1<<16
    MULTIBOOT_HEADER_MAGIC	equ 0x1BADB002
    MULTIBOOT_HEADER_FLAGS	equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE
    MULTIBOOT_CHECKSUM	equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
    EXTERN code, bss, end

    ; This is the GRUB Multiboot header. A boot signature
    dd MULTIBOOT_HEADER_MAGIC
    dd MULTIBOOT_HEADER_FLAGS
    dd MULTIBOOT_CHECKSUM
    
    ; AOUT kludge - must be physical addresses. Make a note of these:
    ; The linker script fills in the data for these ones!
    dd mboot
    dd code
    dd bss
    dd end
    dd start

; This is an endless loop here. Make a note of this: Later on, we
; will insert an 'extern _main', followed by 'call _main', right
; before the 'jmp $'.
stublet:
    jmp $


; Shortly we will add code for loading the GDT right here!


; In just a few pages in this tutorial, we will add our Interrupt
; Service Routines (ISRs) right here!



; Here is the definition of our BSS section. Right now, we'll use
; it just to store the stack. Remember that a stack actually grows
; downwards, so we declare the size of the data before declaring
; the identifier '_sys_stack'
SECTION .bss
    resb 8192               ; This reserves 8KBytes of memory here
sys_stack:
Any Help?

-ChosenOreo

Re: OSDever Kernel Error with NASM

Posted: Sun May 29, 2011 5:52 pm
by bluemoon

Code: Select all

nasm -felf -o a.o a.nasm
I copy&paste exactly your code and see no error. I'm using nasm on mac, NASM version 2.09.02 compiled on Sep 17 2010
What's your nasm version?

Re: OSDever Kernel Error with NASM

Posted: Sun May 29, 2011 6:12 pm
by ChosenOreo
I'm using NASM on Xubuntu 11.04 Natty Narwhal

My version is 2.09.04 - Compiled Nov 26 2010

I compiled it with:

Code: Select all

nasm -f aout -o start.o start.asm

Re: OSDever Kernel Error with NASM

Posted: Sun May 29, 2011 8:20 pm
by Brendan
Hi,

I can't see a problem, and because bluemoon didn't have a problem either it makes me wonder if the problem can't be seen.

For example, sometimes when you copy & paste from a web page you get strange white-space characters (like the "non-breaking space" character, and the '\r' linefeed character) and (especially if your text editor supports Unicode) you end up with the strange white-space characters in your source code; and some tools don't like them.


Cheers,

Brendan

Re: OSDever Kernel Error with NASM

Posted: Sun May 29, 2011 8:24 pm
by ChosenOreo
I typed it letter by letter... I wonder if I missed something. I'll try copying the code over, and I'll see if it works!

Re: OSDever Kernel Error with NASM

Posted: Sun May 29, 2011 8:57 pm
by Chandra
ChosenOreo wrote:I typed it letter by letter...
which makes me guess that you mistyped the macro MULTIBOOT_HEADER_MAGIC. All you have to do now is to copy and paste the whole code and see if that works :lol:

Re: OSDever Kernel Error with NASM

Posted: Sun May 29, 2011 10:54 pm
by ChosenOreo
Nope, same error...
What is going on...

Re: OSDever Kernel Error with NASM

Posted: Mon May 30, 2011 12:13 am
by neon
bah, just replace MULTIBOOT_HEADER_MAGIC on lines 20 and 24 with 0x1BADB002....And dont copy and paste anymore. Alternatively use a %define.

Re: OSDever Kernel Error with NASM

Posted: Mon May 30, 2011 12:16 am
by Brendan
Hi,
ChosenOreo wrote:Nope, same error...
What is going on...
I cut & pasted it and assembled it "as is" with no errors; using NASM 2.09.04 under Gentoo, and "nasm -f aout -o start.o start.asm".

Maybe your makefile is assembling an old/different version or something.


Cheers,

Brendan