I made a macro that prints out all the contents of registers in arm assembly with file name uart_print.s
.macro UART_print
//codes…
UART_start:
//codes…
loop:
//codes….
next:
//codes…
There are lots of labels in this macro code. Back in my main assembly code csd_trial.S, I included the macro file and tried using the macro multiple times in different lines of code
#include “uart_init.s”
#include “uart_print.s”
.global main
main:
UART_init // UART Initialization
mov r1, #32
outer_loop:
ldr r0, =Input_data
ldr r6, =Output_data
mov r2, #0
mov r5, #1
UART_print //called macro here!
inner_loop:
add r5, r5, #1
add r6, r6, #4
ldr r3, [r0], #4
ldr r4, [r0]
cmp r3, r4
UART_debug //another one here!
//rest of the code
When I call the macro once, it works. But as soon as I try to use 2 of the same macro it returns an error saying: Error: symbol ‘loop’ is already defined
I figured when the second macro was called, it tried defining the same label once it got to my macro file. I tried reading online and decided to try local labels to try to fix this:
.macro UART_print
.LOCAL UART_start, loop, next
UART_start:
// rest of the code.
The error seems to persist even I defined the labels as local. I thought maybe the syntax differs depending on the assembler version. So I tried reading ARMv7-Cortex reference manuals but couldn’t find what I was looking for. Am I looking at the right direction by trying to set the labels in macro file as local labels? Or is there something else I should do?