flat assembler
Message board for the users of flat assembler.

Index > OS Construction > fasm and Grub

Author
Thread Post new topic Reply to topic
flash



Joined: 11 Mar 2006
Posts: 55
Location: Cuba
flash 24 Mar 2012, 03:37
I am testing a Grub boot fasm code with a "stolen" nasm one. But i am having some troubles with a label address(i think) at "multiboot_entry" for example:
Code:
;
; Imagen de CD arrancable, para compilar con fasm
;

MULTIBOOT_HEADER_MAGIC     equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS        equ 0x00010011
CHECKSUM                              equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
LOADBASE                              equ 0x00100000
STACK_SIZE              equ 0x4000
org LOADBASE

                    jmp             multiboot_entry
                     align   4

multiboot_header:
                      dd MULTIBOOT_HEADER_MAGIC
                   dd MULTIBOOT_HEADER_FLAGS
                   dd CHECKSUM
                 dd multiboot_header
                 dd LOADBASE
                 dd 00
                       dd 00
                       dd multiboot_entry
     
multiboot_entry:
                 mov             esp,pila + STACK_SIZE
                       push    0
                   popf
                        push    ebx

                     mov             edi,0B8000h
                 mov             cx,2000
     clrscr:     mov             [edi],byte ' '
                    add             edi,2
                       loop    clrscr
                      
                    include 'code.asm'
pila:
                   align   4
                   times (STACK_SIZE) db 0
    


The thing is that exactly same code works fine with nasm. What could be wrong with label address?

_________________
i don't hate goto
Post 24 Mar 2012, 03:37
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20335
Location: In your JS exploiting you and your system
revolution 24 Mar 2012, 04:03
Your loadbase is at 1M. 16-bit code cannot jump to an address above 0xffff. Did you forget to place use32 at the start?
Post 24 Mar 2012, 04:03
View user's profile Send private message Visit poster's website Reply with quote
flash



Joined: 11 Mar 2006
Posts: 55
Location: Cuba
flash 25 Mar 2012, 00:15
Thank's revolution, that's solve the problem!
But... i though fasm compiles 32bit code by default Sad
Good to know Smile
Post 25 Mar 2012, 00:15
View user's profile Send private message Reply with quote
egos



Joined: 10 Feb 2009
Posts: 144
egos 25 Mar 2012, 20:26
Grub supports BSS so no reason to put the bits into the file to reserve space for stack.
Code:
; --------------------
; Kernel stub for GRUB
; --------------------

MBH_MAGIC equ 0x1BADB002
MBH_FLAGS equ 0x10000

  use32

  org 0x100000
load_addr:
header_addr:
  dd MBH_MAGIC
  dd MBH_FLAGS
  dd -MBH_MAGIC-MBH_FLAGS
  dd header_addr
  dd load_addr
  dd load_end_addr
  dd bss_end_addr
  dd entry_addr

entry_addr:
  jmp $

load_end_addr:
; align 4
; rb STACK_SIZE
bss_end_addr:
    
Post 25 Mar 2012, 20:26
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4333
Location: Now
edfed 25 Mar 2012, 21:44
as x86 is real mode 16 bits by default, fasm compiles in 16bits by default too.

don't know if it's for that reason, but if somebody asks, i think it can be a good answer cause it's logical.

welcome in the flat assembly orthogonal universe. (not parallel, parallel means same direction) Smile
Post 25 Mar 2012, 21:44
View user's profile Send private message Visit poster's website Reply with quote
flash



Joined: 11 Mar 2006
Posts: 55
Location: Cuba
flash 28 Mar 2012, 04:53
mmmm... the conclusion is something like: put allways "usexx" directive at binary code Wink
Post 28 Mar 2012, 04:53
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.