Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate assembler code from C file in linux

Tags:

c

unix

gcc

I would like to know how to generate assembler code from a C program using Unix. I tried the gcc: gcc -c file.c

I also used firstly cpp and then try as but I'm getting errors.

I'm trying to build an assembler program from 3 different programs

prog1.c prog2.c prog.h

Is it correct to do gcc -S prog1.c prog2.c prog.h? Seems that is not correct. I don't know if I have to generate the assembler from each of them and then link them

Thanks

like image 825
Peter Avatar asked Jul 04 '26 11:07

Peter


1 Answers

According the manual:

`-S'
     Stop after the stage of compilation proper; do not assemble.  The
     output is in the form of an assembler code file for each
     non-assembler input file specified.

     By default, the assembler file name for a source file is made by
     replacing the suffix `.c', `.i', etc., with `.s'.

     Input files that don't require compilation are ignored.

so try gcc -S file.c.

like image 192
Dirk Eddelbuettel Avatar answered Jul 06 '26 23:07

Dirk Eddelbuettel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!