This chapter contains the following sections:
Description
How the Assembler Searches for Include Files
The assembler converts hand-written or compiler-generated assembly language programs into machine language, using the Executable and Linking Format (ELF) for object files.
The assembler takes the following files for input and output:
Figure 6-1: Assembler
This chapter first describes the assembly process. The various assembler optimizations are described in the second section. Third it is described how to call the assebmler and how to use its options. An extensive list of all options and their descriptions is included in the Reference Guide. Finally, a few important basic tasks are described.
The assembler generates relocatable output files with the extension .o. These files serve as input for the linker.
1. Preprocess directives
2. Check syntax of instructions
3. Instruction grouping and reordering
4. Optimization (instruction size and generic instructions)
5. Generation of the relocatable object file and optionally a list file
The assembler integrates file inclusion and macro facilities. See section 4.9, Macro Operations, in Chapter TriCore Assembly Language for more information.
The astc assembler performs various optimizations to reduce the size of the assembled applications. There are two options available to influence the degree of optimization. To enable or disable optimizations:
1. From the Project menu, select Project Options...
2. Expand the Assembler entry and select Optimization.
You can enable or disable the optimizations described below. The command line option for each optimization is given in brackets.
See also option
-O (--optimize)
in section 4.2,
Assembler Options, in Chapter Tool Options of the TriCore
Reference Guide.
When this option is enabled, you can use generic instructions in your assembly source. The assembler tries to replace the generic instructions
by faster or smaller instructions. For example, the instruction
jeq d0,#0,label1 is replaced by jz d0,label1.
By default this option is enabled. Because shorter instructions may influence the number of cycles, you may want to disable this option
when you have written timed code. In that case the assembler encodes all instructions as they are.
When this option is enabled, the assembler tries to find the shortest possible operand encoding for instructions. By default this option is enabled.
EDE uses a makefile to build your entire project. You can set options specific for the assembler. After you have build your project, the output files of the assembling step are available in your project directory.
To assemble your program, click either one of the following buttons:
Assembles the currently selected assembly file (.asm
or .src).
This results in a relocatable object file (.o).
Builds your entire project but looks whether there are already files available that are needed in the building process. If so, these files will not be generated again, which saves time.
Builds your entire project unconditionally. All steps necessary to obtain the final .elf file are performed.
To access the TriCore processor options:
1. From the Project menu, select Project Options...
2. Expand the Processor entry, fill in the Processor Definition page and optionally the Startup page and click OK to accept the processor options.
To get access to the assembler options:
1. From the Project menu, select Project Options...
2. Expand the Assembler entry, fill in the various pages and click OK to accept the compiler options.
The following processor options are available:
EDE options | Command line | ||||||||
Target | |||||||||
Target processor User defined TriCore 2 |
-Ccpu --is-tricore2 | ||||||||
FPU present | --fpu-present | ||||||||
MMU present | --mmu-present | ||||||||
Bypasses | |||||||||
CPU functional problem bypasses |
--silicon-bug= bug
Startup |
|
Automatically add cstart.asm to your project |
EDE only |
Bus Configuration |
|
Initialize bus configuration registers in startup code |
EDE only | |
Table 6-1: Processor options
The following assembler options are available:
EDE options | Command line | ||||||||||||||||||||||||||
Preprocessing | |||||||||||||||||||||||||||
Select TASKING preprocessor or no preprocessor | -m{t|n} | ||||||||||||||||||||||||||
Define preprocessor macro | -Dmacro[=def ] | ||||||||||||||||||||||||||
Include '.def' file | --no-tasking-sfr | ||||||||||||||||||||||||||
List File | |||||||||||||||||||||||||||
Generate list file | -l | ||||||||||||||||||||||||||
Include section summary in list file | -tl | ||||||||||||||||||||||||||
Suboptions for the Generate list file option |
-Lflags
Debug Information |
|
No debug information | Automatic HLL or assembly level debug information Custom debug information
-gAHLS | -gs -gflag
Optimization |
|
Allow generic instructions | Optimize instruction size
-Og/-OG
(= on/off) | -Os/-OS
Warnings |
|
Report all warnings | Suppress all warnings Suppress specific warnings
no option -w | -w -wnum[,num]...
Treat warnings as errors |
--warnings-as-errors |
Miscellaneous |
|
Assemble case sensitive |
-c |
Allow memory management instructions |
--mmu-present |
Allow hardware floating-point instructions |
--fpu-present |
Labels are by default: | local (default) global
| -il -ig
Additional command line options |
options | |
Table 6-2: Assembler options
The following options are only available on the command line:
Description | Command line | ||||||
Display invocation syntax | -? | ||||||
Show description of diagnostic(s) | --diag=[fmt:]{all|nr,...} | ||||||
Redirect diagnostic messages to a file | --error-file[=file] | ||||||
Read options from file |
-f file
Keep output file after errors |
-k |
Specify name of output file |
-o file |
Display version header only |
-V | |
Table 6-3: Assembler command line options
The invocation syntax on the command
line is:
For a complete overview of all options
with extensive description, see section 4.2,
Assembler Options, of Chapter Tool Options of the TriCore Reference Guide.
Before you call the assembler, you need to tell the assembler for which target processor it needs to assemble. Based on the processor type, the assembler includes a special function register file. This is a regular include file which enables you to use virtual registers that are located in memory.
The settings in EDE affect your whole project. If you
already specified these settings, you do not need to specify them again for
the assembler. When you use the command line, you must specify the same options to the assembler as you did for the compiler.
1. From the Project menu, select Project Options...
2. Expand the Processor entry and select Processor Definition.
3. In the Target processor list select the target processor.
4. Click OK to accept the new project settings.
1. From the Project menu, select Project Options...
2. Expand the Processor entry and select Processor Definition.
3. In the Target processor list, select one of the (user defined ...) entries.
4. Specify (part of) the name of the user defined SFR files.
5. (Optional) Specify if your user defined target processor has an FPU (Floating-Point Unit) and/or an MMU (Memory Management Unit).
6. Click OK to accept the new project settings.
astc -Ctc2 test.src
When you use include files, you can specify their location in several ways. The assembler searches the specified locations in the following order:
1. If the .INCLUDE directive contains a pathname, the assembler looks for this file. If no path is specified, the assembler looks in the same directory as the source file.
2. When the assembler did not find the include file, it looks in the directories that are specified in the Directories dialog (-I option).
3. When the assembler did not find the include file (because it is not in the specified include directory or because no directory is specified), it looks which paths were set during installation. You can still change these paths if you like.
See section 1.3.1
, Configuring the Windows Environment and environment variable ASTCINC in section 1.3.2,
Configuring the Command Line Environment, in Chapter Software Installation.
4. When the assembler still did not find the include file, it finally tries the default include directory relative to the installation directory.
The list file is an additional output file that contains information about the generated code. With the options in the List File page of the Assembler entry in the Project Options dialog you choose to generate a list file or to skip it (-l option). You can also customize the amount and form of information (-L option).
If the assembler generates errors or warnings, these are reported in the list file just below the source line that caused the error or warning.
See section 5.1
, Assembler List File Format, in Chapter List File Formats of the Reference Guide for an explanation
of the format of the list file.
astc -l test.src
With this command the list file test.lst is created.
The assembler produces error messages of the following types:
After a fatal error the assembler immediately aborts the assembling process.
Errors are reported, but the assembler continues assembling. No output files are produced unless you have set the assembler option --keep-output-files (the resulting output file may be incomplete).
Warning messages do not result into an erroneous assembly output file. They are meant to draw your attention to assumptions of the assembler for a situation which may not be correct. You can control warnings in the Assembler | Warnings page of the Project | Project Options... menu (assembler option -w).
1. In the Help menu, enable the option Show Help on Tool Errors.
2. In the Build tab of the Output window, double-click on an error or warning message.
astc --diag=[format:]{all | number,...}
See assembler option --diag
in section 4.2,
Assembler Options in Chapter Tool Options of the TriCore
Reference Guide.