Solved

_asm inside a #define

Posted on 1998-09-25
3
907 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 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…

729 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