1

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

1
  • 2
    Use --defsym (numeric) or switch to preprocessed assembly (.S) and then use -D and #if as usual. Commented Nov 27, 2023 at 0:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.