Realtime Rik
Realtime Rik

Reputation: 1714

Creating a loop within an assembly macro - IAR ARM

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

Upvotes: 2

Views: 2095

Answers (1)

Realtime Rik
Realtime Rik

Reputation: 1714

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

Upvotes: 2

Related Questions