flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > High Level Languages > interface C-ASM

Author
Thread Post new topic Reply to topic
alessandro95



Joined: 24 Mar 2013
Posts: 62
interface C-ASM
I started studying C recently, using gcc as compiler, but I found out that it uses AT&T syntax for inline ASM, which is simply horrible!

So I would like to write my ASM functions in a file and then call them from another C file, anyone knows how to do that?
I think I read something about this in the forum but I cannot find it anymore...

Thank in advance!
Post 03 May 2013, 01:40
View user's profile Send private message Reply with quote
Bob++



Joined: 12 Feb 2013
Posts: 92
Currently gcc supports intel's assembly syntax. Not only output it,inline too.
Put this

Code:
.intel_syntax noprefix

before intel's assembly,and use

Code:
-masm=intel

.
But don't forget to switch back to ATT's assembly after:

Code:
.att_syntax noprefix



EDIT:

To use non-inline assembly routines with gcc,it's very simple. Make you assembly generate objcode(on FASM,see "format" section from fasm's documentation) code and then compile with gcc to an executable as following:

Code:
gcc foo.o etc.c -o exe

Post 03 May 2013, 01:54
View user's profile Send private message Reply with quote
alessandro95



Joined: 24 Mar 2013
Posts: 62
Thanks a lot for the fast answer, I prefer to use non-inline assembly so I have some other questions:

Should the assembly routines have some particular name? (begin with underscore or something)

How do I pass parameters?

And if there is a return value where should it be?

The compiler deals with the values of registers or my routines should worry about restoring them?

If you could make me a very basic example, a function that adds two values and return the sum or something like that, I would find it truly useful since I know really a little of C!
Thank again!
Post 03 May 2013, 02:14
View user's profile Send private message Reply with quote
TmX



Joined: 02 Mar 2006
Posts: 773
Location: Jakarta, Indonesia
Maybe you'd like to try this:
http://www.flatassembler.net/examples/msvc.zip

Very Happy
Post 03 May 2013, 02:26
View user's profile Send private message Reply with quote
alessandro95



Joined: 24 Mar 2013
Posts: 62
That does look exactly what I was searching for, thanks a lot!

I'll look at this files, I'll post here again in case I still have some doubts Smile
Post 03 May 2013, 02:30
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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.