Solved

Use of LOCK# SIgnal Prefix in inline assembler

Posted on 1998-03-06
4
550 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

790 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