User forums > General (but related to Code::Blocks)

how to generate .s(assembly) file when compiling code ?

<< < (2/2)

Jenna:
Is your file part of a project ?
If not, this will not work, because would not be able to store the information (it is stored in the project-file).

manmeetvirdi:
Hi there Jens
Thanks for your help !!

Well mine file is a stand alone file "G2.C". I dint created it inside any project.
I created the file G2.C like this : File-->New-->Files-->c/C++ source

Then as suggested by you I created the project G3 like: File-->new-->Project-->console application and then proceeded ahead to create C project.
Once G3 project was created I included the file G2.C into this project.
Now sure enough  "check" option is now enabled as you said (shown in G2_asm2.jpg)

Jens also I found the other way
Settings-->Compiler and  Debugger-->Other settings --> advanced option (shown in G2_asm1.jpg)
and then included the lines which you mentined in post 2.
...and voila after compiling I got G2.S file

manmeetvirdi:
And this is what mine first assembly file contains


--- Code: --- .file "G2.c"
.text
.def _printf; .scl 3; .type 32; .endef
_printf:
pushl %ebp
movl %esp, %ebp
pushl %ebx
subl $36, %esp
leal 12(%ebp), %eax
movl %eax, -12(%ebp)
movl -12(%ebp), %eax
movl %eax, 4(%esp)
movl 8(%ebp), %eax
movl %eax, (%esp)
call ___mingw_vprintf
movl %eax, %ebx
movl %ebx, %eax
addl $36, %esp
popl %ebx
popl %ebp
ret
.def ___main; .scl 2; .type 32; .endef
.section .rdata,"dr"
LC0:
.ascii "\12\12Hi there\12\12\0"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $16, %esp
call ___main
movl $LC0, (%esp)
call _printf
leave
ret
.def ___mingw_vprintf; .scl 2; .type 32; .endef


--- End code ---

Jenna:

--- Quote from: manmeetvirdi on August 19, 2011, 11:29:20 am ---Jens also I found the other way
Settings-->Compiler and  Debugger-->Other settings --> advanced option (shown in G2_asm1.jpg)
and then included the lines which you mentined in post 2.
...and voila after compiling I got G2.S file


--- End quote ---

That's what I posted here:

--- Quote from: jens on August 02, 2010, 07:29:49 am ---You can place it in "Compiler settings -> Other options".
The assembly code will be in the *.o-files in this case (because C::B uses the -o-option), and it will be done for all processed files.
[...]
I double the command, so the file will be processed twice, one-time only the assembly is generated, the second time I do the normal processing, otherwise your build will be broken due to missing object-file or because an old object-file is taken (if it exists).


--- End quote ---

But as stated it is done for every file in the project, and that can slow down the build process for larger projects.

Navigation

[0] Message Index

[*] Previous page

Go to full version