gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

ASM > Porting PocketNES to GCC?

#81958 - Dwedit - Wed May 03, 2006 2:01 am

In this post, wintermute wrote:
I must admit I'd be interested in seeing how much the performance differs when compiled with a recent gcc.

I'm sure it wouldn't differ at all, since 99.99% of the code executed each frame is already assembly code.

The big thing stopping me from doing it is that I don't understand how to construct the necessary makefiles, linkscripts, crt0.s, or make the appropriate changes to the asm .s files. Does GCC's assembler have all the features necessary to compile PocketNES, including macros, conditional compilation, and something equivalent to Image$$RO$$Limit? Does GCC use a different calling convention than SDT? That could break all the calls from ASM to C.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#81959 - tepples - Wed May 03, 2006 2:11 am

Dwedit wrote:
The big thing stopping me from [porting Loopy/Flubba emulators to GCC] is that I don't understand how to construct the necessary makefiles, linkscripts, crt0.s, or make the appropriate changes to the asm .s files.

You can start by familiarizing yourself with wintermute's port of the GNU tools: get at least Hello World running using the standard GBA link script and crt0 provided with devkitARM. Here are the manuals for Gas (assembler), ld (linker), and the rest of binutils.

Quote:
Does GCC's assembler have all the features necessary to compile PocketNES, including macros

Yes, Gas has macros.

Quote:
conditional compilation

Yes, Gas has if.

Quote:
and something equivalent to Image$$RO$$Limit?

I don't know what the heck an Image$$RO$$Limit is, but while using Google to look for clues, I found this porting guide.

Quote:
Does GCC use a different calling convention than SDT?

GCC uses the ARM-Thumb Procedure Call Standard.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#81987 - gladius - Wed May 03, 2006 7:47 am

GCC's macros do not have feature parity with the ARM assemblers unfortunately. For PocketNES this is not a big deal because Loopy didn't go hog wild on the macros thankfully :). Porting snesadvance/snesds on the other hand...

The section values (image limit, size, start, etc.) are defined by GCC as well, yes, but they have different names that are assigned by your linkscript.

You'd want to learn some linkscript-fu before embarking on a port. Start by hacking up the default ones included in devkitarm. There are examples of modfied linkscripts floating about, I hacked them up for pocketspc somewhat so you might want to take a look there.

The crt0 stuff is not neccesary with pocketnes, it has code that does all that for itself, you'd just need to link in boot.s instead of crt0.s.

And, finally, the calling convention is the same.

#82001 - sgeos - Wed May 03, 2006 10:38 am

Food for thought: How much trouble would writing a (more than likely perl) filter to convert from one macro set to the other be?

-Brendan

#82016 - wintermute - Wed May 03, 2006 1:13 pm

building assembly files using arm-elf-gcc -x assembler-with-cpp -c <source>.s -o <object>.o gives you access to the C preprocessor. That way you can gain access to all the features of the preprocessor such as C style comments and #defines. Capitalising the extension does the same thing.

As for the linker supplied variables it's really just a matter of figuring out the equivalent name or supplying an equivalent value from the linker script.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#82229 - FluBBa - Thu May 04, 2006 5:49 pm

Quirky used a lot from PocketNES when making his PocketBeeb, which can be compiled by GCC.
_________________
I probably suck, my not is a programmer.