gccassemblygnu-assemblermicroblaze

Substituting for a .SET on the the command line


I have some (Microblaze) assembly I need to build (via the GCC cross-assembler and linker) and execute many times with the (same) constants, currently fixed via

.SET

commands, changed each time.

Is there a way to automate the setting of in-assembly constants in this way and so avoid the dull task of resetting the code for each build?


Solution

  • You can use the power of C pre-processor in your assembler files. This could be done simply changing file extension from .s to .S (capital S) on Unix-like platform or to .sx on Windows. Then using gcc instead of gas over these files will let C pre-processor first run through the source and then gas will be called automatically.

    In this case you can use all regular pre-processor #define, #ifdef, etc. And of cause you can pass these defines from the command line with gcc's -D parameter.