beautypg.com

Placement directives, Keyword, described in the – Zilog Z8F0130 User Manual

Page 230

background image

Using the ANSI C-Compiler

UM013037-1212

206

Zilog Developer Studio II – Z8 Encore!
User Manual

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 with an underscore (_). 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.

Placement Directives

The Zilog C-Compiler provides language extensions for the following directives:

Placement of a Variable

– see page 206

Placement of Consecutive Variables

– see page 206

Alignment of a Variable

– see page 207

Placement of a Variable

The following syntax can be used to declare a global or static variable at an address:

char placed_char _At 0xff; // placed_char is assigned an address

0xff.

far struct {

char ch;

int ii;

} ss _At 0xeff; // ss is assigned an address 0xeff


rom char init_char _At 0xffff = 33;

// init_char is in rom and initialized to 33

Only placed variables with

rom

storage class specifier can be initialized. The placed vari-

ables with

near

and

far

storage class specifier cannot be initialized. The uninitialized

placed variables are not initialized to zero by the compiler start-up routine.

Placement of Consecutive Variables

The compiler also provides syntax to place several variables at consecutive addresses.

For example:

Note: