What's the corresponding prefix in arm assembly for “lock” in x86?
问题 I have a x86 assembly code: unsigned int oldval; __asm__ __volatile__ ( "movl $1, %0 \n" "lock xaddl %0, (%1) \n" : "=a" (oldval) : "b" (n))l; return oldval; and I want to translate it into arm assembly. Is there any prefix in arm assembly that does the same thing as "lock" here? 回答1: I don't know ARM, but from glossing over the manual, the following should approximate your atomic exchange-and-add: foo: LDREX R1, [R0] ; R0 is "n", load linked ADD R2, R1, 1 ; R2 = R1 + 1 STREX R3, R2, [R0] ;