GAS (gnu assembler) and conditional execution

57 views Asked by At

Stupid question. I am writing code in pure assembly for STM32 variants. I want to make two different versions from the same source file by assembling twice with a simple change that is selectable by the command line. Example: the fast version sets the uart baud rate to 1.5 Mbaud, the slow version sets the uart baud rate to 115.2 kbaud. I can have both lines in the source, with conditional assembly directives wrapping around, sorta like:

.if zap=fast then assemble
   ldr   r0,=<fast baud rate>
.else assemble
   ldr   r0,=<slow baud rate>
.endif

and then run the assembler twice in my make batch file, like so:

arm-none-eabi-gcc.exe -c -mcpu-cortex-m4 -mthumb -Wall  source.s  -zap=fast -o fast.o
arm-none-eabi-gcc.exe -c -mcpu-cortex-m4 -mthumb -Wall  source.s  -zap=slow -o slow.o

and so on with sub-files, and run the linker twice for two images.

There must be a way to do this, but I can't find it in the manual. Any help? Thanks in advance. Jeff Casey

0

There are 0 answers