.thumb_func setmutex: ldrex r1,[r0] // initiate exclusive access cbnz r1,1f // branch if it's already set mov r2,#1 // strex r1,r2,[r0] // try setting location to 1 1: mov r0,r1 // set return value = 0 if set succeeded, 1 if set failed bx lr // return |