0

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?

adrianmcmenamin
  • 1,081
  • 1
  • 15
  • 44
  • Not sure I understand your question, what do you want to automate? But yes, if you have some source for the constants you can use external tools to generate a bunch of `.set` directives which you can then pass to the assembler before the files that reference them. – Jester Mar 12 '15 at 23:29

1 Answers1

1

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.

dkz
  • 921
  • 6
  • 10