HC08ASMRM
HC08ASMRM
HC08ASMRM
How to Contact Us
3 Environment 121
Current directory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
Environment macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Global initialization file - mctools.ini (PC only) . . . . . . . . . . . . . . . . . . . . . . . 124
Local configuration file (usually project.ini) . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Line continuation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Environment variables details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
ABSPATH: Absolute file path. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
ASMOPTIONS: Default assembler options . . . . . . . . . . . . . . . . . . . . . . . . 128
COPYRIGHT: Copyright entry in object file . . . . . . . . . . . . . . . . . . . . . . . 129
DEFAULTDIR: Default current directory. . . . . . . . . . . . . . . . . . . . . . . . . . 130
ENVIRONMENT: Environment file specification . . . . . . . . . . . . . . . . . . . 131
ERRORFILE: Filename specification error . . . . . . . . . . . . . . . . . . . . . . . . 132
GENPATH: Search path for input file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
INCLUDETIME: Creation time in the object file. . . . . . . . . . . . . . . . . . . . 135
OBJPATH: Object file path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
SRECORD: S-Record type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
TEXTPATH: Text file path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
TMP: Temporary directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
USERNAME: User Name in object file . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
4 Files 141
Input files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Source files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Include files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Output files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Object files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Absolute files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
S-Record Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Listing files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Debug listing files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Error listing file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
File processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
6 Sections 221
Section attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
9 Macros 331
Macro overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
Defining a macro. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
Calling macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
Macro parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
Macro argument grouping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
Labels inside macros. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
Macro expansion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
Nested macros. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
II Appendices
A Global Configuration File Entries 379
[Installation] Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .379
Path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
Group. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
[Options] Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
DefaultDir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
[XXX_Assembler] Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
SaveOnExit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
SaveAppearance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
SaveEditor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382
SaveOptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382
RecentProject0, RecentProject1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382
[Editor] Section. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
Editor_Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
Editor_Exe. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
Editor_Opts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
EditorDDEServiceName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .395
Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .396
Index 403
Highlights
The major features of the HC(S)08/RS08 Assembler are:
• Graphical User Interface
• On-line Help
• 32-bit Application
• Conformation to the Freescale Assembly Language Input Standard
Programming Overview
In general terms, an embedded systems developer programs small but powerful
microprocessors to perform specific tasks. These software programs for controlling the
hardware is often referred to as firmware. One such use for firmware might be controlling
small stepping motors in an automobile seat.
The developer instructs what the hardware should do with one or more programming
languages, which have evolved over time. The three principal languages in use to program
embedded microprocessors are C and its variants, various forms of C++, and assembly
languages which are specially tailored to families of microcontrollers. C and C++ have
been fairly standardized through years of use, whereas assembly languages vary widely
and are usually designed by semiconductor manufacturers for specific families or even
subfamilies of their embedded microprocessors.
Assembly language instructions are considered as being at a lower level (closer to the
hardware) than the essentially standardized C instructions. Programming in C may require
some additional assembly instructions to be generated over and beyond what an
experienced developer could do in straight assembly language to accomplish the same
result. As a result, assembly language programs are usually faster to execute than C
instructions, but require much more programming effort. In addition, each chip series
usually has its own specialized assembly language which is only applicable for that family
(or subfamily) of CPU derivatives.
Higher-level languages like C use compilers to translate the syntax used by the
programmer to the machine-language of the microprocessor, whereas assembly language
uses assemblers. It is also possible to mix assembly and C source code in a single project.
See the Mixed C and Assembler Applications chapter.
This manual covers the Assembler dedicated to the Freescale 8-bit HC(S)08/RS08 series
of microcontrollers. There is a companion manual for this series that covers the HC(S)08
Compiler.
Project directory
A project directory contains all of the environment files that you need to configure your
development environment.
In the process of designing a project, you can either start from scratch by making your
own Source code, configuration (*.ini), and various layout files for your project for use
with standalone project-building tools. This was how embedded microprocessor projects
were developed in the recent past. On the other hand, you can have the CodeWarrior IDE
coordinate and manage the entire project. This is recommended because it is easier and
faster than employing standalone tools. However, you can still utilize any of the Build
Tools in the CodeWarrior suite.
External Editor
The CodeWarrior IDE reduces programming effort because its internal editor is
configured with the Assembler to enable error feedback. You can use the Configuration
dialog box of the standalone Assembler or other standalone CodeWarrior Tools to
configure or to select your choice of editors. Refer to the Editor Setting dialog box section
of this manual.
The Microcontroller New Project dialog box appears, showing the Device and
Connection panel of the Wizard Map (Figure 1.3).
5. Enter the Project Parameters of the Wizard Map for your project.
a. For the programming language, check Relocatable Assembly and uncheck both C
and C++.
b. Type the name for the project in the Project name text box.
In the event that you want another location for the project directory than the default
in the Location: text box, press Set and browse to the new location. There is no
need to first prepare an empty folder, as the CodeWarrior IDE automatically
creates its own folder, called the project directory.
NOTE If you do not use the default Location for the project directory, you need not
enter a name in the Project name: text box. Whatever you enter in the File
name: text box will be entered into Location automatically.
The CodeWarrior IDE uses the default *.mcp extension, so you do not have to
explicitly append any extension to the filename.
NOTE To add any existing files to your project, browse in the Add existing files to the
project panel for the files and press the Add button. The added files then appear
in the Project Files panel on the right. No user files are to be added for this
project, so you can either uncheck the Copy files to project check box or make
sure that no files are selected and leave this check box checked.
The default (None) is selected. For this simple demonstration project, you do not need
the Rapid Application Development (RAD) tool (Processor Expert) in the
CodeWarrior Development Studio for Microcontrollers V6.1. A basic demonstration
assembly language project is being created. In practice, you would probably routinely
use Processor Expert because of its many advantages.
9. Press Finish >. The Wizard now creates the project (Figure 1.6).
If you expand the three folder icons, actually groups of files, by clicking in the
CodeWarrior project window, you can view some of the files created by the CodeWarrior
IDE. In general, any files in the project window with red check marks will remain checked
until they are successfully assembled, compiled, or linked. At this final stage of the
Wizard, you could safely close the project and reopen it later. A CodeWarrior project
reopens in the same configuration it had when it was last saved (Figure 1.8).
Figure 1.8 Project window showing some of the files that the Wizard created
Examine the types and location of folders and files that the CodeWarrior IDE created in
the actual project directory so that you know their location if you later configure the
Assembler. If you work with standalone tools such as a Compiler, Linker, or Simulator/
Debugger, you may need to specify the paths to these files. So it is helpful to know their
typical locations and functions.
Use the Windows Explorer (Figure 1.9) to examine the actual folders and files created for
your project and displayed in the project window above. The name and location for the
project directory are what you selected when creating the project using the Wizard.
The project directory holds a total of six subfolders and 15 files at this point. The major
file for any CodeWarrior project is its <project_name>.mcp file. This is the file you
can use to reopen your project.
Return to the CodeWarrior project window. Double-click on the main.asm file in the
Sources group. The CodeWarrior editor opens the main.asm file (Figure 1.10).
You can use this sample main.asm file as a base to rewrite your own assembly source
program. Otherwise, you can import other assembly-code files into the project and delete
the default main.asm file from the project. For this project, the main.asm file contains
the sample Fibonacci program.
As a precaution, you can see if the project is configured correctly and if the source code is
free of syntactical errors. It is not necessary that you do so, but it is recommended that you
make (build) the newly created default project. Either press the Make button from the
toolbar or select Project > Make from the Project menu. All of the red check marks will
disappear after a successful building of the project (Figure 1.11).
Use Windows Explorer to look into the project directory after the first successful build
(make) of the project. Build creates another subfolder and four more files (Figure 1.12).
The new ObjectCode subfolder holds an object file for every assembly source-code file
that is assembled. In this case, the main.asm.o object-code file was generated.
CodeWarrior groups
These groups and their usual functions are:
• Sources
This group contains the assembly source code files.
• Includes
This group holds include files. One include file is for the particular CPU derivative.
In this case, the MC68HC908GP32.inc file is for the MC68HC908GP32
derivative.
• Project Settings – Linker Files
This group holds the burner file, the Linker PRM file, and the Linker mapping file.
NOTE The default configuration of the project by the Wizard does not generate an
assembler output listing file for every *.asm source file. However, you can
afterwards select the Generate a listing file in the assembler options for the
Assembler to generate a format-configurable listing file of the assembly source
code (with the inclusion of include files, if desired). Assembler listing files
(with the *.lst file extension) are located in the bin subfolder in the project
directory when *.asm files are assembled with this option set.
TIP To set up your project for generating assembler output listing files, select:
Edit > <target_name> Settings > Target > Assembler for HC08 > Options >
Output. (The default <target_name> is Standard.) Check Generate a listing
file. If you want to format the listing files differently than the default, check
Configure listing file and make the desired options. You can also add these listing
files to the project window for easier viewing instead of having to continually hunt
for them. For example, you might add the listing files to the Sources group in order
to have them near the assembly source files in the project window.
This initial building of your project shows whether it is created and configured correctly.
Now you can utilize some of the CodeWarrior IDE features for managing your project.
One useful feature is the creation of additional build targets for your projects. You can use
multiple targets to have additional subprojects, each with its own files and configuration.
However, it is not at all necessary to use multiple build targets or rename files and groups
in the CodeWarrior IDE, so you might skip the following sections and resume the
Assembler part of this tutorial at Writing your assembly source files.
Creating a Target
The Wizard created one target which is named Standard. You can check this out for
yourself by double-clicking on the Targets tab in the project window. The Targets panel
appears (Figure 1.13).
2. Enter the name for the new target and select either of the two options.
Use the Clone existing target: option if you plan on using any material from the
existing (Standard) build target. You can later delete whatever you do not want.
3. Press OK.
Now there is another build target for your project (Figure 1.15).
You can use the new target by clicking its icon so that the black arrow is attached to it and
then select the Files tab. The project window now lists the files used for the new build
target. A number of these files will be the same cloned files used by the other targets, but
you can add or delete files as with any build target. You can also select which target is the
default upon opening the project by selecting Project > Set Default Target.
This project just cloned the default Standard build target without changing the
configuration. That does not do much at this point but change the <target_name>. So
let’s create a subfolder in the Sources folder and include another main.asm file that
you can use for your new build target. If you do not create another main.asm file in a
separate folder, any changes to the original main.asm file affect all build targets.
NOTE It is recommended that you rename the files that are not common with files in
other build targets to some unique filename for each build target. We will
rename them later after you see what might occur when common filenames are
used for files that differ among build targets.
One way to have a separate assembler-source file for each project is to remove the original
main.asm file from the project (both build targets simultaneously) and then add the
appropriate main.asm file back into each build target.
1. From the Files tab with either build target active, right-select the main.asm file and
select Remove from the right-context menu (Figure 1.16). In this case the Standard
build target was active when we removed the main.asm file.
Figure 1.16 Removing the original main.asm file simultaneously from all build targets
A Freescale CodeWarrior dialog box appears, asking if you want to remove this file
from the project.
2. Press OK.
The main.asm file is now removed from all build targets. However, main.asm still
exists in the Sources folder in the project directory.
3. From Windows Explorer, create new subfolders, one for each build target, in the
Sources folder. You may name them as you choose, but you should use a
meaningful name, such as the same name as the appropriate build target.
4. Cut the main.asm file from the Sources folder and paste it into each build target
folder (Figure 1.17).
Figure 1.17 Project directory with a separate main.asm source file for each build target
NOTE The main.asm file was added to each build target, but only one of them is
active. The inactive main.asm file will have n/a entries for the Code and Data
columns in the project window (Figure 1.20).
Figure 1.20 Project window showing active and inactive main.asm files
Figure 1.22 Docked-window view for the main.asm file and project window
Now you can modify the main.asm file in a minor manner. Let’s add a NOP instruction
after the CLI instruction.
1. Place the cursor at the end of the comment in the CLI instruction line
2. Press Enter on the keyboard.
3. Type NOP
4. Press Enter once more (Figure 1.23)
5. Save your changes.
There are numerous ways to save any changes made by the editor to the main.asm file.
Some of these are:
• Pressing the Save icon on the Toolbar
• Selecting File > Save or entering Ctrl+S with the keyboard.
• Selecting Project > Check Syntax (Ctrl+;). This also checks the syntax for the
main.asm file, as the name for the command suggests.
• Selecting Project > Compile (Ctrl+F7) or pressing the Compile icon on the Toolbar.
This also checks the syntax, assembles the main.asm file, and produces a
main.asm.o object-code file in the bin folder in the project directory, if
successful.
• Selecting Project > Bring Up To Date (Ctrl+U). If successful, this does everything
that Compile does plus assembling multiple assembly-code files. In addition, each
file with a red check mark is processed. However, no executable output (*.abs) file
is generated.
• Selecting Project > Make (F7) or pressing Make on any of the two Toolbars. This
effects all the functions that Bring Up To Date does in addition to generating an
executable *.asm file in the bin folder, if successful
• Selecting Project > Debug (F5) or pressing the Debug icon on any of the two
Toolbars. This does everything that Make does in addition to starting the Simulator/
Debugger Build Tool (hiwave.exe in the prog folder in the CodeWarrior
installation folder), if successful.
2. Press Options.
The Microcontroller Assembler Option Settings dialog box opens (Figure 1.25).
3. Under the Options tab, check Generate a listing file and also Do not print included
files in listing file (unless you actually want to view the sometimes lengthy include
files).
4. Press OK twice to close the dialog box and the preference panel.
5. Repeat this procedure for the remaining build targets.
With these options set, the Assembler generates a listing file in the bin folder for all
*.asm files for each build target. The filename for this listing file is the same as the
*.asm file, but with the *.lst file extension.
Using the same filename for the main.asm file for all build targets causes a problem for
the assembler output listing file. To which main.asm file does the main.lst listing
file correspond? Eliminate this confusion by choosing a unique filename for the
main.asm file for each build target. In this example, the poor practice of using common
filenames for files in different build targets was done intentionally so that:
• You can see the confusion it causes with listing files.
• You can employ another CodeWarrior functionality: renaming files.
Renaming files
It is possible to change the name of a file in the project window, add it to the project, and
remove the former file from the project window simultaneously.
1. Double-click on the active main.asm file’s icon in the project window.
The editor opens that file.
2. Select File > Save as.
The Save As dialog box appears (Figure 1.26).
4. Right click on the main.asm file name to bring up the context menu
5. Select Remove (Figure 1.27).
The main.asm file is removed from the build target. Repeat the process for the other
build target.
You can use this procedure for renaming other files in the project window:
1. Open the file in the project window that you want to rename.
2. Select File > Save As.
3. Browse for the folder in which to store the new file.
4. Enter a new filename.
5. Press Save.
Renaming a filename in this manner simultaneously removes the older file from and
imports the newer file into the project (window). Repeat this procedure for the other build
targets. You can delete the two unneeded main.asm files from the two subfolders in
Windows Explorer, if you choose, as they no longer are involved with the project. You
could also delete the main.lst listing file and the main.dbg file from the bin folder
if any of them is present.
If you build any of the two build projects from this point, a unique listing file is generated
for each build target in the bin folder.
2. Enter a name for the new group in the Enter name for new group: text box.
3. Press OK.
The new group appears in the project window (Figure 1.29).
NOTE There is only one reason for creating a group: to place one or more files in it. In
this case, the group name has an error. We will correct the name in the next
section.
Place the two listing files located in the bin folder into the new group. (If there are not
two listing files, one for each build target, build the build targets until there are two.)
1. Select the new group Bad Nam
2. Select Project > Add Files.
NOTE You can write an assembly application using one or several assembly units.
Each assembly unit performs one particular task. An assembly unit is
comprised of an assembly source file and, perhaps, some additional include
files. Variables are exported from or imported to the different assembly units
so that a variable defined in an assembly unit can be used in another assembly
unit. You create the application by linking all of the assembly units.
The usual procedure for writing an assembly source-code file is to use the editor that is
integrated into the CodeWarrior IDE. You can begin a new file by pressing the New Text
File icon on the Toolbar to open a new file, write your assembly source code, and later
save it with a *.asm file extension using the Save icon on the Toolbar to name and store
it wherever you want it placed - usually in the Sources folder.
After the assembly-code file is written, it is added to the project using the Project menu. If
the source file is still open in the project window, select the Sources group icon in the
project window, single click on the file that you are writing, and then select Project > Add
<filename> to Project. The newly created file is added to the Sources group in the project.
If you do not first select the destination group’s icon (for example, Sources) in the project
window, the file will probably be added to the bottom of the files and groups in the project
window, which is OK. You can drag and drop the icon for any file wherever you want in
the project window.
;*********************************************************************
;* This stationery serves as the framework for a user application. *
;* For a more comprehensive program that demonstrates the more *
;* advanced functionality of this processor, please see the *
;* demonstration applications, located in the examples *
;* subdirectory of the "CodeWarrior for Microcontrollers V6.1" *
;* program directory. *
;*********************************************************************
; export symbols
XDEF _Startup, main
; we use export 'Entry' as symbol. This allows us to
; reference 'Entry' either in the linker .prm file
; or from C/C++ later on
INCLUDE 'derivative.inc'
; variable/data section
MY_ZEROPAGE: SECTION SHORT ; Insert here your data definition
Counter: DS.B 1
FiboRes: DS.B 1
; code section
MyCode: SECTION
main:
_Startup:
LDHX #__SEG_END_SSTACK ; initialize the stack pointer
TXS
CLI ; enable interrupts
mainLoop:
CLRA ; A contains counter
cntLoop: INCA
CBEQA #14,mainLoop ; larger values cause overflow.
feed_watchdog
STA Counter ; update global.
BSR CalcFibo
STA FiboRes ; store result
LDA Counter
BRA cntLoop ; next round.
; Function to calculate fibonacci numbers. Argument is in A.
CalcFibo:
DBNZA fiboDo ; fiboDo
INCA
RTS
fiboDo:
PSHA ; the counter
CLRX ; second last = 0
LDA #$01 ; last = 1
FiboLoop: PSHA
ADD 1,SP
PULX
DBNZ 1,SP,FiboLoop
FiboDone: PULH ; release counter
RTS ; result in A
;**************************************************************
spurious - Spurious Interrupt Service Routine. *
;* (unwanted interrupt) *
;**************************************************************
spurious: ; placed here so that security value
NOP ; does not change all the time.
RTI
;**************************************************************
;* Interrupt Vectors *
;**************************************************************
ORG $FFFA
DC.W spurious ;
DC.W spurious ; SWI
DC.W _Startup ; Reset
Since the RS08 memory map is different from the HC08 memory map (and so is the
instruction set), Listing 1.2 shows a similar example for RS08.
NOTE In order to assemble files for the RS08 derivative pass the -Crs08 option to the
assembler. This can be done either directly (in the command line or in the
assembler command bar) or by choosing the “Code generation” tab from the
assembler options menu. Then select the “Derivative family” option and enable
the RS08 Derivative Family radio button.
XDEF Entry ; Make the symbol entry visible for external module
; This is necessary to allow the linker to find the
; symbol and use it as the entry point for the
; application.
cstSec: SECTION ; Define a constant relocatable section
var1: DC.B 5 ; Assign 5 to the symbol var1
dataSec: SECTION ; Define a data relocatable section
data: DS.B 1 ; Define one byte variable in RAM
codeSec: SECTION ; Define a code relocatable section
Entry:
LDA var1
main:
INCA
STA data
BRA main
When writing your assembly source code, pay special attention to the following:
• Make sure that symbols outside of the current source file (in another source file or in
the linker configuration file) that are referenced from the current source file are
externally visible. Notice that we have inserted the assembly directive XDEF
_Startup, main where appropriate in the example.
• In order to make debugging from the application easier, we strongly recommend that
you define separate sections for code, constant data (defined with DC) and variables
(defined with DS). This will mean that the symbols located in the variable or constant
data sections can be displayed in the data window component.
• Make sure to initialize the stack pointer when using BSR or JSR instructions in your
application. The stack can be initialized in the assembly source code and allocated to
RAM memory in the Linker parameter file, if a *.prm file is used.
NOTE The default assembly project using the CodeWarrior Wizard initializes the
stack pointer automatically with a symbol defined by the Linker for the end of
the stack __SEG_END_SSTACK. For the RS08 derivative, initializing the
stack does not apply.
The object files are generated and placed into the ObjectCode subfolder in the project
directory. The object file (and its path) that results from assembling the main.asm file in
the default Code Warrior project is:
<project_name>\<project_name>_Data\<build-target_name>\
ObjectCode\main.asm.o.
NOTE The build-target name can be changed to whatever you choose in the Target
Settings preference panel. Select Edit > <target> Settings > Target > Target
Settings and enter the revised target name into the Target Name: text box. The
default Target Name is Standard.
Or, you can assemble all the *.asm files and link the resulting object files to generate the
executable <target_name>.abs file by invoking either Make or Debug from the
Project menu (Project > Make or Project > Debug). This results in the generation of the
<target_name>.abs file in the bin subfolder of the project directory.
Two other files generated by the IDE after Linking (Make) or Debug are:
• <target_name>.map
This Linker map file lists the names, load addresses, and lengths of all segments in
your program. In addition, it lists the names and load addresses of any groups in the
program, the start address, and messages about any errors the Linker encounters.
• <target_name>.abs.s19
This is an S-Record File that can be used for programming a ROM memory.
TIP The remaining file in the default bin subfolder is the <target_name>.dbg
file that was generated back when the *.asm file was successfully assembled.
This debugging file was generated because a bullet was present in the debugging
column in the project window.
You can enter (or deselect by toggling) a debugging bullet by clicking at the
intersection of the *.asm file (or whatever other source-code file selected for
debugging) and the debugging column in the project window. Whenever the
debugger or simulator does not show the file in its Source window, check first to
see if the debugging bullet is present or not in the project window. The bullet must
be present for debugging purposes.
TIP The Wizard does not generate default assembler-output listing files. If you want
such listing files generated, you have to select this option: Edit > <target_name>
Settings > Target > Assembler for HC08 > Options. Select the Output tab in the
HC08 Assembler Option Settings dialog box. Check Generate a listing file and Do
not print included files in list file. (You can uncheck Do not print included files in
list file if you choose, but be advised that the include files are usually quite
lengthy.) Now a *.lst file will be generated in the bin subfolder of the project
directory whenever a *.asm file is assembled.
TIP You can add the *.lst files to the project window for easier viewing. This way
you do not have to continually hunt for them with your editor.
Listing 1.3 shows the main.lst file for this project. The comments are truncated on the
far-right edge due to size constraints of the manual’s page.
Freescale HC08-Assembler
(c) Copyright Freescale 1987-2007
1248 30 _Startup:
1249 31 000000 45 xxxx LDHX #__SEG_END_SSTACK
1250 32 000003 94 TXS
1251 33 000004 9A CLI ;
1252 34 mainLoop:
1253 35 000005 4F CLRA ;
1254 36 000006 4C cntLoop: INCA
1255 37 000007 41 0E FB CBEQA #14,mainLoop ;
1256 38 feed_watchdog
1257 13m 00000A C7 FFFF + STA COPCTL
1258 39 00000D B7 xx STA Counter ;
1259 40 00000F AD 06 BSR CalcFibo
1260 41 000011 B7 xx STA FiboRes ;
1261 42 000013 B6 xx LDA Counter
1262 43 000015 20 EF BRA cntLoop ;
1263 44
1264 45 CalcFibo: ; Function to calculate f
1265 46 000017 4B 02 DBNZA fiboDo ;
1266 47 000019 4C INCA
1267 48 00001A 81 RTS
1268 49 fiboDo:
1269 50 00001B 87 PSHA ;
1270 51 00001C 5F CLRX ;
1271 52 00001D A6 01 LDA #$01 ;
1272 53 00001F 87 FiboLoop: PSHA ;
1273 54 000020 9F TXA
1274 55 000021 9EEB 01 ADD 1,SP
1275 56 000024 88 PULX
1276 57 000025 9E6B 01 F6 DBNZ 1,SP,FiboLoop
1277 58 000029 8A FiboDone: PULH ;
1278 59 00002A 81 RTS ;
1279 60
1280 61 ;*************************************
1281 62 ;* spurious - Spurious Interrupt Servi
1282 63 ;* (unwanted interrupt)
Freescale HC08-Assembler
(c) Copyright Freescale 1987-2005
1290 71 ;************************************
1291 72 ORG $FFFA
1292 73
1293 74 a00FFFA xxxx DC.W spurious ;
1294 75 a00FFFC xxxx DC.W spurious
1295 76 a00FFFE xxxx DC.W _Startup ;
Read any of the Tips if you choose and then press Close to close the Tip of the Day
window.
Now let’s save this configuration in a newly created folder that will become the project
directory.
1. From the File menu, select Save Configuration As.
A Saving Configuration as dialog box appears.
2. Navigate to the folder of your choice and Click on the Create New Folder icon in the
Toolbar.
3. Enter a name for the project directory (Figure 1.36).
4. Press Open.
In this case, Model T becomes the project directory in the Projects folder.
5. Press Save
The project.ini file is created in the Model T folder and becomes the local
configuration file for this project. The current directory for the Microcontroller
Assembler is changed to your project directory (Figure 1.37).
If you were to examine the project directory with the Windows Explorer at this point, it
would only contain the project.ini configuration file that the Assembler just created
(Figure 1.38).
If you further examined the contents of the project.ini configuration file, you would
see that it contains Assembler options in the [AHC08_Assembler] portion of the file. The
project.ini file for this project only has an [AHC08_Assembler] section (Listing
1.5).
[AHC08_Assembler]
StatusbarEnabled=1
ToolbarEnabled=1
WindowPos=0,1,-1,-1,-1,-1,371,209,798,496
EditorType=4
2. In the Output panel, select the check boxes labeled Generate a listing file and Object
File Format.
3. For the Object File Format, select the ELF/DWARF 2.0 Object File Format in the
pull-down menu.
4. The listing file could be much shorter if the Do not print included files in list file check
box is checked, so you may want to select that option also.
5. Press OK to close the Microcontroller Assembler Option Settings dialog box.
NOTE For the RS08 derivative the HIWARE Object File Format is not supported.
Listing 1.6 project.ini file after some assembly options were added
[AHC08_Assembler]
StatusbarEnabled=1
ToolbarEnabled=1
WindowPos=0,1,-1,-1,-1,-1,308,151,767,337
EditorType=4
Options=-F2 -L=%(TEXTPATH)\%n.lst -Li
Input Files
Now that the project’s configuration is set, you can assemble an assembly-code file.
However, the project does not contain any source-code files at this point. You could create
assembly *.asm and include *.inc files from scratch for this project. However, for
simplicity’s sake, you can copy-and-paste the main_Standard.asm and the
derivative.inc files from the previous CodeWarrior project. For this project you
should have a project directory named Model T. Within this folder, you should have
another folder named Sources, which contains the two files described above. Using a
text editor of your choice, modify the main_Standard.asm file so that it appears as
below (Listing 1.7):
;*********************************************************************
;* This stationery serves as the framework for a user application. *
;* For a more comprehensive program that demonstrates the more *
;* advanced functionality of this processor, please see the *
; export symbols
XDEF _Startup, main
; we use export '_Startup' as symbol. This allows us to
; reference '_Startup' either in the linker .prm file
; or from C/C++ later on
INCLUDE 'derivative.inc'
; variable/data section
MY_ZEROPAGE: SECTION SHORT ; Insert here your data definition
Counter: DS.B 1
FiboRes: DS.B 1
; code section
MyCode: SECTION
main:
_Startup:
LDHX #__SEG_END_SSTACK ; initialize the stack pointer
TXS
CLI ; enable interrupts
mainLoop:
CLRA ; A contains counter
cntLoop: INCA
CBEQA #14,mainLoop ; larger values cause overflow.
ADD 1,SP
PULX
DBNZ 1,SP,FiboLoop
FiboDone: PULH ; release counter
RTS ; result in A
2. Browse to the Sources folder in the project directory and select the
main_Standard.asm file.
3. Press Open and the main.asm file should start assembling (Figure 1.42).
The project window provides information about the assembly process or generates error
messages if the assembly was unsuccessful. In this case the A2209 File not found error
message is generated. If you right-click on the text containing the error message, a context
menu appears (Figure 1.43).
NOTE If you get any other types of errors, make sure the main_Standard.asm
file is modified as shown in Listing 1.7
Select Help on “file not found” and help for the A2309 error message appears
(Figure 1.44).
You know that the file exists because it is included in the Sources folder that you
imported into the project directory. The help message for the A2309 error states that the
Assembler looks for this “missing” include file first in the current directory and then in the
directory specified by the GENPATH environment variable. This suggests that the
GENPATH environment variable should specify the location of the derivative.inc
include file.
NOTE If you read the main_Standard.asm file, you could have anticipated this
on account of this statement on line 20: INCLUDE 'derivative.inc'.
TIP You can clear the messages in the Assembler window at any time by selecting
View > Log > Clear Log.
Now that you have supplied the path to the derivative.inc file, let’s attempt again to
assemble the main_Standard.asm file.
Select File > Assemble and again navigate to the main_Standard.asm file and press
Open. However, the A2309 error message reappears but this time for a different include
file - MC68HC908GP32.inc. (Figure 1.47).
assembly-code and include files suggests these include files might require
GENPATH configurations. If possible, set any needed GENPATH in advance
of assembling the source-code files.
Fix this by repeating the GENPATH routine for the other include file (Figure 1.48). The
MC68HC908GP32.inc file is located at this path:
C:\Program Files\Freescale\CodeWarrior for Microcontrollers
V6.1\lib\hc08c\include
The include folder is the typical place for missing include files.
After the GENPATH is set up for the second include file and saved as before, you can try to
assemble the main_Standard.asm file for the third time (Figure 1.49).
The Macro Assembler indicates successful assembling and indicated that the Code Size
was 40 bytes. The message *** 0 error(s), indicates that the
main_Standard.asm file assembled without errors. Do not forget to save the
configuration one additional time.
The Assembler also generated a main_Standard.dbg file (for use with the Simulator/
Debugger), a main_Standard.o object file (for further processing with the Linker),
and a main_Standard.lst output listing file in the project directory. The binary
object-code file has the same name as the input module, but with the *.o extension -
main_Standard.o. The debug file has the same name as the input module, but with
the *.dbg extension - main_Standard.dbg and the assembly output listing file has
the *.lst extension (Figure 1.50).
The ERR.TXT file is present in the project directory because of the earlier failed attempts
at assembling. The ERR.TXT file is empty after a successful assembly. You can delete
this file. Let’s take an additional look at the project.ini file (Listing 1.8).
[AHC08_Assembler]
StatusbarEnabled=1
ToolbarEnabled=1
WindowPos=0,1,-1,-1,-1,-1,141,92,901,452
EditorType=4
Options=-F2 -L=%(TEXTPATH)\%n.lst -Li
CurrentCommandLine=""D:\Data\Projects\Model
T\Sources\main_Standard.asm""
RecentCommandLine0=""D:\Data\Projects\Model
T\Sources\main_Standard.asm""
[Environment Variables]
GENPATH=C:\Program Files\Freescale\CodeWarrior for Microcontrollers
V6.1\lib\hc08c\include;D:\Data\Projects\Model T\Sources
OBJPATH=
TEXTPATH=
ABSPATH=
LIBPATH=
The haphazard running of this project was intentionally designed to fail to illustrate what
occurs if the path of any include file is not properly configured. Be aware that
include files may be included by either *.asm or *.inc files. In addition, remember
that the lib folder in the CodeWarrior installation contains several derivative-specific
include and prm files available for inclusion into your projects.
PRM file
If you are using the CodeWarrior IDE to manage your project, a pre-configured PRM file
for a particular derivative is already set up (Listing 1.9). Listing 1.9 is an example Linker
PRM file for the RS08 derivative.
Listing 1.9 Linker PRM file for the GP32 derivative - Project.prm
NAMES END /* CodeWarrior software will pass all the needed files to the
linker by command line. But here you may add your own files too. */
SEGMENTS /* Here all RAM/ROM areas of the device are listed. Used in
PLACEMENT below. */
ROM = READ_ONLY 0x8000 TO 0xFDFF;
PLACEMENT /* Here all predefined and user segments are placed into the
SEGMENTS defined above. */
DEFAULT_RAM INTO RAM;
_DATA_ZEROPAGE, MY_ZEROPAGE INTO Z_RAM;
DEFAULT_ROM, ROM_VAR, STRINGS INTO ROM;
END
STACKSIZE 0x50
LINK test_rs08.abs
NAMES test_rs08.o END
SEGMENTS
TINY_RAM = READ_WRITE 0x0000 TO 0x000D;
DIRECT_RAM = READ_WRITE 0x0020 TO 0x004F;
ROM = READ_ONLY 0x3800 TO 0x3FFB;
RESET_JMP_AREA= READ_ONLY 0x3FFD TO 0x3FFF;
END
PLACEMENT
DEFAULT_ROM INTO ROM;
DEFAULT_RAM INTO DIRECT_RAM;
VECTOR 0 Entry
INIT Entry
The Linker PRM file allocates memory for the stack and the sections named in the
assembly source code files. If the sections in the source code are not specifically
referenced in the PLACEMENT section, then these sections are included in
DEFAULT_ROM or DEFAULT_RAM. You may use a different PRM file for each build
target instead of the default PRM file generated by the Wizard - Project.prm.
The Linker for Microcontrollers preference panel controls which PRM file is used for
your CodeWarrior project. The default PRM file for a CodeWarrior project is the PRM
file in the project window. Let’s see what other options exist for the PRM file. From the
Edit menu, select <target_name> Settings > Target > Linker for Microcontrollers. The
Linker for Microcontrollers preference panel appears (Figure 1.51).
There are three radio buttons for selecting the PRM file and another for selecting an
absolute, single-file assembly project:
• Use Custom PRM file
This option will browse for an existing PRM file for the build target.
• Use Template PRM file
This option uses a template PRM in the pull-down menu and copies it for use in your
build target.
• Use PRM file from project - the default
Figure 1.52 bin folder in the project directory in Windows Explorer after linking
You can single-step the Simulator through the program from the Run menu in the
Simulator (Run > Assembly Step or Ctrl+F11). You can monitor the seven panels in the
Simulator while following the logic in the Fibonacci application.
Listing 1.11 Layout of a PRM file for the Linker - Model T.prm
SEGMENTS /* Here all RAM/ROM areas of the device are listed. Used in
PLACEMENT below. */
ROM = READ_ONLY 0x8000 TO 0xFDFF;
Z_RAM = READ_WRITE 0x0040 TO 0x00FF;
RAM = READ_WRITE 0x0100 TO 0x023F;
END
PLACEMENT /* Here all predefined and user segments are placed into the
SEGMENTS defined above. */
DEFAULT_RAM INTO RAM;
_DATA_ZEROPAGE, MY_ZEROPAGE INTO Z_RAM;
DEFAULT_ROM, ROM_VAR, STRINGS INTO ROM;
END
STACKSIZE 0x50
NOTE If you are adapting a PRM file from a CodeWarrior project, all you really need
to add is the LINK portion and the object-code filenames to be linked in the
NAMES portion.
NOTE The default size for the stack using the CodeWarrior Wizard for the GP32 is 80
bytes - (STACKSIZE 0x50). This Linker statement and
__SEG_END_SSTACK in the assembly-code snippet below determine the
size and placement of the stack in RAM:
MyCode: SECTION ; code section
main:
_Startup:
LDHX #__SEG_END_SSTACK ; initialize stack pointer
TXS
The statements in the linker parameter file are described in the Linker portion of the
Build Tool Utilities manual.
4. Start the Linker.
The SmartLinker tool is located in the prog folder in the CodeWarrior installation:
prog\linker.exe
5. Press Close to close the Tip of the Day dialog box.
6. Load the project’s configuration file.
Use the same <project.ini> file that the Assembler used for its configuration -
the project.ini file in the project directory.
Select File > Load Configuration and navigate to and select the project’s configuration
file (Figure 1.54).
10. Browse to locate and select the PRM file for your project.
11. Press Open.
The Smart Linker links the object-code files in the NAMES section to produce the
executable *.abs file, as specified in the LINK portion of the Linker PRM file
(Figure 1.56).
You can use the Simulator/Debugger Build Tool, hiwave.exe, located in the prog
folder in the CodeWarrior installation, to simulate the program that was assembled using
the main_Standard.asm source-code file and linked to generate the Model_T.abs
executable. To use the Simulator, follow these steps:
1. Start the Simulator.
The GUI for the Simulator appears (Figure 1.58).
3. The CPU derivative for this project is in the HC08 subfamily, so select HC08 from the
Processor list box.
4. Select Full Chip Simulation in the Connection list box.
5. Press OK.
6. From the File menu, select Load Application.
The Load Executable File dialog box appears (Figure 1.60).
8. Press Open.
The Simulator is now ready to run (Figure 1.61).
You can repeatedly press the Assembly Step (Ctrl+F11) icon to single-step the Simulator
through the assembly source-code and monitor the program’s logic of the Fibonacci
application in the eight panels within the Simulator’s GUI.
;********************************************************************
;* This stationery serves as the framework for a user *
;* application. For a more comprehensive program that *
;* demonstrates the more advanced functionality of this *
;* processor, please see the demonstration applications *
;* located in the examples subdirectory of CodeWarrior for *
;* Microcontrollers V6.1 program directory. *
;********************************************************************
; variable/data section
ORG $0040
Counter: DS.B 1
FiboRes: DS.B 1
; code section
ORG $8000
main:
_Startup:
LDHX #initStack ; initialize the stack pointer
TXS
CLI ; enable interrupts
mainLoop:
CLRA ; A contains a counter.
cntLoop: INCA
CBEQA #14,mainLoop ; Larger values cause overflow.
STA COPCTL ; Feed the watchdog.
STA Counter ; update global
BSR CalcFibo
STA FiboRes ; store result
LDA Counter
BRA cntLoop ; next round
TXA
ADD 1,SP
PULX
DBNZ 1,SP,FiboLoop
FiboDone: PULH ; release counter
RTS ; Result in A
;**************************************************************
;* spurious - Spurious Interrupt Service Routine. *
;* (unwanted interrupt) *
;**************************************************************
spurious: ; Put here so the security
NOP ; value does not change
RTI ; all the time.
;**************************************************************
;* Interrupt Vectors *
;**************************************************************
ORG $FFFA
DC.W spurious ;
DC.W spurious ; SWI
DC.W _Startup ; Reset
When writing your assembly source file for direct absolute file generation, pay special
attention to the following points:
• The Reset vector is usually initialized in the assembly source file with the application
entry point. An absolute section containing the application’s entry point address is
created at the reset vector address. To set the entry point of the application at address
$FFFA on the _Startup label the following code is needed (Listing 1.14).
ORG $FFFA
DC.W spurious ;
DC.W spurious ; SWI
DC.W _Startup ; Reset
The ABSENTRY directive is used to write the address of the application entry point in the
generated absolute file. To set the entry point of the application on the _Startup label in
the absolute file, the following code is needed (Listing 1.15).
ABSENTRY _Startup
CAUTION We strongly recommend that you use separate sections for code,
(variable) data, and constants. All sections used in the assembler
application must be absolute and defined using the ORG directive. The
addresses for constant or code sections have to be located in the ROM
memory area, while the data sections have to be located in a RAM area
(according to the hardware that you intend to use). The programmer is
responsible for making sure that no section overlaps occur.
4. In the Output panel, select Object File Format > ELF/DWARF 2.0 Absolute File.
5. Press OK to close the dialog box.
6. Now, select Linker for Microcontrollers.
The Linker for Microcontrollers preference panel opens (Figure 1.64).
7. Select the Absolute, Single-File Assembly project radio button and press OK.
The assembler is now configured to directly produce an absolute assembly *.abs
output file.
1. Click Next Tip to see the next piece of information about the Assembler.
2. Click Close to close the Tip of the Day dialog box.
a. If you do not want the Assembler to automatically open the standard Tip of the Day
window when the Assembler is started, uncheck Show Tips on StartUp.
b. If you want the Assembler to automatically open the standard Tip of the Day
window at Assembler start up, choose Help > Tip of the Day. The Assembler
displays the Tip of the Day dialog box. Check the Show Tips on StartUp check box.
Window Title
The window title displays the Assembler name and the project name. If a project is not
loaded, the Assembler displays Default Configuration in the window title. An asterisk (*)
after the configuration name indicates that some settings have changed. The Assembler
adds an asterisk (*) whenever an option, the editor configuration, or the window
appearance changes.
Content area
The Assembler displays logging information about the assembly session in the content
area. This logging information consists of:
• the name of the file being assembled,
• the whole name (including full path specifications) of the files processed (main
assembly file and all included files),
• the list of any error, warning, and information messages generated, and
• the size of the code (in bytes) generated during the assembly session.
When a file is dropped into the assembly window content area, the Assembler either loads
the corresponding file as a configuration file or the Assembler assembles the file. The
Assembler loads the file as a configuration if the file has the *.ini extension. If the file
does not end with the *.ini extension, the Assembler assembles the file using the
current option settings.
All text in the assembler window content area can have context information consisting of
two items:
• a filename including a position inside of a file and
• a message number.
File context information is available for all output lines where a filename is displayed.
There are two ways to open the file specified in the file-context information in the editor
specified in the editor configuration:
• If a file context is available for a line, double-click on a line containing file-context
information.
• Click with the right mouse on the line and select “Open”. This entry is only available
if a file context is available.
If the Assembler cannot open a file even though a context menu entry is present, then the
editor configuration information is incorrect (see the Editor Setting dialog box section
below).
The message number is available for any message output. There are three ways to open the
corresponding entry in the help file:
• Select one line of the message and press the F1 key. If the selected line does not have
a message number, the main help is displayed.
• Press Shift-F1 and then click on the message text. If the point clicked does not
have a message number, the main help is displayed.
• Click the right mouse button on the message text and select Help on. This entry is
only available if a message number is available.
Toolbar
The three buttons on the left hand side of the toolbar correspond to the menu items of the
File menu. You can use the New , Load, and Save buttons to reset, load and
save configuration files for the Macro Assembler.
The Help button and the Context Help button allow you to open the Help file or
the Context Help.
When pressing the buttons above, the mouse cursor changes to a question mark beside
an arrow. The Assembler opens Help for the next item on which you click. You can get
specific Help on menus, toolbar buttons, or on the window area by using this Context
Help.
The editable combo box contains a list of the last commands which were executed. After a
command line has been selected or entered in this combo box, click the Assemble button
to execute this command. The Stop button becomes enabled whenever some file
is assembled. When the Stop button is pressed, the assembler stops the assembly process.
Pressing the Options Dialog Box button opens the Option Settings dialog box.
Pressing the Message Dialog Box button opens the Message Settings dialog box.
Pressing the Clear button clears the assembler window’s content area.
Status bar
When pointing to a button in the tool bar or a menu entry, the message area displays the
function of the button or menu entry to which you are pointing.
Menu Description
File menu
With the file menu, Assembler configuration files can be saved or loaded. An Assembler
configuration file contains the following information:
• the assembler option settings specified in the assembler dialog boxes,
• the list of the last command line which was executed and the current command line,
• the window position, size, and font,
• the editor currently associated with the Assembler. This editor may be specifically
associated with the Assembler or globally defined for all Tools (see the Editor
Setting dialog box),
• the Tips of the Day settings, including its startup configuration, and what is the
current entry, and
• Configuration files are text files which have the standard *.ini extension. You can
define as many configuration files as required for the project and can switch among
the different configuration files using the File > Load Configuration, File | Save
Configuration menu entries, or the corresponding toolbar buttons.
1. .... project.ini Recent project list. This list can be used to reopen a
2. .... recently opened project.
Assembler menu
The Assembler menu (Table 2.3) allows you to customize the Assembler. You can
graphically set or reset the Assembler options or to stop the assembling process.
View menu
The View menu (Table 2.4) lets you customize the assembler window. You can specify if
the status bar or the toolbar must be displayed or be hidden. You can also define the font
used in the window or clear the window.
Status Bar Switches display from the status bar in the assembler window.
Log... Customizes the output in the assembler window content area. The
following two entries in this table are available when you select
Log:
Change Font Opens a standard font dialog box. The options selected in the font
dialog box are applied to the assembler window content area.
C:\UltraEdit32\uedit32.exe %f /#:%l
For the Microsoft Developer Studio, use the settings in Listing 2.2:
Modifiers
The configurations may contain some modifiers to tell the editor which file to open and at
which line and column.
• The %f modifier refers to the name of the file (including path and extension) where
the error has been detected.
• The %l modifier refers to the line number where the message has been detected.
• The %c modifier refers to the column number where the message has been detected.
CAUTION The %l modifier can only be used with an editor which can be started with
a line number as a parameter. This is not the case for WinEdit version 3.1
or lower or for the Notepad. When you work with such an editor, you can
start it with the filename as a parameter and then select the menu entry Go
to to jump on the line where the message has been detected. In that case
the editor command looks like:
C:\WINAPPS\WINEDIT\Winedit.exe %f
NOTE Check your editor manual to define the command line which should be used to
start the editor.
In the Save Configuration index, there are four check boxes where you can choose which
items to save into a project file when the configuration is saved.
This dialog box has the following configurations:
• Options: This item is related to the option and message settings. If this check box is
set, the current option and message settings are stored in the project file when the
configuration is saved. By disabling this check box, changes done to the option and
message settings are not saved, and the previous settings remain valid.
• Editor Configuration: This item is related to the editor settings. If you set this check
box, the current editor settings are stored in the project file when the configuration is
saved. If you disable this check box, the previous settings remain valid.
• Appearance: This item is related to many parts like the window position (only loaded
at startup time) and the command-line content and history. If you set this check box,
these settings are stored in the project file when the current configuration is saved. If
you disable this check box, the previous settings remain valid.
• Environment Variables: With this set, the environment variable changes done in the
Environment property panel are also saved.
NOTE By disabling selective options only some parts of a configuration file can be
written. For example, when the best Assembler options are found, the save
option mark can be removed. Then future save commands will not modify the
options any longer.
• Save on Exit: If this option is set, the Assembler writes the configuration on exit. The
Assembler does not prompt you to confirm this operation. If this option is not set, the
assembler does not write the configuration at exit, even if options or other parts of
the configuration have changed. No confirmation will appear in any case when
closing the assembler.
NOTE Almost all settings are stored in the project configuration file. The only
exceptions are:
- The recently used configuration list.
- All settings in the Save Configuration dialog box.
NOTE The configurations of the Assembler can, and in fact are intended to, coexist in
the same file as the project configuration of other tools and the IDF. When an
editor is configured by the shell, the assembler can read this content out of the
project file, if present. The default project configuration filename is
project.ini. The assembler automatically opens an existing
project.ini in the current directory at startup. Also when using the -Prod:
Specify project file at startup assembler option at startup or loading the
configuration manually, a different name other than project.ini can be
chosen.
The content of the dialog box is read from the actual project file out of the
[Environment Variables] section.
The following variables are available (Table 2.5):
General GENPATH
Object OBJPATH
Text TEXTPATH
Absolute ABSPATH
Various Environment Variables: other variables not covered in the above table.
The following buttons are available for the Configuration dialog box:
• Add: Adds a new line or entry
• Change: Changes a line or entry
• Delete: Deletes a line or entry
• Up: Moves a line or entry up
• Down: Moves a line or entry down
Note that the variables are written to the project file only if you press the Save button (or
using File -> Save Configuration or CTRL-S). In addition, it can be specified in the Save
Configuration dialog box if the environment is written to the project file or not.
The options available are arranged into different groups, and a sheet is available for each
of these groups. The content of the list box depends on the selected sheet (Table 2.6):
Group Description
Output Lists options related to the output files generation (which kind
of file should be generated).
Code Generation Lists options related to code generation (memory models, etc.)
An assembler option is set when the check box in front of it is checked. To obtain more
detailed information about a specific option, select it and press the F1 key or the Help
button. To select an option, click once on the option text. The option text is then displayed
inverted.
When the dialog box is opened and no option is selected, pressing the F1 key or the Help
button shows the help about this dialog box.
The available options are listed in the Assembler Options chapter.
Some buttons in the dialog box may be disabled. For example, if an option cannot be
moved to an information message, the Move to: Information button is disabled. The
buttons in Table 2.7 are available in the Message Settings dialog box:
Button Description
Move to: Disabled The selected messages are disabled; they will no longer be
displayed.
Move to: Information The selected messages are changed to information messages.
Move to: Warning The selected messages are changed to warning messages.
Move to: Error The selected messages are changed to error messages.
Move to: Default The selected messages are changed to their default message
types.
Button Description
A panel is available for each error message class and the content of the list box depends on
the selected panel (Table 2.8):
Disabled Lists all disabled messages. That means that messages displayed
in the list box will not be displayed by the Assembler.
Fatal Lists all fatal error messages. When such a message is generated,
translation of the input file stops immediately. Fatal messages
cannot be changed. They are only listed to call context help.
Each message has its own character (‘A’ for Assembler message) followed by a 4- or
5-digit number. This number allows an easy search for the message on-line help.
message in the list box and then click the button associated with the class where you want
to move the message.
Example
To define the A2336: Value too big warning as an error message:
• Click the Warning sheet to display the list of all warning messages in the list box.
• Click on the A2336: Value too big string in the list box to select the message.
• Click Error to define this message as an error message. The Microcontroller dialog
box appears. Press Yes to close the dialog box (Figure 2.13).
NOTE The Move to buttons are enabled when all selected messages can be moved.
When one message is marked, which cannot be moved to a specific group, the
corresponding Move to button is disabled (grayed).
If you want to validate the modification you have performed in the error message
mapping, close the Microcontroller Assembler Message Settings dialog box with the OK
button. If you close it using the Cancel button, the previous message mapping remains
valid.
NOTE During assembling, the subversions of the subparts cannot be requested. They
are only displayed if the Assembler is not processing files.
Message/Error feedback
After assembly, there are several ways to check where different errors or warnings have
been detected. The default format of the error message is as . A typical error message is
like the one in Listing 2.4.
Parameter: KeyName=ParamDef
GENPATH=C:\INSTALL\LIB;D:\PROJECTS\TESTS;/usr/local/lib;
/home/me/my_project
• Putting the definitions in a file given by the value of the ENVIRONMENT system
environment variable.
NOTE The default directory mentioned above can be set via the DEFAULTDIR
system environment variable.
When looking for an environment variable, all programs first search the system
environment, then the default.env (.hidefaults for UNIX) file and finally the
global environment file given by ENVIRONMENT. If no definition can be found, a default
value is assumed.
NOTE The environment may also be changed using the -Env: Set environment
variable assembler option.
Current directory
The most important environment for all tools is the current directory. The current
directory is the base search directory where the tool starts to search for files (e.g., for the
default.env or .hidefaults)
Normally, the current directory of a launched tool is determined by the operating system
or by the program that launches another one (e.g., IDE, Make Utility, etc.).
For the UNIX operating system, the current directory for an executable is also the current
directory from where the binary file has been started.
For MS Windows-based operating systems, the current directory definition is quite
complex:
• If the tool is launched using the File Manager/Explorer, the current directory is the
location of the launched executable tool.
• If the tool is launched using an Icon on the Desktop, the current directory is the one
specified and associated with the Icon in its properties.
• If the tool is launched by dragging a file on the icon of the executable tool on the
desktop, the directory on the desktop is the current directory.
• If the tool is launched by another launching tool with its own current directory
specification (e.g., an editor as IDE, a Make utility, etc.), the current directory is the
one specified by the launching tool.
• When a local project file is loaded, the current directory is set to the directory which
contains the local project file. Changing the current project file also changes the
current directory if the other project file is in a different directory. Note that
browsing for an assembly source file does not change the current directory.
Environment macros
It is possible to use macros (Listing 3.3) in your environment settings.
MyVAR=C:\test
TEXTPATH=$(MyVAR)\txt
OBJPATH=${MyVAR}\obj
C:\WINDOWS\mcutools.ini
D:\INSTALL\prog\mcutools.ini
variables. When a project is loaded using the first default.env file, its ASMOPTIONS
options are added to the configuration file. If this configuration is then stored in a different
directory, where a default.env file exists with these incompatible options, the
Assembler adds the options and remarks the inconsistency. Then a message box appears to
inform the user that those options from the default.env file were not added. In such a
situation, the user can either remove the options from the configuration file with the
advanced option dialog box or he can remove the option from the default.env file
with the shell or a text editor depending upon which options should be used in the future.
At startup, the configuration stored in the project.ini file located in the current Paths
Local Configuration File Entries documents the sections and entries you can put in a
project.ini file.
Most environment variables contain path lists telling where to look for files. A path list is
a list of directory names separated by semicolons following the syntax in Listing 3.5.
Listing 3.5 Syntax used for setting path lists of environment variables
PathList=DirSpec{";"DirSpec}
DirSpec=["*"]DirectoryName
Listing 3.6 Setting the paths for the GENPATH environment variable
GENPATH=C:\INSTALL\LIB;D:\PROJECTS\TESTS;/usr/local/Freescale/lib;/
home/me/my_project
If a directory name is preceded by an asterisk (*), the programs recursively search that
whole directory tree for a file, not just the given directory itself. The directories are
searched in the order they appear in the path list. Listing 3.7 shows the use of an asterisk
(*) for recursively searching the entire C drive for a configuration file with a
\INSTALL\LIB path.
LIBPATH=*C:\INSTALL\LIB
NOTE Some DOS/UNIX environment variables (like GENPATH, LIBPATH, etc.) are
used. For further details refer to Environment variables details.
We strongly recommend working with the Shell and setting the environment by means of
a default.env file in your project directory. (This project dir can be set in the
Shell's 'Configure' dialog box). Doing it this way, you can have different projects in
different directories, each with its own environment.
NOTE When starting the Assembler from an external editor, do not set the
DEFAULTDIR system environment variable. If you do so and this variable
does not contain the project directory given in the editor’s project
configuration, files might not be put where you expect them to be put!
A synonym also exists for some environment variables. Those synonyms may be used for
older releases of the Assembler, but they are deprecated and thus they will be removed in
the future.
Line continuation
It is possible to specify an environment variable in an environment file (default.env
or .hidefaults) over multiple lines using the line continuation character ‘\’
(Listing 3.8):
ASMOPTIONS=\
-W2\
-WmsgNe=10
Listing 3.8 is the same as the alternate source code in Listing 3.9.
ASMOPTIONS=-W2 -WmsgNe=10
But this feature may be dangerous when used together with paths (Listing 3.10).
GENPATH=.\
TEXTFILE=.\txt
will result in
GENPATH=.TEXTFILE=.\txt
To avoid such problems, we recommend that you use a semicolon (;) at the end of a path
if there is a backslash (\) at the end (Listing 3.11).
GENPATH=.\;
TEXTFILE=.\txt
Topic Description
Synonym (where one A synonym exists for some environment variables. These
exists) synonyms may be used for older releases of the Assembler but
they are deprecated and they will be removed in the future. A
synonym has lower precedence than the environment variable.
Arguments Describes and lists optional and required arguments for the
variable.
Default (if one exists) Shows the default setting for the variable if one exists.
Tools
Compiler, Assembler, Linker, Decoder, or Debugger
Syntax
ABSPATH={<path>}
Arguments
<path>: Paths separated by semicolons, without spaces
Description
This environment variable is only relevant when absolute files are directly
generated by the Macro Assembler instead of relocatable object files. When this
environment variable is defined, the Assembler will store the absolute files it
produces in the first directory specified there. If ABSPATH is not set, the generated
absolute files will be stored in the directory where the source file was found.
Example
ABSPATH=\sources\bin;..\..\headers;\usr\local\bin
Tools
Assembler
Syntax
ASMOPTIONS={<option>}
Arguments
<option>: Assembler command-line option
Description
If this environment variable is set, the Assembler appends its contents to its
command line each time a file is assembled. It can be used to globally specify
certain options that should always be set, so you do not have to specify them each
time a file is assembled.
Options enumerated there must be valid assembler options and are separated by
space characters.
Example
ASMOPTIONS=-W2 -L
See also
Assembler Options chapter
Tools
Compiler, Assembler, Linker, or Librarian
Syntax
COPYRIGHT=<copyright>
Arguments
<copyright>: copyright entry
Description
Each object file contains an entry for a copyright string. This information may be
retrieved from the object files using the Decoder.
Example
COPYRIGHT=Copyright
See also
• USERNAME: User Name in object file
• INCLUDETIME: Creation time in the object file
Tools
Compiler, Assembler, Linker, Decoder, Debugger, Librarian, or Maker
Syntax
DEFAULTDIR=<directory>
Arguments
<directory>: Directory to be the default current directory
Description
The default directory for all tools may be specified with this environment variable.
Each of the tools indicated above will take the directory specified as its current
directory instead of the one defined by the operating system or launching tool (e.g.,
editor).
Example
DEFAULTDIR=C:\INSTALL\PROJECT
See also
Current directory
“All tools may store some global data into the mcutools.ini file.The tool first
searches for this file in the directory of the tool itself (path of the executable tool).
If there is no mcutools.ini file in this directory, the tool looks for an
mcutools.ini file located in the MS Windows installation directory (e.g.,
C:\WINDOWS).”
Tools
Compiler, Assembler, Linker, Decoder, Debugger, Librarian, or Maker
Synonym
HIENVIRONMENT
Syntax
ENVIRONMENT=<file>
Arguments
<file>: filename with path specification, without spaces
Description
This variable has to be specified on the system level. Normally the Assembler
looks in the current directory for an environment file named default.env
(.hidefaults on UNIX). Using ENVIRONMENT (e.g., set in the
autoexec.bat (DOS) or .cshrc (UNIX)), a different filename may be
specified.
Example
ENVIRONMENT=\Freescale\prog\global.env
Tools
Compiler, Assembler, or Linker
Syntax
ERRORFILE=<filename>
Arguments
<filename>: Filename with possible format specifiers
Default
EDOUT
Description
The ERRORFILE environment variable specifies the name for the error file (used
by the Compiler or Assembler).
Possible format specifiers are:
• '%n': Substitute with the filename, without the path.
• '%p': Substitute with the path of the source file.
• '%f': Substitute with the full filename, i.e., with the path and name (the same as
'%p%n').
In case of an improper error filename, a notification box is shown.
Examples
Listing 3.12 lists all errors into the MyErrors.err file in the current directory.
ERRORFILE=MyErrors.err
Listing 3.13 lists all errors into the errors file in the \tmp directory.
ERRORFILE=\tmp\errors
Listing 3.14 lists all errors into a file with the same name as the source file, but
with extension *.err, into the same directory as the source file, e.g., if we
compile a file \sources\test.c, an error list file \sources\test.err
will be generated.
ERRORFILE=%f.err
For a test.c source file, a \dir1\test.err error list file will be generated
(Listing 3.15).
ERRORFILE=\dir1\%n.err
Listing 3.16 Naming an error file as a source filename with full path
ERRORFILE=%p\errors.txt
If the ERRORFILE environment variable is not set, errors are written to the default
error file. The default error filename depends on the way the Assembler is started.
If a filename is provided on the assembler command line, the errors are written to
the EDOUT file in the project directory.
If no filename is provided on the assembler command line, the errors are written to
the err.txt file in the project directory.
Another example (Listing 3.17) shows the usage of this variable to support correct
error feedback with the WinEdit Editor which looks for an error file called EDOUT:
NOTE You must set this variable if the WinEdit Editor is used, otherwise the editor
cannot find the EDOUT file.
Tools
Compiler, Assembler, Linker, Decoder, or Debugger
Synonym
HIPATH
Syntax
GENPATH={<path>}
Arguments
<path>: Paths separated by semicolons, without spaces.
Description
The Macro Assembler will look for the sources and included files first in the
project directory, then in the directories listed in the GENPATH environment
variable.
Example
GENPATH=\sources\include;..\..\headers;\usr\local\lib
Tools
Compiler, Assembler, Linker, or Librarian
Syntax
INCLUDETIME=(ON|OFF)
Arguments
ON: Include time information into the object file.
OFF: Do not include time information into the object file.
Default
ON
-
Description
Normally each object file created contains a time stamp indicating the creation
time and data as strings. So whenever a new file is created by one of the tools, the
new file gets a new time stamp entry.
This behavior may be undesired if for SQA reasons a binary file compare has to be
performed. Even if the information in two object files is the same, the files do not
match exactly because the time stamps are not the same. To avoid such problems
this variable may be set to OFF. In this case the time stamp strings in the object file
for date and time are “none” in the object file.
The time stamp may be retrieved from the object files using the Decoder.
Example
INCLUDETIME=OFF
See also
• COPYRIGHT: Copyright entry in object file
• USERNAME: User Name in object file
Tools
Compiler, Assembler, Linker, or Decoder
Syntax
OBJPATH={<path>}
Arguments
<path>: Paths separated by semicolons, without spaces
Description
This environment variable is only relevant when object files are generated by the
Macro Assembler. When this environment variable is defined, the Assembler will
store the object files it produces in the first directory specified in path. If
OBJPATH is not set, the generated object files will be stored in the directory the
source file was found.
Example
OBJPATH=\sources\bin;..\..\headers;\usr\local\bin
Tools
Assembler, Linker, or Burner
Syntax
SRECORD=<RecordType>
Arguments
<RecordType>: Forces the type for the S-Record File which must be generated.
This parameter may take the value ‘S1’, ‘S2’, or ‘S3’.
Description
This environment variable is only relevant when absolute files are directly
generated by the Macro Assembler instead of object files. When this environment
variable is defined, the Assembler will generate an S-Record File containing
records from the specified type (S1 records when S1 is specified, S2 records when
S2 is specified, and S3 records when S3 is specified).
When this variable is not set, the type of S-Record File generated will depend on
the size of the address, which must be loaded there. If the address can be coded on
2 bytes, an S1 record is generated. If the address is coded on 3 bytes, an S2 record
is generated. Otherwise, an S3 record is generated.
Example
SRECORD=S2
Tools
Compiler, Assembler, Linker, or Decoder
Syntax
TEXTPATH={<path>}
Arguments
<path>: Paths separated by semicolons, without spaces.
Description
When this environment variable is defined, the Assembler will store the listing
files it produces in the first directory specified in path. If TEXTPATH is not set,
the generated listing files will be stored in the directory the source file was found.
Example
TEXTPATH=\sources\txt;..\..\headers;\usr\local\txt
Tools
Compiler, Assembler, Linker, Debugger, or Librarian
Syntax
TMP=<directory>
Arguments
<directory>: Directory to be used for temporary files
Description
If a temporary file has to be created, normally the ANSI function tmpnam() is
used. This library function stores the temporary files created in the directory
specified by this environment variable. If the variable is empty or does not exist,
the current directory is used. Check this variable if you get an error message
Cannot create temporary file.
Example
TMP=C:\TEMP
See also
Current directory section
Tools
Compiler, Assembler, Linker, or Librarian
Syntax
USERNAME=<user>
Arguments
<user>: Name of user
Description
Each object file contains an entry identifying the user who created the object file.
This information may be retrieved from the object files using the decoder.
Example
USERNAME=PowerUser
See also
• COPYRIGHT: Copyright entry in object file
• INCLUDETIME: Creation time in the object file
Input files
Input files to the Assembler:
• Source files
• Include files
Source files
The Macro Assembler takes any file as input. It does not require the filename to have a
special extension. However, we suggest that all your source filenames have the *.asm
extension and all included files have the *.inc.extension. Source files will be searched
first in the project directory and then in the directories enumerated in GENPATH: Search
path for input file
Include files
The search for include files is governed by the GENPATH environment variable. Include
files are searched for first in the project directory, then in the directories given in the
GENPATH environment variable. The project directory is set via the Shell, the Program
Manager, or the DEFAULTDIR: Default current directory environment variable.
Output files
Output files from the Assembler:
• Object files
• Absolute files
• S-Record Files
• Listing files
• Debug listing files
• Error listing file
Object files
After a successful assembling session, the Macro Assembler generates an object file
containing the target code as well as some debugging information. This file is written to
the directory given in the OBJPATH: Object file path environment variable. If that
variable contains more than one path, the object file is written in the first directory given;
if this variable is not set at all, the object file is written in the directory the source file was
found. Object files always get the *.o extension.
Absolute files
When an application is encoded in a single module and all the sections are absolute
sections, the user can decide to generate directly an absolute file instead of an object file.
This file is written to the directory given in the ABSPATH: Absolute file path
environment variable. If that variable contains more than one path, the absolute file is
written in the first directory given; if this variable is not set at all, the absolute file is
written in the directory the source file was found. Absolute files always get the *.abs
extension.
S-Record Files
When an application is encoded in a single module and all the sections are absolute
sections, the user can decide to generate directly an ELF absolute file instead of an object
file. In that case an S-Record File is generated at the same time. This file can be burnt into
an EPROM. It contains information stored in all the READ_ONLY sections in the
application. The extension for the generated S-Record File depends on the setting from the
SRECORD: S-Record type environment variable.
• If SRECORD = S1, the S-Record File gets the *.s1 extension.
• If SRECORD = S2, the S-Record File gets the *.s2 extension.
Listing files
After successful assembling session, the Macro Assembler generates a listing file
containing each assembly instruction with their associated hexadecimal code. This file is
always generated when the -L: Generate a listing file assembler option is activated (even
when the Macro Assembler generates directly an absolute file). This file is written to the
directory given in the TEXTPATH: Text file path.environment variable. If that variable
contains more than one path, the listing file is written in the first directory given; if this
variable is not set at all, the listing file is written in the directory the source file was found.
Listing files always get the *.lst extension. The format of the listing file is described in
the Assembler Listing File chapter.
EDOUT. Use WinEdit’s Next Error or CodeWright’s Find Next Error command to see
both error positions and the error messages.
File processing
Figure 4.1 shows the priority levels for the various files used by the Assembler.
NOTE It is not possible to combine options in different groups, e.g., -Lc -W1 cannot
be abbreviated by the terms -LC1 or -LCW1.
ASMOPTIONS If this environment variable is set, the Assembler appends its contents
to its command line each time a file is assembled. It can be used to
globally specify certain options that should always be set, so you do
not have to specify them each time a file is assembled.
Group Description
Output Lists options related to the output files generation (which kind of
file should be generated).
Code Generation Lists options related to code generation (memory models, etc.).
The group corresponds to the property sheets of the graphical option settings.
Each option has also a scope (Table 5.3).
Scope Description
Application This option has to be set for all files (assembly units) of an
application. A typical example is an option to set the memory model.
Mixing object files will have unpredictable results.
Assembly Unit This option can be set for each assembling unit for an application
differently. Mixing objects in an application is possible.
None The scope option is not related to a specific code part. A typical
example are options for the message management.
The options available are arranged into different groups, and a tab selection is available
for each of these groups. The content of the list box depends upon the tab that is selected.
Topic Description
Arguments Describes and lists optional and required arguments for the option.
Description Provides a detailed description of the option and how to use it.
Example Gives an example of usage, and effects of the option where possible.
Assembler settings, source code and/or Linker PRM files are displayed
where applicable. The examples shows an entry in the default.env
for the PC or in the .hidefaults for UNIX.
Modifier Description
%e Extension
%” A double quote (“) if the filename, the path or the extension contains a
space
%’ A single quote (‘) if the filename, the path, or the extension contains a
space
Listing 5.1 Example filename and path used for the following examples
C:\Freescale\my demo\TheWholeThing.myExt
Using the %p modifier as in Listing 5.2 displays the path with a file separator but without
the filename.
Listing 5.2 %p gives the path only with the final file separator
C:\Freescale\my demo\
Using the %N modifier only displays the filename in 8.3 format but without the file
extension (Listing 5.3).
Listing 5.3 %N results in the filename in 8.3 format (only the first 8 characters)
TheWhole
The %n modifier returns the entire filename but with no file extension (Listing 5.4.
Listing 5.4 %n returns just the filename without the file extension
TheWholeThing
Using %E as a modifier returns the first three characters in the file extension (Listing 5.5).
Listing 5.5 %E gives the file extension in 8.3 format (only the first 3 characters)
myE
If you want the entire file extension, use the %e modifier (Listing 5.6).
myExt
The %f modifier returns the path and the filename without the file extension (Listing 5.7).
Listing 5.7 %f gives the path plus the filename (no file extension)
C:\Freescale\my demo\TheWholeThing
Listing 5.8 Use %”%f%” in case there is a space in its path, filename, or extension
“C:\Freescale\my demo\TheWholeThing”
Listing 5.9 Use %’%f%’ where there is a space in its path, filename, or extension
‘C:\Freescale\my demo\TheWholeThing’
TEXTPATH=C:\Freescale\txt
C:\Freescale\txt\myfile.txt
myfile.txt
It is also possible to display the percent sign by using %%. %e%% allows the expression of a
percent sign after the extension as in Listing 5.13.
myExt%
Assembler option
-LicWait: Wait until floating license is available from floating License Server
Assembler option
-WmsgFb (-WmsgFbv, -WmsgFbm): Set message file format for batch mode
-WmsgFi (-WmsgFiv, -WmsgFim): Set message file format for interactive mode
Assembler option
Group
Input
Scope
Assembly Unit
Syntax
-Ci
Arguments
None
Default
None
Description
This option turns off case sensitivity on label names. When this option is activated,
the Assembler ignores case sensitivity for label names. If the Assembler generates
object files but not absolute files directly (-FA2 assembler option), the case of
exported or imported labels must still match. Or, the -Ci assembler option should
be specified in the linker as well.
Example
When case sensitivity on label names is switched off, the Assembler will not
generate an error message for the assembly source code in Listing 5.14.
ORG $200
entry: NOP
BRA Entry
The instruction BRA Entry branches on the entry label. The default setting for
case sensitivity is ON, which means that the Assembler interprets the labels Entry
and entry as two distinct labels.
See also
-F (-Fh, -F2o, -FA2o, -F2, -FA2): Output file format assembler option
Group
Language
Scope
Application
Syntax
-CMacAngBrack(ON|OFF)
Arguments
ON or OFF
Default
None
Description
This option controls whether the < > syntax for macro invocation argument
grouping is available. When it is disabled, the Assembler does not recognize the
special meaning for < in the macro invocation context. There are cases where the
angle brackets are ambiguous. In new code, use the [? ?] syntax instead.
See also
Macro argument grouping
-CMacBrackets: Square brackets for macro arguments grouping option
Group
Language
Scope
Application
Syntax
-CMacBrackets(ON|OFF)
Arguments
ON or OFF
Default
ON
Description
This option controls the availability of the [? ?] syntax for macro invocation
argument grouping. When it is disabled, the Assembler does not recognize the
special meaning for [? in the macro invocation context.
See also
Macro argument grouping
-CMacAngBrack: Angle brackets for grouping Macro Arguments option
Group
Language
Scope
Application
Syntax
-Compat[={!|=|c|s|f|$|a|b}
Arguments
See below.
Default
None
Description
This option controls some compatibility enhancements of the Assembler. The goal
is not to provide 100% compatibility with any other Assembler but to make it
possible to reuse as much as possible. The various suboptions control different
parts of the assembly:
• =: Operator != means equal
The Assembler takes the default value of the != operator as not equal, as it is in
the C language. For compatibility, this behavior can be changed to equal with
this option. Because the danger of this option for existing code, a message is
issued for every != which is treated as equal.
• !: Support additional ! operators
The following additional operators are defined when this option is used:
– !^: exponentiation
– !m: modulo
– !@: signed greater or equal
– !g: signed greater
– !%: signed less or equal
– !t: signed less than
NOTE The default values for the following ! operators are defined:
!.: binary AND
!x: exclusive OR
!+: binary OR
Examples
Listing 5.15 demonstrates that when -Compat=c, comments can start with a *.
When the -Compat=c assembler option is used, the first DC.B directive in
Listing 5.16 has "+ 1 , 1" as a comment. A warning is issued because the
comment does not start with a ";" or a "*". With -Compat=c, this code
generates a warning and three bytes with constant values 1, 2, and 1. Without it,
this code generates four 8-bit constants of 2, 1, 2, and 1.
DC.B 1 + 1 , 1
DC.B 1+1,1
• s: Symbol prefixes
With this suboption, some compatibility prefixes for symbols are supported.
With this option, the Assembler accepts “pgz:” and “byte:” prefixed for
symbols in XDEFs and XREFs. They correspond to XREF.B or XDEF.B with
the same symbols without the prefix.
• f: Ignore FF character at line start
With this suboption, an otherwise improper character recognized from feed
character is ignored.
• $: Support the $ character in symbols
With this suboption, the Assembler supports to start identifiers with a $ sign.
• a: Add some additional directives
With this suboption, some additional directives are added for enhanced
compatibility.
The Assembler actually supports a SECT directive as an alias of the usual
SECTION - Declare Relocatable Section assembly directive. The SECT
directive takes the section name as its first argument.
• b: support the FOR directive
With this suboption, the Assembler supports a FOR - Repeat assembly block
assembly directive to generate repeated patterns more easily without having to
use recursive macros.
Group
Code Generation
Scope
Application
Syntax
-C08|-CS08|-CRS08
Arguments
None
Default
-C08
Description
The Assembler supports three different HC08-derived cores. The HC08 itself
(-C08), the enhanced HCS08 (-CS08), and the RS08 (-CRS08).
The HCS08 family supports additional addressing modes for the CPHX, LDHX, and
STHX instructions and also a new BGND instruction. All these enhancements are
allowed when the -CS08 option is specified. All instructions and addressing
modes available for the HC08 are also available for the HCS08 so that this core
remains binary compatible with its predecessor.
The RS08 family does not support all instructions and addressing modes of the
HC08. Also, the encoding of the supported instructions is not binary compatible.
Table 5.7 Table of new instructions or addressing modes for the HCS08
Group
Input
Scope
Assembly Unit
Syntax
-D<LabelName>[=<Value>]
Arguments
<LabelName>: Name of label.
<Value>: Value for label. 0 if not present.
Default
0 for Value.
Description
This option behaves as if a Label: EQU Value is at the start of the main source
file. When no explicit value is given, 0 is used as the default.
This option can be used to build different versions with one common source file.
Example
Conditional inclusion of a copyright notice. See Listing 5.17 and Listing 5.18.
YearAsString: MACRO
DC.B $30+(\1 /1000)%10
DC.B $30+(\1 / 100)%10
DC.B $30+(\1 / 10)%10
DC.B $30+(\1 / 1)%10
ENDM
ifdef ADD_COPYRIGHT
ORG $1000
DC.B "Copyright by "
DC.B "John Doe"
ifdef YEAR
DC.B " 1999-"
YearAsString YEAR
endif
DC.B 0
endif
1 1 YearAsString: MACRO
2 2 DC.B $30+(\1 /1000)%10
Group
Host
Scope
Assembly Unit
Syntax
-Env<EnvironmentVariable>=<VariableSetting>
Arguments
<EnvironmentVariable>: Environment variable to be set
<VariableSetting>: Setting of the environment variable
Default
None
Description
This option sets an environment variable.
Example
ASMOPTIONS=-EnvOBJPATH=\sources\obj
This is the same as:
OBJPATH=\sources\obj
in the default.env file.
See also
Environment variables details
Group
Output
Scope
Application
Syntax
-F(h|2o|A2o|2|A2)
Arguments
h: HIWARE object-file format; this is the default
2o: Compatible ELF/DWARF 2.0 object-file format
A2o: Compatible ELF/DWARF 2.0 absolute-file format
2: ELF/DWARF 2.0 object-file format
A2: ELF/DWARF 2.0 absolute-file format
Default
-F2
Description
Defines the format for the output file generated by the Assembler:
• With the -Fh option set, the Assembler uses a proprietary (HIWARE) object-
file format.
• With the -F2 option set, the Assembler produces an ELF/DWARF object file.
This object-file format may also be supported by other Compiler or Assembler
vendors.
• With the -FA2 option set, the Assembler produces an ELF/DWARF absolute
file. This file format may also be supported by other Compiler or Assembler
vendors.
Note that the ELF/DWARF 2.0 file format has been updated in the current version
of the Assembler. If you are using HI-WAVE version 5.2 (or an earlier version),
-F2o or -FA2o must be used to generate the ELF/DWARF 2.0 object files which
can be loaded in the debugger.
Example
ASMOPTIONS=-F2
NOTE For the RS08 the HIWARE object file format is not available.
Group
Various
Scope
None
Syntax
-H
Arguments
None
Default
None
Description
The -H option causes the Assembler to display a short list (i.e., help list) of
available options within the assembler window. Options are grouped into Output,
Input, Language, Host, Code Generation, Messages, and Various.
No other option or source files should be specified when the -H option is invoked.
Example
Listing 5.19 is a portion of the list produced by the -H option:
...
MESSAGE:
-N Show notification box in case of errors
-NoBeep No beep in case of an error
-W1 Do not print INFORMATION messages
-W2 Do not print INFORMATION or WARNING messages
-WErrFile Create "err.log" Error File
...
Group
Input
Scope
None
Syntax
-I<path>
Arguments
<path>: File path to be used for includes
Default
None
Description
With the -I option it is possible to specify a file path used for include files.
Example
-Id:\mySources\include
Group
Output
Scope
Assembly unit
Syntax
-L[=<dest>]
Arguments
<dest>: the name of the listing file to be generated.
It may contain special modifiers (see Using special modifiers).
Default
No generated listing file
Description
Switches on the generation of the listing file. If dest is not specified, the listing
file will have the same name as the source file, but with extension *.lst. The
listing file contains macro definition, invocation, and expansion lines as well as
expanded include files.
Example
ASMOPTIONS=-L
In the following example of assembly code (Listing 5.20), the cpChar macro
accepts two parameters. The macro copies the value of the first parameter to the
second one.
When the -L option is specified, the portion of assembly source code in Listing
5.20, together with the code from an include file (Listing 5.21) generates the output
listing in Listing 5.22.
XDEF Start
MyData: SECTION
char1: DS.B 1
char2: DS.B 1
INCLUDE "macro.inc"
CodeSec: SECTION
Start:
cpChar char1, char2
NOP
cpChar: MACRO
LDA \1
STA \2
ENDM
The Assembler stores the content of included files in the listing file. The
Assembler also stores macro definitions, invocations, and expansions in the listing
file.
For a detailed description of the listing file, see the Assembler Listing File chapter.
See also
Assembler options:
• -Lasmc: Configure listing file
• -Lasms: Configure the address size in the listing file
• -Lc: No Macro call in listing file
• -Ld: No macro definition in listing file
• -Le: No Macro expansion in listing file
• -Li: No included file in listing file
Group
Output
Scope
Assembly unit
Syntax
-Lasmc={s|r|m|l|k|i|c|a}
Arguments
s - Do not write the source column
r - Do not write the relative column (Rel.)
m - Do not write the macro mark
l - Do not write the address (Loc)
k - Do not write the location type
i - Do not write the include mark column
c - Do not write the object code
a - Do not write the absolute column (Abs.)
Default
Write all columns.
Description
The default-configured listing file shows a lot of information. With this option, the
output can be reduced to columns which are of interest. This option configures
which columns are printed in a listing file. To configure which lines to print, see
the following assembler options: -Lc: No Macro call in listing file, -Ld: No macro
definition in listing file, -Le: No Macro expansion in listing file, and -Li: No
included file in listing file.
Example
For the following assembly source code, the Assembler generates the default-
configured output listing (Listing 5.23):
DC.B "Hello World"
DC.B 0
In order to get this output without the source file line numbers and other irrelevant
parts for this simple DC.B example, the following option is added:
-Lasmc=ramki. This generates the output listing in Listing 5.24:
For a detailed description of the listing file, see the Assembler Listing File chapter.
See also
Assembler options:
• -L: Generate a listing file
• -Lc: No Macro call in listing file
• -Ld: No macro definition in listing file
• -Le: No Macro expansion in listing file
• -Li: No included file in listing file
• -Lasms: Configure the address size in the listing file
Group
Output
Scope
Assembly unit
Syntax
-Lasms{1|2|3|4}
Arguments
1 - The address size is xx
2 - The address size is xxxx
3 - The address size is xxxxxx
4 - The address size is xxxxxxxx
Default
-Lasms3
Description
The default-configured listing file shows a lot of information. With this option, the
size of the address column can be reduced to the size of interest. To configure
which columns are printed, see the -Lasmc: Configure listing file option. To
configure which lines to print, see the -Lc: No Macro call in listing file, -Ld: No
macro definition in listing file, -Le: No Macro expansion in listing file, and -Li: No
included file in listing file assembler options.
Example
For the following instruction:
NOP
the Assembler generates this default-configured output listing (Listing 5.25):
In order to change the size of the address column the following option is added:
-Lasms1. This changes the address size to two digits.
See also
Assembler Listing File chapter
Assembler options:
• -Lasmc: Configure listing file
• -L: Generate a listing file
• -Lc: No Macro call in listing file
• -Ld: No macro definition in listing file
• -Le: No Macro expansion in listing file
• -Li: No included file in listing file
Group
Output
Scope
Assembly unit
Syntax
-Lc
Arguments
none
Default
none
Description
Switches on the generation of the listing file, but macro invocations are not present
in the listing file. The listing file contains macro definition and expansion lines as
well as expanded include files.
Example
ASMOPTIONS=-Lc
In the following example of assembly code, the cpChar macro accept two
parameters. The macro copies the value of the first parameter to the second one.
When the -Lc option is specified, the following portion of assembly source code in
Listing 5.27, along with additional source code (Listing 5.28) from the
macro.inc include file generates the output in the assembly listing file (Listing
5.29).
XDEF Start
MyData: SECTION
char1: DS.B 1
char2: DS.B 1
INCLUDE "macro.inc"
CodeSec: SECTION
Start:
cpChar char1, char2
NOP
cpChar: MACRO
LDA \1
STA \2
ENDM
The Assembler stores the content of included files in the listing file. The
Assembler also stores macro definitions, invocations, and expansions in the listing
file.
The listing file does not contain the line of source code that invoked the macro.
For a detailed description of the listing file, see the Assembler Listing File chapter.
See also
Assembler options:
• -L: Generate a listing file
• -Ld: No macro definition in listing file
• -Le: No Macro expansion in listing file
• -Li: No included file in listing file
Group
Output
Scope
Assembly unit
Syntax
-Ld
Arguments
None
Default
None
Description
Instructs the Assembler to generate a listing file but not including any macro
definitions. The listing file contains macro invocation and expansion lines as well
as expanded include files.
Example
ASMOPTIONS=-Ld
In the following example of assembly code, the cpChar macro accepts two
parameters. The macro copies the value of the first parameter to the second one.
When the -Ld option is specified, the assembly source code in Listing 5.30 along
with additional source code (Listing 5.31) from the macro.inc file generates an
assembler output listing (Listing 5.32) file:
XDEF Start
MyData: SECTION
char1: DS.B 1
char2: DS.B 1
INCLUDE "macro.inc"
CodeSec: SECTION
Start:
cpChar: MACRO
LDA \1
STA \2
ENDM
The Assembler stores that content of included files in the listing file. The
Assembler also stores macro invocation and expansion in the listing file.
The listing file does not contain the source code from the macro definition.
For a detailed description of the listing file, see the Assembler Listing File chapter.
See also
Assembler options:
• -L: Generate a listing file
• -Lc: No Macro call in listing file
• -Le: No Macro expansion in listing file
• -Li: No included file in listing file
Group
Output
Scope
Assembly unit
Syntax
-Le
Arguments
None
Default
None
Description
Switches on the generation of the listing file, but macro expansions are not present
in the listing file. The listing file contains macro definition and invocation lines as
well as expanded include files.
Example
ASMOPTIONS=-Le
In the following example of assembly code, the cpChar macro accepts two
parameters. The macro copies the value of the first parameter to the second one.
When the -Le option is specified, the assembly code in Listing 5.33 along with
additional source code (Listing 5.34) from the macro.inc file generates an
assembly output listing file (Listing 5.35):
XDEF Start
MyData: SECTION
char1: DS.B 1
char2: DS.B 1
INCLUDE "macro.inc"
CodeSec: SECTION
Start:
cpChar: MACRO
LDA \1
STA \2
ENDM
The Assembler stores the content of included files in the listing file. The
Assembler also stores the macro definition and invocation in the listing file.
The Assembler does not store the macro expansion lines in the listing file.
For a detailed description of the listing file, see the Assembler Listing File chapter.
See also
-L: Generate a listing file
-Lc: No Macro call in listing file
-Ld: No macro definition in listing file-Li: No included file in listing file
Group
Output
Scope
Assembly unit
Syntax
-Li
Arguments
None
Default
None
Description
Switches on the generation of the listing file, but include files are not expanded in
the listing file. The listing file contains macro definition, invocation, and expansion
lines.
Example
ASMOPTIONS=-Li
In the following example of assembly code, the cpChar macro accepts two
parameters. The macro copies the value of the first parameter to the second one.
When -Li option is specified, the assembly source code in Listing 5.36 along with
additional source code (Listing 5.37) from the macro.inc file generates the
following output in the assembly listing file:
XDEF Start
MyData: SECTION
char1: DS.B 1
char2: DS.B 1
INCLUDE "macro.inc"
CodeSec: SECTION
Start:
cpChar: MACRO
LDA \1
STA \2
ENDM
The Assembler stores the macro definition, invocation, and expansion in the listing
file.
The Assembler does not store the content of included files in the listing file.
For a detailed description of the listing file, see the Assembler Listing File chapter.
See also
Assembler options:
• -L: Generate a listing file
• -Lc: No Macro call in listing file
• -Ld: No macro definition in listing file
• -Le: No Macro expansion in listing file
Group
Various
Scope
None
Syntax
-Lic
Arguments
None
Default
None
Description
The -Lic option prints the current license information (e.g., if it is a demo
version or a full version). This information is also displayed in the About box.
Example
ASMOPTIONS=-Lic
See also
Assembler options:
• -LicA: License information about every feature in directory
• -LicBorrow: Borrow license feature
• -LicWait: Wait until floating license is available from floating License Server
Group
Various
Scope
None
Syntax
-LicA
Arguments
None
Default
None
Description
The -LicA option prints the license information of every tool or DLL in the
directory where the executable is (e.g., if tool or feature is a demo version or a full
version). Because the option has to analyze every single file in the directory, this
may take a long time.
Example
ASMOPTIONS=-LicA
See also
Assembler options:
• -Lic: License information
• -LicBorrow: Borrow license feature
• -LicWait: Wait until floating license is available from floating License Server
Group
Host
Scope
None
Syntax
-LicBorrow<feature>[;<version>]:<Date>
Arguments
<feature>: the feature name to be borrowed (e.g., HI100100).
<version>: optional version of the feature to be borrowed (e.g., 3.000).
<date>: date with optional time until when the feature shall be borrowed (e.g.,
15-Mar-2005:18:35).
Default
None
Defines
None
Pragmas
None
Description
This option lets you borrow a license feature until a given date/time. Borrowing
allows you to use a floating license even if disconnected from the floating license
server.
You need to specify the feature name and the date until you want to borrow the
feature. If the feature you want to borrow is a feature belonging to the tool where
you use this option, then you do not need to specify the version of the feature
(because the tool is aware of the version). However, if you want to borrow any
feature, you need to specify the feature’s version number.
You can check the status of currently borrowed features in the tool’s About box.
NOTE You only can borrow features if you have a floating license and if your floating
license is enabled for borrowing. See the provided FLEXlm documentation
about details on borrowing.
Example
-LicBorrowHI100100;3.000:12-Mar-2005:18:25
See also
Assembler options:
• -Lic: License information
• -LicA: License information about every feature in directory
• -LicWait: Wait until floating license is available from floating License Server
Group
Host
Scope
None
Syntax
-LicWait
Arguments
None
Default
None
Description
If a license is not available from the floating license server, then the default
condition is that the application will immediately return. With the -LicWait
assembler option set, the application will wait (blocking) until a license is available
from the floating license server.
Example
ASMOPTIONS=-LicWait
See also
Assembler options:
• -Lic: License information
• -LicA: License information about every feature in directory
• -LicBorrow: Borrow license feature
Group
Code Generation
Scope
Application
Syntax
-M(s|b|t)
Arguments
s: small memory model
t: tiny memory model
Default
-Ms
Description
The Assembler for the MC68HC(S)08 supports two different memory models. The
default is the small memory model, which corresponds to the normal setup, i.e., a
64kB code-address space. The tiny memory model corresponds to the situation
where the default RAM is in the zero page.
NOTE For the Assembler, the memory model does not matter at all. The memory
model is used by the compiler to specify the default allocation of variable and
functions. The Assembler has this option only to generate “compatible” object
files for the memory model consistency check of the linker.
NOTE In the tiny memory model, the default for the compiler is to use zero-page
addressing. The default for the Assembler is to still use extended-addressing
modes. See the Using the direct addressing mode to access symbols section to
see how to generate zero-page accesses.
Example
ASMOPTIONS=-Mt
Group
Language
Scope
Assembly Unit
Syntax
-MacroNest<Value>
Arguments
<Value>: max. allowed nesting level
Default
3000
Description
This option controls how deep macros calls can be nested. Its main purpose is to
avoid endless recursive macro invocations.
Example
See the description of message A1004 for an example.
See also
Message A1004 (available in the Online Help)
Group
Various
Scope
Assembly Unit
Syntax
-MCUasm
Arguments
None
Default
None
Description
This switches ON compatibility mode with the MCUasm Assembler. Additional
features supported, when this option is activated are enumerated in the MCUasm
Compatibility chapter in the Appendices.
Example
ASMOPTIONS=-MCUasm
Group
Messages
Scope
Assembly Unit
Syntax
-N
Arguments
None
Default
None
Description
Makes the Assembler display an alert box if there was an error during assembling.
This is useful when running a makefile (please see the manual about Build Tools)
because the Assembler waits for the user to acknowledge the message, thus
suspending makefile processing. (The 'N' stands for “Notify”.)
This feature is useful for halting and aborting a build using the Make Utility.
Example
ASMOPTIONS=-N
If an error occurs during assembling, an alert dialog box will be opened.
Group
Messages
Scope
Assembly Unit
Syntax
-NoBeep
Arguments
None
Default
None
Description
Normally there is a ‘beep’ notification at the end of processing if there was an
error. To have a silent error behavior, this ‘beep’ may be switched off using this
option.
Example
ASMOPTIONS=-NoBeep
Group
Language
Scope
Assembly Unit
Syntax
-NoDebugInfo
Arguments
None
Default
None
Description
By default, the Assembler produces debugging info for the produced ELF/
DWARF files. This can be switched off with this option.
Example
ASMOPTIONS=-NoDebugInfo
Group
Startup (This option cannot be specified interactively.)
Scope
Assembly Unit
Syntax
-NoEnv
Arguments
None
Default
None
Description
This option can only be specified at the command line while starting the
application. It cannot be specified in any other circumstances, including the
default.env file, the command line or whatever.
When this option is given, the application does not use any environment
(default.env, project.ini or tips file).
Example
xx.exe -NoEnv
(Use the actual executable name instead of “xx”)
See also
Environment chapter
Group
Output
Scope
Assembly Unit
Syntax
-ObjN<FileName>
Arguments
<FileName>: Name of the binary output file generated.
Default
-ObjN%n.o when generating a relocatable file or
-ObjN%n.abs when generating an absolute file.
Description
Normally, the object file has the same name than the processed source file, but with
the .o extension when relocatable code is generated or the .abs extension when
absolute code is generated. This option allows a flexible way to define the output
filename. The modifier %n can also be used. It is replaced with the source filename.
If <file> in this option contains a path (absolute or relative), the OBJPATH
environment variable is ignored.
Example
For ASMOPTIONS=-ObjNa.out, the resulting object file will be a.out. If the
OBJPATH environment variable is set to \src\obj, the object file will be
\src\obj\a.out.
For fibo.c -ObjN%n.obj, the resulting object file will be fibo.obj.
For myfile.c -ObjN..\objects\_%n.obj, the object file will be named
relative to the current directory to ...\objects\_myfile.obj. Note that the
environment variable OBJPATH is ignored, because <file> contains a path.
See also
OBJPATH: Object file path environment variable
Group
None (This option cannot be specified interactively.)
Scope
None
Syntax
-Prod=<file>
Arguments
<file>: name of a project or project directory
Default
None
Description
This option can only be specified at the command line while starting the
application. It cannot be specified in any other circumstances, including the
default.env file, the command line or whatever.
When this option is given, the application opens the file as configuration file.
When the filename does only contain a directory, the default name
project.ini is appended. When the loading fails, a message box appears.
Example
assembler.exe -Prod=project.ini
(Use the Assembler’s executable name instead of assembler.)
See also
Environment chapter
Group
Input
Scope
Assembly Unit
Syntax
-Struct
Arguments
None
Default
None
Description
When this option is activated, the Macro Assembler also support the definition and
usage of structured types. This is interesting for application containing both
ANSI-C and Assembly modules.
Example
ASMOPTIONS=-Struct
See also
Mixed C and Assembler Applications chapter
Group
Various
Scope
None
Syntax
-V
Arguments
None
Default
None
Description
Prints the Assembler version and the current directory.
NOTE Use this option to determine the current directory of the Assembler.
Example
-V produces the following listing (Listing 5.39):
Group
Host
Scope
Assembly Unit
Syntax
-View<kind>
Arguments
<kind> is one of the following:
• “Window”: Application window has the default window size.
• “Min”: Application window is minimized.
• “Max”: Application window is maximized.
• “Hidden”: Application window is not visible (only if there are arguments).
Default
Application is started with arguments: Minimized.
Application is started without arguments: Window.
Description
Normally, the application is started with a normal window if no arguments are
given. If the application is started with arguments (e.g., from the Maker to
assemble, compile, or link a file), then the application is running minimized to
allow for batch processing. However, the application’s window behavior may be
specified with the View option.
Using -ViewWindow, the application is visible with its normal window. Using
-ViewMin the application is visible iconified (in the task bar). Using -ViewMax,
the application is visible maximized (filling the whole screen). Using
Example
C:\Freescale\prog\linker.exe -ViewHidden fibo.prm
Group
Messages
Scope
Assembly Unit
Syntax
-W1
Arguments
None
Default
None
Description
Inhibits the Assembler’s printing INFORMATION messages. Only WARNING
and ERROR messages are written to the error listing file and to the assembler
window.
Example
ASMOPTIONS=-W1
Group
Messages
Scope
Assembly Unit
Syntax
-W2
Arguments
None
Default
None
Description
Suppresses all messages of INFORMATION or WARNING types. Only ERROR
messages are written to the error listing file and to the assembler window.
Example
ASMOPTIONS=-W2
Group
Messages
Scope
Assembly Unit
Syntax
-WErrFile(On|Off)
Arguments
None
Default
An err.log file is created or deleted.
Description
The error feedback from the Assembler to called tools is now done with a return
code. In 16-bit Windows environments this was not possible. So in case of an error,
an “err.log” file with the numbers of written errors was used to signal any errors.
To indicate no errors, the “err.log”file would be deleted. Using UNIX or WIN32, a
return code is now available. Therefore, this file is no longer needed when only
UNIX or WIN32 applications are involved. To use a 16-bit Maker with this tool, an
error file must be created in order to signal any error.
Example
• -WErrFileOn
err.log is created or deleted when the application is finished.
• -WErrFileOff
existing err.log is not modified.
See also
-WStdout: Write to standard output
-WOutFile: Create error listing file
Group
Messages
Scope
Assembly Unit
Syntax
-Wmsg8x3
Default
None
Description
Some editors (e.g., early versions of WinEdit) are expecting the filename in the
Microsoft message format in a strict 8.3 format. That means the filename can have
at most 8 characters with not more than a 3-character extension. Using a newer
Windows OS, longer file names are possible. With this option the filename in the
Microsoft message is truncated to the 8.3 format.
Example
x:\mysourcefile.c(3): INFORMATION C2901: Unrolling loop
With the -Wmsg8x3 option set, the above message will be
x:\mysource.c(3): INFORMATION C2901: Unrolling loop
See also
• -WmsgFb (-WmsgFbv, -WmsgFbm): Set message file format for batch mode
• -WmsgFi (-WmsgFiv, -WmsgFim): Set message file format for interactive
mode
• -WmsgFoi: Message format for interactive mode
• -WmsgFob: Message format for batch mode Option
• --WmsgFonp: Message format for no position information
Group
Messages
Scope
Compilation Unit
Syntax
-WmsgCE<RGB>
Arguments
<RGB>: 24-bit RGB (red green blue) value.
Default
-WmsgCE16711680 (rFF g00 b00, red)
Description
It is possible to change the error message color with this option. The value to be
specified has to be an RGB (Red-Green-Blue) value and has to be specified in
decimal.
Example
-WmsgCE255 changes the error messages to blue.
Group
Messages
Scope
Compilation Unit
Syntax
-WmsgCF<RGB>
Arguments
<RGB>: 24-bit RGB (red green blue) value.
Default
-WmsgCF8388608 (r80 g00 b00, dark red)
Description
It is possible to change the fatal message color with this option. The value to be
specified has to be an RGB (Red-Green-Blue) value and has to be specified in
decimal.
Example
-WmsgCF255 changes the fatal messages to blue.
Group
Messages
Scope
Compilation Unit
Syntax
-WmsgCI<RGB>
Arguments
<RGB>: 24-bit RGB (red green blue) value.
Default
-WmsgCI32768 (r00 g80 b00, green)
Description
It is possible to change the information message color with this option. The value
to be specified has to be an RGB (Red-Green-Blue) value and has to be specified in
decimal.
Example
-WmsgCI255 changes the information messages to blue.
Group
Messages
Scope
Compilation Unit
Syntax
-WmsgCU<RGB>
Arguments
<RGB>: 24-bit RGB (red green blue) value.
Default
-WmsgCU0 (r00 g00 b00, black)
Description
It is possible to change the user message color with this option. The value to be
specified has to be an RGB (Red-Green-Blue) value and has to be specified in
decimal.
Example
-WmsgCU255 changes the user messages to blue.
Group
Messages
Scope
Compilation Unit
Syntax
-WmsgCW<RGB>
Arguments
<RGB>: 24-bit RGB (red green blue) value.
Default
-WmsgCW255 (r00 g00 bFF, blue)
Description
It is possible to change the warning message color with this option. The value to be
specified has to be an RGB (Red-Green-Blue) value and has to be specified in
decimal.
Example
-WmsgCW0 changes the warning messages to black.
Group
Messages
Scope
Assembly Unit
Syntax
-WmsgFb[v|m]
Arguments
v: Verbose format.
m: Microsoft format.
Default
-WmsgFbm
Description
The Assembler can be started with additional arguments (e.g., files to be assembled
together with assembler options). If the Assembler has been started with arguments
(e.g., from the Make tool), the Assembler works in the batch mode. That is, no
assembler window is visible and the Assembler terminates after job completion.
If the Assembler is in batch mode, the Assembler messages are written to a file and
are not visible on the screen. This file only contains assembler messages (see
examples below).
The Assembler uses a Microsoft message format as the default to write the
assembler messages (errors, warnings, or information messages) if the Assembler
is in the batch mode.
With this option, the default format may be changed from the Microsoft format
(with only line information) to a more verbose error format with line, column, and
source information.
Example
Assume that the assembly source code in Listing 5.40 is to be assembled in the
batch mode.
var1: equ 5
var2: equ 5
if (var1=var2)
NOP
endif
endif
The Assembler generates the error output (Listing 5.41) in the assembler window if
it is running in batch mode:
Listing 5.41 Example error listing in the Microsoft (default) format for batch mode
Listing 5.42 Example error listing in the verbose format for batch mode
ASMOPTIONS=-WmsgFbv
>> in "C:\tw2.asm", line 6, col 0, pos 81
endif
^
ERROR A1001: Conditional else not allowed here
See also
ERRORFILE: Filename specification error
-WmsgFi (-WmsgFiv, -WmsgFim): Set message file format for interactive mode
-WmsgFob: Message format for batch mode
-WmsgFoi: Message format for interactive mode
-WmsgFonf: Message format for no file information
-WmsgFonp: Message format for no position information
Group
Messages
Scope
Assembly Unit
Syntax
-WmsgFi[v|m]
Arguments
v: Verbose format.
m: Microsoft format.
Default
-WmsgFiv
Description
If the Assembler is started without additional arguments (e.g., files to be assembled
together with Assembler options), the Assembler is in the interactive mode (that is,
a window is visible).
While in interactive mode, the Assembler uses the default verbose error file format
to write the assembler messages (errors, warnings, information messages).
Using this option, the default format may be changed from verbose (with source,
line and column information) to the Microsoft format (which displays only line
information).
NOTE Using the Microsoft format may speed up the assembly process because the
Assembler has to write less information to the screen.
Example
If the Assembler is running in interactive mode, the default error output is shown in
the assembler window as in Listing 5.44.
Listing 5.43 Example error listing in the default mode for interactive mode
Listing 5.44 Example error listing in MIcrosoft format for interactive mode
ASMOPTIONS=-WmsgFim
X:\TWE.ASM(12): ERROR: conditional else not allowed here
See also
ERRORFILE: Filename specification error environment variable
Assembler options:
• -WmsgFb (-WmsgFbv, -WmsgFbm): Set message file format for batch mode
• -WmsgFob: Message format for batch mode
• -WmsgFoi: Message format for interactive mode
• -WmsgFonf: Message format for no file information
• -WmsgFonp: Message format for no position information
Group
Messages
Scope
Assembly Unit
Syntax
-WmsgFob<string>
Arguments
<string>: format string (see below).
Default
-WmsgFob"%f%e(%l): %K %d: %m\n”
Description
With this option it is possible to modify the default message format in the batch
mode. The formats in Listing 5.45 are supported (assumed that the source file is
x:\Freescale\sourcefile.asmx).
----------------------------------------------------
%s Source Extract
%p Path x:\Freescale\
%f Path and name x:\Freescale\sourcefile
%n Filename sourcefile
%e Extension .asmx
%N File (8 chars) sourcefi
%E Extension (3 chars) .asm
%l Line 3
%c Column 47
%o Pos 1234
%K Uppercase kind ERROR
%k Lowercase kind error
%d Number A1051
%m Message text
%% Percent %
\n New line
Example
ASMOPTIONS=-WmsgFob”%f%e(%l): %k %d: %m\n”
produces a message, displayed in Listing 5.46, using the format in Listing 5.45.
The options are set for producing the path of a file with its filename, extension, and
line.
See also
Assembler options:
• -WmsgFb (-WmsgFbv, -WmsgFbm): Set message file format for batch mode
• -WmsgFi (-WmsgFiv, -WmsgFim): Set message file format for interactive
mode
• -WmsgFoi: Message format for interactive mode
• -WmsgFonf: Message format for no file information
• -WmsgFonp: Message format for no position information
Group
Messages
Scope
Assembly Unit
Syntax
-WmsgFoi<string>
Arguments
<string>: format string (see below)
Default
-WmsgFoi"\n>> in \"%f%e\", line %l, col %c, pos
%o\n%s\n%K %d: %m\n"
Description
With this option it is possible modify the default message format in interactive
mode. The following formats are supported (supposed that the source file is
x:\Freescale\sourcefile.asmx):
%p Path x:\Freescale\
%f Path and name x:\Freescale\sourcefile
%n Filename sourcefile
%e Extension .asmx
%N File (8 chars) sourcefi
%E Extension (3 chars) .asm
%l Line 3
%c Column 47
%o Pos 1234
%K Uppercase kind ERROR
%k Lowercase kind error
%d Number A1051
%m Message text
%% Percent %
\n New line
Example
ASMOPTIONS=-WmsgFoi”%f%e(%l): %k %d: %m\n”
produces a message in following format (Listing 5.48):
See also
ERRORFILE: Filename specification error environment variable
Assembler options:
• -WmsgFb (-WmsgFbv, -WmsgFbm): Set message file format for batch mode
• -WmsgFi (-WmsgFiv, -WmsgFim): Set message file format for interactive
mode
• -WmsgFob: Message format for batch mode
• -WmsgFonf: Message format for no file information
• -WmsgFonp: Message format for no position information
Group
Messages
Scope
Assembly Unit
Syntax
-WmsgFonf<string>
Arguments
<string>: format string (see below)
Default
-WmsgFonf"%K %d: %m\n"
Description
Sometimes there is no file information available for a message (e.g., if a message
not related to a specific file). Then this message format string is used. The
following formats are supported:
Format Description Example
----------------------------------
%K Uppercase kind ERROR
%k Lowercase kind error
%d Number L10324
%m Message text
%% Percent %
\n New line
Example
ASMOPTIONS=-WmsgFonf”%k %d: %m\n”
produces a message in following format:
information L10324: Linking successful
See also
ERRORFILE: Filename specification error environment variable
Assembler options:
• -WmsgFb (-WmsgFbv, -WmsgFbm): Set message file format for batch mode
• -WmsgFi (-WmsgFiv, -WmsgFim): Set message file format for interactive
mode
• -WmsgFob: Message format for batch mode
• -WmsgFoi: Message format for interactive mode
• -WmsgFonp: Message format for no position information
Group
Messages
Scope
Assembly Unit
Syntax
-WmsgFonp<string>
Arguments
<string>: format string (see below)
Default
-WmsgFonp"%f%e: %K %d: %m\n"
Description
Sometimes there is no position information available for a message (e.g., if a
message not related to a certain position). Then this message format string is used.
The following formats are supported (supposed that the source file is
x:\Freescale\sourcefile.asmx)
Listing 5.49 Supported message formats for when there is no position information
%p Path x:\Freescale\
%f Path and name x:\Freescale\sourcefile
%n Filename sourcefile
%e Extension .asmx
%N File (8 chars) sourcefi
%E Extension (3 chars) .asm
%K Uppercase kind ERROR
%k Lowercase kind error
%d Number L10324
%m Message text
%% Percent %
\n New line
Example
ASMOPTIONS=-WmsgFonf”%k %d: %m\n”
produces a message in following format:
information L10324: Linking successful
See also
ERRORFILE: Filename specification error environment variable
Assembler options:
• -WmsgFb (-WmsgFbv, -WmsgFbm): Set message file format for batch mode
• -WmsgFi (-WmsgFiv, -WmsgFim): Set message file format for interactive
mode
• -WmsgFob: Message format for batch mode
• -WmsgFoi: Message format for interactive mode
• -WmsgFonf: Message format for no file information
Group
Messages
Scope
Assembly Unit
Syntax
-WmsgNe<number>
Arguments
<number>: Maximum number of error messages.
Default
50
Description
With this option the amount of error messages can be reported until the Assembler
stops assembling. Note that subsequent error messages which depends on a
previous one may be confusing.
Example
ASMOPTIONS=-WmsgNe2
The Assembler stops assembling after two error messages.
See also
Assembler options:
• -WmsgNi: Number of Information messages
• -WmsgNw: Number of Warning messages
Group
Messages
Scope
Assembly Unit
Syntax
-WmsgNi<number>
Arguments
<number>: Maximum number of information messages.
Default
50
Description
With this option the maximum number of information messages can be set.
Example
ASMOPTIONS=-WmsgNi10
Only ten information messages are logged.
See also
Assembler options:
• -WmsgNe: Number of error messages
• -WmsgNw: Number of Warning messages
Group
Messages
Scope
None
Syntax
-WmsgNu[={a|b|c|d}]
Arguments
a: Disable messages about include files
b: Disable messages about reading files
c: Disable messages about generated files
d: Disable messages about processing statistics
e: Disable informal messages
Default
None
Description
The application produces some messages which are not in the normal message
categories (WARNING, INFORMATION, ERROR, or FATAL). With this option
such messages can be disabled. The purpose for this option is to reduce the amount
of messages and to simplify the error parsing of other tools:
• a: The application provides information about all included files. With this
suboption this option can be disabled.
• b: With this suboption messages about reading files e.g., the files used as input
can be disabled.
• c: Disables messages informing about generated files.
• d: At the end of the assembly, the application may provide information about
statistics, e.g., code size, RAM/ROM usage, and so on. With this suboption this
option can be disabled.
• e: With this option, informal messages (e.g., memory model, floating point
format, etc.) can be disabled.
NOTE Depending on the application, not all suboptions may make sense. In this case
they are just ignored for compatibility.
Example
-WmsgNu=c
Group
Messages
Scope
Assembly Unit
Syntax
-WmsgNw<number>
Arguments
<number>: Maximum number of warning messages.
Default
50
Description
With this option the maximum number of warning messages can be set.
Example
ASMOPTIONS=-WmsgNw15
Only 15 warning messages are logged.
See also
Assembler options:
• -WmsgNe: Number of error messages
• -WmsgNi: Number of Information messages
Group
Messages
Scope
Assembly Unit
Syntax
-WmsgSd<number>
Arguments
<number>: Message number to be disabled, e.g., 1801
Default
None
Description
With this option a message can be disabled so it does not appear in the error output.
Example
-WmsgSd1801
See also
Assembler options:
• -WmsgSe: Setting a message to Error
• -WmsgSi: Setting a message to Information
• -WmsgSw: Setting a Message to Warning
Group
Messages
Scope
Assembly Unit
Syntax
-WmsgSe<number>
Arguments
<number>: Message number to be an error, e.g., 1853
Default
None
Description
Allows changing a message to an error message.
Example
-WmsgSe1853
See also
• -WmsgSd: Setting a message to disable
• -WmsgSi: Setting a message to Information
• -WmsgSw: Setting a Message to Warning
Group
Messages
Scope
Assembly Unit
Syntax
-WmsgSi<number>
Arguments
<number>: Message number to be an information, e.g., 1853
Default
None
Description
With this option a message can be set to an information message.
Example
-WmsgSi1853
See also
Assembler options:
• -WmsgSd: Setting a message to disable
• -WmsgSe: Setting a message to Error
• -WmsgSw: Setting a Message to Warning
Group
Messages
Scope
Assembly Unit
Syntax
-WmsgSw<number>
Arguments
<number>: Error number to be a warning, e.g., 2901
Default
None
Description
With this option a message can be set to a warning message.
Example
-WmsgSw2901
See also
Assembler options:
• -WmsgSd: Setting a message to disable
• -WmsgSe: Setting a message to Error
• -WmsgSi: Setting a message to Information
Group
Messages
Scope
Assembly Unit
Syntax
-WOutFile(On|Off)
Arguments
None
Default
Error listing file is created.
Description
This option controls if a error listing file should be created at all. The error listing
file contains a list of all messages and errors which are created during a assembly
process. Since the text error feedback can now also be handled with pipes to the
calling application, it is possible to obtain this feedback without an explicit file.
The name of the listing file is controlled by the environment variable
ERRORFILE: Filename specification error.
Example
-WOutFileOn
The error file is created as specified with ERRORFILE.
-WErrFileOff
No error file is created.
See also
Assembler options:
• -WErrFile: Create "err.log" error file
• -WStdout: Write to standard output
Group
Messages
Scope
Assembly Unit
Syntax
-WStdout(On|Off)
Arguments
None
Default
output is written to stdout
Description
With Windows applications, the usual standard streams are available. But text
written into them does not appear anywhere unless explicitly requested by the
calling application. With this option is can be controlled if the text to error file
should also be written into stdout.
Example
-WStdoutOn
All messages are written to stdout.
-WErrFileOff
Nothing is written to stdout.
See also
Assembler options:
• -WErrFile: Create "err.log" error file
• -WOutFile: Create error listing file
Section attributes
An attribute is associated with each section according to its content. A section may be:
• a data section,
• a constant data section, or
• a code section.
Code sections
A section containing at least one instruction is considered to be a code section. Code
sections are always allocated in the target processor’s ROM area.
Code sections should not contain any variable definitions (variables defined using the DS
directive). You do not have any write access on variables defined in a code section. In
addition, variables in code sections cannot be displayed in the debugger as data.
Constant sections
A section containing only constant data definition (variables defined using the DC or DCB
directives) is considered to be a constant section. Constant sections should be allocated in
the target processor’s ROM area, otherwise they cannot be initialized at application loading
time.
Data sections
A section containing only variables (variables defined using the DS directive) is
considered to be a data section. Data sections are always allocated in the target processor’s
RAM area.
NOTE A section containing variables (DS) and constants (DC) or code is not a data
section. The default for such a section with mixed DC and code content is to
put that content into ROM.
We strongly recommend that you use separate sections for the definition of variables and
constant variables. This will prevent problems in the initialization of constant variables.
Section types
First of all, you should decide whether to use relocatable or absolute code in your
application. The Assembler allows the mixing of absolute and relocatable sections in a
single application and also in a single source file. The main difference between absolute
and relocatable sections is the way symbol addresses are determined.
This section covers these two types of sections:
• Absolute sections
• Relocatable sections
Absolute sections
The starting address of an absolute section is known at assembly time. An absolute section
is defined through the ORG - Set Location Counter assembler directive. The operand
specified in the ORG directive determines the start address of the absolute section. See
Listing 6.1 for an example of constructing absolute sections using the ORG assembler
directive.
Listing 6.1 Example source code using ORG for absolute sections
XDEF entry
ORG $8000 ; Absolute constant data section.
cst1: DC.B $26
cst2: DC.B $BC
...
ORG $080 ; Absolute data section.
var: DS.B 1
ORG $8010 ; Absolute code section.
entry:
In the previous example, two bytes of storage are allocated starting at address $A00. The
constant variable - cst1 - will be allocated one byte at address $8000 and another
constant - cst2 - will be allocated one byte at address $8001. All subsequent
instructions or data allocation directives will be located in this absolute section until
another section is specified using the ORG or SECTION directives.
When using absolute sections, it is the user’s responsibility to ensure that there is no
overlap between the different absolute sections defined in the application. In the previous
example, the programmer should ensure that the size of the section starting at address
$8000 is not bigger than $10 bytes, otherwise the section starting at $8000 and the
section starting at $8010 will overlap.
Even applications containing only absolute sections must be linked. In that case, there
should not be any overlap between the address ranges from the absolute sections defined
in the assembly file and the address ranges defined in the linker parameter (PRM) file.
The PRM file used to link the example above, can be defined as in Listing 6.2.
Relocatable sections
The starting address of a relocatable section is evaluated at linking time according to the
information stored in the linker parameter file. A relocatable section is defined through the
SECTION - Declare Relocatable Section assembler directive. See Listing 6.3 for an
example using the SECTION directive.
Listing 6.3 Example source code using SECTION for relocatable sections
XDEF entry
constSec: SECTION ; Relocatable constant data section.
cst1: DC.B $A6
cst2: DC.B $BC
In the previous example, two bytes of storage are allocated in the constSec section. The
constant cst1 is allocated at the start of the section at address $A00 and another constant
cst2 is allocated at an offset of 1 byte from the beginning of the section. All subsequent
instructions or data allocation directives will be located in the relocatable constSec
section until another section is specified using the ORG or SECTION directives.
When using relocatable sections, the user does not need to care about overlapping
sections. The linker will assign a start address to each section according to the input from
the linker parameter file.
The user can decide to define only one memory area for the code and constant sections and
another one for the variable sections or to split the sections over several memory areas.
Listing 6.4 PRM file for Listing 6.3 defining one RAM area and one ROM area
SECTIONS
/* READ_ONLY memory area. */
MY_ROM = READ_ONLY 0x8000 TO 0xFDFF;
/* READ_WRITE memory area. */
MY_RAM = READ_WRITE 0x0100 TO 0x023F;
END
PLACEMENT
/* Relocatable variable sections are allocated in MY_RAM. */
DEFAULT_RAM, dataSec , SSTACK INTO MY_RAM;
/* Relocatable code and constant sections are allocated in MY_ROM. */
DEFAULT_ROM, constSec INTO MY_ROM;
END
INIT entry /* entry is the entry point to the application. */
VECTOR ADDRESS 0xFFFE entry /* Initialization for Reset vector.*/
• Constants sections should be defined in the ROM memory area in the PLACEMENT
section (otherwise, they are allocated in RAM).
• The specification of the application entry point (INIT command).
• The definition of the reset vector (VECTOR ADDRESS command).
According to the PRM file above:
• the dataSec section will be allocated starting at 0x0080.
• the codeSec section will be allocated starting at 0x0B00.
• the constSec section will be allocated next to the codeSec section.
Listing 6.5 PRM file for Listing 6.3 defining multiple RAM and ROM areas
Modularity
An application is more modular when programming can be divided into smaller units
called sections. The sections themselves can be distributed among different source files.
Multiple developers
When an application is split over different files, multiple developers can be involved in the
development of the application. To avoid major problems when merging the different
files, attention must be paid to the following items:
• An include file must be available for each assembly source file, containing XREF
directives for each exported variable, constant and function. In addition, the interface
to the function should be described there (parameter passing rules as well as the
function return value).
• When accessing variables, constants, or functions from another module, the
corresponding include file must be included.
• Variables or constants defined by another developer must always be referenced by
their names.
• Before invoking a function implemented in another file, the developer should respect
the function interface, i.e., the parameters are passed as expected and the return value
is retrieved correctly.
Early development
The application can be developed before the application memory map is known. Often the
application’s definitive memory map can only be determined once the size required for
code and data can be evaluated. The size required for code or data can only be quantified
once the major part of the application is implemented. When absolute sections are used,
defining the definitive memory map is an iterative process of mapping and remapping the
code. The assembly files must be edited, assembled, and linked several times. When
relocatable sections are used, this can be achieved by editing the PRM file and linking the
application.
Enhanced portability
As the memory map is not the same for each derivative (MCU), using relocatable sections
allow easy porting of the code for another MCU. When porting relocatable code to another
target you only need to link the application again with the appropriate memory map.
Tracking overlaps
When using absolute sections, the programmer must ensure that there is no overlap
between the sections. When using relocatable sections, the programmer does not need to
be concerned about any section overlapping another. The labels’ offsets are all evaluated
relatively to the beginning of the section. Absolute addresses are determined and assigned
by the linker.
Reusability
When using relocatable sections, code implemented to handle a specific I/O device (serial
communication device), can be reused in another application without any modification.
Comment line
A comment can occupy an entire line to explain the purpose and usage of a block of
statements or to describe an algorithm. A comment line contains a semicolon followed by
a text (Listing 7.1). Comments are included in the assembly listing, but are not significant
to the Assembler.
An empty line is also considered to be a comment line.
Source line
Each source statement includes one or more of the following four fields:
• a Label field,
• an Operation field,
• one or several operands, or
• a comment.
Characters on the source line may be either upper or lower case. Directives and
instructions are case-insensitive, whereas symbols are case-sensitive unless the assembler
option for case insensitivity on label names (-Ci: Switch case sensitivity on label names
OFF) is activated.
Label field
The label field is the first field in a source line. A label is a symbol followed by a colon.
Labels can include letters (A–Z or a–z), underscores, periods and numbers. The first
character must not be a number.
Labels are required on assembler directives that define the value of a symbol (SET or
EQU). For these directives, labels are assigned the value corresponding to the expression
in the operand field.
Labels specified in front of another directive, instruction or comment are assigned the
value of the location counter in the current section.
NOTE When the Macro Assembler expands a macro it generates internal symbols
starting with an underscore ‘_’. Therefore, to avoid potential conflicts, user
defined symbols should not begin with an underscore
NOTE For the Macro Assembler, a .B or .W at the end of a label has a specific
meaning. Therefore, to avoid potential conflicts, user- defined symbols should
not end with .B or .W.
Operation field
The operation field follows the label field and is separated from it by a white space. The
operation field must not begin in the first column. An entry in the operation field is one of
the following:
• an instruction’s mnemonic - an abbreviated, case-insensitive name for a member in
the Instruction set
• a Directive name, or
• a Macro name.
Instruction set
Executable instructions for the M68HC08 processor are defined in the CPU08 Reference
Manual.
CBEQA #<expression>,<label>
CBEQX #<expression>,<label>
DBNZA <label>
DBNZX <label>
DIV Divide
NOP No operation
BGND Background
CBEQA <label>
CBEQX <label>
DBNZA <label>
DBNZX <label>
NOP No Operation
SUBX
NOTE For RS08 both D[X] and ,X notations refer to the memory location $000E. The
,X notation is supported for compatibility reasons with HC(S)08. Wherever ,X
is supported, D[X] is also supported. In situations where the use of ,X would
lead to double commas (e.g. BCLR 0,,X) the use of ,X is not allowed.
Directive
Assembler directives are described in the Assembler Directives chapter of this manual.
Macro
A user-defined macro can be invoked in the assembler source program. This results in the
expansion of the code defined in the macro. Defining and using macros are described in
the Macros chapter in this manual.
Inherent
Instructions using this addressing mode do not have any associated instruction fetch
(Listing 7.2). Some of them are acting on data in the CPU registers.
CLRA
DAA
Immediate
The opcode contains the value to use with the instruction rather than the address of this
value.
The effective address of the instruction is specified using the # character as in Listing 7.3.
XDEF Entry
initStack: EQU $0400
MyData: SECTION
data: DS.B 1
MyCode: SECTION
Entry:
LDHX #initStack ; init Stack Pointer
TXS ; with value $400-1 = $03FF
In this example, the hexadecimal value $0400 is loaded in value in the register HX and
the decimal value 100 is loaded into register A.
Direct
The direct addressing mode is used to address operands in the direct page of the memory
(location $0000 to $00FF).
For most of the direct instructions, only two bytes are required: the first byte is the opcode
and the second byte is the operand address located in page zero. See Listing 7.4 for an
example of the direct addressing mode.
XDEF Entry
initStack: EQU $0400
MyData: SECTION SHORT
data: DS.B 1
MyCode: SECTION
Entry:
LDHX #initStack ; init Stack Pointer
TXS ; with value $400 - 1 = $03FF
main: LDA #$55
STA data
BRA main
In this example, the value $55 is stored in the variable data, which is located on the direct
page. The MyData section must be defined in the direct page in the linker parameter file.
The opcode generated for the STA data instruction is two bytes long.
Extended
The extended addressing mode is used to access memory location located above the direct
page in a 64-kilobyte memory map.
For the extended instructions, three bytes are required: the first byte is the opcode and the
second and the third bytes are the most and least significant bytes of the operand address.
See Listing 7.5 for an example of the extended addressing mode.
XDEF Entry
initStack: EQU $0400
ORG $B00
data: DS.B 1
MyCode: SECTION
Entry:
LDHX #initStack ; init Stack Pointer
TXS ; with value $400-1 = $03FF
main: LDA #$55
STA data
BRA main
In this example, the value $55 is stored in the variable data. This variable is located at
address $0B00 in the memory map. The opcode of the STA data instruction is then three
bytes long.
Indexed, no offset
This addressing mode is used to access data with variable addresses through the HX index
register of the HC08 controller. The X index register contains the least significant byte of
the operand while the H index register contains the most significant byte.
Indexed, no offset instructions are one byte long. See Listing 7.6 for an example of using
the indexed (no offset) addressing mode.
...
Entry:
...
LDHX #$0FFE
LDA ,X
...
JMP ,X
...
The value stored in memory location $0FFE is loaded into accumulator A. The JMP
instruction causes the program to jump to the address pointed to by the HX register.
XDEF Entry
initStack: EQU $0400
MyData: SECTION SHORT
data: DS.B 8
MyCode: SECTION
Entry:
LDHX #initStack ; init Stack Pointer
TXS ; with value $400-1 = $03FF
main:
LDHX #data
LDA 5 ,X
...
JMP $FF,X
...
The value contained in the memory at the location calculated using the address of data
(pointed to by the HX register) + 5 is loaded in accumulator A. The JMP instruction causes
the program to jump to the address pointed to by the HX register + $FF.
XDEF Entry
initStack: EQU $0400
MyData: SECTION
data: DS.B 8
MyCode: SECTION
Entry:
LDHX #initStack ; init Stack Pointer
TXS ; with value $400-1 = $03FF
main:
LDHX #table
STA $500 ,X
...
JMP $1000,X
...
The value contained in the memory at the location calculated using the address of data
(pointed to by register HX) + $500 is loaded in accumulator A. The JMP instruction causes
the program to jump to the address pointed to by the HX register + $1000.
Relative
This addressing mode is used by all branch instructions to determine the destination
address. The signed byte following the opcode is added to the contents of the program
counter.
As the offset is coded on a signed byte, the branching range is -127 to +128. The
destination address of the branch instruction must be in this range. See Listing 7.9 for an
example of using the relative addressing mode.
main:
NOP
NOP
BRA main
This addressing mode allow easy access of the data on the stack. If the interrupts are
disabled, the Stack pointer can also be used as a second Index register. See Listing 7.10 for
an example of using the Stack Pointer *8-bit offset) addressing mode.
entry:
LDHX #$0500 ; init Stack Pointer to 04FF
TXS
LDA #$40
STA $50, SP ; Location $54F = $40
In this example, stack pointer, 8-bit offset mode is used to store the value $40 in memory
location $54F.
entry:
LDHX #$0100 ; init Stack Pointer to 00FF
TXS
In this example, stack pointer, 16-bit offset mode is used to store the value in memory
location $5FF in accumulator A.
Memory-to-memory immediate-to-direct
This addressing mode is generally used to initialize variables and registers in page zero.
The register A is not affected. See Listing 7.12 for an example for using the memory-to-
memory immediate-to-direct addressing mode.
The MOV #$20,MyData instruction stores the value $20 in memory location $50
‘MyData’.
Memory-to-memory direct-to-direct
This addressing mode is generally used to transfer variables and registers in page zero.
The A register is not affected. See Listing 7.13 for an example of using the memory-to-
memory direct-to-direct addressing mode.
The MOV #$10,MyData1 instruction stores the value $10 in memory location $50
‘MyData1’ using the memory-to-memory Immediate-to-Direct addressing mode. The
MOV MyData1,MyData2 instruction moves the content of MyData1 into MyData2
using memory to memory Direct-to-Direct addressing mode. The content of MyData2
(memory location $51) is then $10.
XDEF Entry
ConstSCT: SECTION
Const: DC.B 1,11,21,31,192,12,0
CodeSCT: SECTION
Entry: LDHX #$00FF
TXS
main:
LDHX #Const
LOOP: MOV X+, MyReg
BEQ main
BRA LOOP
In this example, the table Const contains seven bytes defined in a constant section in
ROM. The last value of this table is zero.
The HX register is initialized with the address of Const. All the values of this table are
stored one after another in page-zero memory location MyReg using the MOV X+,
MyReg instruction. When the value 0 is encountered, the HX register is reset with the
address of the first element of the #Const table.
XDEF entry
MyData: SECTION SHORT
MyReg1: DS.B 1
MyReg2: DS.B 1
MyCode: SECTION
entry:
LDA #$02
STA MyReg1
INCA
STA MyReg2
LDHX #$1000
MOV MyReg1,X+
MOV MyReg2,X+
main: BRA main
The page-zero memory locations MyReg1 and MyReg2 are first respectively initialized
with $02 and $03. The contents of those data are then written in memory location
$1000 and $1001. The HX register points to memory location $1002.
XDEF Entry
ORG $F000
data: DC.B 1,11,21,31,$C0,12
CodeSCT: SECTION
Entry: LDHX #$00FF
TXS
main:
LDA #$C0
LDHX #data
LOOP: CBEQ X+,IS_EQUAL
BRA LOOP
IS_EQUAL: ...
Using this addressing mode, it is possible to scan the memory to find a location containing
a specific value.
The value located at the memory location pointed to by HX is compared to the value in the
A register. If the two values match, the program branches to IS_EQUAL. HX points to the
memory location next to the one containing the searched value.
In this example, the value $C0 is searched starting at memory location $F000. This value
is found at the memory location $F004, the program branches to IS_EQUAL, and the HX
register contains $F005.
XDEF Entry
ORG $F000
data: DCB.B $40,$00
DC.B 1,11,21,31,$C0,12 ; $C0 is located at $F000+$40+4
CodeSCT: SECTION
Entry: LDHX #$00FF
TXS
main:
LDA #$C0
LDHX #data
LOOP: CBEQ $30,X+,IS_EQUAL
BRA LOOP
IS_EQUAL: ...
Using this addressing mode, it is possible to scan the memory to find a location containing
a specific value starting at a specified location to which is added an offset.
The value located at memory location pointed to by HX + $30 is compared to the value
in the A register. If the two values match, program branch to IS_EQUAL. HX points to
memory location next to the one containing the searched value.
In this example, the value $C0 is searched starting at memory location
$F000+$30=$F030. This value is found at memory location $F044, the program
branches to IS_EQUAL. The HX register contains the memory location of the searched
value minus the offset, incremented by one: $F044-$30+1=$F015.
Inherent (RS08)
Instructions using this addressing mode have no associated instruction fetch. Some of
them are acting on data in the CPU registers.
Example:
CLRA
INCA
NOP
Tiny
The tiny addressing mode is used to access only the first 16 bytes of the memory map
(addresses from $0000 to $000F). The instructions using this addressing mode are
encoded using one byte only. This addressing mode is available for INC, DEC, ADD and
SUB instructions.
Example:
XDEF Entry
MyData: SECTION RS08_TINY
data: DS.B 1
MyCode: SECTION
Entry:
In this example, the value of the variable data is added to the accumulator. The data is
located in the tiny memory area, so the encoding of the ADD instruction will be one byte
long. Note that the tiny section has to be placed into the tiny memory area at link time.
Short
The RS08 short addressing mode is used to access only the first 32 bytes of the memory
map (addresses from $0000 to $001F). The instructions using this addressing mode are
encoded using one byte only. This addressing mode is available for CLR, LDA and STA
instructions.
Example:
XDEF Entry
MyData: SECTION RS08_SHORT
data: DS.B 1
MyCode: SECTION
Entry:
main: LDA data
BRA main
In this example, the value of the variable data is loaded into the accumulator. The data is
located in the short memory area, so the encoding of the LDA instruction will be one byte
long. Note that the short section has to be placed into the tiny memory area at linktime.
Direct
The direct addressing mode is used to address operands in the direct page of the memory
(location $0000 to $00FF).
Example:
XDEF Entry
MyData: SECTION
data: DS.B 1
MyCode: SECTION
Entry:
main: LDA #$55
STA data
BRA main
In this example, the value $55 is stored in the variable data. The opcode generated for the
instruction STA data is two bytes long.
Extended
The extended addressing mode is used only for JSR and JMP instructions. The 14-bit
address is located in the lowest 14 bits of the encoding after the two-bit opcode.
Example:
XDEF Entry
XREF target
data: DS.B 1
MyCode: SECTION
Entry:
main: LDA #$55
JMP target
In this example a jump is executed at an address defined by the external symbol target.
Relative
This addressing mode is used by all branch instructions to determine the destination
address. The signed byte following the opcode is added to the contents of the program
counter.
As the offset is coded on a signed byte, the branching range is -127 to +128. The
destination address of the branch instruction must be in this range.
Example:
main:
NOP
NOP
BRA main
Immediate
The opcode contains the value to use with the instruction rather than the address of this
value. The effective address of the instruction is specified using the # character as in the
example below.
Example:
XDEF Entry
MyData: SECTION
data: DS.B 1
MyCode: SECTION
Entry:
main: LDA #100
BRA main
Indexed
When using the indexed addressing mode, an index register is used as reference to access
the instruction’s operand. For the RS08, the index registers are located at $000F (register
X) and $000E (register D[X]). The D[X] register is called the index data register, and can
be designated by either one of the D[X] or ,X notations. As a restriction, when the use of
,X would lead to double commas in the assembly source, the use of ,X is not allowed.
Example:
XDEF Entry
MyData: SECTION
data: DS.B 1
MyCode: SECTION
Entry:
main: CLR D[X] ; equivalent to CLR ,X
CLR X
In this example the contents of both X and D[X] registers are replaced by zeros.
Comment Field
The last field in a source statement is an optional comment field. A semicolon (;) is the
first character in the comment field.
Example:
Symbols
The following types of symbols are the topics of this section:
• User-defined symbols
• External symbols
• Undefined symbols
• Reserved symbols
User-defined symbols
Symbols identify memory locations in program or data sections in an assembly module. A
symbol has two attributes:
• The section, in which the memory location is defined
• The offset from the beginning of that section.
Symbols can be defined with an absolute or relocatable value, depending on the section in
which the labeled memory location is found. If the memory location is located within a
relocatable section (defined with the SECTION - Declare Relocatable Section assembler
directive), the label has a relocatable value relative to the section start address.
Symbols can be defined relocatable in the label field of an instruction or data definition
source line (Listing 7.18).
Sec: SECTION
label1: DC.B 2 ; label1 is assigned offset 0 within Sec.
label2: DC.B 5 ; label2 is assigned offset 2 within Sec.
label3: DC.B 1 ; label3 is assigned offset 7 within Sec.
Sec: SECTION
label1: DC.B 2 ; label1 is assigned offset 0 within Sec.
label2: EQU 5 ; label2 is assigned value 5.
label3: EQU label1 ; label3 is assigned the address of label1.
External symbols
A symbol may be made external using the XDEF - External Symbol Definition assembler
directive. In another source file, an XREF - External Symbol Reference assembler
directive must reference it. Since its address is unknown in the referencing file, it is
considered to be relocatable. See Listing 7.20 for an example of using XDEF and XREF.
Undefined symbols
If a label is neither defined in the source file nor declared external using XREF, the
Assembler considers it to be undefined and generates an error message. Listing 7.21
shows an example of an undeclared label.
codeSec: SECTION
entry:
NOP
BNE entry
NOP
JMP end
JMP label ; <- Undeclared user-defined symbol: label
end:RTS
END
Reserved symbols
Reserved symbols cannot be used for user-defined symbols.
Register names are reserved identifiers.
For the HC08 processor the reserved identifiers are listed in Listing 7.22.
A, CCR, H, X, SP
The keywords LOW and HIGH are also reserved identifiers. They are used to refer to the
low byte and the high byte of a memory location.
Constants
The Assembler supports integer and ASCII string constants:
Integer constants
The Assembler supports four representations of integer constants:
• A decimal constant is defined by a sequence of decimal digits (0-9).
Example: 5, 512, 1024
• A hexadecimal constant is defined by a dollar character ($) followed by a sequence
of hexadecimal digits (0-9, a-f, A-F).
Example: $5, $200, $400
• An octal constant is defined by the commercial at character (@) followed by a
sequence of octal digits (0-7).
Example: @5, @1000, @2000
• A binary constant is defined by a percent character followed by a sequence of binary
digits (0-1)
Example:
%101, %1000000000, %10000000000
The default base for integer constant is initially decimal, but it can be changed using the
BASE - Set number base assembler directive. When the default base is not decimal,
decimal values cannot be represented, because they do not have a prefix character.
String constants
A string constant is a series of printable characters enclosed in single (‘) or double quote
("). Double quotes are only allowed within strings delimited by single quotes. Single
quotes are only allowed within strings delimited by double quotes. See Listing 7.23 for a
variety of string constants.
Floating-Point constants
The Macro Assembler does not support floating-point constants.
Operators
Operators recognized by the Assembler in expressions are:
• Addition and subtraction operators (binary)
• Multiplication, division and modulo operators (binary)
• Sign operators (unary)
• Shift operators (binary)
• Bitwise operators (binary)
• Logical operators (unary)
• Relational operators (binary)
• HIGH operator
• PAGE operator
• Force operator (unary)
Syntax
Addition: <operand> + <operand>
Subtraction: <operand> – <operand>
Description
The + operator adds two operands, whereas the – operator subtracts them. The
operands can be any expression evaluating to an absolute or relocatable expression.
Addition between two relocatable operands is not allowed.
Example
See Listing 7.24 for an example of addition and subtraction operators.
Syntax
Multiplication: <operand> * <operand>
Division: <operand> / <operand>
Modulo: <operand> % <operand>
Description
The * operator multiplies two operands, the / operator performs an integer
division of the two operands and returns the quotient of the operation. The %
operator performs an integer division of the two operands and returns the
remainder of the operation
Example
See Listing 7.25 for an example of the multiplication, division, and modulo
operators.
23 * 4 ; multiplication (= 92)
23 / 4 ; division (= 5)
23 % 4 ; remainder(= 3)
Syntax
Plus: +<operand>
Minus: -<operand>
Description
The + operator does not change the operand, whereas the – operator changes the
operand to its two’s complement. These operators are valid for absolute expression
operands.
Example
See Listing 7.26 for an example of the unary sign operators.
+$32 ; ( = $32)
-$32 ; ( = $CE = -$32)
Syntax
Shift left: <operand> << <count>
Shift right: <operand> >> <count>
Description
The << operator shifts its left operand left by the number of bits specified in the
right operand.
The >> operator shifts its left operand right by the number of bits specified in the
right operand.
The operands can be any expression evaluating to an absolute expression.
Example
See Listing 7.27 for an example of the binary shift operators.
Syntax
Bitwise AND: <operand> & <operand>
Bitwise OR: <operand> | <operand>
Bitwise XOR: <operand> ^ <operand>
Description
The & operator performs an AND between the two operands on the bit level.
The | operator performs an OR between the two operands on the bit level.
The ^ operator performs an XOR between the two operands on the bit level.
The operands can be any expression evaluating to an absolute expression.
Example
See Listing 7.28 for an example of the binary bitwise operators
Syntax
One’s complement: ~<operand>
Description
The ~ operator evaluates the one’s complement of the operand.
The operand can be any expression evaluating to an absolute expression.
Example
See Listing 7.29 for an example of the unary bitwise operator.
Syntax
Logical NOT: !<operand>
Description
The ! operator returns 1 (true) if the operand is 0, otherwise it returns 0 (false).
The operand can be any expression evaluating to an absolute expression.
Example
See Listing 7.30 for an example of the unary logical operator.
!(8<5) ; = $1 (TRUE)
Syntax
Equal: <operand> = <operand>
<operand> == <operand>
Not equal: <operand> != <operand>
<operand> <> <operand>
Less than: <operand> < <operand>
Less than or equal: <operand> <= <operand>
Greater than: <operand> > <operand>
Greater than or equal: <operand> >= <operand>
Description
These operators compare two operands and return 1 if the condition is true or 0 if
the condition is false.
Example
See Listing 7.31 for an example of the binary relational operators
3 >= 4 ; = 0 (FALSE)
label = 4 ; = 1 (TRUE) if label is 4, 0 or (FALSE) otherwise.
9 < $B ; = 1 (TRUE)
HIGH operator
The HIGH operator is HIGH.
Syntax
High Byte: HIGH(<operand>)
Description
This operator returns the high byte of the address of a memory location.
Example
Assume data1 is a word located at address $1050 in the memory.
LDA #HIGH(data1)
This instruction will load the immediate value of the high byte of the address of
data1 ($10) in register A.
LDA HIGH(data1)
This instruction will load the direct value at memory location of the higher byte of
the address of data1 (i.e., the value in memory location $10) in register A.
HIGH_6_13 Operator
Syntax
High Byte: HIGH_6_13(<operand>)
Description
This operator returns the high byte of a 14-bit address of a memory location.
Example
Assume data1 is a word located at address $1010 in the memory.
LDA #HIGH_6_13(data1)
This instruction will load the value $40 in the accumulator.
LOW operator
The LOW operator is LOW.
Syntax
LOW Byte: LOW(<operand>)
Description
This operator returns the low byte of the address of a memory location.
Example
Assume data1 is a word located at address $1050 in the memory.
LDA #LOW(data1)
This instruction will load the immediate value of the lower byte of the address of
data1 ($50) in register A.
LDA LOW(data1)
This instruction will load the direct value at memory location of the lower byte of
the address of data1 (i.e., the value in memory location $50) in register A.
MAP_ADDR_6 Operator
Syntax
MAP_ADDR_6(<operand>)
Description
This operator returns the lower 6 bits for a memory location. It should be used to
determine the offset in the paging window for a certain memory address.Note that
the operator automatically adds the offset of the base of the paging window ($C0).
Example
MOV #HIGH_6_13(data), $001F
STA MAP_ADDR_6(data)
In this example, the RS08 PAGE register (mapped at $001F) is loaded with the
memory page corresponding to data and then the value contained in the
accumulator is stored at the address pointed by data.
PAGE operator
The PAGE operator is PAGE.
Syntax
PAGE Byte: PAGE(<operand>)
Description
This operator returns the page byte of the address of a memory location.
Example
Assume data1 is a word located at address $28050 in the memory.
LDA #PAGE(data1)
This instruction will load the immediate value of the page byte of the address of
data1 ($2).
LDA PAGE(data1)
This instruction will load the direct value at memory location of the page byte of
the address of data1 (i.e., the value in memory location $2).
NOTE The PAGE keyword does not refer to the RS08 PAGE register but to the PAGE
operator described above.
Syntax
8-bit address: <<operand> or <operand>.B
16-bit address: ><operand> or <operand>.W
Description
The < or .B operators force direct addressing mode, whereas the > or .W operators
force extended addressing mode.
Use the < operator to force 8-bit indexed or 8-bit direct addressing mode for an
instruction.
Use the > operator to force 16-bit indexed or 16-bit extended addressing mode for
an instruction.
The operand can be any expression evaluating to an absolute or relocatable
expression.
Example
<label ; label is an 8-bit address.
label.B ; label is an 8-bit address.
>label ; label is an 16-bit address.
label.W ; label is an 16-bit address.
For the RS08 the < operand forces the operand to short or tiny addressing mode
(depending on the instruction in which it is used). The same result can be obtained
by adding .S or .T to the referred symbol. The > operator forces an address to 8
bits, even if it fits in 4 or 5 bits (so short or tiny addressing modes can be used).
Operator precedence
Operator precedence follows the rules for ANSI - C operators (Table 7.6)
.
Expression
An expression is composed of one or more symbols or constants, which are combined
with unary or binary operators. Valid symbols in expressions are:
• User defined symbols
• External symbols
• The special symbol ‘*’ represents the value of the location counter at the beginning
of the instruction or directive, even when several arguments are specified. In the
following example, the asterisk represents the location counter at the beginning of
the DC directive:
DC.W 1, 2, *-2
Once a valid expression has been fully evaluated by the Assembler, it is reduced as one of
the following type of expressions:
• Absolute expression: The expression has been reduced to an absolute value, which is
independent of the start address of any relocatable section. Thus it is a constant.
Simple relocatable expression: The expression evaluates to an absolute offset from
the start of a single relocatable section.
• Complex relocatable expression: The expression neither evaluates to an absolute
expression nor to a simple relocatable expression. The Assembler does not support
such expressions.
All valid user defined symbols representing memory locations are simple relocatable
expressions. This includes labels specified in XREF directives, which are assumed to be
relocatable symbols.
Absolute expression
An absolute expression is an expression involving constants or known absolute labels or
expressions. An expression containing an operation between an absolute expression and a
constant value is also an absolute expression.
See Listing 7.32 for an example of an absolute expression.
Expressions involving the difference between two relocatable symbols defined in the same
file and in the same section evaluate to an absolute expression. An expression as
label2-label1 can be translated as:
Listing 7.34 Simplified result for the difference between two relocatable symbols
Example
In the example in Listing 7.35, the expression tabEnd-tabBegin evaluates to an
absolute expression and is assigned the value of the difference between the offset of
tabEnd and tabBegin in the section DataSec.
Listing 7.35 Absolute expression relating the difference between two relocatable
symbols
DataSec: SECTION
tabBegin: DS.B 5
tabEnd: DS.B 1
ConstSec: SECTION
label: EQU tabEnd-tabBegin ; Absolute expression
CodeSec: SECTION
entry: NOP
XREF XtrnLabel
DataSec: SECTION
tabBegin: DS.B 5
tabEnd: DS.B 1
CodeSec: SECTION
entry:
LDA tabBegin+2 ; Simple relocatable expression
BRA *-3 ; Simple relocatable expression
LDA XtrnLabel+6 ; Simple relocatable expression
Table 7.7 Expression type resulting from operator and operand type
-, !, ~ absolute absolute
-, !, ~ relocatable complex
+ absolute absolute
+ relocatable relocatable
Table 7.8 Expression type resulting from operator and their operands
Translation limits
The following limitations apply to the Macro Assembler:
• Floating-point constants are not supported.
• Complex relocatable expressions are not supported.
• Lists of operands or symbols must be separated with a comma.
• Include may be nested up to 50.
• The maximum line length is 1023.
Directive overview
Section-Definition directives
Use the directives in Table 8.1 to define new sections.
Directive Description
Constant-Definition directives
Use the directives in Table 8.2 to define assembly constants.
Directive Description
Data-Allocation directives
Use the directives in Table 8.3 to allocate variables.
Directive Description
Symbol-Linkage directives
Symbol-linkage directives (Table 8.4) are used to export or import global symbols.
Directive Description
ABSENTRY - Application entry point Specify the application entry point when an
absolute file is generated
XDEF - External Symbol Definition Make a symbol public (visible from outside)
Assembly-Control directives
Assembly-control directives (Table 8.5) are general purpose directives used to control the
assembly process.
Directive Description
BASE - Set number base Specify default base for constant definition
INCLUDE - Include text from another Include text from another file.
file
Directive Description
LLEN - Set Line Length Define line length in assembly listing file.
PLEN - Set Page Length Define page length in the assembler listing
file.
SPC - Insert Blank Lines Insert an empty line in the assembly listing
file.
TITLE - Provide Listing Title Define the user defined title for the
assembler listing file.
Directive Description
Directive Description
Syntax
ABSENTRY <label>
Synonym
None
Description
This directive is used to specify the application Entry Point when the Assembler
directly generates an absolute file. The -FA2 assembly option - ELF/DWARF 2.0
Absolute File - must be enabled.
Using this directive, the entry point of the assembly application is written in the
header of the generated absolute file. When this file is loaded in the debugger, the
line where the entry point label is defined is highlighted in the source window.
This directive is ignored when the Assembler generates an object file.
If the example in Listing 8.1 is assembled using the -FA2 assembler option, an
ELF/DWARF 2.0 Absolute file is generated.
ABSENTRY entry
ORG $fffe
Reset: DC.W entry
ORG $70
entry: NOP
NOP
main: RSP
NOP
BRA main
According to the ABSENTRY directive, the entry point will be set to the address of
entry in the header of the absolute file.
Syntax
ALIGN <n>
Synonym
None
Description
This directive forces the next instruction to a boundary that is a multiple of <n>,
relative to the start of the section. The value of <n> must be a positive number
between 1 and 32767. The ALIGN directive can force alignment to any size. The
filling bytes inserted for alignment purpose are initialized with ‘\0’.
ALIGN can be used in code or data sections.
Example
The example shown in Listing 8.2 aligns the HEX label to a location, which is a
multiple of 16 (in this case, location 00010 (Hex))
Assembler
7 7 ; on an address,
8 8 ; which is a
9 9 ; multiple of 16.
Syntax
BASE <n>
Synonym
None
Description
The directive sets the default number base for constants to <n>. The operand <n>
may be prefixed to indicate its number base; otherwise, the operand is considered
to be in the current default base. Valid values of <n> are 2, 8, 10, 16. Unless a
default base is specified using the BASE directive, the default number base is
decimal.
Example
See Listing 8.3 for examples of setting the number base.
Be careful. Even if the base value is set to 16, hexadecimal constants terminated by
a D must be prefixed by the $ character, otherwise they are supposed to be decimal
constants in old style format. For example, constant 45D is interpreted as decimal
constant 45, not as hexadecimal constant 45D.
Syntax
CLIST [ON|OFF]
Synonym
None
Description
The CLIST directive controls the listing of subsequent conditional assembly
blocks. It precedes the first directive of the conditional assembly block to which it
applies, and remains effective until the next CLIST directive is read.
When the ON keyword is specified in a CLIST directive, the listing file includes all
directives and instructions in the conditional assembly block, even those which do
not generate code (which are skipped).
When the OFF keyword is entered, only the directives and instructions that
generate code are listed.
A soon as the -L: Generate a listing file assembler option is activated, the
Assembler defaults to CLIST ON.
Example
Listing 8.4 is an example where the CLIST OFF option is used.
CLIST OFF
Try: EQU 0
IFEQ Try
LDA #103
ELSE
LDA #0
ENDIF
CLIST ON
Try: EQU 0
IFEQ Try
LDA #103
ELSE
LDA #0
ENDIF
DC - Define Constant
Syntax
[<label>:] DC [.<size>] <expression> [,
<expression>]...
where <size> = B (default), W, or L.
Synonym
DCW (= 2 byte DCs), DCL (= 4 byte DCs),
FCB (= DC.B), FDB (= 2 byte DCs),
FQB (= 4 byte DCs)
Description
The DC directive defines constants in memory. It can have one or more
<expression> operands, which are separated by commas. The
<expression> can contain an actual value (binary, octal, decimal, hexadecimal,
or ASCII). Alternatively, the <expression> can be a symbol or expression that
can be evaluated by the Assembler as an absolute or simple relocatable expression.
One memory block is allocated and initialized for each expression.
The following rules apply to size specifications for DC directives:
• DC.B: One byte is allocated for numeric expressions. One byte is allocated per
ASCII character for strings (Listing 8.8).
• DC.W: Two bytes are allocated for numeric expressions. ASCII strings are right
aligned on a two-byte boundary (Listing 8.9).
• DC.L: Four bytes are allocated for numeric expressions. ASCII strings are right
aligned on a four byte boundary (Listing 8.10).
If the value in an operand expression exceeds the size of the operand, the assembler
truncates the value and generates a warning message.
See also
Assembler directives:
• DCB - Define Constant Block
• DS - Define Space
• ORG - Set Location Counter
• SECTION - Declare Relocatable Section
Syntax
[<label>:] DCB [.<size>] <count>, <value>
where <size> = B (default), W, or L.
Description
The DCB directive causes the Assembler to allocate a memory block initialized
with the specified <value>. The length of the block is <size> * <count>.
<count> may not contain undefined, forward, or external references. It may
range from 1 to 4096.
The value of each storage unit allocated is the sign-extended expression <value>,
which may contain forward references. The <count> cannot be relocatable. This
directive does not perform any alignment.
The following rules apply to size specifications for DCB directives:
• DCB.B: One byte is allocated for numeric expressions.
• DCB.W: Two bytes are allocated for numeric expressions.
• DCB.L: Four bytes are allocated for numeric expressions.
See also
Assembler directives:
• DC - Define Constant
• DS - Define Space
• ORG - Set Location Counter
• SECTION - Declare Relocatable Section
DS - Define Space
Syntax
[<label>:] DS[.<size>] <count>
where <size> = B (default), W, or L.
Synonym
RMB (= DS.B)
RMD (2 bytes)
RMQ (4 bytes)
Description
The DS directive is used to reserve memory for variables (Listing 8.12). The
content of the memory reserved is not initialized. The length of the block is
<size> * <count>.
<count> may not contain undefined, forward, or external references. It may
range from 1 to 4096.
The label Counter references the lowest address of the defined storage area.
NOTE Storage allocated with a DS directive may end up in constant data section or
even in a code section, if the same section contains constants or code as well.
The Assembler allocates only a complete section at once.
Example
In Listing 8.13, a variable, a constant, and code were put in the same section.
Because code has to be in ROM, then all three elements must be put into ROM. In
order to allocate them separately, put them in different sections (Listing 8.14).
See also
• DC - Define Constant
• ORG - Set Location Counter
• SECTION - Declare Relocatable Section
Syntax
IF <condition>
[<assembly language statements>]
[ELSE]
[<assembly language statements>]
ENDIF
Synonym
ELSEC
Description
If <condition> is true, the statements between IF and the corresponding ELSE
directive are assembled (generate code).
If <condition> is false, the statements between ELSE and the corresponding
ENDIF directive are assembled. Nesting of conditional blocks is allowed. The
maximum level of nesting is limited by the available memory at assembly time.
Example
Listing 8.15 is an example of the use of conditional assembly directives:
Try: EQU 1
IF Try != 0
LDA #103
ELSE
LDA #0
ENDIF
Syntax
END
Synonym
None
Description
The END directive indicates the end of the source code. Subsequent source
statements in this file are ignored. The END directive in included files skips only
subsequent source statements in this include file. The assembly continues in the
including file in a regular way.
Example
The END statement in Listing 8.17 causes any source code after the END statement
to be ignored, as in Listing 8.18.
Syntax
ENDFOR
Synonym
None
Description
The ENDFOR directive indicates the end of a FOR block.
NOTE The FOR directive is only available when the -Compat=b assembler option is
used. Otherwise, the FOR directive is not supported.
Example
See Listing 8.28 in the FOR section.
See also
Assembler directives:
• FOR - Repeat assembly block
• -Compat: Compatibility modes
Syntax
ENDIF
Synonym
ENDC
Description
The ENDIF directive indicates the end of a conditional block. Nesting of
conditional blocks is allowed. The maximum level of nesting is limited by the
available memory at assembly time.
Example
See Listing 8.30 in the IF section.
See also
IF - Conditional assembly assembler directive
Syntax
ENDM
Synonym
None
Description
The ENDM directive terminates the macro definition (Listing 8.19).
Example
The ENDM statement in Listing 8.19 terminates the cpChar macro.
cpChar: MACRO
LDA \1
STA \2
ENDM
CodeSec: SECTION
Start:
cpChar char1, char2
LDA char1
STA char2
Syntax
<label>: EQU <expression>
Synonym
None
Description
The EQU directive assigns the value of the <expression> in the operand field to
<label>. The <label> and <expression> fields are both required, and the
<label> cannot be defined anywhere else in the program. The <expression>
cannot include a symbol that is undefined or not yet defined.
The EQU directive does not allow forward references.
Example
See Listing 8.20 for examples of using the EQU directive.
Time: DS.B 3
0000 0000 Hour: EQU Time ; first byte addr.
0000 0002 Minute: EQU Time+1 ; second byte addr
0000 0004 Second: EQU Time+2 ; third byte addr
Syntax
EVEN
Synonym
None
Description
This directive forces the next instruction to the next even address relative to the
start of the section. EVEN is an abbreviation for ALIGN 2. Some processors require
word and long word operations to begin at even address boundaries. In such cases,
the use of the EVEN directive ensures correct alignment. Omission of this directive
can result in an error message.
Example
See Listing 8.21 for instances where the EVEN directive causes padding bytes to
be inserted.
See also
ALIGN - Align Location Counter assembly directive
Syntax
FAIL <arg>|<string>
Synonym
None
Description
There are three modes of the FAIL directive, depending upon the operand that is
specified:
• If <arg> is a number in the range [0–499], the Assembler generates an error
message, including the line number and argument of the directive. The
Assembler does not generate an object file.
• If <arg> is a number in the range [500–$FFFFFFFF], the Assembler
generates a warning message, including the line number and argument of the
directive.
• If a string is supplied as an operand, the Assembler generates an error message,
including the line number and the <string>. The Assembler does not
generate an object file.
• The FAIL directive is primarily intended for use with conditional assembly to
detect user-defined errors or warning conditions.
Examples
The assembly code in Listing 8.22 generates the error messages in Listing 8.23.
The value of the operand associated with the ‘FAIL 200’ or
‘FAIL 600’directives determines (1) the format of any warning or error
message and (2) whether the source code segment will be assembled.
cpChar: MACRO
IFC "\1", ""
FAIL 200
MEXIT
ELSE
LDA \1
ENDIF
Listing 8.23 Error messages resulting from assembling the source code in Listing 8.22
Listing 8.24 is another assembly code example which again incorporates the FAIL 200
and the FAIL 600 directives. Listing 8.25 is the error message that was generated as a
result of assembling the source code in Listing 8.24.
cpChar: MACRO
IFC "\1", ""
FAIL 200
MEXIT
ELSE
LDA \1
ENDIF
Listing 8.25 Error messages resulting from assembling the source code in Listing 8.24
Listing 8.26 has additional uses of the FAIL directive. In this example, the
FAIL string and FAIL 600 directives are used. Any error messages
generated from the assembly code as a result of the FAIL directive are listed in
Listing 8.27.
cpChar: MACRO
IFC "\1", ""
FAIL "A character must be specified as first parameter"
MEXIT
ELSE
LDA \1
ENDIF
Listing 8.27 Error messages resulting from assembling the source code in Listing 8.26
Syntax
FOR <label>=<num> TO <num>
ENDFOR
Synonym
None
Description
The FOR directive is an inline macro because it can generate multiple lines of
assembly code from only one line of input code.
FOR takes an absolute expression and assembles the portion of code following it,
the number of times represented by the expression. The FOR expression may be
either a constant or a label previously defined using EQU or SET.
NOTE The FOR directive is only available when the -Compat=b assembly option is
used. Otherwise, the FOR directive is not supported.
Example
Listing 8.28 is an example of using FOR to create a 5-repetition loop.
FOR label=2 TO 6
DC.B label*7
ENDFOR
7 3 ENDFOR
8 2 000002 1C DC.B label*7
9 3 ENDFOR
10 2 000003 23 DC.B label*7
11 3 ENDFOR
12 2 000004 2A DC.B label*7
13 3 ENDFOR
See also
ENDFOR - End of FOR block
-Compat: Compatibility modes assembler option
IF - Conditional assembly
Syntax
IF <condition>
[<assembly language statements>]
[ELSE]
[<assembly language statements>]
ENDIF
Synonym
None
Description
If <condition> is true, the statements immediately following the IF directive
are assembled. Assembly continues until the corresponding ELSE or ENDIF
directive is reached. Then all the statements until the corresponding ENDIF
directive are ignored. Nesting of conditional blocks is allowed. The maximum
level of nesting is limited by the available memory at assembly time.
The expected syntax for <condition> is:
<condition> := <expression> <relation> <expression>
<relation> := =|!=|>=|>|<=|<|<>
The <expression> must be absolute (It must be known at assembly time).
Example
Listing 8.30 is an example of the use of conditional assembly directives
Try: EQU 0
IF Try != 0
LDA #103
ELSE
LDA #0
ENDIF
Syntax
IFcc <condition>
[<assembly language statements>]
[ELSE]
[<assembly language statements>]
ENDIF
Synonym
None
Description
These directives can be replaced by the IF directive Ifcc <condition> is
true, the statements immediately following the Ifcc directive are assembled.
Assembly continues until the corresponding ELSE or ENDIF directive is reached,
after which assembly moves to the statements following the ENDIF directive.
Nesting of conditional blocks is allowed. The maximum level of nesting is limited
by the available memory at assembly time.
Table 8.9 lists the available conditional types:
Example
Listing 8.32 is an example of the use of conditional assembler directives:
Try: EQU 0
IFNE Try
LDA #103
ELSE
LDA #0
ENDIF
Syntax
INCLUDE <file specification>
Synonym
None
Description
This directive causes the included file to be inserted in the source input stream. The
<file specification> is not case-sensitive and must be enclosed in
quotation marks.
The Assembler attempts to open <file specification> relative to the
current working directory. If the file is not found there, then it is searched for
relative to each path specified in the GENPATH: Search path for input file
environment variable.
Example
INCLUDE "..\LIBRARY\macros.inc"
Syntax
LIST
Synonym
None
Description
Specifies that instructions following this directive must be inserted into the listing
and into the debug file. This is a default option. The listing file is only generated if
the -L: Generate a listing file assembler option is specified on the command line.
The source text following the LIST directive is listed until a NOLIST - Disable
Listing or an END - End assembly assembler directive is reached
This directive is not written to the listing and debug files.
Example
The assembly source code using the LIST and NOLIST directives in Listing 8.34
generates the output listing in Listing 8.35.
aaa: NOP
LIST
bbb: NOP
NOP
NOLIST
ccc: NOP
NOP
LIST
ddd: NOP NOP
Syntax
LLEN<n>
Synonym
None
Description
Sets the number of characters from the source line that are included on the listing
line to <n>. The values allowed for <n> are in the range [0 - 132]. If a value
smaller than 0 is specified, the line length is set to 0. If a value bigger than 132 is
specified, the line length is set to 132.
Lines of the source file that exceed the specified number of characters are truncated
in the listing file.
Example
The following portion of code in Listing 8.37 generates the listing file in Listing 8.37.
Notice that the LLEN 24 directive causes the output at the location-counter line 7 to be
truncated.
DC.B $55
LLEN 32
DC.W $1234, $4567
LLEN 24
DC.W $1234, $4567
EVEN
Syntax
LONGEVEN
Synonym
None
Description
This directive forces the next instruction to the next long-word address relative to
the start of the section. LONGEVEN is an abbreviation for ALIGN 4.
Example
See Listing 8.38 for an example where LONGEVEN aligns the next instruction to
have its location counter to be a multiple of four (bytes).
Syntax
<label>: MACRO
Synonym
None
Description
The <label> of the MACRO directive is the name by which the macro is called.
This name must not be a processor machine instruction or assembler directive
name. For more information on macros, see the Macros chapter.
Example
See Listing 8.39 for a macro definition.
XDEF Start
MyData: SECTION
char1: DS.B 1
char2: DS.B 1
cpChar: MACRO
LDA \1
STA \2
ENDM
CodeSec: SECTION
Start:
cpChar char1, char2
LDA char1
STA char2
Syntax
MEXIT
Synonym
None
Description
MEXIT is usually used together with conditional assembly within a macro. In that
case it may happen that the macro expansion should terminate prior to termination
of the macro definition. The MEXIT directive causes macro expansion to skip any
remaining source lines ahead of the ENDM - End macro definition directive.
Example
See Listing 8.40 allows the replication of simple instructions or directives using
MACRO with MEXIT.
XDEF entry
char2: ds.b 1
codSec: SECTION
entry:
save char1, char2
Syntax
MLIST [ON|OFF]
Description
When the ON keyword is entered with an MLIST directive, the Assembler includes
the macro expansions in the listing and in the debug file.
When the OFF keyword is entered, the macro expansions are omitted from the
listing and from the debug file.
This directive is not written to the listing and debug file, and the default value is
ON.
Synonym
None
Example
The assembly code in Listing 8.42, with MLIST ON, generates the assembler
output listing in Listing 8.43
XDEF entry
MLIST ON
swap: MACRO
LDA \1
LDX \2
STA \2
STX \1
ENDM
codSec: SECTION
entry:
LDA #$F0
LDX #$0F
main:
STA first
STX second
swap first, second
NOP
BRA main
datSec: SECTION
first: DS.B 1
second: DS.B 1
Listing 8.43 Assembler output listing of the example in Listing 8.42 with MLIST ON
1 1 XDEF entry
3 3 swap: MACRO
4 4 LDA \1
5 5 LDX \2
6 6 STA \2
7 7 STX \1
8 8 ENDM
9 9
10 10 codSec: SECTION
11 11 entry:
12 12 000000 A6F0 LDA #$F0
13 13 000002 AE0F LDX #$0F
14 14 main:
15 15 000004 C7 xxxx STA first
16 16 000007 CF xxxx STX second
17 17 swap first, second
18 4m 00000A C6 xxxx + LDA first
19 5m 00000D CE xxxx + LDX second
20 6m 000010 C7 xxxx + STA second
21 7m 000013 CF xxxx + STX first
22 18 000016 9D NOP
23 19 000017 20EB BRA main
24 20
25 21 datSec: SECTION
26 22 000000 first: DS.B 1
27 23 000001 second: DS.B 1
For the same code, with MLIST OFF, the listing file is as shown in Listing 8.44.
Listing 8.44 Assembler output listing of the example in Listing 8.42 with MLIST OFF
8 8 ENDM
9 9 codSec: SECTION
10 10 entry:
11 11 000000 A6F0 LDA #$F0
12 12 000002 AE0F LDX #$0F
13 13 main:
14 14 000004 C7 xxxx STA first
15 15 000007 CF xxxx STX second
16 16 swap first, second
21 17 000016 9D NOP
22 18 000017 20EB BRA main
23 19 datSec: SECTION
24 20 000000 first: DS.B 1
25 21 000001 second: DS.B 1
The MLIST directive does not appear in the listing file. When a macro is called
after a MLIST ON, it is expanded in the listing file. If the MLIST OFF is
encountered before the macro call, the macro is not expanded in the listing file.
Syntax
NOLIST
Synonym
NOL
Description
Suppresses the printing of the following instructions in the assembly listing and
debug file until a LIST - Enable Listing assembler directive is reached.
Example
See Listing 8.45 for an example of using LIST and NOLIST.
aaa: NOP
LIST
bbb: NOP
NOP
NOLIST
ccc: NOP
NOP
LIST
ddd: NOP
NOP
Listing 8.46 Assembler output listing from the assembler source code in Listing 8.45
Assembler
Abs. Rel. Loc Obj. code Source line
---- ---- ------ --------- -----------
1 1 000000 9D aaa: NOP
2 2
4 4 000001 9D bbb: NOP
5 5 000002 9D NOP
6 6
12 12 000005 9D ddd: NOP
13 13 000006 9D NOP
See Also
LIST - Enable Listing assembler directive
Syntax
NOPAGE
Synonym
None
Description
Disables pagination in the listing file. Program lines are listed continuously,
without headings or top or bottom margins.
Syntax
OFFSET <expression>
Synonym
None
Description
The OFFSET directive declares an offset section and initializes the location
counter to the value specified in <expression>. The <expression> must be
absolute and may not contain references to external, undefined or forward defined
labels.
Example
Listing 8.47 shows how the OFFSET directive can be used to access an element of
a structure.
6 6 OFFSET 0
7 7 000000 ID: DS.B 1
8 8 000001 COUNT: DS.W 1
9 9 000003 VALUE: DS.L 1
10 10 0000 0007 SIZE: EQU *
11 11
12 12 DataSec: SECTION
13 13 000000 Struct: DS.B SIZE
14 14
15 15 CodeSec: SECTION
16 16 entry:
17 17 000003 CE xxxx LDX #Struct
18 18 000006 8600 LDA #0
19 19 000008 6A00 STA ID, X
20 20 00000A 6201 INC COUNT, X
21 21 00000C 42 INCA
22 22 00000D 6A03 STA VALUE, X
When a statement affecting the location counter other than EVEN, LONGEVEN,
ALIGN, or DS is encountered after the OFFSET directive, the offset section is
ended. The preceding section is activated again, and the location counter is restored
to the next available location in this section (Listing 8.48).
7 7 ConstSec: SECTION
8 8 000000 11 cst1: DC.B $11
9 9 000001 13 cst2: DC.B $13
10 10
11 11 OFFSET 0
12 12 000000 ID: DS.B 1
13 13 000001 COUNT: DS.W 1
14 14 000003 VALUE: DS.L 1
15 15 0000 0007 SIZE: EQU *
16 16
17 17 000002 22 cst3: DC.B $22
In the example above, the cst3 symbol, defined after the OFFSET directive,
defines a constant byte value. This symbol is appended to the section ConstSec,
which precedes the OFFSET directive.
Syntax
ORG <expression>
Synonym
None
Description
The ORG directive sets the location counter to the value specified by
<expression>. Subsequent statements are assigned memory locations starting
with the new location counter value. The <expression> must be absolute and
may not contain any forward, undefined, or external references. The ORG directive
generates an internal section, which is absolute (see the Sections chapter).
Example
See Listing 8.49 for an example where ORG sets the location counter.
org $2000
b1: nop
b2: rts
Viewing Listing 8.50, you can see that the b1 label is located at address $2000 and label
b2 is at address $2001.
Listing 8.50 Assembler output listing from the source code in Listing 8.49
See also
Assembler directives:
• DC - Define Constant
• DCB - Define Constant Block
• DS - Define Space
• SECTION - Declare Relocatable Section
Syntax
PAGE
Synonym
None
Description
Insert a page break in the assembly listing.
Example
The portion of code in Listing 8.51 demonstrates the use of a page break in the
assembler output listing.
code: SECTION
DC.B $00,$12
DC.B $00,$34
PAGE
DC.B $00,$56
DC.B $00,$78
Listing 8.52 Assembler output listing from the source code in Listing 8.51
Syntax
PLEN<n>
Synonym
None
Description
Sets the listings page length to <n> lines. <n> may range from 10 to 10000. If
the number of lines already listed on the current page is greater than or equal to
<n>, listing will continue on the next page with the new page length setting.
The default page length is 65 lines.
Syntax
RAD50 <str>[, cnt]
Synonym
None
Description
This directive places strings encoded with the RAD50 encoding into constants. The
RAD50 encoding places 3 string characters out of a reduced character set into 2
bytes. It therefore saves memory when comparing it with a plain ASCII
representation. It also has some drawbacks, however. Only 40 different character
values are supported, and the strings have to be decoded before they can be used.
This decoding does include some computations including divisions (not just shifts)
and is therefore rather expensive.
The encoding takes three bytes and looks them up in a string table (Listing 8.53).
If the remaining string is shorter than 3 bytes, it is filled with spaces (which
correspond to the RAD50 character 0).
The optional argument cnt can be used to explicitly state how many 16-bit values
should be written. If the string is shorter than 3*cnt, then it is filled with spaces.
See the example C code below (Listing 8.56) about how to decode it.
Example
The string data in Listing 8.54 assembles to the following data (Listing 8.55). The
11 characters in the string are represented by 8 bytes.
Listing 8.55 Assembler output where 11 characters are contained in eight bytes
This C code shown in Listing 8.56 takes the data and prints “Hello World”.
#include "stdio.h"
extern unsigned short rad50[];
extern int rad50Len; /* address is value. Exported asm label */
#define rad50len ((int) &rad50Len)
Syntax
<name>: SECTION [SHORT][<number>]
Synonym
None
Description
This directive declares a relocatable section and initializes the location counter for
the following code. The first SECTION directive for a section sets the location
counter to zero. Subsequent SECTION directives for that section restore the
location counter to the value that follows the address of the last code in the section.
<name> is the name assigned to the section. Two SECTION directives with the
same name specified refer to the same section.
<number> is optional and is only specified for compatibility with the MASM
Assembler.
A section is a code section when it contains at least one assembly instruction. It is
considered to be a constant section if it contains only DC or DCB directives. A
section is considered to be a data section when it contains at least a DS directive or
if it is empty.
Example
The example in Listing 8.57 demonstrates the definition of a section aaa, which is
split into two blocks, with section bbb in between them.
The location counter associated with the label zz is 1, because a NOP instruction
was already defined in this section at label xx.
The optional qualifier SHORT specifies that the section is a short section, That
means than the objects defined there can be accessed using the direct addressing
mode.
For RS08, there are two additional section qualifiers: RS08_SHORT and
RS08_TINY. When a section is declared as RS08_SHORT (or RS08_TINY) all
the objects defined there can be accessed using the short (and respectively tiny)
addressing modes.
The example in Listing 8.58 demonstrates the definition and usage of a SHORT
section, and uses the direct addressing mode to access the symbol data.
See also
Assembler directives:
• ORG - Set Location Counter
• DC - Define Constant
• DCB - Define Constant Block
• DS - Define Space
Syntax
<label>: SET <expression>
Synonym
None
Description
Similar to the EQU - Equate symbol value directive, the SET directive assigns the
value of the <expression> in the operand field to the symbol in the <label>
field. The <expression> must resolve as an absolute expression and cannot
include a symbol that is undefined or not yet defined. The <label> is an
assembly time constant. SET does not generate any machine code.
The value is temporary; a subsequent SET directive can redefine it.
Example
See Listing 8.59 for examples of the SET directive.
The value associated with the label count is decremented after each DC.B
instruction.
Syntax
SPC<count>
Synonym
None
Description
Inserts <count> blank lines in the assembly listing. <count> may range from 0
to 65. This has the same effect as writing that number of blank lines in the
assembly source. A blank line is a line containing only a carriage return.
Syntax
TABS <n>
Synonym
None
Description
Sets the tab length to <n> spaces. The default tab length is eight. <n> may range
from 0 to 128.
Syntax
TITLE "title"
Synonym
TTL
Description
Print the <title> on the head of every page of the listing file. This directive must
be the first source code line. A title consists of a string of characters enclosed in
quotes (").
The title specified will be written on the top of each page in the assembly listing
file.
Syntax
XDEF [.<size>] <label>[,<label>]...
where <size> = B(direct), W (default), L or S or T
Synonym
GLOBAL, PUBLIC
Description
This directive specifies labels defined in the current module that are to be passed to
the linker as labels that can be referenced by other modules linked to the current
module.
The number of symbols enumerated in an XDEF directive is only limited by the
memory available at assembly time.
The S and T size designators are only available for RS08, and result in marking the
symbol as short or tiny.
Example
See Listing 8.60 for the case where the XDEF assembler directive can specify
symbols that can be used by other modules.
Syntax
XREF [.<size>] <symbol>[,<symbol>]...
where <size> = B(direct), W (default), or L or S or T.
Synonym
EXTERNAL
Description
This directive specifies symbols referenced in the current module but defined in
another module. The list of symbols and corresponding 32-bit values is passed to
the linker.
The number of symbols enumerated in an XREF directive is only limited by the
memory available at assembly time.
The S and T size designators are only available for RS08, and result in marking the
symbol as short or tiny.
Example
XREF OtherGlobal ; Reference "OtherGlobal" defined in
; another module. (See the XDEF
; directive example.)
Syntax
XREFB <symbol>[,<symbol>]...
Synonym
None
Description
This directive specifies symbols referenced in the current module but defined in
another module. Symbols enumerated in a XREFB directive, can be accessed using
the direct address mode. The list of symbols and corresponding 8-bit values is
passed to the linker.
The number of symbols enumerated in a XREFB directive is only limited by the
memory available at assembly time.
Example
Macro overview
A macro must be defined before it is called. When a macro is defined, it is given a name.
This name becomes the mnemonic by which the macro is subsequently called.
The Assembler expands the macro definition each time the macro is called. The macro call
causes source statements to be generated, which may include macro arguments. A macro
definition may contain any code or directive except nested macro definitions. Calling
previously defined macros is also allowed. Source statements generated by a macro call
are inserted in the source file at the position where the macro is invoked.
To call a macro, write the macro name in the operation field of a source statement. Place
the arguments in the operand field. The macro may contain conditional assembly
directives that cause the Assembler to produce in-line-coding variations of the macro
definition.
Macros call produces in-line code to perform a predefined function. Each time the macro
is called, code is inserted in the normal flow of the program so that the generated
instructions are executed in line with the rest of the program.
Defining a macro
The definition of a macro consists of four parts:
• The header statement, a MACRO directive with a label that names the macro.
• The body of the macro, a sequential list of assembler statements, some possibly
including argument placeholders.
• The ENDM directive, terminating the macro definition.
• eventually an instruction MEXIT, which stops macro expansion.
See the Assembler Directives chapter for information about the MACRO, ENDM, MEXIT,
and MLIST directives.
The body of a macro is a sequence of assembler source statements. Macro parameters are
defined by the appearance of parameter designators within these source statements. Valid
macro definition statements includes the set of processor assembly language instructions,
assembler directives, and calls to previously defined macros. However, macro definitions
may not be nested.
Calling macros
The form of a macro call is:
[<label>:] <name>[.<sizearg>] [<argument> [,<argument>]...]
Although a macro may be referenced by another macro prior to its definition in the source
module, a macro must be defined before its first call. The name of the called macro must
appear in the operation field of the source statement. Arguments are supplied in the
operand field of the source statement, separated by commas.
The macro call produces in-line code at the location of the call, according to the macro
definition and the arguments specified in the macro call. The source statements of the
expanded macro are then assembled subject to the same conditions and restrictions
affecting any source statement. Nested macros calls are also expanded at this time.
Macro parameters
As many as 36 different substitutable parameters can be used in the source statements that
constitute the body of a macro. These parameters are replaced by the corresponding
arguments in a subsequent call to that macro.
A parameter designator consists of a backslash character (\), followed by a digit (0 - 9) or
an uppercase letter (A - Z). Parameter designator \0 corresponds to a size argument that
follows the macro name, separated by a period (.).
Consider the following macro definition:
MyMacro: MACRO
DC.\0 \1, \2
ENDM
When this macro is used in a program, e.g.:
MyMacro.B $10, $56
the Assembler expands it to:
DC.B $10, $56
Arguments in the operand field of the macro call refer to parameter designator \1 through
\9 and \A through \Z, in that order. The argument list (operand field) of a macro call
cannot be extended onto additional lines.
At the time of a macro call, arguments from the macro call are substituted for parameter
designators in the body of the macro as literal (string) substitutions. The string
corresponding to a given argument is substituted literally wherever that parameter
designator occurs in a source statement as the macro is expanded. Each statement
generated in the execution is assembled in line.
It is possible to specify a null argument in a macro call by a comma with no character (not
even a space) between the comma and the preceding macro name or comma that follows
an argument. When a null argument itself is passed as an argument in a nested macro call,
a null value is passed. All arguments have a default value of null at the time of a macro
call.
NOTE This escaping only takes place inside of [? ?] arguments. A backslash is only
removed in this process if it is just before a bracket ([]), a question mark
(?), or a second backslash (\).
MyMacro: MACRO
DC \1
ENDM
MyMacro1: MACRO
\1
ENDM
Listing 9.2 has some macro calls with rather complicated arguments:
DC $10, $56
DC "[?"
DC $10, $56
DC $10, $56
The Macro Assembler does also supports for compatibility with previous version’s macro
grouping with an angle bracket syntax (Listing 9.4):
However, this old syntax is ambiguous as < and > are also used as compare operators. For
example, the following code (Listing 9.5) does not produce the expected result:
Because of this the old angle brace syntax should be avoided in new code. There is also
and option to disable it explicitly.
See also the -CMacBrackets: Square brackets for macro arguments grouping and the
-CMacAngBrack: Angle brackets for grouping Macro Arguments assembler options.
clear: MACRO
LDX #\1
LDA #16
\@LOOP: CLR 0,X
INCX
DECA
BNE \@LOOP
ENDM
clear temporary
clear data
The two macro calls of clear are expanded in the following manner (Listing 9.8):
clear temporary
LDX #temporary
LDA #16
_00001LOOP: CLR 0,X
INCX
DECA
BNE _00001LOOP
clear data
LDX #data
LDA #16
_00002LOOP: CLR 0,X
INCX
DECA
BNE _00002LOOP
Macro expansion
When the Assembler reads a statement in a source program calling a previously defined
macro, it processes the call as described in the following paragraphs.
The symbol table is searched for the macro name. If it is not in the symbol table, an
undefined symbol error message is issued.
The rest of the line is scanned for arguments. Any argument in the macro call is saved as a
literal or null value in one of the 35 possible parameter fields. When the number of
arguments in the call is less than the number of parameters used in the macro the
argument, which have not been defined at invocation time are initialize with ““ (empty
string).
Starting with the line following the MACRO directive, each line of the macro body is saved
and is associated with the named macro. Each line is retrieved in turn, with parameter
designators replaced by argument strings or assembler-generated label strings.
Once the macro is expanded, the source lines are evaluated and object code is produced.
Nested macros
Macro expansion is performed at invocation time, which is also the case for nested
macros. If the macro definition contains nested macro call, the nested macro expansion
takes place in line. Recursive macro calls are also supported.
A macro call is limited to the length of one line, i.e., 1024 characters.
Page header
The page header consists of three lines:
• The first line contains an optional user string defined in the TITLE directive.
The second line contains the name of the Assembler vendor (Freescale) as well
as the target processor name - HC(S)08.
• The third line contains a copyright notice.
Demo Application
Freescale HC08-Assembler
(c) COPYRIGHT Freescale 1991-2005
Source listing
The printed columns can be configured in various formats with the -Lasmc: Configure
listing file assembler option. The default format of the source listing has the five columns
as in :
Abs.
This column contains the absolute line number for each instruction. The absolute line
number is the line number in the debug listing file, which contains all included files and
where any macro calls have been expanded.
12 3i STA \2
13 4i ENDM
14 10 CodeSec: SECTION
15 11 Start:
16 12 cpChar char1, char2
17 2m 000000 C6 xxxx + LDA char1
18 3m 000003 C7 xxxx + STA char2
19 13 000006 9D NOP
20 14 000007 9D NOP
Rel.
This column contains the relative line number for each instruction. The relative line
number is the line number in the source file. For included files, the relative line number is
the line number in the included file. For macro call expansion, the relative line number is
the line number of the instruction in the macro definition. See Listing 10.3.
An i suffix is appended to the relative line number when the line comes from an included
file. An m suffix is appended to the relative line number when the line is generated by a
macro call.
In the previous example, the line number displayed in the Rel. column. represent the line
number of the corresponding instruction in the source file.
1i on absolute line number 10 denotes that the instruction cpChar: MACRO is located
in an included file.
2m on absolute line number 17 denotes that the instruction LDA char1 is generated
by a macro expansion.
Loc
This column contains the address of the instruction. For absolute sections, the address is
preceded by an a and contains the absolute address of the instruction. For relocatable
sections, this address is the offset of the instruction from the beginning of the relocatable
section. This offset is a hexadecimal number coded on 6 digits.
A value is written in this column in front of each instruction generating code or allocating
storage. This column is empty in front of each instruction that does not generate code (for
example SECTION, XDEF). See Listing 10.4.
In the previous example, the hexadecimal number displayed in the column Loc. is the
offset of each instruction in the section codeSec.
There is no location counter specified in front of the instruction INCLUDE
"macro.inc" because this instruction does not generate code.
The instruction LDA char1 is located at offset 0 from the section codeSec start
address.
The instruction STA char2 is located at offset 3 from the section codeSec start
address.
Obj. code
This column contains the hexadecimal code of each instruction in hexadecimal format.
This code is not identical to the code stored in the object file. The letter ‘x’ is displayed at
the position where the address of an external or relocatable label is expected. Code at any
position when ‘x’ is written will be determined at link time. See Listing 10.5.
Source line
This column contains the source statement. This is a copy of the source line from the
source module. For lines resulting from a macro expansion, the source line is the expanded
line, where parameter substitution has been done. See Listing 10.6.
Memory models
The memory models are only important if you mix C and assembly code. In this case all
sources must be compiled or assembled with the same memory model.
The Assembler supports all memory models of the compiler. Depending on your
hardware, use the smallest memory model suitable for your programming needs.
Table 11.1 summarizes the different memory models. It shows when to use a particular
memory model and which assembler switch to use.
–Mt TINY SP rel direct In the TINY memory model, all data
including stack must fit into the zero
page. Data pointers are assumed to
have 8-bit addresses if not explicitly
specified with the keyword __far. The
code address space is still 64k and
function pointers are still 16 bits in
length.
NOTE The default pointer size for the compiler is also affected by the memory model
chosen.
Return Value
Check the backend chapter in the compiler manual for the details of parameter passing.
We recommend that you generate a header file for each assembler source file. This header
file should contain the interface to the assembly module.
An external declaration for the variable or constant must be inserted in the header file
(Listing 11.2).
The variables or constants can then be accessed in the usual way, using their names
(Listing 11.3).
ASMData = ASMConst + 3;
An external declaration for the variable or constant must be inserted into the assembly
source file (Listing 11.5).
This can also be done in a separate file, included in the assembly source file.
The variables or constants can then be accessed in the usual way, using their names
(Listing 11.6).
NOTE The compiler supports also the automatic generation of assembler include files.
See the description of the -La compiler option in the compiler manual.
LDA CConst
....
LDA CData
....
XREF CData
XDEF AddVar
XDEF ASMData
DataSec: SECTION
ASMData: DS.B 1
CodeSec: SECTION
AddVar:
ADD CData ; add CData to the parameter in register A
STA ASMData ; result of the addition in ASMData
RTS
We recommend that you generate a header file for each assembly source file (Listing
11.7). This header file (mixasm.h in Listing 11.8) should contain the interface to the
assembly module.
Listing 11.8 Header file for the assembly mixasm.asm file: mixasm.h
/* mixasm.h */
#ifndef _MIXASM_H_
#define _MIXASM_H_
#endif /* _MIXASM_H_ */
The function can then be invoked in the usual way, using its name.
Example of a C file
A C source code file (mixc.c) has the main() function which calls the AddVar()
function. See Listing 11.9. (Compile it with the -Cc compiler option when using the
HIWARE Object File Format.)
void main(void) {
AddVar(10);
if (ASMData != CData + 10){
Error = 1;
} else {
Error = 0;
}
for(;;); // wait forever
}
CAUTION Be careful, as the Assembler will not make any checks on the number and
type of the function parameters.
LINK mixasm.abs
NAMES
mixc.o mixasm.o
END
SECTIONS
MY_ROM = READ_ONLY 0x4000 TO 0x4FFF;
MY_RAM = READ_WRITE 0x2400 TO 0x2FFF;
MY_STACK = READ_WRITE 0x2000 TO 0x23FF;
END
PLACEMENT
DEFAULT_RAM INTO MY_RAM;
DEFAULT_ROM INTO MY_ROM;
SSTACK INTO MY_STACK;
END
INIT main
NOTE We recommend that you use the same memory model and object file format for
all the generated object files.
NOTE Some limitations apply in the usage of the structured types in the Macro
Assembler. See Structured type: Limitations.
typeName: STRUCT
lab1: DS.W 1 lab2: DS.W 1 ...
ENDSTRUCT
where:
• typeName is the name associated with the defined type. The type name is
considered to be a user-defined keyword. The Macro Assembler will be case-
insensitive on typeName.
• STRUCT specifies that the type is a structured type.
• lab1 and lab2 are the fields defined inside of the typeName type. The fields
will be considered as user-defined labels, and the Macro Assembler will be case-
sensitive on label names.
• As with all other directives in the Assembler, the STRUCT and UNION directives are
case-insensitive.
• The STRUCT and UNION directives cannot start on column 1 and must be preceded
by a label.
Table 11.2 shows how the ANSI-C standard types are converted in the assembler notation:
short DS.W
int DS.W
long DS.L
enum DS.W
Variable definition
The Macro Assembler can provide a way to define a variable with a specific type. This is
done using the following syntax (Listing 11.12):
var: typeName
where:
• var is the name of the variable.
• typeName is the type associated with the variable.
myType: STRUCT
field1: DS.W 1
field2: DS.W 1
field3: DS.B 1
field4: DS.B 3
field5: DS.W 1
ENDSTRUCT
DataSection: SECTION
structVar: TYPE myType ; var ‘structVar’ is of type ‘myType’
Variable declaration
The Macro Assembler can provide a way to associated a type with a symbol which is
defined externally. This is done by extending the XREF syntax:
XREF var: typeName, var2
where:
• var is the name of an externally defined symbol.
• typeName is the type associated with the variable var.
var2 is the name of another externally defined symbol. This symbol is not associated
with any type. See Listing 11.13 for an example.
myType: STRUCT
field1: DS.W 1
field2: DS.W 1
field3: DS.B 1
field4: DS.B 3
field5: DS.W 1
ENDSTRUCT
myType: STRUCT
field1: DS.W 1
field2: DS.W 1
field3: DS.B 1
field4: DS.B 3
field5: DS.W 1
ENDSTRUCT
XREF myData:myType
XDEF entry
CodeSec: SECTION
entry:
LDA myData:field3 ; Loads register A with the content of
; field field3 from variable myData.
myType: STRUCT
field1: DS.W 1
field2: DS.W 1
field3: DS.B 1
field4: DS.B 3
field5: DS.W 1
ENDSTRUCT
XREF.B myData
XDEF entry
CodeSec: SECTION
entry:
LDX #myData
LDA myType->field3,X ; Adds the offset of field 'field3'
; (4) to X and loads A with the
; content of the pointed address
Assembly applications
This section covers:
• Directly generating an absolute file
• Mixed C and assembly applications
NOTE The .text and .data names are only supported when the ELF object file
format is used.
There are no checks at all that variables are in RAM. If you mix code and data in a section
you cannot place the section into ROM. That is why we suggest that you separate code and
data into different sections.
If you want to place a section in a specific address range, you have to put the section name
in the placement portion of the linker parameter file (Listing 12.1).
SECTIONS
ROM1 = READ_ONLY 0x0200 TO 0x0FFF;
SpecialROM = READ_ONLY 0x8000 TO 0x8FFF;
RAM = READ_WRITE 0x4000 TO 0x4FFF;
PLACEMENT
DEFAULT_ROM INTO ROM1;
mySection INTO SpecialROM;
DEFAULT_RAM INTO RAM;
END
In the previous portion of code, the label cst1 is located at address $A00, and label
cst2 is located at address $A01.
1 1 ORG $800
2 2 a000800 var: DS.B 1
3 3 ORG $A00
4 4 a000A00 A6 cst1: DC.B $A6
5 5 a000A01 BC cst2: DC.B $BC
Locate program assembly source code in a separate absolute section (Listing 13.3).
XDEF entry
ORG $C00 ; Absolute code section.
entry:
LDA cst1 ; Load value in cst1
ADD cst2 ; Add value in cst2
STA var ; Store in var
BRA entry
In the portion of assembly code above, the LDA instruction is located at address $C00,
and the ADD instruction is at address $C03. See Listing 13.4.
NOTE There should be no overlap between the absolute sections defined in the
assembly source file and the memory areas defined in the PRM file.
NOTE As the memory areas (segments) specified in the PRM file are only used to
allocate relocatable sections, nothing will be allocated there when the
application contains only absolute sections. In that case you can even specify
invalid address ranges in the PRM file.
In the previous portion of code, the label cst1 will be located at an offset 0 from the
section constSec start address, and label cst2 will be located at an offset 1 from the
section constSec start address. See Listing 13.7.
Locate program assembly source code in a separate relocatable section (Listing 13.8).
XDEF entry
codeSec: SECTION ; Relocatable code section.
entry:
LDA cst1 ; Load value in cst1
ADD cst2 ; Add value in cst2
STA var ; Store in var
BRA entry
In the previous portion of code, the LDA instruction is located at an offset 0 from the
codeSec section start address, and ADD instruction at an offset 3 from the codeSec
section start address.
In order to avoid problems during linking or execution from an application, an assembly
file should at least:
• Initialize the stack pointer if the stack is used
• The RSP instruction can be used to initialize the stack pointer to $FF.
• Publish the application’s entry point using the XDEF directive.
NOTE The programmer should ensure that the memory ranges he specifies in the
SECTIONS block are valid addresses for the controller he is using. In addition,
when using the SDI debugger the addresses specified for code or constant
sections must be located in the target board ROM area. Otherwise, the
debugger will not be able to load the application
BRA entry
int:
PSHH
LDHX #Data ; Load address of symbol Data in X
; X <- address of the appropriate element in the tab
Ofset: TSTA
BEQ Ofset3
Ofset2:
AIX #$1
DECA
BNE Ofset2
Ofset3:
INC 0, X ; The table element is incremented
PULH
RTI
entry:
LDHX #$0E00 ; Init Stack Pointer to $E00-$1=$DFF
TXS
CLRX
CLRH
NOTE The IRQ1Func, SWIFunc, and ResetFunc functions are published. This is
required, because they are referenced in the linker PRM file.
NOTE The HC08 processor automatically pushes the PC, X, A, and CCR registers on
the stack when an interrupt occurs. The interrupt functions do not need to save
and restore those registers. To maintain compatibility with the M6805 Family,
the H register is not stacked. It is the user’s responsibility to save and restore it
prior to returning.
The vector table is initialized using the linker VECTOR ADDRESS command (Listing
13.11).
LINK test.abs
NAMES
test.o
END
SECTIONS
MY_ROM = READ_ONLY 0x0800 TO 0x08FF;
MY_RAM = READ_WRITE 0x0B00 TO 0x0CFF;
MY_STACK = READ_WRITE 0x0D00 TO 0x0DFF;
END
PLACEMENT
DEFAULT_RAM INTO MY_RAM;
DEFAULT_ROM INTO MY_ROM;
SSTACK INTO MY_STACK;
END
INIT ResetFunc
VECTOR ADDRESS 0xFFF8 IRQ1Func
VECTOR ADDRESS 0xFFFC SWIFunc
VECTOR ADDRESS 0xFFFE ResetFunc
NOTE The statement INIT ResetFunc defines the application entry point.
Usually, this entry point is initialized with the same address as the reset vector.
NOTE The statement VECTOR ADDRESS 0xFFF8 IRQ1Func specifies that the
address of the IRQ1Func function should be written at address 0xFFF8.
Listing 13.12 Initializing the Vector Table in source code with a relocatable section
XDEF ResetFunc
XDEF IRQ0Int
DataSec: SECTION
Data: DS.W 5 ; Each interrupt increments an element of the table.
CodeSec: SECTION
; Implementation of the interrupt functions.
IRQ1Func:
LDA #0
BRA int
SWIFunc:
LDA #4
BRA int
ResetFunc:
LDA #8
BRA entry
DummyFunc:
RTI
int:
PSHH
LDHX #Data ; Load address of symbol Data in X
; X <- address of the appropriate element in the tab
Ofset: TSTA
BEQ Ofset3
Ofset2:
AIX #$1
DECA
BNE Ofset2
Ofset3:
INC 0, X ; The table element is incremented
PULH
RTI
entry:
LDHX #$0E00 ; Init Stack Pointer to $E00-$1=$DFF
TXS
CLRX
CLRH
CLI ; Enables interrupts
loop: BRA loop
VectorTable: SECTION
; Definition of the vector table.
IRQ1Int: DC.W IRQ1Func
IRQ0Int: DC.W DummyFunc
SWIInt: DC.W SWIFunc
ResetInt: DC.W ResetFunc
NOTE In the previous example, the constant IRQ1Int is initialized with the address
of the label IRQ1Func. The constant IRQ0Int is initialized with the address
of the label Dummy Func because this interrupt is not in use.
NOTE All the labels specified as initialization value must be defined, published (using
XDEF) or imported (using XREF) before the vector table section. No forward
reference is allowed in the DC directive.
NOTE The constant IRQ0Int is exported so that the section containing the vector
table is linked with the application.
The section should now be placed at the expected address. This is performed in the linker
parameter file (Listing 13.13).
LINK test.abs
NAMES
test.o+
END
ENTRIES
IRQ0Int
END
SECTIONS
MY_ROM = READ_ONLY 0x0800 TO 0x08FF;
MY_RAM = READ_WRITE 0x0B00 TO 0x0CFF;
MY_STACK = READ_WRITE 0x0D00 TO 0x0DFF;
/* Define the memory range for the vector table */
Vector = READ_ONLY 0xFFF8 TO 0xFFFF;
END
PLACEMENT
DEFAULT_RAM INTO MY_RAM;
DEFAULT_ROM INTO MY_ROM;
SSTACK INTO MY_STACK;
/* Place the section 'VectorTable' at the appropriated address. */
VectorTable INTO Vector;
END
INIT ResetFunc
NOTE The statement VectorTable INTO Vector specifies that the vector table
should be loaded in the read only memory area Vector. This means, the
constant IRQ1Int will be allocated at address 0xFFF8, the constant
IRQ0Int will be allocated at address 0xFFFA, the constant SWIInt will be
allocated at address 0xFFFC, and the constant ResetInt will be allocated at
address 0xFFFE.
NOTE The ‘+’ after the object file name switches smart linking off. If this statement is
missing in the PRM file, the vector table will not be linked with the application,
because it is never referenced. The smart linker only links the referenced
objects in the absolute file.
XDEF ResetFunc
DataSec: SECTION
Data: DS.W 5 ; Each interrupt increments an element of the table.
CodeSec: SECTION
; Implementation of the interrupt functions.
IRQ1Func:
LDA #0
BRA int
SWIFunc:
LDA #4
BRA int
ResetFunc:
LDA #8
BRA entry
DummyFunc:
RTI
int:
PSHH
LDHX #Data ; Load address of symbol Data in X
; X <- address of the appropriate element in the tab
Ofset: TSTA
BEQ Ofset3
Ofset2:
AIX #$1
DECA
BNE Ofset2
Ofset3:
INC 0, X ; The table element is incremented
PULH
RTI
entry:
LDHX #$0E00 ; Init Stack Pointer to $E00-$1=$DFF
TXS
CLRX
CLRH
CLI ; Enables interrupts
ORG $FFF8
; Definition of the vector table in an absolute section
; starting at address $FFF8.
IRQ1Int: DC.W IRQ1Func
IRQ0Int: DC.W DummyFunc
SWIInt: DC.W SWIFunc
ResetInt: DC.W ResetFunc
The section should now be placed at the expected address. This is performed in the linker
parameter file (Listing 13.15).
LINK test.abs
NAMES
test.o+
END
SECTIONS
MY_ROM = READ_ONLY 0x0800 TO 0x08FF;
NOTE The ‘+’ after the object file name switches smart linking off. If this statement
is missing in the PRM file, the vector table will not be linked with the
application, because it is never referenced. The smart linker only links the
referenced objects in the absolute file.
XDEF AddSource
XDEF Source
DataSec: SECTION
Source: DS.W 1
CodeSec: SECTION
AddSource:
RSP
ADD Source
STA Source
RTS
XREF AddSource
; The AddSource function adds the value stored in the variable
; Source to the contents of the A register. The result of the
; computation is stored in the Source variable.
;
; Input Parameter: The A register contains the value that should be
; added to the Source variable.
; Output Parameter: Source contains the result of the addition.
XREF Source
; The Source variable is a 1-byte variable.
XDEF entry
INCLUDE "Test1.inc"
CodeSec: SECTION
entry: RSP
LDA #$7
JSR AddSource
BRA entry
The application’s *.prm file should list both object files building the application. When a
section is present in the different object files, the object file sections are concatenated into
a single absolute file section. The different object file sections are concatenated in the
order the object files are specified in the *.prm file.
SECTIONS
MY_ROM = READ_ONLY 0x2B00 TO 0x2BFF; /* READ_ONLY mem. */
MY_RAM = READ_WRITE 0x2800 TO 0x28FF; /* READ_WRITE mem. */
END
PLACEMENT
/* variables are allocated in MY_RAM */
DataSec, DEFAULT_RAM INTO MY_RAM;
NOTE The CodeSec section is defined in both object files. In test1.o, the
CodeSec section contains the symbol AddSource. In test2.o, the
CodeSec section contains the entry symbol. According to the order in
which the object files are listed in the NAMES block, the function AddSource
is allocated first and the entry symbol is allocated next to it.
XREF.B ExternalDirLabel
XREF ExternalExtLabel
…
LDA ExternalDirLabel ; Direct addressing mode is used.
…
LDA ExternalExtLabel ; Extended addressing mode is used.
XDEF.B DirLabel
XDEF ExtLabel
…
LDA DirLabel ; Direct addressing mode is used.
…
LDA ExtLabel ; Extended addressing mode is used.
…
BSCT
DirLabel: DS.B 3
dataSec: SECTION
ExtLabel: DS.B 5
…
codeSec: SECTION
…
LDA DirLabel ; Direct addressing mode is used.
…
LDA ExtLabel ; Extended addressing mode is used.
…
dataSec: SECTION
label: DS.B 5
…
codeSec: SECTION
…
LDA <label ; Direct addressing mode is used.
LDA label.B ; Direct addressing mode is used.
…
LDA >label ; Extended addressing mode is used.
LDA label.W ; Extended addressing mode is used.
…
shortSec: SECTION SHORT
DirLabel: DS.B 3
dataSec: SECTION
ExtLabel: DS.B 5
…
codeSec: SECTION
…
LDA DirLabel ; Direct addressing mode is used.
…
LDA ExtLabel ; Extended addressing mode is used.
Appendices
This document has the following appendices:
• Global Configuration File Entries
• Local Configuration File Entries
• MASM Compatibility
• MCUasm Compatibility
[Installation] Section
Path
Arguments
Last installation path.
Description
Whenever a tool is installed, the installation script stores the installation
destination directory into this variable.
Example
Path=C:\install
Group
Arguments
Last installation program group.
Description
Whenever a tool is installed, the installation script stores the installation program
group created into this variable.
Example
Group=Assembler
[Options] Section
DefaultDir
Arguments
Default directory to be used.
Description
Specifies the current directory for all tools on a global level. See also
DEFAULTDIR: Default current directory environment variable.
Example
DefaultDir=C:\install\project
[XXX_Assembler] Section
This section documents the entries that can appear in an [XXX_Assembler] section of
the mcutools.ini file.
NOTE XXX is a placeholder for the name of the name of the particular Assembler you
are using. For example, if you are using the HC08 Assembler, the name of this
section would be [HC08_Assembler].
SaveOnExit
Arguments
1/0
Description
1 if the configuration should be stored when the Assembler is closed, 0 if it should
not be stored. The Assembler does not ask to store a configuration in either cases.
SaveAppearance
Arguments
1/0
Description
1 if the visible topics should be stored when writing a project file, 0 if not. The
command line, its history, the windows position and other topics belong to this
entry.
This entry corresponds to the state of the Appearance check box in the Save
Configuration dialog box.
SaveEditor
Arguments
1/0
Description
If the editor settings should be stored when writing a project file, 0 if not. The
editor setting contain all information of the Editor Configuration dialog box. This
entry corresponds to the state of the check box Editor Configuration in the Save
Configuration dialog box.
SaveOptions
Arguments
1/0
Description
1 if the options should be contained when writing a project file, 0 if not.
This entry corresponds to the state of the Options check box in the Save
Configuration dialog box.
RecentProject0, RecentProject1
Arguments
Names of the last and prior project files
Description
This list is updated when a project is loaded or saved. Its current content is shown
in the file menu.
Example
SaveOnExit=1
SaveAppearance=1
SaveEditor=1
SaveOptions=1
RecentProject0=C:\myprj\project.ini
RecentProject1=C:\otherprj\project.ini
[Editor] Section
Editor_Name
Arguments
The name of the global editor
Description
Specifies the name of the editor used as global editor. This entry has only a
descriptive effect. Its content is not used to start the editor.
Saved
Only with Editor Configuration set in the File > Configuration Save Configuration
dialog box.
Editor_Exe
Arguments
The name of the executable file of the global editor (including path).
Description
Specifies the filename which is started to edit a text file, when the global editor
setting is active.
Saved
Only with Editor Configuration set in the File > Configuration Save Configuration
dialog box.
Editor_Opts
Arguments
The options to use with the global editor
Description
Specifies options (arguments), which should be used when starting the global
editor. If this entry is not present or empty, %f is used. The command line to
launch the editor is built by taking the Editor_Exe content, then appending a
space followed by the content of this entry.
Saved
Only with Editor Configuration set in the File > Configuration Save Configuration
dialog box.
Example
[Editor]
editor_name=IDF
editor_exe=C:\Freescale\prog\idf.exe
editor_opts=%f -g%l,%c
Example
Listing A.1 shows a typical mcutools.ini file.
[Installation]
Path=c:\Freescale
Group=Assembler
[Editor]
editor_name=IDF
editor_exe=C:\Freescale\prog\idf.exe
editor_opts=%f -g%l,%c
[Options]
DefaultDir=c:\myprj
[HC08_Assembler]
SaveOnExit=1
SaveAppearance=1
SaveEditor=1
SaveOptions=1
RecentProject0=c:\myprj\project.ini
RecentProject1=c:\otherprj\project.ini
[Editor] Section
Editor_Name
Arguments
The name of the local editor
Description
Specifies the name of the editor used as local editor. This entry has only a
description effect. Its content is not used to start the editor.
This entry has the same format as for the global editor configuration in the
mcutools.ini file.
Saved
Only with Editor Configuration set in the File > Configuration > Save
Configuration dialog box.
Editor_Exe
Arguments
The name of the executable file of the local editor (including path).
Description
Specifies the filename with is started to edit a text file, when the local editor setting
is active. In the editor configuration dialog box, the local editor selection is only
active when this entry is present and not empty.
This entry has the same format as for the global editor configuration in the
mcutools.ini file.
Saved
Only with Editor Configuration set in the File > Configuration > Save
Configuration dialog box.
Editor_Opts
Arguments
The options to use with the local editor
Description
Specifies options (arguments), which should be used when starting the local editor.
If this entry is not present or empty, %f is used. The command line to launch the
editor is build by taking the Editor_Exe content, then appending a space followed
by the content of this entry.
This entry has the same format as for the global editor configuration in the
mcutools.ini file.
Saved
Only with Editor Configuration set in the File > Configuration > Save
Configuration dialog box.
Example
[Editor]
editor_name=IDF
editor_exe=C:\Freescale\prog\idf.exe
editor_opts=%f -g%l,%c
[XXX_Assembler] Section
This section documents the entries that can appear in an [XXX_Assembler] section of
a project.ini file.
NOTE XXX is a placeholder for the name of the name of the particular Assembler you
are using. For example, if you are using the HC08 Assembler, the name of this
section would be [HC08_Assembler].
RecentCommandLineX, X= integer
Arguments
String with a command line history entry, e.g., fibo.asm
Description
This list of entries contains the content of the command line history.
Saved
Only with Appearance set in the File > Configuration > Save Configuration dialog
box.
CurrentCommandLine
Arguments
String with the command line, e.g., fibo.asm -w1
Description
The currently visible command line content.
Saved
Only with Appearance set in the File > Configuration > Save Configuration dialog
box.
StatusbarEnabled
Arguments
1/0
Special
This entry is only considered at startup. Later load operations do not use it any
more.
Description
Current status bar state.
• 1: Status bar is visible
• 0: Status bar is hidden
Saved
Only with Appearance set in the File > Configuration > Save Configuration dialog
box.
ToolbarEnabled
Arguments
1/0
Special
This entry is only considered at startup. Afterwards, any load operations do not use
it any longer.
Description
Current toolbar state:
• 1: Toolbar is visible
• 0: Toolbar is hidden
Saved
Only with Appearance set in the File > Configuration > Save Configuration dialog
box.
WindowPos
Arguments
10 integers, e.g., 0,1,-1,-1,-1,-1,390,107,1103,643
Special
This entry is only considered at startup. Afterwards, any load operations do not use
it any longer.
Changes of this entry do not show the “*” in the title.
Description
This numbers contain the position and the state of the window (maximized, etc.)
and other flags.
Saved
Only with Appearance set in the File > Configuration > Save Configuration dialog
box.
WindowFont
Arguments
size: = 0 -> generic size, < 0 -> font character height, > 0 -> font cell height
weight: 400 = normal, 700 = bold (valid values are 0–1000)
italic: 0 = no, 1 = yes
font name: max. 32 characters.
Description
Font attributes.
Saved
Only with Appearance set in the File > Configuration > Save Configuration dialog
box.
Example
WindowFont=-16,500,0,Courier
TipFilePos
Arguments
any integer, e.g., 236
Description
Actual position in tip of the day file. Used that different tips are shown at different
calls.
Saved
Always when saving a configuration file.
ShowTipOfDay
Arguments
0/1
Description
Should the Tip of the Day dialog box be shown at startup?
• 1: It should be shown
• 0: No, only when opened in the help menu
Saved
Always when saving a configuration file.
Options
Arguments
current option string, e.g.: -W2
Description
The currently active option string. This entry can be very long.
Saved
Only with Options set in the File > Configuration > Save Configuration dialog
box.
EditorType
Arguments
0/1/2/3/4
Description
This entry specifies which editor configuration is active:
• 0: global editor configuration (in the file mcutools.ini)
• 1: local editor configuration (the one in this file)
• 2: command line editor configuration, entry EditorCommandLine
• 3: DDE editor configuration, entries beginning with EditorDDE
• 4: CodeWarrior with COM. There are no additional entries.
For details, see also Editor Setting dialog box.
Saved
Only with Editor Configuration set in the File > Configuration > Save
Configuration dialog box.
EditorCommandLine
Arguments
Command line, for UltraEdit-32: “c:\Programs Files\IDM
Software Solutions\UltraEdit-32\uedit32.exe %f -g%l,%c”
Description
Command line content to open a file. For details, see also Editor Setting dialog
box.
Saved
Only with Editor Configuration set in the File > Configuration > Save
Configuration dialog box.
EditorDDEClientName
Arguments
client command, e.g., “[open(%f)]”
Description
Name of the client for DDE editor configuration. For details, see also Editor
Setting dialog box.
Saved
Only with Editor Configuration set in the File > Configuration > Save
Configuration dialog box.
EditorDDETopicName
Arguments
Topic name, e.g., system
Description
Name of the topic for DDE editor configuration. For details, see also Editor Setting
dialog box.
Saved
Only with Editor Configuration set in the File > Configuration > Save
Configuration dialog box.
EditorDDEServiceName
Arguments
service name, e.g., system
Description
Name of the service for DDE editor configuration. For details, see also Editor
Setting dialog box.
Saved
Only with Editor Configuration set in the File > Configuration > Save
Configuration dialog box.
Example
The example in Listing B.1 shows a typical layout of the configuration file (usually
project.ini).
[Editor]
Editor_Name=IDF
Editor_Exe=c:\Freescale\prog\idf.exe
Editor_Opts=%f -g%l,%c
[HC08_Assembler]
StatusbarEnabled=1
ToolbarEnabled=1
WindowPos=0,1,-1,-1,-1,-1,390,107,1103,643
WindowFont=-16,500,0,Courier
TipFilePos=0
ShowTipOfDay=1
Options=-w1
EditorType=3
RecentCommandLine0=fibo.asm -w2
RecentCommandLine1=fibo.asm
CurrentCommandLine=fibo.asm -w2
EditorDDEClientName=[open(%f)]
EditorDDETopicName=system
EditorDDEServiceName=msdev
EditorCommandLine=c:\Freescale\prog\idf.exe %f -g%l,%c
Comment Line
A line starting with a (*) character is considered to be a comment line by the Assembler.
Constants (Integers)
For compatibility with the MASM Assembler, the following notations are also supported
for integer constants:
• A decimal constant is defined by a sequence of decimal digits (0-9) followed by a d
or D character.
• A hexadecimal constant is defined by a sequence of hexadecimal digits (0-9, a-f,
A-F) followed by a h or H character.
• An octal constant is defined by a sequence of octal digits (0-7) followed by an o, O,
q, or Q character.
• A binary constant is defined by a sequence of binary digits (0-1) followed by a b or
B character.
Operators
For compatibility with the MASM Assembler, the following notations in Table C.1 are
also supported for operators:
Operator Notation
Arithmetic AND !.
Arithmetic OR !+
Directives
Table C.2 enumerates the directives that are supported by the Macro Assembler for
compatibility with MASM:
Labels
When MCUasm compatibility mode is activated, labels must be followed by a colon, even
when they start on column 1.
When MCUasm compatibility mode is activated, following portion of code generate an
error message, because the label label is not followed by a colon.
label DC.B 1
When MCUasm compatibility mode is not activated, the previous portion of code does not
generate any error message.
SET directive
When MCUasm compatibility mode is activated, relocatable expressions are also allowed
in a SET directive.
When MCUasm compatibility mode is activated, the following portion of code does not
generate any error messages:
label: SET *
When MCUasm compatibility mode is not activated, the previous portion of code
generates an error message because the SET label can only refer to absolute expressions.
Obsolete directives
Table D.1 enumerates the directives, which are not recognized any longer when the
MCUasm compatibility mode is switched ON.
X
XDEF Directive 280, 328
XREF Directive 262, 280, 329
XREFB Directive 280, 329, 399