Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
50
Добавлен:
14.04.2015
Размер:
1.37 Mб
Скачать

Keil Software — Cx51 Compiler User’s Guide

159

 

 

Segment Naming Conventions

Objects generated by the Cx51 compiler (program code, program data, and constant data) are stored in segments which are units of code or data memory. A segment may be relocatable or may be absolute. Each relocatable segment has a type and a name. This section describes the conventions used by the Cx51 comiler for naming these segments.

Segment names include a module_name which is the name of the source file in which the object is declared. In order to accommodate a wide variety of existing software and hardware tools, all segment names are converted and stored in uppercase.

Each segment name has a prefix that corresponds to the memory type used for the segment. The prefix is enclosed in question marks (?). The following is a list of the standard segment name prefixes:

 

Segment Prefix

Memory Type

Description

 

 

 

?PR?

program

Executable program code

 

 

 

?CO?

code

Constant data in program memory

 

 

 

?BI?

bit

Bit data in internal data memory

 

 

 

?BA?

bdata

Bit-addressable data in internal data memory

 

 

 

?DT?

data

Internal data memory

 

 

 

?FD?

far

Far memory (RAM space)

 

 

 

?FC?

const far

Far memory (constant ROM space)

 

 

 

6

 

?ID?

idata

Indirectly-addressable internal data memory

 

 

?PD?

pdata

Paged data in external data memory

 

 

?XD?

xdata

Xdata memory (RAM space)

 

 

?XC?

const xdata

Xdata memory (constant ROM space)

 

 

 

 

160

Chapter 6. Advanced Programming Techniques

 

 

Data Objects

Data objects are the variables and constants you declare in your C programs. The Cx51 compiler generates a separate segment for each memory type for which a variable is declared. The following table lists the segment names generated for different variable data objects.

Segment Name

Description

?BA?module_name

Bit-addressable data objects

?BI?module_name

Bit objects

?CO?module_name

Constants (strings and initialized variables)

?DT?module_name

Objects declared in data

?FC?module_name

Objects declared in const far (requires OMF2 directive)

?FD?module_name

Objects declared in far (requires OMF2 directive)

?ID?module_name

Objects declared in idata

?PD?module_name

Objects declared in pdata

?XC?module_name

Objects declared in const xdata (requires OMF2 directive)

?XD?module_name

Objects declared in xdata

6

Keil Software — Cx51 Compiler User’s Guide

161

 

 

Program Objects

Program objects include the code generated for C program functions by the Cx51 compiler. Each function in a source module is assigned a separate code segment using the ?PR?function_name?module_name naming convention. For example, the function error_check in the file SAMPLE.C would result in a segment name of ?PR?ERROR_CHECK?SAMPLE.

Segments are also created for local variables that are declared within the body of a function. These segment names follow the above conventions and have a different prefix depending upon the memory area in which the local variables are stored.

Function arguments were historically passed using fixed memory locations. This is still true for routines written in PL/M-51. However, Cx51 can pass up to 3 function arguments in registers. Other arguments are passed using the traditional fixed memory areas. Memory space is reserved for all function arguments regardless of whether or not some of these arguments may be passed in registers. The parameter areas must be publicly known to any calling module. So, they are publicly defined using the following segment names:

?function_name?BYTE ?function_name?BIT

For example, if func1 is a function that accepts both bit arguments as well as arguments of other data types, the bit arguments are passed starting at ?FUNC1?BIT, and all other parameters are passed starting at ?FUNC1?BYTE.

Refer to “Interfacing C Programs to Assembler” on page 163 for examples of the 6 function argument segments.

Functions that have parameters, local variables, or bit variables contain all additional segments for these variables. These segments can be overlaid by the BL51 Linker/Locator.

162

Chapter 6. Advanced Programming Techniques

 

 

They are created as follows based on the memory model used.

Small model segment naming conventions

 

Information

Segment Type

Segment Name

 

 

Program code

code

?PR?function_name?module_name

 

 

Local variables

data

?DT?function_name?module_name

 

 

Local bit variables

bit

?BI?function_name?module_name

 

 

 

 

 

Compact model segment naming conventions

 

 

Information

Segment Type

Segment Name

 

 

Program code

code

?PR?function_name?module_name

 

 

Local variables

pdata

?PD?function_name?module_name

 

 

Local bit variables

bit

?BI?function_name?module_name

 

 

 

 

 

Large model segment naming conventions

 

 

Information

Segment Type

Segment Name

 

 

Program code

code

?PR?function_name?module_name

 

 

Local variables

xdata

?XD?function_name?module_name

 

 

Local bit variables

bit

?BI?function_name?module_name

 

The names for functions with register parameters and reentrant attributes are 6 modified slightly to avoid run-time errors. The following table lists deviations

from the standard segment names.

Declaration

Symbol

Description

void func (void) …

FUNC

Names of functions that have no arguments or

 

 

whose arguments are not passed in registers are

 

 

transferred to the object file without any changes.

 

 

The function name is converted to uppercase.

void func1 (char) …

_FUNC1

For functions with arguments passed in registers,

 

 

the underscore character (‘_’) is prefixed to the

 

 

function name. This identifies those functions that

 

 

transfer arguments in CPU registers.

void func2 (void) reentrant

_?FUNC2

For functions that are reentrant, the string “_?” is

 

prefixed to the function name. This is used to

 

 

identify reentrant functions.

 

 

 

Соседние файлы в папке HLP