FASM module building

BlitzMax Forums/BlitzMax Programming/FASM module building

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?

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...

Try importing the assembly into a bmax file instead and let the bmk utility worry about those files.

Yeah, just do something like

Import "mysource.s"

which should work...

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:
format MS COFF
include 'C:\fasm\include\win32a.inc'
section "code" code ;readable executable

public AddOne as "AddOne"

proc AddOne num 	   ;Testing
	pusha
	mov eax,[num]
	mov edx,[eax]
	inc edx
	mov [eax],edx

	popa
	ret
endp


The AsmLib.bmx module file:
Module terabit.asmlib

ModuleInfo "Version: 0.1"
ModuleInfo "Author: Lee Page"
ModuleInfo "License: Public Domain"
ModuleInfo "Modserver: terabit"

Import "test.s"

extern
Function AddOne(a:Int)="AddOne"
end extern


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.)

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.

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.