6.1 Advantages of Inline Assembly

Because the inline assembler doesn't require separate assembly and link steps, it is more convenient than a separate assembler. Inline assembly code can use any C variable or function name that is in scope, so it is easy to integrate it with your program's C code. Because the assembly code can be mixed in line with C or C++ statements, it can do tasks that are cumbersome or impossible in C or C++.

The uses of inline assembly include

Writing functions in assembly language

Spot-optimizing speed-critical sections of code

Calling DOS and BIOS routines with the INT instruction

Creating TSR (terminate-and-stay-resident) code or handler routines that require knowledge of processor states

Inline assembly is a special-purpose tool. If you plan to port an application to different machines, you'll probably want to place machine-specific code in a separate module. Because the inline assembler doesn't support all of MASM's macro and data directives, you may find it more convenient to use MASM for such modules.