beautypg.com

Inline assembly – Zilog Z8F0130 User Manual

Page 229

background image

UM013037-1212

Inline Assembly

Zilog Developer Studio II – Z8 Encore!

User Manual

205

putch ('\n');

}

void funcf (far char *str)

{

while (*str)

putch (*str++);

putch ('\n');

}

void funcr (rom char *str)

{

while (*str)

putch (*str++);

putch ('\n');

}

void main (void)

{

funcn (N"nstr");

funcf (F"fstr");

funcr (R"rstr");

}

Inline Assembly

There are two methods of inserting assembly language within C code:

Inline Assembly Using the Pragma Directive

– see page 205

Inline Assembly Using the asm Statement

– see page 205

Inline Assembly Using the Pragma Directive

The first method uses the

#pragma

feature of ANSI C with the following syntax:

#pragma asm

"

"

This

#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. The compiler does not process the

<assembly line>. Except for escape sequences, it is passed through the compiler verbatim.

Inline Assembly Using the asm Statement

The second method of inserting assembly language uses the

asm

statement:

asm(

"

"

);