As was previously described, __asm, __dasm, and __fasm are treated as extensions to the C/C++ language. Each could be viewed as having a prototype declaration as follows, with the string argument (char *) receiving special processing by the compiler:
__int64 __asm(char *, ...);
double __dasm(char *, ...);
float __fasm(char *, ...);
In this syntax, the string argument is a null-terminated character string consisting of one or more ASAXP assembly language statements with registers specified using a special metalanguage. The metalanguage is compatible with that allowed by DEC C for DIGITAL UNIX. Subsequent arguments are processed as if they were arguments to any C/C++ function call, but are passed as arguments to the assembly code described by the first string argument. For example, consider the following code:
c = __dasm(“mult %0, %1, $f0”, 4., 5.);
In this example, the reference to %0
refers to the first argument in the generated assembly code (with a value of 4). In a similar fashion, %1
refers to the second argument to the generated assembly code (with a value of 5).
Within the string argument, an embedded semicolon (;) or newline character (\n) is used to separate multiple assembly language statements. For example:
c = __dasm(“mult %0, %1, $f0;”
“mult $f0, $f0”, 4., 5.);
Note that a semicolon is still required to separate statements, despite the fact that the strings are on separate physical lines in the source code.
The next example uses one string continued over two lines. The explicit statement separator is still required, but in this case, a newline character (\n) is used instead of a semicolon.
c = __dasm(“mult %0, %1, $f0\n\
mult $f0, $f0”, 4., 5.);
Note that the compiler interprets the line-continuation character (\) by simply reading characters on the next line. No newline characters are read into the string at compile time, unless explicit newline characters (\n) are embedded in the string.
References to registers can be made by using conventions similar to those used by the Alpha ASAXP stand-alone assembler. Additionally, for compatibility across the Alpha operating systems, the acc metalanguage for register aliases is allowed. Register names must be specified in lowercase.