473,387 Members | 1,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

GCC on FreeBSD - C and ASM

I have a few old routines written in Intel ASM; years ago they were
used inline a C-program. Now I find that to use inline-assembler with
GCC I have to use AT&T ASM. I figured the easiest solution would be to
simply put all the assembler in its own clean file, build that, and
link it to the C (from whence I'd be able to call the ASM routines). I
hope I'm not imaginatively expanding on the concept of linked object
files. It seems I >should< be able to call the assembler from the C.
How? Any decent resources on the topic?

Thanks!
- Elliot :)
Nov 14 '05 #1
3 1592
Push the arguments in the stack

int a = myasm_routine(arg1,arg2,arg3);

Supposing word size args (32 bits) the asm
routine will find the args at esp+4,esp+8,esp+12,etc

That's all.

How is the ASM routine reading its input?

Does it expect it in some special places like
registers or like?

If yes, add an interface asm code like this:
; routine expects args in eax,edx
; put arg1 in eax
movl 4(%esp),%eax
; put arg2 in edx
movl 8(%esp),%edx
call original_asm_routine
ret

Use the -S option of your compiler and look
at the generated assembler.

Good luck

Nov 14 '05 #2
"jacob navia" <ja***@jacob.remcomp.fr> writes:
Push the arguments in the stack

int a = myasm_routine(arg1,arg2,arg3);

Supposing word size args (32 bits) the asm
routine will find the args at esp+4,esp+8,esp+12,etc

That's all.

How is the ASM routine reading its input?

Does it expect it in some special places like
registers or like?

If yes, add an interface asm code like this:
; routine expects args in eax,edx
; put arg1 in eax
movl 4(%esp),%eax
; put arg2 in edx
movl 8(%esp),%edx
call original_asm_routine
ret

Use the -S option of your compiler and look
at the generated assembler.


I suppose the OP is probably using an x86 system, but I can't be
certain; it may be obvious from the context, but not to me.

I have no idea whether Jacob's response is correct, because he's
really talking about assembly language, not about C.

Which is why both the question and the answer really belong in a
system-specific newsgroup, where it can be discussed intelligently,
rather than here in comp.lang.c, where it's off-topic.

I can understand the OP making that mistake; it happens all the time,
and the usual (and proper) response is to suggest a better place to
get help.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #3
Serpent wrote:
I have a few old routines written in Intel ASM; years ago they were
used inline a C-program. Now I find that to use inline-assembler with
GCC I have to use AT&T ASM. I figured the easiest solution would be to
simply put all the assembler in its own clean file, build that, and
link it to the C (from whence I'd be able to call the ASM routines). I
hope I'm not imaginatively expanding on the concept of linked object
files. It seems I >should< be able to call the assembler from the C.
How? Any decent resources on the topic?

Thanks!
- Elliot :)


Check out NASM and it's related website.

Brian
Nov 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: siliconmike | last post by:
http://dev.mysql.com/doc/mysql/en/freebsd.html says: You can link MySQL on FreeBSD 4.x against the LinuxThreads library, which avoids a few of the problems that the native FreeBSD thread...
13
by: Uwe Mayer | last post by:
<posted & mailed> Hi, AFAICT there seems to be a bug on FreeBSD's Python 2.3.4 open function. The documentation states: > Modes 'r+', 'w+' and 'a+' open the file for updating (note that...
3
by: Kim Pedersen | last post by:
Hello list I use Gentoo (linux) but is considering shifting to FreeBSD. Is Java 1.5 fully supported under FreeBSD (netbeans, eclipse etc)? Regards Kim
0
by: Bill Moran | last post by:
I'm having some problems. Hopefully there are some FreeBSD folks here that can help me out, if not, I'll try the FreeBSD lists next. I'm running Postgres 7.4 installed from a just cvsupped...
1
by: Vyacheslav Sotnikov | last post by:
Hello python-list, is anybody has any success in taking this components live together? I need to access remote Oracle 9i from freebsd 6.2 machine using python 2.4.4. Thanks in advance for answer.
4
by: robert | last post by:
When i freeze a python app (simple - no strange sys calls) for x86 Linux, does this stuff run well also on x86 FreeBSD? Robert
2
by: Ruslan A Dautkhanov | last post by:
Hello ! I'm about to install O9i on FreeBSD box. uname -a: FreeBSD stat2.scn.ru 5.2.1-RELEASE-p3 FreeBSD 5.2.1-RELEASE-p3 #2: Fri Apr 23 19:19:43 KRAST 2004...
0
by: Akira Kitada | last post by:
Hi list, I was trying to build Python 2.6 on FreeBSD 4.11 and found it failed to build some of the modules. """ Failed to find the necessary bits to build these modules: _bsddb ...
0
by: Akira Kitada | last post by:
Hi Marc-Andre, Thanks for the suggestion. I opened a ticket for this issue: http://bugs.python.org/issue4204 Now I understand the state of the multiprocessing module, but it's too bad to see...
0
by: M.-A. Lemburg | last post by:
On 2008-10-25 20:19, Akira Kitada wrote: Thanks. The errors you are getting appear to be related to either some missing header files or a missing symbol definition to enable these - looking...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.