In C, there's a neat feature that lets you put together variable names.
For example, if you write:
and you call the macro like this:
Now, I want to do something similar in Assembly with cc65:
I'd like to create a macro to declare variables that have to be exported for Assembly and for C.
So, instead of this:
I want to write this:
And the macro shall look like this:
Is this possible?
For example, if you write:
Code:
#define NumberA 1
#define NumberB 2
#define GetNum(name) (Number##name)
#define NumberB 2
#define GetNum(name) (Number##name)
and you call the macro like this:
Code:
int i = GetNum(A);
then the preprocessor will transform it intoCode:
int i = NumberA;
Now, I want to do something similar in Assembly with cc65:
I'd like to create a macro to declare variables that have to be exported for Assembly and for C.
So, instead of this:
Code:
SomeVariable: .res 1
.export SomeVariable
.export _SomeVariable = SomeVariable
.export SomeVariable
.export _SomeVariable = SomeVariable
I want to write this:
Code:
DECLARE_GLOBAL SomeVariable, 1
And the macro shall look like this:
Code:
.macro DECLARE_GLOBAL name, size
name: .res size
.export name
.export _##name = name
.endmacro
name: .res size
.export name
.export _##name = name
.endmacro
Is this possible?