STARTUP.A51

The file STARTUP.A51  contains the startup code for a C51 target program. This source file is located in the \FSI\LIB  directory. Include a copy of this file in each 8051 project that needs custom startup code.

This code is executed immediately upon reset of the target system and optionally performs the following operations in order:
  Clears internal data memory

  Clears external data memory

  Clears paged external data memory

  Initializes the small model reentrant stack and pointer

  Initializes the large model reentrant stack and pointer

  Initializes the compact model reentrant stack and pointer

  Initializes the 8051 hardware stack pointer

  Transfers control to the main C function.

STARTUP.A51  provides assembly constants you may change to control the actions taken at startup. These are defined in the following table.

Constant Name

Description

IDATALEN

Indicates the number of bytes of idata that are to be initialized to 0.  The default is 80h because most 8051 derivatives contain at least 128 bytes of internal data memory. Use a value of 100h for the 8052 and other derivatives that have 256 bytes of internal data memory.

If your target system supports a power-down mode and you want to disable internal data memory clearing, set IDATALEN  to 0. However, you must ensure that the byte variable ?C_DSTK_LEVEL is set to zero. This is required by functions included from the library.

XDATASTART

Specifies the xdata address to start initializing to 0.

XDATALEN

Indicates the number of bytes of xdata to be initialized to 0. The default is 0.

PDATASTART

Specifies the pdata address to start initializing to 0.

PDATALEN

Indicates the number of bytes of pdata to be initialized to 0. The default is 0.

IBPSTACK

Indicates whether or not the small model reentrant stack pointer (?C_IBP) should be initialized. A value of 1 causes this pointer to be initialized. A value of 0 prevents initialization of this pointer. The default is 0.

IBPSTACKTOP

Specifies the top start address of the small model reentrant stack area. The default is 0xFF in idata memory.

C51 does not check to see if the stack area available satisfies the requirements of the applications. It is your responsibility to perform such a test.

XBPSTACK

Indicates whether or not the large model reentrant stack pointer (?C_XBP) should be initialized. A value of 1 causes this pointer to be initialized. A value of 0 prevents initialization of this pointer. The default is 0.

XBPSTACKTOP

Specifies the top start address of the large model reentrant stack area. The default is 0xFFFF in xdata memory.

C51 does not check to see if the stack area available satisfies the requirements of the applications. It is your responsibility to perform such a test.

PBPSTACK

Indicates whether the compact model reentrant stack pointer (?C_PBP) should be initialized. A value of 1 causes this pointer to be initialized. A value of 0 prevents initialization of this pointer. The default is 0.

PBPSTACKTOP

Specifies the top start address of the compact model reentrant stack area. The default is 0xFF in pdata memory.

C51 does not check to see if the stack area available satisfies the requirements of the applications. It is your responsibility to perform such a test.

PPAGEENABLE

Enables (a value of 1) or disables (a value of 0) the initialization of port 2 of the 8051 device. The default is 0. The addressing of port 2 allows the mapping of 256 byte variable memory in any arbitrary xdata page.

PPAGE

Specifies the value to write to Port 2 of the 8051 for pdata memory access. This value represents the xdata memory page to use for pdata.  This is the upper 8 bits of the absolute address range to use for pdata.

As an example, if the pdata area begins at address 1000h (page 10h) in the xdata memory, PPAGEENABLE  should be set to 1 and PPAGE  should be set to 10h. The L51 Linker/Locator must contain a value between 1000h and 10FFh in the PDATA control directive. For example:

L51 <input modules> PDATA (1050H)

Neither L51 nor C51 checks to see if the PDATA control directive and the PPAGE  assembler constant are specified correctly. You must ensure that these parameters contain suitable values.