* Using gcc to compiler assembly
@ 2002-11-02 23:08 Andrew Haydon
2002-11-03 18:26 ` Maciej Hrebien
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Haydon @ 2002-11-02 23:08 UTC (permalink / raw)
To: linux-assembly
[-- Attachment #1: Type: text/plain, Size: 495 bytes --]
Gurus,
How to use GCC compiling assembly codes? I attached my example code and
tried gcc -c -o foo.o foo.S. This line "typedef foo_bar_t int;" choked. I
read the Makefiles for linux kernel and still could not understand how these
assebmly codes were compiled by GCC.
Thanks in advance,
Andrew
_________________________________________________________________
Unlimited Internet access -- and 2 months free!��� Try MSN.
http://resourcecenter.msn.com/access/plans/2monthsfree.asp
[-- Attachment #2: foo.h --]
[-- Type: application/octet-stream, Size: 80 bytes --]
#ifndef FOO_H
#define FOO_H
typedef foo_bar_t int;
#define FOO_BAR 100
#endif
[-- Attachment #3: foo.S --]
[-- Type: application/octet-stream, Size: 47 bytes --]
#include "foo.h"
.text
movl $ FOO_BAR, %eax
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Using gcc to compiler assembly
2002-11-02 23:08 Using gcc to compiler assembly Andrew Haydon
@ 2002-11-03 18:26 ` Maciej Hrebien
0 siblings, 0 replies; 3+ messages in thread
From: Maciej Hrebien @ 2002-11-03 18:26 UTC (permalink / raw)
To: linux-assembly
Andrew Haydon wrote:
>
> How to use GCC compiling assembly codes? I attached my example code and
> tried gcc -c -o foo.o foo.S. This line "typedef foo_bar_t int;" choked.
Yes, "typedef" isn't assembly directive nor asm instruction.
> I
> read the Makefiles for linux kernel and still could not understand how these
> assebmly codes were compiled by GCC.
Some of them are only preporcessed by gcc (-E flag) and then send to the
assembler, linker... Maybe asm code is passed to gcc streight, i don't
remember, but notice that the code isn't mixed in form Your example is.
If You mix C & assembly code try C's asm keyword, ie:
void foo()
{
double a;
/* ... */
asm("fsin" : "=st" (a));
}
For details on how to pass arguments to asm() see gcc's man page.
It's the first solution. The second one is to separate Your asm and C
code in their own files. Assemble Your low level code to *.o and then
pass it to the C compiler. I think it's better solution but of course
it's Your code.
Regards,
--
Maciej Hrebien
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: Using gcc to compiler assembly
@ 2002-11-03 20:19 Joseph D. Wagner
0 siblings, 0 replies; 3+ messages in thread
From: Joseph D. Wagner @ 2002-11-03 20:19 UTC (permalink / raw)
To: Linux Assembly Programming List
What you've got isn't pure Assembly; it's some strange jumble of C and
Assembly.
To include Assembly in C, use
asm {
; // Assembly Code Here
}
or
__asm {
; // Assembly Code Here
}
depending on the compiler.
To program in pure Assembly, ditch GCC. Go with NASM.
http://sourceforge.net/projects/nasm
And based on your lack of distinction between C and Assembly, I also
recommend:
http://www.amazon.com/exec/obidos/tg/detail/-/0130910139/
Joseph Wagner
-----Original Message-----
From: linux-assembly-owner@vger.kernel.org
[mailto:linux-assembly-owner@vger.kernel.org] On Behalf Of Andrew Haydon
Sent: Saturday, November 02, 2002 5:09 PM
To: linux-assembly@vger.kernel.org
Subject: Using gcc to compiler assembly
Gurus,
How to use GCC compiling assembly codes? I attached my example code and
tried gcc -c -o foo.o foo.S. This line "typedef foo_bar_t int;" choked.
I
read the Makefiles for linux kernel and still could not understand how
these
assebmly codes were compiled by GCC.
Thanks in advance,
Andrew
_________________________________________________________________
Unlimited Internet access -- and 2 months free! Try MSN.
http://resourcecenter.msn.com/access/plans/2monthsfree.asp
-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-11-03 20:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-02 23:08 Using gcc to compiler assembly Andrew Haydon
2002-11-03 18:26 ` Maciej Hrebien
-- strict thread matches above, loose matches on Subject: below --
2002-11-03 20:19 Joseph D. Wagner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).