Solved

Use of LOCK# SIgnal Prefix in inline assembler

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now