FASM module building

BlitzMax Forums/BlitzMax Programming/FASM module building

TeraBit(Posted 2009) [#1]
Hi All,

I have a bunch of assembly routines that I would like to turn into a module. They are written in FASM and I can output them as a DLL and get them to run with BlitzMax in that way, but I wanted to turn it into a module directly.

How do I go about making (out of the assembly code of course) the pair of files:

MyLib.win32.x86.a
MyLib.win32.x86.i

which are required for a module using FASM?

FASM can optionally export the procdures as a COFF .OBJ file. Is there some way of converting that to pair of '.a & .o' files?


TeraBit(Posted 2009) [#2]
Ok.. I've got further. I've output as a COFF .OBJ file.

I then use the MingW AR.EXE to package that as a '.A' file, like so...

AR.EXE vrc test.release.x86.a Test.obj
which seems to output the 'test.release.x86.a' file in the correct format.

I have also added a test.release.x86.i file which consists of:
AddOne%(obj%)&=mem:p("AddOne@4")
matching the signature (I think) of my FASM proc:

public AddOne as "AddOne@4"

Upon trying to use the module I get the error:
Compile Error: Can't find interface for module 'tera.AsmMod'


I've got this nagging feeling I'm going about this the wrong way...


zzz(Posted 2009) [#3]
Try importing the assembly into a bmax file instead and let the bmk utility worry about those files.


Brucey(Posted 2009) [#4]
Yeah, just do something like

Import "mysource.s"

which should work...


TeraBit(Posted 2009) [#5]
I think that's what was worrying me. I was sure that you could simply import it. But what I'm getting is this:

The test.s file:


The AsmLib.bmx module file:


When I import it and try to use the AddOne function, it reports:
C:/Projects/Integrate/.bmx/test.bmx.gui.release.win32.x86.o:
undefined reference to `AddOne'


The module appears to build ok, but I'm missing something about the naming somewhere (admittedly it's been a while since I've done much with this kind of thing.)


zzz(Posted 2009) [#6]
Try adding an underscore in front of the procedure names in the assembly source. Not really sure why, guess the linker wants it that way, but it should make it work.


TeraBit(Posted 2009) [#7]
Try adding an underscore in front of the procedure names in the assembly source. Not really sure why, guess the linker wants it that way, but it should make it work.


That works! Thanks.

I'll post a working example mod when I've tidied it up a bit.