Solved

_asm inside a #define

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Create string splitting user defined function in C++ 23 291
Prototype for MessageDlg in Embacadero XE 2 2 35
C++ question 3 62
Dialogbox API leak? 18 81
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
  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 …
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 viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

895 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

12 Experts available now in Live!

Get 1:1 Help Now