• Keine Ergebnisse gefunden

EPSONAssembly list file

File format: Text file

File name: <File name>.lst (The <File name> is the same as that of the input file.) Output destination: Current directory

Description: Assembly source file in which assembled results (address and object code) are added to each line. It is delivered when the startup option (-l) is specified.

For specific examples, refer to Section 11.9 "Assembly List File".

Error file

File format: Text file

File name: as33.err

Output destination: Current directory

Description: File delivered when the startup option (-e) is specified. It records error messages and other information which the as33 delivers via the Standard Output (stdout).

11.3 Starting Method

11.3.1 Startup Format

General form of command line

as33 ^ [<startup option>] ^ [<file name>]

^ denotes a space.

[ ] indicates the possibility to omit.

<file name>: Specify an assembly source file name including the extension.

Operations on work bench

Select options and a source file, then click the [AS33] button.

In the command line, only one source file can be specified at a time.

The wb33 allows multiple files to be selected, in which case the as33 is executed as many times as the number of files selected.

11.3.2 Startup Options

The as33 comes provided with the following three types of startup options:

-g

Function: Addition of debugging information Specification on wb33: Check [debug info].

Explanation: · Creates an output file containing symbolic debugging information.

· Always specify this function when you perform symbolic debugging.

· Even if this option is not selected, the debugging information added in the C Compiler gcc33 or the Preprocessor pp33 for source display will not be cut off.

-l

Function: Output of assembly list file Specification on wb33: Check [list file].

Explanation: · Outputs an assembly list file.

-e

Function: Output of error files Specification on wb33: None

Explanation: · Delivers also in a file (as33.err) the contents that are output by the as33 via the Standard Output (stdout), such as error messages.

When entering options in the command line, you need to place one or more spaces before and after the option.

Example: c:\cc33\as33 -g -e -l test.ms

11.4 Messages

The as33 delivers its messages through the Standard Output (stdout).

If the as33 is started up by using the wb33's [AS33] button, the message is output to "wb33.err". When execution is completed, a message is displayed in the output window (default).

End message

The as33 outputs only the following end message when it ends normally.

Assembly Completed Usage output

If no file name was specified or an option was not specified correctly, the as33 ends after delivering the following message concerning the usage:

Assembler 33 Ver x.xx

Copyright (C) SEIKO EPSON CORP. 199x Usage:

as33 [options] <filename>

Options:

-e : produce log file (as33.err)

-g : generate debug information in object file -l : produce list file

Output:

object file (.o) list file (.lst) log file (as33.err) Example:

as33 -e -g -l sample.ms When error/warning occurs

If an error is produced, an error message will appear before the end message shows up.

Example: test.ms(7): Error: Invalid instruction syntax.

Assembly Completed

In the case of an error, the as33 ends without creating an output file.

If a warning is issued, a warning message will appear before the end message shows up.

Example: test.ms(12): Warning: Numeric range.

Assembly Completed

In the case of a warning, the as33 ends after creating an output file.

For details on errors and warnings, refer to Section 11.10 "Error/Warning Messages".

CHAPTER 11: ASSEMBLER

EPSON

11.5 Relocatable Assembling and Absolute Assembling

The as33 supports both the relocatable assembling and the absolute assembling. It even allows to develop software with relocatable modules and absolute modules existing in a mixed fashion.

11.5.1 Relocatable Assembling

The relocatable assembling is a method that assembles files without fixing addresses, so that the program will be able to work wherever on the memory the modules may be mapped. Therefore, no absolute address specification will be made in the source files. The C Compiler delivers assembly source files in the relocatable format.

In the relocatable assembling, the assembler performs the processing by applying the relative addresses from top of each section to the individual codes.

This information is output in the object file along with the codes, and all the addresses are determined by the processing of the Linker lk33.

Modules assembled by this method can freely be combined with other modules. This will let you use general-purpose modules thus assembled relocatably as a library in the software development for other models. For relocation by the Linker lk33, refer to Chapter 12, "Linker".

Refer to Chapter 15, "Librarian", for making libraries using the output objects.

The .abs pseudo-instruction, .org pseudo-instruction, and .set pseudo-instruction cannot be employed in the relocatable source files.

11.5.2 Absolute Assembling

The absolute assembling is a method that assembles source files by priory specifying the addresses where codes are to be mapped.

However, since the usefulness of the source files for various purposes is lost when they are linked with other modules, do not use this method unless you are creating a simple test program.

The absolute assembling is specified by the .abs pseudo-instruction written in the first line of the source file, and the address are set by using the .org pseudo-instruction. The .org pseudo-instruction and the .set pseudo-instruction to define absolute addresses can be employed only in the absolute source.

Example:

.abs ...Specifies the absolute assembling.

.code

.org 0x80000 ...Maps the following codes from address 0x80000.

.word 0x80004

BOOT:

ext 0x20

ld.w %r8,0x0

ld.w %sp,%r8 ; set SP

ld.w %r8,0x0 ; set global pointer :

.data

.org 0xC0000 ...Maps the following data from address 0xC0000.

.word 0x12345678

This method causes all the codes in that file to have absolute addresses. It cannot make part of a file relocatable.

However, even when a program is created in the form of one absolute source file, it needs to be passed through the Linker lk33 in order to obtain an execution file in which final addresses are defined. (In case of one file, remove the check on the [use .cm file] in the Work Bench wb33 for linking.)

Make sure there is only one instance of the CODE section, DATA section, and BSS section in each absolute file.

Basically, create a relocatable assembly source file, then relocate it by using the map function of the lk33.

11.6 Scope

Symbols defined in each source file can freely be referred to within that file. Such reference range of symbols is termed scope.

This scope remains the same both in the relocatable and the absolute assembling. Usually, reference can be made only within a defined file. If a symbol that does not exist in that file is referenced, the as33 creates the object file assuming that the symbol is an undefined symbol, leaving the problem to be solved by the lk33.

If your development project requires the use of multiple source files, it is necessary for the scope to be extended to cover other source files. The as33 has the pseudo-instructions (.global, .comm) that can be used for this purpose.

Use these instructions to declare that the symbol is a global symbol, so that it can referenced in other source files.

Symbols that can be referenced in only the file where they are defined are called "local symbols". Symbols that are declared to be global are called "global symbols". Local symbols – even when symbols of the same name are specified in two or more different files – are handled as different symbols. Global symbols – if defined as overlapping in multiple files – cause a warning to be generated in the lk33.

Example:

file1: file in which global symbol is defined

.global SYMBOL ...Global declaration of a symbol which is to be defined in this file.

SYMBOL:

: :

LABEL: ...Local symbol

: (Can be referred to only in this file)

.comm VAR1 4

file2: file in which a global symbol is referred

ext SYMBOL@rh

ext SYMBOL@m

call SYMBOL@rl ...Symbol externally referred :

ext VAR1@h

ext VAR1@m

ld.w %r1, VAR1@l ...Symbol externally referred

LABEL: ...Local symbol

: (Treated as a different symbol from LABEL of file1)

The as33 regards the symbols SYMBOL and VAR1 in the file2 as those of undefined addresses in the assembling, and includes that information in the object file it delivers. Those addresses are finally determined by the processing of the linker.

CHAPTER 11: ASSEMBLER

EPSON

11.7 Definition of Sections

In addition to the programs that control the CPU and peripheral circuits, the source file contains permanently fixed data, such as character generators, which does not require initialization, symbols for the variables stored in RAM and I/O memory control registers. These data and symbols, which bear different attributes, must finally be relocated into the corresponding physical memory locations by the linker, for example, programs must be relocated into the program area in ROM, and fixed data into the data area in ROM. For this reason, the Assembler is designed in such a way that the object code is classified by attribute into each section.

The following three sections exist:

1. CODE section Block for programs

2. DATA section Block for the data to be written into ROM 3. BSS section Block that is mapped into RAM, etc.

To allow to specify these sections in assembly source files, the as33 comes provided with pseudo-instructions.

Since the Compiler generates pseudo-instructions, you need not be concerned about sections when programming the C source.

CODE section

The .code pseudo-instruction defines a CODE section. A statement from this instruction to an instruction that defines some other section is assumed to be a program code/data, and is an object for the CODE section. The source file will be regarded as a CODE section by default. Therefore, the part that goes from top of the file, to another section will be processed as CODE section.

DATA section

The .data pseudo-instruction defines a DATA section. A statement from this instruction to an instruction that defines some other section is assumed to be data, and is an object for the DATA section. Therefore, nothing but the symbols to reference addresses and the pseudo-instructions to define data (.word, .half, .byte, .ascii, .space), those to define alignment (.align), and comments can be written in this area.

Although data can be written in the CODE section too, if you want the data blocks to be stored separately from programs after they are linked, data must be written in the DATA section.

BSS section

The .comm pseudo-instruction and the .lcomm pseudo-instruction are designed to define the symbol and size of a variables area. When either one of the instructions is described, the symbol will be set in a BSS section.

Although the BSS section basically consists in a RAM area, it can as well be used as a data memory area, such as I/O memory. Code definition in this area is meaningless in embedded type microcomputers, such as those of the E0C33 Family. When some other instruction or definition follows the .comm or .lcomm pseudo-instruction, the section changes to the type defined prior to the BSS section.

Although this section has no actual data as an object, it is required to generate symbol and map information.

Section management for relocatable source

In the relocatable assembling, identical sections will be joined together in order to create an object file composed of three integrated sections of CODE, DATA and BSS. Even for a section having no data described or no definition made, the section information will be delivered in the object file.

Sample definition of sections :

CODE1 (Program) :

.data :

DATA1 (Data definition) :

.comm RAM0,1

:

BSS1 (RAM area definition) :

.code :

CODE2 (Program) :

.data :

DATA2 (Data definition) :

.code :

CODE3 (Program) :

If you define sections in the manner shown above, the as33 will create an absolute object file composed in the following manner:

(0x00000000) CODE1 CODE2 CODE3

CODE section (0x00000000) DATA1

DATA2 DATA section

(0x00000000) BSS1 BSS section

CHAPTER 11: ASSEMBLER

EPSON