Program Objects

Program objects include the code generated for C program functions by the C51 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, C51 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 the “A51” section under “Interfacing to Other Languages” later in this chapter for examples of the 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 L51 Linker/Locator. 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 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.