Creating a loop within an assembly macro - IAR ARM

1.9k views Asked by At

I am trying to create a loop within an IAR Arm assembly macro but cannot figure out how to make local labels, if the macro is called more than once I get duplicate label error from the assembler. My code is as follows:

myMacro MACRO
     MOV R1, #0
label:  enter code here
     do some stuff here
     ADD R1, R1, #1         
     CMP R1, #10
     BLE label
     ENDM
1

There are 1 answers

0
Realtime Rik On BEST ANSWER

Solved below:

myMacro MACRO
         LOCAL label
         MOV R1, #0
    label:  enter code here
         do some stuff here
         ADD R1, R1, #1         
         CMP R1, #10
         BLE label
         ENDM