How do you get assembler output from GCC in SGDK

SGDK only sub forum

Moderator: Stef

Post Reply
astrofra
Interested
Posts: 28
Joined: Sun Dec 14, 2014 8:50 am
Location: Orleans | France
Contact:

How do you get assembler output from GCC in SGDK

Post by astrofra » Wed Nov 16, 2016 8:06 pm

Dear all,

I'm trying to obtain the assembler code generated out of my .C files by GCC.
The aim is to understand how my C code is translated into ASM and maybe find some way to optimize certain critical parts of my code.

The "stackoverflow" thread here mentions the -S option, that works when used in a single command line.
However, I'd like to use it on my whole project, when it is built by the SGDK's makefile.

I tried this compilation flags in 'makefile.gen' :

Code: Select all

release: FLAGS= $(DEFAULT_FLAGS) -S -O3 -fno-web -fno-gcse -fno-unit-at-a-time -fomit-frame-pointer
but it fails during the compilation :

Code: Select all

D:/apps/dev/sgdk/bin/gcc -m68000 -Wall -fno-builtin -Iinc -Isrc -Ires -ID:/apps/dev/sgdk/inc -ID:/apps/dev/sgdk/res -BD:/apps/dev/sgdk/bin -S -O3 -fno-web -fno-gcse -fno-unit-at-a-time -fomit-frame-pointer -c src/boot/rom_head.c -o out/rom_head.o
D:/apps/dev/sgdk/bin/ld -T D:/apps/dev/sgdk/md.ld -nostdlib --oformat binary -o out/rom_head.bin out/rom_head.o
out/rom_head.o: file not recognized: File format not recognized
make: *** [out/rom_head.bin] Error 1
Any idea? :')
I'm probably doing something stupid...
640 polygons are enough for everyone.

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: How do you get assembler output from GCC in SGDK

Post by Stef » Wed Nov 16, 2016 10:21 pm

In fact it does work: the .o file contains the assembly output instead of binary code, it's why it can't complete the linking process...
But at least you have your assembly code :)

Miquel
Very interested
Posts: 514
Joined: Sat Jul 30, 2016 12:33 am

Re: How do you get assembler output from GCC in SGDK

Post by Miquel » Thu Nov 17, 2016 6:37 pm

This is how I do it:

Code: Select all

$(CC) -c -g -Wa,-a,-ad $(FLAGS) $< > $@
It not only outputs asm code, but everything else.
HELP. Spanish TVs are brain washing people to be hostile to me.

astrofra
Interested
Posts: 28
Joined: Sun Dec 14, 2014 8:50 am
Location: Orleans | France
Contact:

Re: How do you get assembler output from GCC in SGDK

Post by astrofra » Mon Nov 21, 2016 9:10 pm

Thanks dudes.
Alas, none of the above seems to work on my SGDK version. Probably, I'm not using these option the proper way.
I finally find a working alternative here :
http://www.systutorials.com/240/generat ... using-gcc/

I dump all the ASM source code directly from the console, using '> asm_src.txt'

Thanks for your help, anyway :)
640 polygons are enough for everyone.

Post Reply