Solved

Use of LOCK# SIgnal Prefix in inline assembler

Posted on 1998-03-06
4
553 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

695 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