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

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

19

 

 

Modular Program Development Process

This section is a brief discussion of the program development process with the

1

relocatable Ax51 assembler, Lx51 Linker/Locator, and the OHx51 code

conversion program.

Segments, Modules, and Programs

In the initial design stages, the tasks to be performed by the program are defined, and then partitioned into subprograms. Here are brief introductions to the kinds of subprograms used with the Ax51 assembler and Lx51 linker/locator.

A segment is a block of code or data memory. A segment may be relocatable or absolute. A relocatable segment has a name, type, and other attributes. Segments with the same name, from different modules, are considered part of the same segment and are called partial segments. Several partial segments with the same name are combined into one segment by the Lx51 linker/locater. An absolute segment cannot be combined with other segments.

A module contains one or more segments or partial segments. A module is a source code unit that can be translated independently. It contains all symbol definitions that are used within the module. A module might be a single ASCII text file that is created by any standard text editor. However, with you may use the include assembler directive to merge several text files. The Ax51 assembler translates a source file into an object file. Each object file is one module.

After assembly of all modules of the program, Lx51 processes the object module files. The Lx51 linker/locator assigns absolute memory locations to all the relocatable segments, combining segments with the same name and type. Lx51 also resolves all references between modules. Lx51 outputs an absolute object module file with the completed program, and a map file that lists the results of the link/locate process.

20 Chapter 1. Introduction

1

Translate and Link Process

Typically you will use the Ax51 assembler and the tools within the µVision2

IDE. For more information on using the µVision2 IDE refer to the User’s Guide

µVision2: Getting Started for 8051.

However, you may invoke the Ax51 assembler also from the command line. Simply type the name of the assembler version that you want to use, for example A51 at the Windows command prompt. On this command line, you must include the name of the assembler source file to be translated, as well as any other necessary control directives required to translate your source file. Example:

A51 DEMO.A51

The assembler output for this command line is:

A51 MACRO ASSEMBLER V6.00

ASSEMBLY COMPLETE. 0 WARNING(S), 0 ERROR(S)

After assembly of all your program modules, the object modules are linked and all variables and addresses are resolved and located into an executable program by the Lx51 linker. The following example shows a simple command line for the linker:

BL51 DEMO.OBJ, PRINT.OBJ

The linker generates an absolute object file as well as a map file that contains detailed statistic information and screen messages. The output of the linker is:

BL51 LINKER/LOCATER V4.00

LINK/LOCATE RUN COMPLETE. 0 WARNING(S), 0 ERROR(S)

Then you might convert the executable program into an Intel HEX file for PROM programming. This is done with the OHx51 hex conversion utility with the following invocation:

OH51 DEMO

The output of the hex conversion utility is:

OBJECT TO HEX FILE CONVERTER OH51 V2.40

GENERATING INTEL HEX FILE: DEMO.HEX

OBJECT TO HEX CONVERSION COMPLETED.

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

21

 

 

An example listing file generated by the assembler is shown on the following page.

A51 MACRO ASSEMBLER

ASSEMBLER DEMO PROGRAM

 

07/07/2000 18:32:30 PAGE 1

1

MACRO ASSEMBLER A51 V6.01

 

 

 

 

 

OBJECT MODULE PLACED IN demo.OBJ

 

 

 

 

 

ASSEMBLER INVOKED BY: C:\KEIL\C51\BIN\A51.EXE DEMO.A51 DEBUG

 

LOC

OBJ

 

LINE

SOURCE

 

 

 

 

 

 

 

 

1

$title

(ASSEMBLER DEMO PROGRAM)

 

 

 

 

2

; A simple Assembler Module for Demonstration

 

 

 

 

3

 

 

 

 

 

 

 

 

 

4

; Symbol Definition

 

 

000D

 

5

CR

EQU

13

 

; Carriage?Return

 

000A

 

6

LF

EQU

10

 

; Line?Feed

 

 

 

 

7

 

 

 

 

 

 

 

 

 

8

; Segment Definition

 

 

 

 

 

9

?PR?DEMO

SEGMENT

CODE ; Program Part

 

 

 

 

10

?CO?DEMO

SEGMENT

CODE ; Constant Part

 

 

 

 

11

 

 

 

 

 

 

 

 

 

12

; Extern Definition

 

 

 

 

 

13

EXTRN CODE (PRINTS, DEMO)

 

 

 

 

14

 

 

 

 

 

 

 

 

 

15

; The Program Start

 

 

----

 

 

16

 

CSEG

AT

0

; Reset Vector

 

0000

020000

F

17

 

JMP

Start

 

 

 

 

 

18

 

 

 

 

 

 

----

 

 

19

 

RSEG

?PR?DEMO

; Program Part

 

0000

900000

F

20

START:

MOV

DPTR,#Txt

; Demo Text

 

0003

120000

F

21

 

CALL

PRINTS

; Print String

 

 

 

 

22

;

 

 

 

 

 

0006

020000

F

23

 

JMP

DEMO

 

; Demo Program

 

 

 

 

24

 

 

 

 

 

 

 

 

 

25

; The Text Constants

 

 

----

 

 

26

 

RSEG

?CO?DEMO

; Constant Part

 

0000

48656C6C

 

27

Txt:

DB

'Hello World',CR,LF,0

 

0004

6F20576F

 

 

 

 

 

 

 

 

0008

726C640D

 

 

 

 

 

 

 

 

000C

0A00

 

 

 

 

 

 

 

 

 

 

 

28

 

 

 

 

 

 

 

 

 

29

 

END

 

 

; End of Module

 

SYMBOL TABLE LISTING

 

 

 

 

 

 

 

------ ----- -------

 

 

 

 

 

 

 

N A M E

 

T Y P E

V A L U E

ATTRIBUTES

 

 

?CO?DEMO . . . . .

C SEG

000EH

 

REL=UNIT

 

 

?PR?DEMO . . . . .

C SEG

0009H

 

REL=UNIT

 

 

CR . . . . . . . .

N NUMB

000DH

A

 

 

 

 

DEMO . . . . . . .

C ADDR

-----

 

EXT

 

 

 

LF . . . . . . . .

N NUMB

000AH

A

 

 

 

 

PRINTS . . . . . .

C ADDR

-----

 

EXT

 

 

 

START. . . . . . .

C ADDR

0000H

R

SEG=?PR?DEMO

 

 

TXT. . . . . . . .

C ADDR

0000H

R

SEG=?CO?DEMO

 

 

REGISTER BANK(S) USED: 0

 

 

 

 

 

 

ASSEMBLY COMPLETE.

0 WARNING(S), 0 ERROR(S)

 

 

 

 

22

 

 

Chapter 1. Introduction

 

 

 

 

 

 

 

Filename Extensions

1

 

Typically, the filename extension is used to indicate the contents of each file.

 

The following table lists the file name extensions that are used in the 8051 tool

 

 

chain.

 

 

 

 

 

 

 

 

 

Extension

Content and Description

 

 

 

.A51

 

Source code file: contains ASCII text that is the input for the Ax51 assembler.

 

 

 

.ASM

 

 

 

 

.SRC

 

 

 

 

.C

 

C source code file: contains ASCII text that is the input for the Cx51 ANSI C

 

 

 

.C51

 

compiler.

 

 

 

.INC

 

Include file: contains ASCII text that is merged into an source code file with the

 

 

 

.H

 

include directive. Also these files are input files for Ax51 or Cx51.

 

 

 

.OBJ

Relocatable object file: is the output of the Ax51 or Cx51 that contains the program

 

 

 

 

 

code and control information. Several relocatable object files are typically input files

 

 

 

 

 

for the Lx51 Linker/Locater.

 

 

 

.LST

 

Listing object file: is generated by Ax51 or Cx51 to document the translation

 

 

 

 

 

process. A listing file typically contains the ASCII program text and diagnostic

 

 

 

 

 

information about the source module. Appendix F describes the format of the Ax51

 

 

 

 

 

listing file.

 

 

 

.

(none)

Absolute object file: is the output of the Lx51. Typically it is a complete program

 

 

 

.ABS

that can be executed on the x51 CPU.

 

 

 

.M51

 

Linker map file: is the listing file generated from Lx51. A map file contains

 

 

 

.MAP

information about the memory usage and other statistic information.

 

 

 

.HEX

Hex file: is the output file of the OHx51 object hex converter in Intel HEX file

 

 

 

.H86

 

format. HEX files are used as input file for PROM programmers or other utility

 

 

 

 

 

programs.

 

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