3 ASSEMBLER

This chapter contains the following sections:

Description
Invocation
Asm51 Options
Segments and Memory Allocation

3.1 Description

The 8051 assembler asm51 is a three pass program:

Pass 1 Reads the source file and performs lexical actions such as evaluating equate statements. This pass will generate an intermediate token file.

Pass 2 Performs optimization of jump instructions.

Pass 3 Generates machine code and list file.

Because of the three passes, the assembler can perform optimizations for the generic jump and call instructions (jmp/call), even with forward references.

File inclusion and macro facilities are not integrated into the assembler. Rather, they are provided by the macro preprocessor mpp51, which is supplied as a separate program. The assembler can be used with or without the mpp51 macro preprocessor. Alternatively, another macro preprocessor, such as a standard C-preprocessor may be used.

3.2 Invocatio n

The command line invocation of asm51 is:

When you use a UNIX shell (C-shell, Bourne shell), controls containing special characters (such as '( )' ) must be enclosed with "". The invocations for UNIX and PC are the same, except for the -? option in the C-shell:

Invocation with -V only displays a version header. -? shows the invocation syntax.

The asm51 assembler requires the source file name to be its first argument. This file contains assembly code which is either hand written, generated by cc51 or processed by mpp51. Any name is allowed for this file. If this name does not have an extension, the extension .src is assumed. The remaining arguments on the invocation line are considered assembler controls which are processed before the first source line is read. For a description of all possible controls, please refer to the chapter on assembler controls.

In the default situation, an object file with extension .obj and a list file with extension .lst are produced. With appropriate assembler controls it is possible to suppress these files, or give them another name. Error messages are written to the terminal, unless they are directed to an error list file with the $errorprint() assembler control.

3.3 Asm51 Options

The assembler recognizes the following options:

Option Description
-? Display invocation syntax
-Ccpu Use special function register definitions for cpu
-Idirectory Look in directory for the .sfr file
-V Display version header only

Table 3-1: Options summary

A detailed description of the option is given below.

With options that can be set from within EDE, you will find a mouse icon that describes the corresponding action.

-?

Option:

-?

Description:

Display an explanation of the invocation syntax at stdout.

Example:

asm51  -?

-C

Option:

From the Project menu, select Project Options... Expand the Processor entry and select Processor Selection. Choose a processor from the list of derivatives or select User specified and enter your own processor type.

-Ccpu

Arguments:

The cpu name which identifies your 8051 derivative.

Description:

Use special function register definitions for cpu. The filename looked for is "regcpu.sfr".

With the -I option you can specify an alternative directory to look for the .sfr file.

Example:

To specify to the assembler to look for a file named regp87cl881.sfr, and to use this file as a special function register definition file, enter:

-I

-I

From the Project menu, select Directories... Add one or more directory paths to the Include Files Path field.

Option:

-Idirectory

Arguments:

The name of the directory to search for the .sfr file.

Description:

Specify alternative directories to search for .sfr files. First the path specified with the -I option is searched. If the .sfr file is not found, the directory ..\include relative to the directory where the assembler binary is located is searched.

With the -C option you can specify the .sfr file which should be used.

Example:

asm51 -I\proj\include test.asm

-C

-V

Option:

-V

Description:

With this option you can display the version header of the assembler. This option must be the only argument of asm51. Other options are ignored. The assembler exits after displaying the version header.

Example:

asm51 -V
TASKING 8051 asssembler     vx.yrz Build nnn
Copyright years Altium BV   Serial# 00000000

3.4 Segments and Memory Allocation

A segment is a logical piece of code or data which will be assigned to physical memory as a single block. Every segment has a name, a memory type (CODE, DATA, IDATA, XDATA or BIT) and possibly some segment attributes. There are two types of segments: relocatable segments and absolute segments.

The assembler can handle up to 253 different segments in a module. Each module consists of at least one segment. Segments in different modules, but with the same name will be combined into one segment by the linker. The resulting number of segments the linker generates may not exceed 1250.


Copyright © 2002 Altium BV