Assembler & C tips and tricks

Topics related to the API, programming discussions & questions, coding tips, bugs, etc. should go here.
Post Reply
User avatar
Jubatian
Posts: 1561
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Assembler & C tips and tricks

Post by Jubatian »

Browsing the Wiki I found that the Assembler tips and tricks article is severely outdated, and the C tips and tricks is empty. I made an attempt at fixing these up so they have sensible content. What do you think? A notable thing which seems competely unknown here are Named Address Spaces, which I included in the C tips & tricks article. It makes a lot easier to handle ROM data!

If there is anything else, maybe it should or could be added. It is a bit odd for me how little history these had.
User avatar
Artcfox
Posts: 1382
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: Assembler & C tips and tricks

Post by Artcfox »

Great tips and tricks!

I remember reading about the named address space thing back when it was added to avr gcc, but there was a reason why I never used it. It might have been that it limited my library code to only working with certain newer compilers, or that they are only supported in C and not C++.

The asm tips and tricks are helpful as well, thanks for adding them to the wiki. :-)
User avatar
Jubatian
Posts: 1561
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: Assembler & C tips and tricks

Post by Jubatian »

Artcfox wrote: Sat May 12, 2018 12:40 pmIt might have been that it limited my library code to only working with certain newer compilers, or that they are only supported in C and not C++.
It seems old enough for me by now, and as I found, GCC wasn't even the first, it followed IAR's similar feature (here). I like that it makes ROM access look cleaner, and the compiler checks properly those address space qualifiers, so you can't end up with accidentally passing a RAM array to something meant to work with ROM data. Then it is also a nice point that it seems easier to port, for example like Jhhoward did for Joyrider, which can also be compiled native for PC. However true, with some research I found that C++ in GCC lacks Named Address Spaces, so you are stuck with the pgmspace stuff there.

(By the way... He is still active, relasing things like this: https://github.com/jhhoward/MicroCity - could be interesting! And maybe one could merciessly grab and port it for the Uzebox, too :) By the way he ports pgmspace stuff too, it can be observed in the game's main definitions. Maybe I will add some notes on this, too)
Artcfox wrote: Sat May 12, 2018 12:40 pmThe asm tips and tricks are helpful as well, thanks for adding them to the wiki. :-)
Originally I think those came from Alec, but possibly from the very early days of the project. I just fixed it up by current knowledge, adding a few new things only (such as the method to delay some cycles by a parameter, which was originally developed for Mode 74).
Post Reply