Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you add preprocessor directives in assembly?

I would like to execute some assembly instructions based on a define from a header file.

Let's say in test.h I have #define DEBUG.

In test.asm I want to check somehow like #ifdef DEBUG do something...

Is such thing possible? I was not able to find something helpful in the similar questions or online.

like image 879
Alexandru Cimpanu Avatar asked May 19 '15 13:05

Alexandru Cimpanu


1 Answers

Yes, you can run the C preprocessor on your asm file. Depends on your build environment how to do this. gcc, for example, automatically runs it for files with extension .S (capital). Note that whatever you include, should be asm compatible. It is common practice to conditionally include part of the header, using #ifndef ASSEMBLY or similar constructs, so you can have C and ASM parts in the same header.

like image 197
Jester Avatar answered Oct 26 '22 14:10

Jester