Solved

Use of LOCK# SIgnal Prefix in inline assembler

Posted on 1998-03-06
4
549 Views
Last Modified: 2012-08-13
I am using the CMPXCHG assembler instruction in some inline assembler in a C routine.  Intel doc says I need to
use the LOCK prefix with the CMPXCHG instruction to
make it atomic.  How do I do that?  LOCK seems to be
an instruction in the doc, but is invalid in the inline
assembler.  I'm using VC++ 5.0.
0
Comment
Question by:cumbow
  • 3
4 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 200 total points
ID: 1183115
answer coming.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1183116
LOCK is not an instruction, it is a prefix.  That means it is placed before the instruction, like

LOCK CMPXCHG EBX,Semaphore

If that is what you had, then the problem might be that VC does not support the CMPXCHG function.  (It doesn't support every intel instruction.)  If this doesn't work, let me know, there are ways around this.
0
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1183117
The inline assembler does not support every single instruction from the set.

0
 
LVL 22

Expert Comment

by:nietod
ID: 1183118
The docs say that VC supports the entire 486 instruction set and this is a 486 instruction.  However, I believe I've other instructions that it didn't support that it should have.  If you can't get it working with the lock as a prefix, post the code that you are trying to get working.  We can use the emit instuction to get it to work.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question