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

402 Appendix A. Application Examples

 

 

CSAMPLE – C Compiler Example

A

 

This section describes shows a x51 program, developed with the Cx51 compiler.

 

This program demonstrates the concept of modular programming development

 

 

and can be translated using the various tool versions.

 

 

 

The program calculates the sum of two input numbers and displays the result.

 

 

Numbers are input with the getchar library function and results are output with

 

 

the printf library function. The program consists of three source modules,

 

 

which are translated using the following command lines.

 

 

Using C51 and BL51

 

 

The following commands are required to translate and link the C example with

 

 

the C51 compiler and the BL51 linker/locater. The output file can be converted

 

 

into an Intel HEX file with the OH51 hex file converter.

 

 

 

 

 

C51 CSAMPLE1.C DEBUG OBJECTEXTEND

 

 

C51 CSAMPLE2.C DEBUG OBJECTEXTEND

 

 

C51 CSAMPLE3.C DEBUG OBJECTEXTEND

 

 

The DEBUG and OBJECTEXTEND control directs the compiler to include

 

 

complete symbol information in the object file.

 

 

After compilation, the files are linked using the BL51 linker/locator:

 

 

 

 

 

BL51 CSAMPLE1.OBJ, CSAMPLE2.OBJ, CSAMPLE3.OBJ PRECEDE (?DT?CSAMPLE3) IXREF

 

 

In the above linker command line, the PRECEDE control locates the

 

 

?DT?CSAMPLE3 segment before other internal data memory segments. The

 

 

IXREF control includes a cross reference report in the linker listing (M51) file.

 

 

The linker creates an absolute object module that is stored in the file CSAMPLE1.

 

 

This file can be used as input for debuggers or may be used to create an Intel

 

 

HEX file using the OH51 object hex converter with the following command:

 

 

 

 

 

OH51 CSAMPLE1

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

403

 

 

Using C51 and LX51

The commands for translating the application with the C51 compiler and the

A

LX51 linker/locater are:

C51 CSAMPLE1.C DEBUG OMF251

C51 CSAMPLE2.C DEBUG OMF251

C51 CSAMPLE3.C DEBUG OMF251

The DEBUG control directs the compiler to include symbol information in the object file. The OMF251 control generates extended object files that support the extensions of the LX51 linker/locater. The files are linked with:

LX51 CSAMPLE1.OBJ, CSAMPLE2.OBJ, CSAMPLE3.OBJ SEGMENTS (?DT?CSAMPLE3) IXREF

The SEGMENTS control replaces the PRECEDE control used in the BL51 command line to locate the ?DT?CSAMPLE3 segment before other internal data memory segments. The IXREF control includes a cross reference in the linker listing (MAP) file. The file CSAMPLE1 is the absolute object module created by the linker. This file can be used as input for debuggers or may be converted into an Intel HEX file using OHX51 with the following command:

OHX51 CSAMPLE1

Using C251 and L251

The Intel/Atmel WM 251 application is build with the following commands:

C251 CSAMPLE1.C DEBUG

C251 CSAMPLE2.C DEBUG

C251 CSAMPLE3.C DEBUG

After assembly, the files are linked by the L251 linker/locator with:

L251 CSAMPLE1.OBJ, CSAMPLE2.OBJ, CSAMPLE3.OBJ SEGMENTS (?DT?CSAMPLE3) IXREF

The SEGMENTS control locates the ?DT?CSAMPLE3 segment before other internal data memory segments. The IXREF control includes a cross reference in the linker listing (MAP) file. The file CSAMPLE1 is the absolute object module created by the linker. This file can be used as input for debuggers or may be converted into an Intel HEX file using OH251 with the following command:

OH251 CSAMPLE1

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