No subject


Fri Feb 9 23:20:10 PST 2007


---
The LOCK prefix can be prepended only to the following instructions and only to
those forms
of the instructions where the destination operand is a memory operand: ADD,
ADC, AND,
BTC, BTR, BTS, CMPXCHG, CMPXCH8B, DEC, INC, NEG, NOT, OR, SBB, SUB, XOR,
XADD, and XCHG. If the LOCK prefix is used with one of these instructions and
the source
operand is a memory operand, an undefined opcode exception (#UD) may be
generated. An
undefined opcode exception will also be generated if the LOCK prefix is used
with any instruc-
tion not in the above list. The XCHG instruction always asserts the LOCK#
signal regardless of
the presence or absence of the LOCK prefix.
---

AMD agrees (Architecture Programmer's Manual, vol. 3):
---
The LOCK prefix can only be used with forms of the following instructions that
write a memory
operand: ADC, ADD, AND, BTC, BTR, BTS, CMPXCHG, CMPXCHG8B, DEC, INC, NEG, NOT,
OR, SBB, SUB, XADD, XCHG, and XOR. An invalid-opcode exception occurs if the
LOCK prefix is
used with any other instruction.
---

So you're using the lock prefix where it isn't allowed.
It's both not allowed on MOV and on other instructions on which it can be used
it's only allowed if the destination is a memory operand. Those all seem to be
instructions which both read and write their destination (memory) operand.
(I didn't know any of this until I looked it up just now)

Sorry, it seems the bug is in your code...


-- 



More information about the Digitalmars-d-bugs mailing list