Share via


Symbols and Labels in SHx Inline Assembly

A symbol (or identifier) consists of a sequence of letters and digits. The first character must be a letter. The compiler treats the underscore character _ as a letter. Symbols are names supplied by programmers for variables, functions, and labels in a program. No symbols, except labels, can be defined using inline assembly language. In addition, C/C++ symbols defined outside of __asm statements cannot be referenced from within __asm statements.

A label is a symbol attached to an assembly source statement. A label is written with a (:) appended to the end of the symbol.

The following example shows how to use a label in an __asm block.

__asm("label1:");   //label1 is a label
__asm("label2");   //label2 is invalid. Does not terminate with a colon

Labels within __asm strings are case-sensitive. Reserved words such as register names and operation names are treated as case-insensitive.

By default, labels defined in inline assembly have a file scope. If you want to create labels with function scope, simply add 'L_' or '?' at the beginning of the label name. The inline assembler then treats it as a local label.

The following example shows how to define a local label.

__asm("L_label1:"); // L_label1 is a local label
__asm("?label2"); // ?label2 is a local label
__asm("label3:"); // label3 is not a local label, because it does not      // start with either L_ or ?

See Also

Elements of the SHx __asm Block | The __asm Keyword in SHx Inline Assembly | __asm Restrictions in SHx Inline Assembly | Constants in SHx Inline Assembly | SH-4 Mode Bits | SHx Inline Assembly Parameters | Branching in SHx Inline Assembly

 Last updated on Thursday, April 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.