## ALP Programming Guide and Reference

[prev][next][parent][TOC]

### Description

The LOCK prefix causes the LOCK# signal of the processor to be asserted during processing of the instruction that follows it. In a multiprocessor environment, this signal can be used to ensure that the processor has exclusive use of any shared memory while LOCK# is asserted. The read-modify -write sequence typically used to implement test-and-set on the Pentium processor is the BTS instruction.

The LOCK prefix functions only with the following instructions:

     BTS, BTR, BTC                        mem, reg/imm

     XCHG                                 reg, mem

     XCHG                                 mem, reg

     ADD, OR, ADC, SBB, AND, SUB, XOR     mem, reg/imm

     NOT, NEG, INC, DEC                   mem

     CMPXCHG, XADD

An undefined opcode trap will be generated if a LOCK prefix is used with any instruction not listed above.

The XCHG instruction always asserts LOCK# regardless of the presence or absence of the LOCK prefix.

The integrity of the LOCK prefix is not affected by the alignment of the memory field. Memory locking is observed for arbitrarily misaligned fields.