Solved

_asm inside a #define

Posted on 1998-09-25
3
906 Views
Last Modified: 2008-03-17
In MSVC 4.1 I can write the following code

      __asm {
            jb 0x01
            jb 0xf9
      }

If however I put it into a macro:-

#define OB3 __asm { \
      jb 01 \
      jb 0xf9 \
}

and then use the macro in my code:-

OB3;

I get an error on each use of the macro.

warning E4405 warning 'jb' is a reserved word
error C2400 inline assembler syntax error in 'first operator'; found 'constant'.

This seems to happen with any assembler I create. How can I generate assembler within a macro?
0
Comment
Question by:icd
[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 Comments
 
LVL 1

Expert Comment

by:Bonev
ID: 1173762
What about the semicolon after the macro?
0
 
LVL 86

Accepted Solution

by:
jkr earned 50 total points
ID: 1173763
The problem is that the macro evaluates to a single line, i.e. __asm { jb 01 jb 0xf9}. Try
#define OB3\
__asm { jb 01}; \
__asm { jb 0xf9 };

0
 
LVL 5

Author Comment

by:icd
ID: 1173764
Thanks, that did it.
0

Featured Post

Independent Software Vendors: 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

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…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

740 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