flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > Calling FASM code from D example

Author
Thread Post new topic Reply to topic
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY
Hi guys!
Here it is an example of calling FASM code from D.
I've created a simple hello world function in FASM and assembled as DLL.
Then I've created a D source file showing how to call this function.

I hope you like it and try the D language (it's really nice).
Now you see how to mix D and FASM, so no excuse to not use it! Very Happy

Source codes and executables are in zip file.
Enjoy!

Step 1
Assembling:
Quote:

fasm fasmdll.asm


Step 2
Compiling D code:
1) Get DMD at www.digitalmars.com
2) Install it following the site instructions
3) Compile like this:
Quote:

dmd dpart.d -O -release


Step 3
Run dpart.exe


PS: Soon, I'll add an example of static linking as soon as I find a way to deal with OMF object files.


Description: fasmdll.asm - DLL fasm source
dpart.d - D main program source

Download
Filename: DandFASMex.zip
Filesize: 51.31 KB
Downloaded: 466 Time(s)

Post 16 Dec 2006, 02:38
View user's profile Send private message Reply with quote
Vortex



Joined: 17 Jun 2003
Posts: 318
Vortex
You should try to convert OMF modules to MS COFF with the help of the MS linker :

Code:
link -edit objfile.obj    

_________________
Code it... That's all...
Post 16 Dec 2006, 08:25
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
so this is in fact example of calling DLL (written in FASM) from D?
Post 17 Dec 2006, 02:10
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY
Yes, but there are some tricks in the D code to make it possible to import the functions.
Post 17 Dec 2006, 17:27
View user's profile Send private message Reply with quote
MCD



Joined: 21 Aug 2004
Posts: 604
Location: Germany
MCD
OzzY wrote:

I hope you like it and try the D language (it's really nice).

I had a glance at the language specification of D, and since then I recognized that it would be the best (available) HLL successor for the C language, as C#, java... are all to bloated for me and they force you to use OOP on everything.

1 concern I had in the D language was the garbage collection, but this seems quiet better implemented as in java and can also be switched off completely.

I was wondereing if there are yet SIMD-libraries (MMX,SSE...) for D yet, cause I like using them (for graphics for example). Anyway, those SIMD stuff can easily be written in fasm anyway.

_________________
MCD - the inevitable return of the Mad Computer Doggy

-||__/
.|+-~
.|| ||
Post 26 Dec 2006, 07:05
View user's profile Send private message Reply with quote
nermest



Joined: 15 Sep 2006
Posts: 1
nermest
btw, you don't have to create dll for using C-like functions(from C or fasm sources)!

extern (C) fasm_func(char val, char*vals, int num);
Post 07 Jul 2007, 14:22
View user's profile Send private message Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY
nermest wrote:
btw, you don't have to create dll for using C-like functions(from C or fasm sources)!

extern (C) fasm_func(char val, char*vals, int num);


The problem is that fasm doesn't produce OMF. So we need to convert COFF->OMF in some way. Do you know any tool?
Post 19 Jan 2008, 21:18
View user's profile Send private message Reply with quote
Uwar



Joined: 09 Oct 2009
Posts: 11
Uwar
DigitalMars: coff2omf or Agner Fog http://www.agner.org/optimize/objconv.zip
Post 13 Oct 2009, 18:19
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-2020, Tomasz Grysztar.

Powered by rwasa.