C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
Defining __asm Blocks as C Macros
                                             Up Contents Index Back
─────C/C++ Language─────────────────────────────────────────────────────────
 
     To use macros to insert assembly code into C or C++ code, follow
     these rules:
 
        1. Enclose the __asm block in braces.
 
        2. Put the __asm keyword in front of each assembly instruction.
 
        3. Use enclosing C comments ( /* comment */ ); if you use
           C++ single-line comments ( // ), the compiler ignores
           the rest of the macro.
 
        4. Use the backslash (\) to join the statements into a
           single line.
 
     For example:
 
          #define BEEP __asm       \
          /* Beep sound */         \
          {                        \
             __asm mov ah, 2       \
             __asm mov dl, 7       \
             __asm int 21h         \
          }
 
     This macro expands to a single line:
 
          __asm { __asm mov ah, 2  __asm mov dl, 7 __asm int 21h }
                                    -♦-