Char and short enumerations, Inline assembly using the pragma directive, Inline assembly using the asm statement – Zilog ZUSBOPTS User Manual
Page 195

UM017105-0511
Language Extensions
Zilog Developer Studio II – ZNEO™
User Manual
167
Inline Assembly Using the Pragma Directive
The first method uses the
#pragma
feature of ANSI C with the following syntax:
#pragma asm
“
<assembly line>
”
#pragma
can be inserted anywhere within the C source file. The contents of
<assembly line> must be legal assembly language syntax. The usual C escape sequences
(such as
\n
,
\t
, and
\r
) are properly translated. Currently, the compiler does not process
the <assembly line>. Except for escape sequences, it is passed through the compiler verba-
tim.
Inline Assembly Using the asm Statement
The second method of inserting assembly language uses the
asm
statement:
asm(
“
<assembly line>
”
);
The
asm
statement cannot be within an expression and can be used only within the body of
a function.
The <assembly line> can be any string.The compiler does not check the legality of the
string.
As with the
#pragma asm
form, the compiler does not process the <assembly line>
except for translating the standard C escape sequences.
The compiler prefixes the name of every global variable name with "_". Global variables
can therefore be accessed in inline assembly by prefixing their name with "_ ". The local
variables and parameters cannot be accessed in inline assembly.
Char and Short Enumerations
The enumeration data type is defined as
int
as per ANSI C. The C-Compiler provides
language extensions to specify the enumeration data type to be other than
int
to save
space. The following syntax is provided by the C-Compiler to declare them as
char
or
short
:
enum
{
RED = 0,
YELLOW,
BLUE,
INVALID
} char color;
enum
{
NEW= 0,
OPEN,