LDR R2, =0x01           ; Lock value

next:
  LDREX R0, [R1]        ; Read lock from *R1                         <-- Lock value should be 0
  CMP R0, #0            ; Check if 0                                 <-- R0 << Lock value from *R1
  STREXEQ R0, R2, [R1]  ; Attempt to store new value to *R1          <-- Write'n'read R2 if R0 == 0
  CMPEQ R0, #0          ; Test if store suceeded                     <-- R0 << Report from "STREX.EQ"
BNE next                ; Retry if not                               <-- Try "LDREX" again or leave

DMB                     ; Flush L1 cache
