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

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

69

 

 

Chapter 3. Writing Assembly Programs

The Ax51 macro assembler is a multi pass assembler that translates x51 assembly language programs into object files. These object files are then combined or linked using the Lx51 Linker/Locator to form an executable, ready to run, absolute object module. As a subsequent step, absolute object modules can be converted to Intel HEX files suitable for loading onto to your target hardware, device programmer, or ICE (In-Circuit Emulator) unit.

The following sections describe the components of an assembly program, and some aspects of writing assembly programs. An assembly program consists of

one or more statements. These statements contain directives, controls, and 3 instructions.

Assembly Statements

Assembly program source files are made up of statements that may include assembler controls, assembler directives, or x51 assembly language instructions (mnemonics). For example:

$TITLE(Demo Program #1)

CSEG AT 0000h

JMP $

END

This example program consists of four statements. $TITLE is an assembler control, CSEG and END are assembler directives, and JMP is an assembly language instruction.

Each line of an assembly program can contain only one control, directive, or instruction statement. Statements must be contained in exactly one line. Multi– line statements are not allowed.

Statements in x51 assembly programs are not column sensitive. Controls, directives, and instructions may start in any column. Indentation used in the examples in this manual, is done for program clarity and is neither required nor expected by the assembler. The only exception is that arguments and instruction operands must be separated from controls, directives, and instructions by at least one space.

Shaded directives and options are available only in AX51 and A251.

70

Chapter 3. Writing Assembly Programs

 

 

All x51 assembly programs must include the

END directive. This directive

signals to the assembler that this is the end of the assembly program. Any instructions, directives, or controls found after the END directive are ignored. The shortest valid assembly program contains only an END directive.

 

Directives

 

Assembler directives instruct the assembler how to process subsequent assembly

 

language instructions. Directives also provide a way for you to define program

 

constants and reserve space for variables.

3

“Chapter 4. Assembler Directives” on page 99 provides complete descriptions

and examples of all of the assembler directives that you may include in your

 

program. Refer to this chapter for more information about how to use directives.

 

Controls

Assembler controls direct the operation of the assembler when generating a listing file or object file. Typically, controls do not impact the code that is generated by the assembler. Controls can be specified on the command line or within an assembler source file.

The conditional assembly controls are the only assembler controls that will impact the code that is assembled by the Ax51 assembler. The IF, ELSE, ENDIF, and ELSEIF controls provide a powerful set of conditional operators that can be used to include or exclude certain parts of your program from the assembly.

“Chapter 7. Invocation and Controls” on page 195 describes the available assembler controls in detail and provides an example of each. Refer to this chapter for more information about control statements.

Instructions

Assembly language instructions specify the program code that is to be assembled by the Ax51 assembler. The Ax51 assembler translates the assembly

Shaded directives and options are available only in AX51 and A251.

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