flat assembler
Message board for the users of flat assembler.

Index > Main > How to export a symbol in FASM?

Author
Thread Post new topic Reply to topic
AlectronikLabs



Joined: 11 Jan 2023
Posts: 1
AlectronikLabs 11 Jan 2023, 20:23
I am looking for a way to export and import symbols, for interfacing with C and both call FASM code from C as well as the other way round. Sorry if this has already been asked but I've been searching quite a bit both here on the board as well as with google and couldn't find anything FASM related.

In NASM the equivalent would be
Code:
global XY    
.

Many thanks in advance! Wink
Post 11 Jan 2023, 20:23
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8358
Location: Kraków, Poland
Tomasz Grysztar 11 Jan 2023, 21:01
There has been a recent thread about this: https://board.flatassembler.net/topic.php?t=22496

In short, you need to use object output (COFF or ELF), "public" directive to export symbols, and "extrn" directive to import symbols. The old FAQ also had a macro that emulated "global":
Code:
   macro global [symbol]
    {
     local isextrn,isglobal
     if defined symbol & ~ defined isextrn
       public symbol
     else if used symbol & defined isglobal
       extrn symbol
       isextrn = 1
     end if
     isglobal = 1
    }    
Post 11 Jan 2023, 21:01
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.