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

404 Appendix A. Application Examples

 

BANK_EX1 – Code Banking with C51

A

The following C51 example shows how to compile and link a program using

multiple code banks.

 

The program begins with function main in C_ROOT.C. The main function calls

 

 

functions in other code banks. These functions, in turn, call functions in yet

 

different code banks. The printf function outputs the number of the code bank

 

in each function.

C_ROOT.C

Keil Software — A51/AX51/A251 Macro Assembler and Utilities

405

 

 

Using C51 and BL51

The program can be translated using the following commands:

C51 C_ROOT.C DEBUG OBJECTEXTEND

C51 C_BANK0.C DEBUG OBJECTEXTEND

C51 C_BANK1.C DEBUG OBJECTEXTEND

C51 C_BANK2.C DEBUG OBJECTEXTEND

A

contains the main function and is located in the common area. C_BANK0.C, C_BANK1.C, and C_BANK2.C contain the bank functions and are located in the bank area. The BL51 linker/locator is invoked as follows:

BL51 COMMON{C_ROOT.OBJ}, BANK0{C_BANK0.OBJ},

BANK1{C_BANK1.OBJ}, BANK2{C_BANK2.OBJ}

BANKAREA(8000H,0FFFFH)

The BANKAREA (8000H, 0FFFFH) control defines the address space 80000H to 0FFFFH as the area for code banks. The COMMON control places the C_ROOT.OBJ module in the common area. The BANK0, BANK1, and BANK2 controls place modules in bank 0, 1, and 2 respectively.

The BL51 linker/locator creates a listing file, C_ROOT.M51, which contains information about memory allocation and about the intra-bank jump table that is generated. BL51 also creates the output file C_ROOT that in banked object file format. You must use the OC51 banked object file converter to convert this file into standard object files:

OC51 C_ROOT

For this example program, the OC51 banked object file converter produces three standard object files from C_ROOT. They are listed in the following table.

Filename Contents

C_ROOT.B00 All information (including symbols) for code bank 0 and the common area.

C_ROOT.B01 Information for code bank 1 and the common area.

C_ROOT.B02 Information for code bank 2 and the common area.

You can create Intel HEX files for each of these object files by using the OH51 object to hex converter. The Intel HEX files you create with OH51 contain complete information for each code bank including the common area:

OH51 C_ROOT.B00 HEXFILE (C_ROOT.H00)

OH51 C_ROOT.B01 HEXFILE (C_ROOT.H01)

OH51 C_ROOT.B02 HEXFILE (C_ROOT.H02)

406 Appendix A. Application Examples

Using C51 and LX51

A

When you are using the extended LX51 linker/locater the program is generated

as shown below:

 

C51

C_ROOT.C

DEBUG OMF251

 

C51

C_BANK0.C

DEBUG OMF251

 

C51

C_BANK1.C

DEBUG OMF251

 

C51

C_BANK2.C

DEBUG OMF251

LX51 COMMON{C_ROOT.OBJ}, BANK0{C_BANK0.OBJ},

BANK1{C_BANK1.OBJ}, BANK2{C_BANK2.OBJ}

BANKAREA(8000H,0FFFFH)

The LX51 linker/locator creates a listing file, C_ROOT.MAP, which contains information about memory allocation and about the intra-bank jump table that is generated. The linker output file C_ROOT can be directly converted into an Intel HEX file with OHX51:

OHX51 C_ROOT

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