The information in this article applies to:
SYMPTOMSThe Microsoft Macro Assembler (MASM) version 6.x will not assemble a statement with both a LOCK and a REP prefix. MASM 6.x generates the following error message: MASM versions 5.1 and 5.1a will assemble without error, however, code that uses the LOCK prefix with an incorrect instruction, but the code generated will run without errors only on some machines. CAUSE
The validity of using LOCK with REP depends upon the processor on which the
program is to be executed. A LOCK REP instruction is allowed on 186
processors and is even required in certain cases. However, on 386, 486, and
the Pentium processors, the LOCK REP instruction will generate an invalid
opcode exception.
BTS, BTR, BTC -> bit test and change instructionsAn invalid opcode exception results from using the LOCK prefix before any other instruction, or with these instructions that do not modify memory (that is, if the destination is a register). Because of the danger of allowing improper use of the LOCK instruction, MASM 6.x does not allow it to be used with the REP prefix even though the Intel 80186 manual specifically calls for such use in certain circumstances. Programmers developing embedded applications using the 80186 series may need this capability, however, and the sample code shows a technique for doing this. In these cases, the programmer will need to be certain that the code will never be run on a CPU where it could cause errors. STATUSMicrosoft has confirmed that allowing LOCK to be assembled for invalid instructions is a problem in MASM versions 5.1 and 5.1a. This problem was corrected in MASM version 6.0, and by design is not allowed to be used with the REP prefixes. RESOLUTIONWhen programming for the 80186 processor using MASM 6.x, a byte can be inserted into the program that contains 0F0h, the prefix for LOCK. The sample code below demonstrates this solution. Macros can be used to make this an easier workaround. MORE INFORMATIONSample Code
REFERENCES
Intel iAPX 86/88, 186/188 User[ASCII 146]s Manual Programmer[ASCII 146]s Reference.
Intel Literature Sales Additional query words: 5.10 5.10a 6.00 6.00a 6.00b 6.10 6.10a buglist5.10 buglist5.10a fixlist6.00
Keywords : |
Last Reviewed: January 4, 2000 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |