flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > How do you link MS Visual Studio C/C++ with Fasm ?

Author
Thread Post new topic Reply to topic
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
Can anyone provide any example or way to actually do this ? I need a way urgently... because I need to work on a paid project with a company ... thanks Smile
Post 17 Nov 2006, 12:24
View user's profile Send private message Reply with quote
Raedwulf



Joined: 13 Jul 2005
Posts: 375
Location: United Kingdom
Raedwulf
Well, what sort of source code are you using... C or C++.
Have you got a FASM source file? You will need to assemble FASM src as MSCOFF object format...

More details please so we can give you more specific answers.
Post 17 Nov 2006, 12:36
View user's profile Send private message MSN Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
in FASM, create MS COFF file. there, declare your procedure as public:
Code:
proc string, size
...
endp
public myproc as '_myproc'    

in C, declare it:
Code:
extern "C" {
myproc(char*, int);
}    

and link it with OBJ file created from FASM source. In visual studio, it's (i think):

project context menu (right click on project) -> properties -> Link -> additional dependencies
Post 17 Nov 2006, 16:37
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Maverick



Joined: 07 Aug 2006
Posts: 251
Location: Citizen of the Universe
Maverick
By the way, does somebody happen to have some good docs about the MSCOFF object format produced and used by VisualC 8.0?
Post 17 Nov 2006, 17:07
View user's profile Send private message Visit poster's website Reply with quote
wisepenguin



Joined: 30 Mar 2005
Posts: 129
wisepenguin
i had a topic on the board a while ago about using FASM within
the 2005 IDE, and actually compile the fasm source code within
msvc2005 with asm syntax colouring.

i will try and find it for you, or search for "fasm 2005 ide" or similar
on the board
Post 17 Nov 2006, 19:54
View user's profile Send private message Reply with quote
wisepenguin



Joined: 30 Mar 2005
Posts: 129
wisepenguin
Post 17 Nov 2006, 19:58
View user's profile Send private message Reply with quote
Quantum



Joined: 24 Jun 2005
Posts: 122
Quantum
vid
Quote:

extern "C"

That works in C++ only. In plain C you have to use just extern (not required in most cases, because all unknown functions are assumed to be extern by default). So, to make it compatible with both C and C++, some preprocessing is required:
Code:
#ifdef __cplusplus
        extern "C" {
#endif
int myproc(void); 
#ifdef __cplusplus
        }
#endif
    


Maverick
http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx


Last edited by Quantum on 20 Nov 2006, 01:27; edited 1 time in total
Post 18 Nov 2006, 14:47
View user's profile Send private message Reply with quote
Maverick



Joined: 07 Aug 2006
Posts: 251
Location: Citizen of the Universe
Maverick

Thanks a lot, Quantum Smile

And many thanks also to sleepsleep who emailed the files this morning. Smile

_________________
Greets,
Fabio
Post 18 Nov 2006, 16:01
View user's profile Send private message Visit poster's website Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
So,Quantum... that works without any modification to it?
Post 19 Nov 2006, 19:18
View user's profile Send private message Reply with quote
Quantum



Joined: 24 Jun 2005
Posts: 122
Quantum
In FASM:
Code:
public myproc as '_myproc'
myproc:
mov eax,5
ret
    


In C:
+ the example above
Code:
printf("%d", myproc());
    


Prints out: 5
Post 20 Nov 2006, 01:26
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. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.