flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Error on my ASM code

Author
Thread Post new topic Reply to topic
Tivoilos



Joined: 07 Jan 2010
Posts: 1
Tivoilos 08 Jan 2010, 00:01
I am working on a basic Kernel construction for a upcomming OS I am working on an need a little bit of help.

Code:
; 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:
    


I am getting a error at

Code:
dd MULTIBOOT_CHECKSUM    


any ideas why it might come up as a invalid expression?
Post 08 Jan 2010, 00:01
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 08 Jan 2010, 00:34
I had to made the following modifications to make the error stop in fasm:
Code:
    ; Multiboot macros to make a few lines later more readable
    MULTIBOOT_PAGE_ALIGN        equ (1 shl 0)
    MULTIBOOT_MEMORY_INFO       equ (1 shl 1)
    MULTIBOOT_AOUT_KLUDGE       equ (1 shl 16)
    MULTIBOOT_HEADER_MAGIC      equ 0x1BADB002
    MULTIBOOT_HEADER_FLAGS      equ MULTIBOOT_PAGE_ALIGN or MULTIBOOT_MEMORY_INFO or MULTIBOOT_AOUT_KLUDGE
    MULTIBOOT_CHECKSUM  equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)      


In your assembler probably will be enough to add parentheses in the first three constants.

PS: Well it turns out that the parentheses were not needed in fasm to make it work but yet you add them always for EQUs when them are calculations rather than simple numbers to avoid undesired effects.
Post 08 Jan 2010, 00:34
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.