1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML 2.0//EN">
4 <TITLE>80386 Programmer's Reference Manual -- Opcode LOCK
</TITLE>
7 <B>up:
</B> <A HREF=
"c17.htm">
8 Chapter
17 --
80386 Instruction Set
</A><BR>
9 <B>prev:
</B><A HREF=
"LMSW.htm"> LMSW Load Machine Status Word
</A><BR>
10 <B>next:
</B><A HREF=
"LODS.htm"> LODS/LODSB/LODSW/LODSD Load String Operand
</A>
14 <H1>LOCK -- Assert LOCK# Signal Prefix
</H1>
17 Opcode Instruction Clocks Description
19 F0 LOCK
0 Assert LOCK# signal for the next instruction
24 The LOCK prefix causes the LOCK# signal of the
80386 to be asserted
25 during execution of the instruction that follows it. In a multiprocessor
26 environment, this signal can be used to ensure that the
80386 has
27 exclusive use of any shared memory while LOCK# is asserted. The
28 read-modify-write sequence typically used to implement test-and-set on the
30 <A HREF=
"BTS.htm">BTS
</A> instruction.
32 The LOCK prefix functions only with the following instructions:
35 <A HREF=
"BT.htm">BT
</A>,
<A HREF=
"BTS.htm">BTS
</A>,
<A HREF=
"BTR.htm">BTR
</A>,
<A HREF=
"BTC.htm">BTC
</A> mem, reg/imm
36 <A HREF=
"XCHG.htm">XCHG
</A> reg, mem
37 <A HREF=
"XCHG.htm">XCHG
</A> mem, reg
38 <A HREF=
"ADD.htm">ADD
</A>,
<A HREF=
"OR.htm">OR
</A>,
<A HREF=
"ADC.htm">ADC
</A>,
<A HREF=
"SBB.htm">SBB
</A>,
<A HREF=
"AND.htm">AND
</A>,
<A HREF=
"SUB.htm">SUB
</A>,
<A HREF=
"XOR.htm">XOR
</A> mem, reg/imm
39 <A HREF=
"NOT.htm">NOT
</A>,
<A HREF=
"NEG.htm">NEG
</A>,
<A HREF=
"INC.htm">INC
</A>,
<A HREF=
"DEC.htm">DEC
</A> mem
42 An undefined opcode trap will be generated if a LOCK prefix is used
43 with any instruction not listed above.
45 <A HREF=
"XCHG.htm">XCHG
</A> always asserts LOCK# regardless of the presence or absence of
48 The integrity of the LOCK is not affected by the alignment of the
49 memory field. Memory locking is observed for arbitrarily misaligned
52 Locked access is not assured if another
80386 processor is executing an
53 instruction concurrently that has one of the following characteristics:
55 <LI> Is not preceded by a LOCK prefix
57 <LI> Is not one of the instructions in the preceding list
59 <LI> Specifies a memory operand that does not exactly overlap the
60 destination operand. Locking is not guaranteed for partial overlap,
61 even if one memory operand is wholly contained within another.
64 <H2>Flags Affected
</H2>
68 <H2>Protected Mode Exceptions
</H2>
70 #UD if LOCK is used with an instruction not listed in the
"Description"
71 section above; other exceptions can be generated by the subsequent
74 <H2>Real Address Mode Exceptions
</H2>
76 Interrupt
6 if LOCK is used with an instruction not listed in the
77 "Description" section above; exceptions can still be generated by the
78 subsequent (locked) instruction
80 <H2>Virtual
8086 Mode Exceptions
</H2>
82 #UD if LOCK is used with an instruction not listed in the
"Description"
83 section above; exceptions can still be generated by the subsequent (locked)
88 <B>up:
</B> <A HREF=
"c17.htm">
89 Chapter
17 --
80386 Instruction Set
</A><BR>
90 <B>prev:
</B><A HREF=
"LMSW.htm"> LMSW Load Machine Status Word
</A><BR>
91 <B>next:
</B><A HREF=
"LODS.htm"> LODS/LODSB/LODSW/LODSD Load String Operand
</A>