flat assembler
Message board for the users of flat assembler.

Index > Main > Invalid use of symbol using format elf and use16

Author
Thread Post new topic Reply to topic
MAD_DËMON



Joined: 03 Mar 2006
Posts: 23
MAD_DËMON
I think that fasm has a bug that makes impossible to assemble control transfers instructions that make use of relative addresing

I tried to compile a little test code that uses elf format and use16
but it produces error

Code:
format elf

use16

public start

SECTION '.text'

start:
 call atoi
 ret

atoi:
 mov ax,bx
    


Error Message:

test.asm [13]:
call atoi
error: invalid use of symbol.

I ported this code to nasm and it compiles fine to elf format, then I linked it with ld to output binary and I checked the opcodes and the displacement value of the call instruction and it's fine in the binary output file, the elf format worked with 16 bit code
Post 24 Sep 2006, 22:38
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7756
Location: Kraków, Poland
Tomasz Grysztar
This is actually the same thing that was discussed here: http://board.flatassembler.net/topic.php?t=5703
Post 24 Sep 2006, 23:03
View user's profile Send private message Visit poster's website Reply with quote
MAD_DËMON



Joined: 03 Mar 2006
Posts: 23
MAD_DËMON
I have found how to fix this issue hopefully, declaring 'org $0' inside the text section, so it compiles fine now
Post 25 Sep 2006, 16:45
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7756
Location: Kraków, Poland
Tomasz Grysztar
However this way you disable the relocations. And if you don't need the relocations, why not use direct binary output instead of object?
Post 25 Sep 2006, 17:32
View user's profile Send private message Visit poster's website Reply with quote
MAD_DËMON



Joined: 03 Mar 2006
Posts: 23
MAD_DËMON
Tomasz Grysztar wrote:
However this way you disable the relocations. And if you don't need the relocations, why not use direct binary output instead of object?


becuase binary format in fasm doesn't allow me the use of sections, I think that nasm was able of this, I need to keep the code and data isolated in format binary, without matterring in which place of the source they are declared, as I'm trying to keep my sources in modules and each source module has code and data.
Post 25 Sep 2006, 18:11
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
I think he means using "format elf executable" (which allows the use of sections too).
Post 25 Sep 2006, 18:17
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7756
Location: Kraków, Poland
Tomasz Grysztar
MAD_DËMON wrote:
becuase binary format in fasm doesn't allow me the use of sections, I think that nasm was able of this, I need to keep the code and data isolated in format binary, without matterring in which place of the source they are declared, as I'm trying to keep my sources in modules and each source module has code and data.

So you link the few objects, each with code and data section into one? The you won't be able to cross-reference the code and data between different files if you disable the relocations.
Post 25 Sep 2006, 18:23
View user's profile Send private message Visit poster's website Reply with quote
MAD_DËMON



Joined: 03 Mar 2006
Posts: 23
MAD_DËMON
well, so then I think that the best solution is that I need a way for put all declared data in a position ahead of all code, without mattering the place where the data is declared using format binary directive.
Post 25 Sep 2006, 20:07
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7756
Location: Kraków, Poland
Tomasz Grysztar
The idea of flat binary formatter is that the structure and order of the source exactly reflects the structure and order of the resulting file. This is a kind of WYSIWYG applied to assembly. Wink Very Happy
Post 25 Sep 2006, 20:51
View user's profile Send private message Visit poster's website 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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.