[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Use of LOCK# SIgnal Prefix in inline assembler

Posted on 1998-03-06
4
Medium Priority
?
557 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 400 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 …
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

650 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