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 > A little simple question

#25841 - ProblemBaby - Sun Aug 29, 2004 12:20 pm

Iam using both c and asm in my project.
My gba.h file contains a lot of register flags but also C-structures
so It cant be included by a .S-file.
Does it exist a compilator directive to see if it is a C or S file that includes the header.
Something like this:

flags
#if C_CODE
struct...
#endif

#if ASM_CODE
.byte...
#endif

I would be comfortable!
and then I wonder how to make a function prototype in asm.

#25847 - tepples - Sun Aug 29, 2004 3:46 pm

Assembly language doesn't use function prototypes.

It'd probably work better to make separate headers that in turn #include common files.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#25849 - f(DarkAngel) - Sun Aug 29, 2004 4:19 pm

Or you can write headers that has only cpp directives, like reg definitions - then you can define vu16p to nothing for as headers, and include type definitions file in c headers that includes the as headers.
_________________
death scream...

#26128 - torne - Wed Sep 08, 2004 12:35 pm

You can trivially determine whether the header has been included by C or ASM just by defining some flag of your own: for example, in your .S, put #define THIS_IS_ASM before you include any files ;)

#26136 - Lord Graga - Wed Sep 08, 2004 1:24 pm

I suggest that you do not use a gba.h when you write asm. This will give you more overview when optimizing your code.[/code]

#26152 - torne - Wed Sep 08, 2004 4:57 pm

Graga, what do you mean? What effect does defining things in the preprocessor have on optimisation?