Memory models, Mory model (see the, E the – Zilog Z8F0130 User Manual
Page 223: Section
![background image](https://www.manualsdir.com/files/771166/content/doc223.png)
UM013037-1212
Memory Models
Zilog Developer Studio II – Z8 Encore!
User Manual
199
struct{
near char num;
/* Warning: near space specifier is ignored. */
near char * ptr;
/* Correct: ptr points to a char in near memory.
ptr itself is stored in the memory space of structure (far). */
} far mystruct;
/* All of mystruct is allocated in far memory.*/
Memory Models
The Z8 Encore! C-Compiler provides two memory models:
•
•
Each of these models directs the compiler to where to place data in memory by default, to
maximize the efficiency of an application. This feature allows you to control where global
and static data are allocated, as well as where frames containing local and parameter data
are stored.
Small Memory Model
In the small memory model, global variables are allocated in the RData address space. The
address of these variables is 8 bits. The locals and parameters are allocated on the stack,
which is also located in the RData address space. The address of a local or parameter is an
8-bit address. Global variables can be manually placed into the EData or ROM address
space by using the address specifiers
far
and
rom
, respectively. Local (nonstatic) vari-
ables and parameters are always allocated in the RData address space, and any address
specifiers used in their declarations are ignored. Use of the small memory model does not
impose any restriction on your code size; only data memory is affected by the choice of
model.
The small memory model always produces more efficient code than the large model if
your application can use it. The use of the small model places stringent limits on the data
space available for the stack and data. It does help to produce smaller code, by enabling
the compiler to use shorter instructions with more compact addressing modes. If you are
near but slightly over the data-space limits of the small model, you might still be able to
use the small model by declaring enough selected global or static variables as
far
to get
your use of RData down to the available space.
The code used to access those
far
variables is less efficient than code to access
near
(i.e.,
RData) variables. Therefore, if you follow this plan, you must identify variables that are
seldom accessed in your program and designate them as
far
.
- Z8F0131 Z8F0230 Z8F0231 Z8F0430 Z8F0431 Z8F043A Z8F0830 Z8F0831 Z8F083A Z8F1232 Z8F1233 Z8F0113 Z8F011A Z8F0123 Z8F012A Z8F0213 Z8F021A Z8F0223 Z8F022A Z8F0411 Z8F0412 Z8F0413 Z8F041A Z8F0421 Z8F0422 Z8F0423 Z8F042A Z8F0811 Z8F0812 Z8F0813 Z8F081A Z8F0821 Z8F0822 Z8F0823 Z8F082A Z8F0880 Z8F1621 Z8F1622 Z8F1680 Z8F1681 Z8F1682 Z8F2421 Z8F2422 Z8F2480 Z8F3221 Z8F3222 Z8F3281 Z8F3282 Z8F4821 Z8F4822 Z8F4823 Z8F6081 Z8F6082 Z8F6421 Z8F6422 Z8F6423 Z8F6481 Z8F6482 Z8FS021A ZMOT1AHH Z8FS040B ZMOT0BHH ZMOT0BSB Z8FMC04 Z8FMC08 Z8FMC16