Solved

_asm inside a #define

Posted on 1998-09-25
3
899 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
3 Comments
 
LVL 1

Expert Comment

by:Bonev
Comment Utility
What about the semicolon after the macro?
0
 
LVL 86

Accepted Solution

by:
jkr earned 50 total points
Comment Utility
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
Comment Utility
Thanks, that did it.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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.

772 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

10 Experts available now in Live!

Get 1:1 Help Now