Share via


The _asm Keyword in MIPS Inline Assembly

The _asm keyword invokes the inline assembler, and can appear anywhere in a C or C++ statement. The compiler treats the __asm statement as an intrinsic function call. You must include a #pragma intrinsic statement that declares an __asm keyword.

The following C++ code shows how to declare _asm with a #pragma directive.

extern "C" { 
void __asm(char*,); 
}; 
#pragma intrinsic (__asm) 

Note   It is not necessary to perform these declarations in C source modules.

In an __asm declaration, the string argument is a null terminated character string consisting of one or more assembly language statements. The compiler passes any subsequent arguments to the assembly code described by the first string argument. The following example generates instructions to multiply 4 and 5, and store the result in the t0 register.

__asm("mul t0, %0, %1", 4, 5); 

In this example, the reference to %0 refers the value "4" to the first argument in the generated assembly code. %1 refers the value "5" to the second argument in the generated assembly code.

Within the string argument of the __asm prototype, an embedded semicolon (;) or newline (\n) is used to separate multiple assembly language statements. The following example shows how to use a semicolon to signify multiple assembly language statements.

__asm(".set noat;" 
"mult $1, $4, $5; " 
".set at "); 

See Also

MIPS Device Inline Assembly Language | Intrinsic Functions and MIPS Inline Assembly | MIPS Assembly Language Resources | MIPS Inline Assembly Language Examples | MIPS __asm Statement Registers | C or C++ References in MIPS Inline Assembly | Restrictions to MIPS __asm Statements

 Last updated on Thursday, April 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.