MN102L00 Series Cross Assembler User’s Manual MICROCOMPUTER

Transcription

MN102L00 Series Cross Assembler User’s Manual MICROCOMPUTER
MICROCOMPUTER
MN102L00
MN102L00 Series
Cross Assembler
User’s Manual
Pub.No.12210-071E
MS-DOS is a registered trademark of Microsoft Corporation.
MIFES is a trademark of Megasoft, Inc.
PC/AT is a registered trademark of International Business Machine, Incorporated.
VZ Editor is a registered trademark of Village Center, Inc.
SPARC station is a trademark of SPARC International, Inc., licensed exclusively to Sun Microsystems Corporation.
Sun OS is a trademark of Sun Microsystems Corporation.
Windows is a trademark of Microsoft Corporation.
PanaXSeries is a trademark of Matsushita Electric Industrial Co., Ltd.
The other corporation names, logotype and product names written in this book are trademarks or registered trademarks of their
corresponding corporations.
Request for your special attention and precautions in using the technicalinformation
and semiconductors described in this book
(1) An export permit needs to be obtained from the competent authorities of the Japanese Government if any of
the products or technologies described in this book and controlled under the "Foreign Exchange and Foreign
Trade Law" is to be exported or taken out of Japan
(2) The contents of this book are subject to change without notice in matters of improved function. When
Þnalizing your design, therefore, ask for the most up-to-date version in advance in order to check for any
changes.
(3) We are not liable for any damage arising out of the use of the contents of this book, or for any infringement
of patents or any other rights owned by a third party.
(4) No part of this book may be reprinted or reproduced by any means without written permission from our
company.
If you have any inquiries or questions about this book or our semiconductors, please contact one of our sales
ofÞces listed at the back of this book or Matsushita Electronics Corporation's Sales Department
About This Manual
This manual describes the functions and operation of the cross-assembler for this series of microcontrollers.
¥ Manual Features
¥
Chapters on installation, program development ßow, and introductory operation are provided, so Þrsttime users can quickly get an overview and easily master operation.
¥
Optimization, a special feature of the Cross-Assembler, is explained in its own chapter.
¥
Explanations of how to operate the assembler and linker and how to write programs are made mostly
through the use of examples.
¥
Syntax, usage notes, and examples are given for each assembler directive, assembler control statement,
and macro control statement.
¥
Use of the library manager, a tool for managing library Þles, is also explained.
¥
For users of engineering workstations (EWS), a separate chapter describes differences from the MSDOS version.
¥
Chapters provides listings of machine-language instructions and error messages, as well as sample
programs that demonstrate usage.
< About This Manual 1 >
¥ How to read
Chapter 1 Installation
Heading
1.3.4
Environment Settings
Before using the Cross-Assembler, verify or change the following two Þles.
CONFIG.SYS
If FILES and BUFFERS speciÞcations do not already exist in CONFIG.SYS, then you must add them.
If they do already exist, then check their settings, and change them if necessary.
Program example
FILES=20
BUFFERS=20
NOTE:
Be sure to make these settings. If the assembler is started without them, then
the error message "bad tmpbss(w)" will be output and processing will stop. This
means that the number of Þles that can be opened simultaneously is insufÞcient.
Terminology:
CONFIG.SYS
This is the Þle that sets the MS-DOS operating environment. FILES speciÞes
the number of Þles that can be read and written simultaneously.
BUFFERS speciÞes the size of memory used for reading/writing disks.
Usage note
Supplementary explanation
Installing PC Version 14
¥ Heading
Chapter titles are shown here on each page, so the reader can get a quick idea of contents while ßipping
through the pages.
¥ Program example
These are actual examples of command options and instructions used by the assembler. First-time users
should refer to these examples when trying to use the assembler.
¥ Usage note
These give important information. Usage note provide cautions about usage, so they should always be read.
¥ Supplementary explanation
These are hints ands terminology deÞnitions that can help the reader use the assembler.
<About This Manual 2 >
¥ Reference Techniques
Table of Contents
Table of Contents
Chapter Contents
1.1 Purpose of This Chapter
Table of Contents
...................................
...................................
...................................
....................................
...........
Chapter1..
Chapter 1...
Chapter 2...
..........
Chapter 8...
Index
Index
...........
...........
...........
...........
...........
...........
...........
...........
¥
...........
...........
...........
...........
...........
...........
...........
...........
Main Contents
This shows the main contents of this manual. Use it to look up the start of each chapter.
¥
Table Of Contents
This shows the title of all sections of this manual.
¥
Chapter Contents
Located at the start of each chapter, this shows the titles of all sections in that chapter.
¥
Index
Refer to the index at the back of this manual to look up technical terms.
< About This Manual 3 >
¥ Related Manuals
The following related manuals are available. Please contact your sales representative for more details.
MN102L00 Series LSI User's ManualÓ
<Describes the device hardware>
MN102L00 Series Instruction Manual"
<Describes the instruction set>
MN102L00 Series C Compiler User's Manual: Usage Guide"
<Describes the installation, the commands, and options of the C
Compiler>
MN102L00 Series C Compiler User's Manual: Language Description"
<Describes the syntax of the C Compiler>
MN102L00 Series C Compiler User's Manual: Library Reference"
<Describes the the standard library of the C Compiler>
MN102L00 Series C Source Code Debugger User's Manual"
<Describes the use of the C source code debugger>
(NOTE: Not required for C Source Code Debugger for Windows¨ users.)
MN102L00 Series C Source Code Debugger for Windows¨ User's Manual
<Describes the use of the C source code debugger for Windows¨>
MN102L00 Series Installation Manual"
<Describes the installation of the C compiler, cross-assembler and C
source code debugger and the procedure for bringing up the in-circuit
emulator>
<About This Manual 4 >
< About This Manual 5 >
Table of Contents
Chapter 1
Installation
Chapter 2
Program Development Flow
Chapter 3
Introduction To Operation
Chapter 4
Optimization
Chapter 5
Using Assembler
Chapter 6
Using Linker
Chapter 7
Types Of Source Statements
Chapter 8
Chapter 9
Chapter 10
Writing Source Statements
Writing Machine Language Instruction
Statements And Directive Statements
Writing Assembler Control Statements
Chapter 11
Writing Macro Control Statements
Chapter 12
List Of Machine Language Instructions
Chapter 13
Error Messages
Chapter 14
Readinig List Files
Chapter 15
Using Library Manager
Chapter 16
EWS Version
Chapter 17
Appendix
Index
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
index
Ta b l e o f C o n t e n t s
Chapter 1
Installation
1.1
Purpose Of This Chapter ................................................................................................................... 2
1.2
Installing the PC Version Of the Assembler..................................................................................... 3
1.2.1 Hardware Environment ............................................................................................................... 3
1.3
File Organization .............................................................................................................................. 4
1.4
Installation ........................................................................................................................................ 6
1.5
Configuring the Operating Environment .......................................................................................... 7
1.6
User Customization ........................................................................................................................... 9
1.6.1 Assembler Customization ........................................................................................................... 9
1.6.2 Linker Customization ................................................................................................................ 11
1.7
File Conversion Utility ................................................................................................................... 13
Chapter 2
Program Development Flow
2.1
Purpose Of This Chapter................................................................................................................. 18
2.2
Program Development Flow ........................................................................................................... 19
2.3
Programming With Assemble........................................................................................................ r 21
Chapter 3
Introduction To Operation
3.1
Purpose Of This Chapter................................................................................................................. 26
3.2
Files Used By Assembler And Linker ............................................................................................ 27
3.3
Basic Operation Of Assembler And Linker .................................................................................... 29
3.4
Assembling And Linking Multiple Sections .................................................................................. 35
3.5
Conditional Assembly And Linking ............................................................................................... 46
3.6
Error Correction Using Tag Jumps ................................................................................................. 53
Chapter 4
4.1
<TOC 1 >
Optimization
Purpose Of This Chapter................................................................................................................. 58
4.2
Rules Of Usage ............................................................................................................................... 59
4.2.1 Usage Example .......................................................................................................................... 71
Chapter 5
Using Assembler
5.1
Purpose of This Chapter ................................................................................................................. 80
5.2
Starting Assembler .......................................................................................................................... 81
5.3
Command Options .......................................................................................................................... 85
5.3.1 Output File Options ................................................................................................................... 86
5.3.2 Error Message Options............................................................................................................ 110
5.3.3 Preprocessor Options .............................................................................................................. 116
5.3.4 Program Generation Options ................................................................................................... 123
5.3.5 Other Options .......................................................................................................................... 127
5.4
Operation example ........................................................................................................................ 129
Chapter 6
Using Linker
6.1
Purpose Of This Chapter............................................................................................................... 132
6.2
Starting Linker .............................................................................................................................. 133
6.3
Command Options ........................................................................................................................ 136
6.3.1 Output File Options ................................................................................................................. 137
6.3.2 Error Message Options ............................................................................................................ 142
6.3.3 Program Generation Options ................................................................................................... 146
6.3.4 Library File Options ................................................................................................................ 152
6.3.5 Other Options .......................................................................................................................... 154
6.4
Operation Examples ...................................................................................................................... 157
Chapter 7
Types Of Source Statement
7.1
Purpose of This Chapter ............................................................................................................... 160
7.2
Program Format ............................................................................................................................. 161
7.3
Machine Language Instruction Statements And Directive Statements......................................... 163
7.4
Assembler Control Statements...................................................................................................... 164
7.5
Macro Control Statements ............................................................................................................ 165
<TOC 2 >
7.6
Comment Statements .................................................................................................................... 166
7.7
Blank Statements .......................................................................................................................... 167
Chapter 8
Writing Source Statements
8.1
Purpose of This Chapter ............................................................................................................... 170
8.2
Permitted Characters ..................................................................................................................... 171
8.3
Numbers ........................................................................................................................................ 172
8.4
Character Constants ...................................................................................................................... 175
8.5
Address Constants ......................................................................................................................... 177
8.6
Location Counter .......................................................................................................................... 178
8.7
Expressions ................................................................................................................................... 179
8.7.1 Operators ................................................................................................................................. 180
8.7.2 Expression Evaluation ............................................................................................................. 182
8.7.3 Expression Syntax ................................................................................................................... 184
8.7.4 Expression Attributes .............................................................................................................. 185
8.8
Reserved Words ............................................................................................................................ 187
Chapter 9
Writing Machine Language Instruction Statements And Directive Statements
9.1
Purpose Of This Chapter ............................................................................................................... 190
9.2
Instruction Statement Fields ......................................................................................................... 191
9.2.1 Writing Label Field ................................................................................................................ 192
9.2.2 Writing Operation Field .......................................................................................................... 193
9.2.3 Writing Operand Field ............................................................................................................ 194
9.2.4 Writing Comment Field .......................................................................................................... 195
9.3
Writing Machine Language Instruction Statements ..................................................................... 196
9.4
Writing Directive Statements ........................................................................................................ 197
9.4.1 section ..................................................................................................................................... 199
9.4.2 align ......................................................................................................................................... 201
9.4.3 end ........................................................................................................................................... 203
9.4.4 listoff, liston ............................................................................................................................ 204
<TOC 3 >
9.4.5 notation .................................................................................................................................... 206
9.4.6 org ........................................................................................................................................... 208
9.4.7 opt............................................................................................................................................ 210
9.4.8 page ......................................................................................................................................... 212
9.4.9 radix ......................................................................................................................................... 213
9.4.10 dc ............................................................................................................................................. 215
9.4.11 ds ............................................................................................................................................. 217
9.4.12 dw ............................................................................................................................................ 219
9.4.13 dd ............................................................................................................................................. 221
9.4.14 global ....................................................................................................................................... 225
9.4.15 tit ............................................................................................................................................. 227
9.4.16 xlistoff, xliston ........................................................................................................................ 228
Chapter 10 Writing Assembler Control Statements
10.1
Purpose Of This Chapter............................................................................................................... 232
10.2
#include ......................................................................................................................................... 233
10.3
#define .......................................................................................................................................... 235
10.4
#undef ........................................................................................................................................... 237
10.5
Conditional Assembly ................................................................................................................... 239
10.5.1 #ifdef,#ifndef ........................................................................................................................... 241
10.5.2 #if,#ifn ..................................................................................................................................... 243
10.5.3 #ifeq,#ifneq ............................................................................................................................. 246
10.5.4 #iflt,#ifle .................................................................................................................................. 251
10.5.5 #ifgt,#ifge ................................................................................................................................ 255
10.5.6 #ifb,#ifnb ................................................................................................................................. 259
Chapter 11 Writing Macro Control Statements
11.1
Purpose Of This Chapter............................................................................................................... 266
11.2
Macro Definitions (macro, endm) ................................................................................................. 267
11.3
Macro Calls And Expansion .......................................................................................................... 269
11.4
Macro Operators ........................................................................................................................... 272
11.5
Local Symbol Declaration (local) ................................................................................................. 275
11.6
Forced Termination Of Macro Expansion (exitm) ....................................................................... 278
<TOC 4 >
11.7
Purging Macro Definitions (purge) ............................................................................................... 283
11.8
rept ................................................................................................................................................ 285
11.9
irp .................................................................................................................................................. 288
11.10 irpc ................................................................................................................................................ 291
11.11 front / back .................................................................................................................................... 294
Chapter 12 List Of Machine Language Instructions
12.1
Purpose Of This Chapter............................................................................................................... 298
12.2
Addressing Modes ........................................................................................................................ 299
12.3
List Of Machine Language Instructions ....................................................................................... 303
12.3.1 Data Move Instructions ........................................................................................................... 304
12.3.2 Arithmetic Instructions............................................................................................................ 307
12.3.3 Logical Instructions................................................................................................................. 310
12.3.4 Subroutine Call Instructions .................................................................................................... 312
12.3.5 Unconditional Branch Instructions ......................................................................................... 312
12.3.6 Conditional Branch Instructions ............................................................................................. 313
12.3.7 Bit Manipulation Instructions ................................................................................................. 316
12.3.8 Other Instructions.................................................................................................................... 316
Chapter 13 Error Messages
13.1
Purpose Of This Chapter ............................................................................................................... 318
13.2
Assembler Errors .......................................................................................................................... 319
13.2.1 Error Messages ........................................................................................................................ 319
13.2.2 Warning Messages .................................................................................................................. 322
13.2.3 Fatal Error Messages............................................................................................................... 323
13.3
Linker Errors ................................................................................................................................. 326
13.3.1 Fatal Error Messages............................................................................................................... 328
Chapter 14 Readinig List Files
14.1
<TOC 5 >
Purpose Of This Chapter ............................................................................................................... 332
14.2
Reading List Files ......................................................................................................................... 333
14.2.1 Output Format Of Machine Language Code........................................................................... 334
14.2.2 Symbol Table .......................................................................................................................... 337
14.2.3 Cross-Reference Table ............................................................................................................ 339
Chapter 15 Using Library Manager
15.1
Purpose Of This Chapter ............................................................................................................... 342
15.2
Starting Library Manager .............................................................................................................. 343
15.3
Error/Warning Messages .............................................................................................................. 351
Chapter 16 EWS Version
16.1
Purpose of This Chapter ............................................................................................................... 356
16.2
Installation .................................................................................................................................... 357
16.2.1 Hardware Environmen ............................................................................................................ 357
16.2.2 File Organization..................................................................................................................... 358
16.2.3 Installation............................................................................................................................... 359
16.3
Differences With MS-DOS Version ............................................................................................. 360
16.4
Configuration ................................................................................................................................ 361
16.4.1 Configuration .......................................................................................................................... 361
16.4.2 Configuration File Contents .................................................................................................... 363
16.5
Kanji Use ...................................................................................................................................... 365
Chapter 17 Appendix
17.1
Numeric Restrictions .................................................................................................................... 368
17.1.1 Numeric Value in Assembler .................................................................................................. 370
17.2
List Of Command Options ............................................................................................................ 371
17.2.1 List Of Assembler Command Options .................................................................................... 372
17.2.2 List Of Linker Command Options .......................................................................................... 374
17.3
List Of Assembler Directives ....................................................................................................... 376
17.4
List Of Assembler Control Statements ......................................................................................... 379
17.5
Program Example ......................................................................................................................... 381
<TOC 6 >
<TOC 7 >
Chapter 1
Installation
1
Chapter 1 Installation
1.1
Purpose Of This Chapter
This chapter describes installation of the Cross-Assembler.
It also describes the environment settings, memory requirements, and DOS version of personal
computers that can use the assembler and linker.
2
Purpose Of This Chapter
Chapter 1 Installation
1.2
Installing the PC Version Of the Assembler
This section describes the personal computers that can use the assembler and linker, their environment,
and memory requirements
1.2.1
Hardware Environment
Personal Computer
This package is developed under DOS extender (EXEGCCV) , so it requires the following system.
¥
Machine
PC/AT or compatibles
¥
CPU
Intel 80386 or higher
¥
Memory
Minimum of 5.6 Mbytes free (recommended) This software
uses extended memory, so does not run on personal computers
with only 640 Kbytes of memory.
¥
Memory manager
Fully compliant with the VCPI standard
¥
OS
MS-DOS: ver.3.3 or later
¥
Windows:
95/98/NT3.51/NT4.0/2000
Conventional Memory Requirements
The amount of conventional memory (640 Kbytes or less of the memory area) required depends on
such factors as assembler and linker options and program size, so the following is only the bare
minimum.
¥
Conventional memory requirements
NOTE:
Minimum of 320 Kbytes
A long file name cannot be used under Windows NT3.51/NT4.0/2000.
Installing the PC Version Of the Assembler
3
Chapter 1 Installation
1.3
File Organization
The distribution disk contains the following Þles.
A>DIR B:
Volume in
Directory of B
32RT
AS102L00
AS102L00
AS102L00
DPMI32VM
EXCV102
EXEGCCV
LD102L00
LD102L00
LD102L00
PAINST
SLIB102L
SLIB102L
WINDPMI
drive B: has
no label
EXE
EXE
OUT
RC
OVL
EXE
EXE
EXE
OUT
RC
EXE
EXE
OUT
386
14 Þles
1,386,441,
156,204
1,986
183,028
946
58,744
53,248
100,944
1,986
100,356
1,010
26,168
1,986
44,692
17,996
216 bytes
98-11-10
98-11-10
98-11-10
98-11-10
98-11-10
98-11-10
98-11-10
98-11-10
98-11-10
98-11-10
98-11-10
98-11-10
98-11-10
98-11-10
749,284 bytes
free
11:25
11:25
11:25
11:25
11:25
11:25
11:25
11:25
11:25
11:25
11:25
11:25
11:25
11:25
Þles
File sizes and dates differ between shipping versions.
AS102L00.EXE AS102L00.OUT (assembler)
This pair constitutes the executable for the assembler.
LD102L00.EXE LD102L00.OUT (linker)
This pair constitutes the executable for the linker.
PAINST.EXE (installer)
This utility is for customizing the assembler and linker, changing work areas, etc.This chapter describes
how to use this.
EXCV102.EXE (file conversion utility)
This utility converts EX format executable Þles from the linker to Intel HEX format.
SLI102L.EXE (library manager)
This utility manages library Þles.
EXEGCCV.EXE (DOS extender)
The assembler and linker use this module to run in extended memory.
AS102L00.RC (assembler configuration)
This Þle contains customization parameters for the assembler.
LD102L00.RC (linker configuration)
This Þle contains customization parameters for the linker.
4
File Organization
Chapter 1 Installation
32RTM.EXE, DPMI32VM.OVL, WINDPMI.386
This Þle executes EXCV102.EXE(Þle conversion utility) in DOS and Windows 3.1.
There may also be a README.DOC Þle in addition to the above Þles. This Þle contains new
information unavailable in this manual, so please be sure to read it.
File Organization
5
Chapter 1 Installation
1.4
Installation
The explanation below assumes the use of a personal computer with two ßoppy disk drives.
Before installation, create a backup of the ßoppy disk containing the assembler.
Backup
The ßoppy disk containing the assembler does not contain MS-DOS. You should provide a ßoppy disk
with MS-DOS if needed.
Insert the original ßoppy disk of the assembler in the B drive, and copy it to the A drive.
>COPY B:*.*
Store the original ßoppy disk in a safe place.
After this, use the copied ßoppy disk. The installation process writes to the ßoppy disk, so do not afÞx
a write-protect seal to it.
Installation
Before starting installation, read section 1.6, "User Customization", and determine if you need any
customization. If needed, then perform the customization before the installation. Installation of the
assembler and linker does require special operations. If you develop programs on the copied ßoppy
disk, then they can be used as is.
To use with a hard disk, copy the following programs to the appropriate directory on the hard disk, and
set command search path in the directory. That will be the end of installation.
EXEGCCV.EXE
AS102L00.EXE
AS102L00.OUT
LD102L00.EXE
LD102L00.OUT
AS102L00.RC
LD102L00.RC
6
Installation
Chapter 1 Installation
1.5
ConÞguring the Operating Environment
Two Þles may require editing before you can use the package.
CONFIG.SYS (obligatory)
Add the following lines to CONFIG.SYS. If the Þle already contains such lines, make sure that the
numbers are greater than or equal to the numbers appearing here.
NOTE:
Any changes made do not take effect until the next reboot.
FILES=20
BUFFERS=20
NOTE:
If these numbers are too low, the assembler aborts with the totally opaque error
message "bad tmpbss (w)," its way of saying that the operating system provides
insufficient room to open all necessary files simultaneously
Terminology:
CONFIG.SYS
This is the file that sets the MS-DOS operating environment. Files specify the
number of files that can be read and written simultaneously. BUFFERS
specifies the size of memory used for reading/writing disks.
Configuring the Operating Environment
7
Chapter 1 Installation
AUTOEXEC.BAT
If you do not want intermediate work Þles cluttering the current directory, then modify
AUTOEXEC.BAT. This modiÞcation is not necessary if you do not mind them being generated there.
Before making this setting, create a subdirectory TMP below the root directory to hold the intermediate
work Þles
.
A>MD
TMP
Add the following line to AUTOEXEC.BAT.
SET
TMP=A:\ TMP
Add the following line to AUTOEXC.BAT when operating under MS-DOS or MS-DOS mode of
Windows 9X.
SET
LONGNAME=OFF
NOTE:
When you have finished the above procedure, reset the personal computer and
boot it again. This enables use of the new environment setting.
Terminology:
8
AUTOEXEC.BAT
This is a batch file automatically executed when MS-DOS starts. SET sets the
value of an MS-DOS environment variable. Environment variables can be
freely referenced by application programs.
Configuring the Operating Environment
Chapter 1 Installation
1.6
User Customization
ConÞguring the Package PAINST is a utility for updating such assembler and linker conÞguration
options as default radix and language for messages.
It stores these conÞguration options in the Þles AS102L00.RC or LD102L00.RC. For this reason, make
sure to use a copied ßoppy disk, and remove the write-protect tab before starting the change process.
1.6.1
Assembler Customization
To customize the assembler, load the conÞguration utility with the following command line.
A>PAINST AS102L00.EXE
¥
Selecting Items
The utility starts with a list of conÞguration items.
PanaX Series Assembler
Installer For IBM PC/AT
Copyright(c) 1996
ConÞguration ***
***AS 102L00.EXE
ConÞguration Options
Number formatting
Language
Optimization
RF Þle output
Version2.0 Release 1
Panasonic/KMC
Extended C syntax
English
OFF
OFF
UP and DOWN to select.
LEFT and RIGHT to change.
ESC to exit.
Use the up and down arrow keys to select an item and the left and right arrow keys to cycle between the
settings available for that item.
Press the Esc key to terminate editing.
The following Table lists the conÞguration items, their descriptions, factory settings, and available
settings.
Table 1-1
Screen Label
Assembler Configuration Options
Description
Factory Setting
Available Settings
Number formating
SpeciÞes the format for Extended C syntax
displaying intergers
Matsushita, Intel,
Extended C syntax
Language
Specify the default
English
Japanese, English
Optimization
settings for command
OFF
ON, OFF
RF Þle output
line options.
OFF
ON, OFF
User Customization
9
Chapter 1 Installation
¥
Exiting
Pressing the ESC key displays a slightly different screen listing the new settings.
PanaX Series Assembler
***AS 102L00.EXE
ConÞguration Options
Number formatting
Language
Optimization
RF Þle output
Installer For IBM PC/AT
Copyright(c) 1996
ConÞguration ***
Version2.0 Release 1
Panasonic/KMC
Extended C syntax
English
OFF
OFF
OK to update settings(Y/N)?
Press Y to update the conÞguration Þle (AS102L00.RC) on disk or N to cancel all changes.
10
User Customization
Chapter 1 Installation
1.6.2
Linker Customization
To customize the linker, load the conÞguration utility with the following command line.
A>PAINST LD102L00.EXE
¥
Selecting Items
The utility starts with a list of conÞguration items.
PanaX Series Assembler
***AS 102L00.EXE
Language
Debugging information output
Symbol table output
MAP Þle output
EX.Þle output with errors
UP and DOWN to select.
Installer For IBM PC/AT
Copyright(c) 1996
ConÞguration ***
LEFT and RIGHT to change.
Version2.0 Release 1
Panasonic/KMC
English
OFF
OFF
OFF
OFF
ESC to exit.
Use the up and down arrow keys to select an item and the left and right arrow keys to cycle between the
settings available for that item.
Press the Esc key to terminate editing.
The following Table lists the conÞguration items, their descriptions, factory settings, and available
settings.
Table 1-2
Screen Label
Linker Configuration Options
Description
Language
Factory Setting
Available Setting
English
Japanese, English
Debugging
information output
Specify the default
settings for command
OFF
ON, OFF
Symbol table
output
line options.
OFF
ON, OFF
MAP Þle output
OFF
ON, OFF
EX Þleoutput with
errors
OFF
ON, OFF
User Customization
11
Chapter 1 Installation
¥
Exiting
Pressing the ESC key displays a slightly different screen listing the new settings.
PanaX Series Assembler
***AS 102L00.EXE
Language
Debugging information output
Symbol table output
MAP Þle output
EX.Þle output with errors
OK to update settings(Y/N)?
Installer For IBM PC/AT
Copyright(c) 1996
ConÞguration ***
Version2.0 Release 1
Panasonic/KMC
English
OFF
OFF
OFF
OFF
Press Y to update the conÞguration Þle (LD102L00.RC) on disk or N to cancel all changes.
12
User Customization
Chapter 1 Installation
1.7
File Conversion Utility
This utility converts EX format executable Þles from the linker to Intel HEX or Motorola format.
The default format is Intel HEX, with extended addresses for code sizes above 0xFFFF up to
0xFFFFF. A code size greater than 1 Mbyte produces an error.
The limit for the Motorola S2 format is 0xFFFFFF.
Command Syntax
The general command formatused to start the Þle conversion utility is shown below.
A>EXCV102 [options] ex_format_filename
Contents of brackets [ ]may be omitted.
Command Line Options
Option
Description
-j
Displays error and warning messages in Japanese. *1
-e
Displays error and warning messages in English. *2
-h
Displays help information regarding Þle conversion utility options to the screen.
-w
Perform conversion using a work Þle during execution. This enables a large
amount of data to be converted even if the personal computer has little memory.
However, conversion speed will be slower.
-i
Output the execution Þle in Intel HEX format.
-S2
Output the execution Þle in Motorola S2 format.
S1
Output the execution Þle in Motorola S1 format.
-oÞle
Specify the Þle name to output
-p
Performs conversion only for the codes that actually exist. If omitted, 0xFF is
padded for the address that does not exist. Perform conversion only for the
addresses of the speciÞed range.
-R start address,
end address
If omitting the end address, a conversion is performed until the last address in EX
format Þle.
-A start address
Perform conversion for the starting address of EX format Þle into the speciÞed
address.
*1 Option for UNIX version.
*2 Option for DOS/V, PC9800 version
File Conversion Utility
13
Chapter 1 Installation
NOTE:
Like outputing the range of 0x80000 - 0x180000 (1Mbyte) in Intel HEX format,
even if a cord size for output is within 1 Mbyte and an end address is greater than
0xFFFFF, you should use -A Option and adjust a start address in order that the
end address do not excel 0xFFFFF. If the code size for output is within 1 Mbyte
but excel 0xFFFFF, a correct output will not be given.
(Example)
Output the code for 0x80000 to 0x180000 into the Intel HEX file starting with
0x0
>excv102
-A0
-R80000, 180000 sample. ex
Default SpeciÞcation
Default operation is as follows.
Operation
Default operation
Output message
UNIX, PC/AT version :
DOS/V, PC9800 version
English
Japanese
Conversion
No use of work Þle.
Output format
Intel HEX format.
Padding
None
Output Þlename
the same Þlename as EX format Þle with Ò.hexÓ extension.
Conversion range
from the start to the end address in EX format Þle.
Ruels of Output Filename
Option
14
Extension
i
.hex
S2, S1
.sf
default
.hex
File Conversion Utility
Chapter 1 Installation
Option SpeciÞcation Examples
1. Specify the range for data conversion (-R)
excv102
-R1000, 1020 sample.ex
(Description)
Converts the data of 1000 to 1020 address in the sample.ex Þle.
2. Specify the start address for format conversion (-A)
excv102
-A1000 saple.ex
(Description)
sample. ex Þle has the starting address information speciÞed at linking.
Use these information to convert the starting address when converting the format.
at the example above, a conversion is performed for the starting address at 1000.
excv102
R4000, 8000-A1000 sample.ex
(Description)
Conversion is performed for the data of 4000 to 8000 address in sample.ex Þle as data from
1000 address.
3. Convert to Intel HEX format
excv102
-i
sample.ex
(Description)
Conversion is performed to intel HEX format.
4. Specify the conversion into motorola S format
excv102
-S1
sample.ex
excv102
-S2
sample.ex
(Description)
Conversion is performed into motorola S format.
-S1 : 16 bits address format
-S2 : 24 bits address format
5. Specify the conversion without padding
excv102
-p
sample.ex
(Description)
no padding (0xff)the blank space of the data at converting the format.
File Conversion Utility
15
Chapter 1 Installation
16
Chapter 2
Program Development Flow
2
Chapter 2 Program Development Flow
2.1
Purpose Of This Chapter
Programs can be developed with a compiler or an assembler.
Currently most program development is done with a compiler, but an assembler is where compact code
generation or faster processing speed is required.
This chapter gives an overview of development with the assembler, and explains the ßow of
development through completion.
18
Purpose Of This Chapter
Chapter 2 Program Development Flow
2.2
Program Development Flow
Main development ßow
The microcomputers are used in such diverse applications as AV equipment, household electronics,
information equipment, automobiles, robots, portable phones, computer peripherals, etc. Programs
developed with the Cross-Assembler are ultimately incorporated into these products.
In order to execute a program in an environment (on hardware) different from the operating
environment of the machine used for its development, the developer must debug it on a target board
using a source code debugger, and must then perform a special process called ROM conversion to
incorporate the Þnished program.
Assembler and compiler
Both the assembler and C compiler can be used to develop programs for the microcomputers.
Compared to assembly language, C language is a more productive language. Programs coded using a
high-level language also offer superior documentabirity.
On the other hand, microcomputer operations can be directly coded by programming with assembly
language. Compared to high-level languages, programs can be created with more compact code size,
less redundancy, and faster processing.
Given the features of both languages, the main body of a program can be coded using C language,
while parts that require fast processing can be coded using assembly language.
When developing a program, the programmer must Þrst consider which language to use, program
structure, processing speed required to meet the target performance of the end product, ROM size of
the device, and several other related factors.
Source code debugger
Programs developed under MS-DOS must have their operation veriÞed on the same hardware
environment as when incorporated into a product.
Nearly all microcomputers will ultimately be incorporated within end products. Therefore, program
debugging must also be performed under the same conditions as the end product. This is why a source
code debugger and in-circuit emulator are provided.
The probe of the in-circuit emulator can operate in place of the microcomputer by connecting it
through the microcomputer socket in the product.
The source code debugger is a program for controlling the in-circuit emulator's hardware. It writes
executable Þles created under MS-DOS into emulator memory, creating the same state as when written
into microcomputer ROM. It can start program execution as the address of any source statement, and
can temporarily stop execution. Also, when execution is stopped, the source code debugger can display
values of internal registers and memory and can be used to verify desired operation of programs by
changing those values. It also enables more detailed operation checks with step operation, whereby
execution proceeds one instruction at a time.
Using this development environment, the developer can prove programs in the same state as when
Þnally incorporated into the microprocessor.
Program Development Flow
19
Chapter 2 Program Development Flow
ROM conversion
Programs that have been completely debugged using the source code debugger and in-circuit emulator
must be written into ROM in order to be incorporated within the end product.
There are two methods of ROM conversion.
¥
Limited production
Using a device type that has internal EPROM, write the Þnished program into the EPROM using
dedicated programming equipment (ROM writer). Any number of erases and writes can be performed.
All devices provide device types with internal EPROM. This method is also suitable for producing
prototypes before moving to volume production.
¥
Volume production
When all product tests are complete, write the program into the mask ROM of a device. Matsushita
Electronics Corporation will convert the executable Þle to a mask.
Please consult with your sales representative for details.
20
Program Development Flow
Chapter 2 Program Development Flow
2.3
Programming With Assembler
Before creating programs using the assembler, you must understand the following items.
Required knowledge
¥
Machine-language instructions
¥
Device operation
¥
Editor use
¥
C compiler use
¥
Assembler and linker use (in this manual)
¥
Debugger use
Program development is an iterative process of editing, assembling, linking, and debugging many times
until Þnished. Therefore, you should as much as possible automate assembler and linker commands,
debugger calls, and error correction.
MAKE
When a program is divided into multiple Þles for joint development efforts by several programmers, a
control system must be created for assembly and linking without error.
If this is not done, then an old undebugged program could be linked within the iterative development
process.
To solve this problem, the following program is effective running under MS-DOS.
¥
MAKE
With MAKE the programmer deÞnes the dependency relationships of the Þles needed to generate the
Þnal executable Þle and list Þles. Afterwards MAKE will automatically assemble and link only those
Þles that have been modiÞed.
Program format
The Cross-Assembler utilizes a program format called section address format.
Section address format speciÞes the start addresses of programs for each section linked. Even when the
program is divided between multiple Þles, or when a Þle is divided into multiple sections, identical
sections are linked together with the same attributes. Therefore, the programmer must create programs
such that addresses do not overlap.
Refer to chapter 6, "Using The Linker", for details.
Programming With The Assembler
21
Chapter 2 Program Development Flow
Programming style
It is important to use a consistent style for program coding from start to Þnish. When several people
are to create a program, they should meet in advance to decide on a common style.
You should consider the following points regarding the Þxed style of the Cross-Assembler.
¥
Header Þles
Constants and variables used in all Þles and deÞne identiÞers used in common should be gathered into
a single header Þle. As a result, changes can be made at just one location in the header Þle.
¥
Library Þles
Subroutine programs frequently used by different Þles should be gathered by function as library Þles to
make programs easier to use.
¥
Declaration position global directives
Use one position for global directive declarations. The global directive can be declared anywhere
within a program, but confusion will result if the declaration positions differ across source Þles.
¥
Unify radix and notation directives
Choose a common default radix for coding numbers, constant values, strings, etc.
¥
Comment statements
Comments reveal program algorithms and processing details within a program. Choose a common
format for coding comment statements.
Optimization
The following conditional branch instructions and unconditional branch instructions are objects of
optimization with this series.
¥
Conditional branch instructions that are objects of optimization
¥
Unconditional branch instructions that are objects of optimization
Coding is not a simple task if the programmer must always select the optimal instruction from the
above instructions. In particular, it is nearly impossible to select the optimal instructions when coding
a program divided between Þles in section format.
Optimization solves this problem. The assembler and linker generate the optimal code when invoked,
regardless of the source code.
The assembler evaluates source statements. For conditional branch instructions, it generates code that
can be optimized only when the branch label range (-128-127) is exceeded.
For unconditional branch instructions, it generates code that can be optimized from JMP and BRA
instructions.
The linker evaluates instructions that were the object of optimization, and selects the optimal codes.
As a result, the programmer must be aware that the generated code will differ from the source
statements coded in the list Þle.
Refer to chapter 4, "Optimization", for details.
22
Programming With The Assembler
Chapter 2 Program Development Flow
Conditional assembly
If a program for product A is to be created by partially modifying a program for product B, then both
can be combined into a single program by using conditional assembler control instructions.
Conditional assembly is done by deÞning a single symbol at the start of the program using a deÞne
control directive.
Here is an example.
#define
TYPE
A
Using TYPE and conditional assembler control directives to process different parts of the program, the
programmer writes code in the format below.
.
.
.
TYPE
Program of product A
#else
Program of product B
#endif
.
.
.
TYPE has been deÞned with deÞne, so in this case the program for product A will be assembled. If the
statement
#define
TYPE
A
is omitted, then the program for product B will be assembled.
By using conditional assembler control directives in this manner, different versions of programs can be
managed in a single source Þle.
Refer to chapter 10, "Writing Assembler Control Statements", for details.
Macros
Macros are an important function of the assembler. A macro assigns a name to a process, thereby
simplifying the coding of that process. By assigning an appropriate macro name to a block of multiple
machine language instructions, the programmer can create custom instructions.
When performing Þnal program debugging, the programmer must verify whether the intended
operations are being performed or not. A source code debugger is provided for this. The programmer
uses the debugger to download generated and linked object code and then verify operation.
The g option of the assembler and linker generates information that allows the debugger to work with
symbols. This allows symbols to be used for specifying debugger start addresses, breakpoint settings,
memory references and changes, etc.
Programming With The Assembler
23
Chapter 2 Program Development Flow
24
Chapter 3
Introduction To Operation
3
Chapter 3 Introduction To Operation
3.1
Purpose Of This Chapter
Many options are provided with the Cross-Assembler and Linker, but you can use the assembler and
linker without knowing all of them. This chapter explains how to use the most useful options while
demonstrating actual operation.
This chapter Þrst uses an example to show how to run the assembler and linker. Next, it explains
assembler and linker use when assembler control statements and macro instructions are included for
high-level operations.
To make correction of syntax errors generated at the assembly level easier, this chapter also explains
error Þle generation and the procedure for correcting the source Þle with the tag jump function of an
editor using that error Þle.
After reading this chapter once through and trying actual operation, you will have mastered basic
assembler and linker operation.
26
Purpose Of This Chapter
Chapter 3 Introduction To Operation
3.2
Files Used By Assembler And Linker
Figure 3-1 shows the inter-relationships of the Þles used by the assembler and linker.
Map file
Source file
Include file
SAMPLE.MAP
SANPLE.ASM
SAMPLE.H
-a
-l
List file
Assembler
SAMPLE.LST
Library file
SAMPLE.LIB
@
Relocatable object files
SAMPLE.RF ...
Linker
-m
Map file
Executable file
SAMPLE.MAP
SAMPLE.EX
Figure: 3-1 Files Used
The assembler inputs source Þles and include Þles, and outputs relocatable object Þles.
Include Þles are not special Þles, but are just Þles that comprise parts of the source Þle. They are
incorporated into assembly at the location of include directives deÞned within source statements.
Depending on the option speciÞcations input for the source Þle and map Þle, a list Þle will be output
with fully resolved addresses.
Files Used By The Assembler And Linker 27
Chapter 3 Introduction To Operation
The map Þle is used to output a list Þle with fully resolved addresses.
The linker inputs relocatable object Þles output by the assembler and, depending on option
speciÞcations, library Þles. It generates an executable format Þle and, depending on option
speciÞcations, a map Þle.
Library Þles are collections of relocatable object Þles of frequently used programs and hardware
interface programs. Only needed modules are speciÞed to have the linker extract the appropriate
relocatable object Þles from library Þles and load them into the executable format Þle. Several library
Þles are provided, but you can maintain them or newly create them yourself. Refer to chapter 15,
"Using The Library Manager", for details.
Below are the default Þle extensions and formats when Þle extensions are omitted.
¥
Source Þle
.ASM (text format)
¥
Map Þle
.MAP (text format)
¥
List Þle
.LST (text format)
¥
Relocatable object Þle .RF (binary format)
¥
Library Þle
.LIB (binary format)
¥
Executable format Þle
.EX (binary format)
NOTE:
When extensions are omitted, the assembler searches the appropriate directory
for a file with the specified file name and the extension .ASM. For example, if the
file name SAMPLE is specified, then the assembler will search for
SAMPLE.ASM.
You cannot force different extensions for map Þles and list Þles. You can only specify whether or not to
output these Þles. However, the extensions of relocatable object Þles and the executable format Þle can
be changed with assembler and linker option speciÞcations. Since those options mean default
extensions cannot be applied, you would then have to include extensions in Þle name speciÞcations.
28
Files Used By The Assembler And Linker
Chapter 3 Introduction To Operation
3.3
Basic Operation Of Assembler And Linker
The Cross-Assembler uses a section address format, in which the start address for each section as
deÞned with the section directive corresponds to its start address when linked. This allows the
programmer to freely change the order of linking Þles.
The following explanation illustrates a simple example of only one section. In this example you will
assemble and link two source Þles, PROGRAM1.ASM and PROGRAM2.ASM.
These two Þles have related external references and external deÞnitions, where the subroutine of
PROGRAM2.ASM is called from PROGRAM1.ASM. Therefore the Þnal list Þles cannot be created
just by assembling PROGRAM1.ASM. In this example, you will generate with the linker a map Þle
and then generate the Þnal list Þles.
Create source files
First, create the source Þles. Using an editor, create the two programs shown below
(PROGRAM1.ASM and PROGRAM2.ASM).
The contents of PROGRAM1.ASM are as follows.
__CODE
main
_DATA
data1
global
section
data_set
CODE, PUBLIC, 2
mov
mov
mov
jsr
bra
section
ds
end
0, A0
0xff, D0
0x80, D1
data_set
main
DATA, PUBLIC, 2
4
PROGRAM1.ASM consists of a section called _CODE (attribute CODE, link type PUBLIC) and a
section called _DATA (attribute DATA, link type PUBLIC).
The contents of PROGRAM2.ASM are as follows.
Basic Operation Of The Assembler And Linker 29
Chapter 3 Introduction To Operation
__CODE
data_set
global
section
data_set
CODE, PUBLIC, 2
mov
0, D2
cmp
bcc
D1, D2
data_set_end
mov
add
add
bra
D0, (A00
1, D2
2, A0
data_set_loop
data_set_loop
data_set_end
rts
end
PROGRAM2.ASM also consists of a section called _CODE (attribute CODE, link type PUBLIC), and
it makes an external declaration of data_set.
Assemble
Assemble the two programs that you created to generate relocatable object Þles.
A>AS102L00 PROGRAM1
A>AS102L00 PROGRAM2
This will generate two relocatable object Þles (PROGRAM1.RF and PROGRAM2.RF). List Þles
cannot be generated at this stage. These Þles will be generated after linking when the relationships of
external references and external deÞnitions are resolved.
Link
Link the two relocatable object Þles to generate an executable format Þle. A map Þle will be generated
along with the executable format Þle at this time.
A>LD102L00 -m -T_CODE=80000 PROGRAM1 PROGRAM2
m optionOption to output map Þle.
T optionOption to specify section address.
This will link the two relocatable object Þles (PROGRAM1.RF and PROGRAM2.RF) and create an
executable format Þle (PROGRAM1.EX) and map Þle (PROGRAM1.MAP) in the current directory.
30
Basic Operation Of The Assembler And Linker
Chapter 3 Introduction To Operation
NOTE:
The file name and directory for output can be specified with the o (small letter o)
option. If the o option is omitted, then the name of the first file specified to be
linked (PROGRAM1 in this example) will be appended with the file extension .EX
to become the name of the executable format file. The map file name cannot be
specified, just as for the executable file name when the o option is omitted, the
map file will be output as the name of the first file specified to be linked with the
extension .MAP appended.
Generate final list files
After link processing is complete, generate the Þnal list Þles using the map Þle (PROGRAM1.MAP).
A>AS102L00 -l -a PROGRAM1 PROGRAM1
A>AS102L00 -l -a PROGRAM1 PROGRAM2
l option
Option to output a list Þle.
a option
Option to read a map Þle. Specify the map Þle name after it. This example
speciÞes PROGRAM1 as the map Þle name with .MAP omitted.
This operation will generate the Þnal list Þles (PROGRAM1.LST and PROGRAM2.LST) in the
current directory.
With the above operations, you can generate an executable format Þle and Þnal list Þles in the current
directory.
You must generate the Þnal list Þles using the map Þle after linking. This is because linking determines
the start addresses of sections following the T option for Þles in section address format. In addition,
there may be addresses unresolved until after link processing due to forward references, optimization,
etc. (Refer to chapter 4, "Optimization".)
Basic Operation Of The Assembler And Linker 31
Chapter 3 Introduction To Operation
The contents of the Þnal list Þle PROGRAM1.LST are as follows.
A>TYPE PROGRAM1.LST
***
Loc
mn102L00
Object
080000
080003
080006
080009
08000E
DC0000
F8FF00
F98000
F4E1020000
EAF0
08001E
08001F
080020
080021
00
00
00
00
ROM size is
No errors in
No warnings
524322(Hex.
this
in this
*** Symbol
00080000
0008001E
00080010
0008001E
00080000
Table ***
A_CODE
A_DATA
T data_set
D data1
T main
Cross
Line
1
2
3
4
5
6
7
8
9
10
11
12
12
12
12
13
PROGRAM1.
Assembler
Source
_CODE
main
_DATA
data1
Basic Operation Of The Assembler And Linker
Page1
global
data_set
section
CODE, PUBLIC, 2
mov
mov
mov
jsr
0, A0
0xff, D0
0x80, D1
data_set
section
ds
DATA, PUBLIC, 2
4
end
00080022)
assembly
assembly
PROGRAM1
32
LST
***
.LST
Page2
Chapter 3 Introduction To Operation
The contents of the Þnal list Þle PROGRAM2.LST are as follows.
A>TYPE
***
Loc
PROGRAM2.LST
mn102L00
Object
080010
8A00
080012
080014
F396
E607
080016
080017
080019
08001B
00
D601
D002
EAF5
08001D
FE
ROM size is
No errors in
No warnings
524318(Hex.
this
in this
*** Symbol
00080010
00080010
0008001D
00080012
Table ***
A_CODE
T data_set
T data_set_
T data_set_
Cross
Line
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
PROGRAM1.
Assembler
Source
_CODE
data_set
data_set_
data_set__
LST
***
Page1
global
data_set
section
CODE, PUBLIC, 2
mov
0, D0
loop
cmp
bcc
D1, D2
data_set_end
mov
add
add
bra
D0, (A0)
1, D2
2, A0
data_set_loop
end
rts
end
008001E)
assembly
assembly
PROGRAM2
.LST
Page2
end
loop
Here is a simple explanation of how to read the list Þles. A list Þle shows four items of information.
Source statements and machine language code
¥
ROM size
¥
Errors and warning messages
¥
Symbol table
Source statements and their corresponding machine language code are further divided into Loc, Object,
Line, and Source headings.
Basic Operation Of The Assembler And Linker 33
Chapter 3 Introduction To Operation
The Loc heading gives location counter values, which show execution addresses in the Þnal list Þles.
PROGRAM1.LST starts from location 80000 (hex.), and PROGRAM2.LST starts from location 80010
(hex.).
The Object heading shows the codes of instructions converted to machine language by the assembler.
Instructions consist of one to four bytes (1 byte=8 bits), shown as two to eight hex digits. After some
machine language code, the symbol 'M' will be added. The 'M' indicates an instruction that was
expanded from a macro instruction.
The Line heading shows line numbers added by the assembler. The Source heading shows the source
statements as coded.
34
Basic Operation Of The Assembler And Linker
Chapter 3 Introduction To Operation
3.4
Assembling And Linking Multiple Sections
In section 3.3, "Basic Operation Of The Assembler And Linker", source Þles each comprising one
section were assigned to the same section as a basic example. However, normally a program will be
divided into multiple sections to clearly divide programs by function and type.
The start addresses of a program in section format are set for each section during linking. Therefore,
when a program divided into multiple Þles is developed, work can proceed without the programmer
staying aware of the code size of each Þle. The programmer an also freely change the order in which
Þles are linked.
The following explanation illustrates a simple example dividing two source Þles into sections for each
routine, allocated to two sections.
Create source files
Using an editor, create the two programs shown below (PROGRAM3.ASM and PROGRAM4.ASM).
The contents of PROGRAM3.ASM are as follows.
_CODE_00
main
_DATA
data1
global
global
section
main
data_set, time_filler
CODE, PUBLIC, 2
mov
mov
mov
jsr
jsr
bra
0, A0
0xff, D0
0x80, D1
data_set
time_filler
main
section
ds
end
DATA, PUBLIC, 2
4
Assembling And Linking Multiple Sections 35
Chapter 3 Introduction To Operation
The contents of PROGRAM4.ASM are as follows.
_CODE_01
data_set
data_set_
global
data_set, time_filler
section
CODE, PUBLIC, 2
mov
0, D2
loop
cmp
bcc
D1, D2
data_set_end
mov
add
add
bra
D0, (A0)
1, D2
2, A0
data_set_loop
rts
section
CODE, PUBLIC, C2
data_set_end
_CODE_00
time_filler
Time_filler
time_filler
mov
_loop
cmp
bcc
bra
_end
rts
end
0, D2
D1, D0
time_filler_end
time_filler_loop
As can be seen from the above two Þles, these programs are divided as follows.
36
¥
main, time_Þller..._CODE_00
¥
data_set..._CODE_01
¥
data1..._DATA
Assembling And Linking Multiple Sections
Chapter 3 Introduction To Operation
Assemble and generate list files
Next assemble the two programs. Assemble with the option for output of list Þles in order to see what
the list Þle is like when Þnal addresses are not resolved.
A>AS102L00 -l -g PROGRAM3
A>AS102L00 -l -g PROGRAM4
g option
Option to output debug information in the relocatable object Þle.
l option
Option to output list Þle (not normally speciÞed at this stage before linking, but
specify it here to see intermediate values).
This will assemble the two source Þles PROGRAM3.ASM and PROGRAM4.ASM in the current
directory. It will add debug information (g option) to the relocatable object Þles PROGRAM3.RF and
PROGRAM4.RF, and generate list Þles PROGRAM3.LST and PROGRAM4.LST respectively in the
current directory (l option). Adding debug information (g option) enables symbols to be used during
debugging.
Let's take a look at the list Þles that were created.
Assembling And Linking Multiple Sections 37
Chapter 3 Introduction To Operation
The contents of the list Þle PROGRAM3.LST are as follows.
A>TYPE PROGRAM3.LST
***
Loc
mn102L00
Object
000000
000003
000006
000009
00000E
000013
DC0000
F8FF00
F98000
F4E1000000
F4E1000000
EA00
000000
000001
000002
000003
00
00
00
00
ROM size is
No errors in
No warnings
25 (Hex.
this
in this
*** Symbol
00000000
00000000
00000000
00000000
00000000
00000000
Table ***
A_CODE_00
A_DATA
*U data_set
D data1
T main
*U time_fil
Cross
Line
1
2
3
4
5
6
7
8
+9
+10
R11
12
13
14
14
14
14
15
PROGRAM3.
Assembler
Source
_CODE_00
main
_DATA
data1
LST
***
Page1
global
global
main
data_set, time_filler
section
CODE, PUBLIC, 2
mov
mov
mov
jsr
jsr
bra
0, A0
0xff, D0
0x80, D1
data_set
time_filler
main
section
ds
DATA, PUBLIC, 2
4
end
00000019)
assembly
assembly
PROGRAM3
.LST
Page2
ler
There is a plus sign '+' before line numbers 9 and 10. This indicates that the object code does not have
Þnal values. This is because the two functions data_set and time_Þller do not exist in this program, so
the call addresses will not be resolved unless linked. That further means that this list Þle is not the Þnal
list Þle.
There is an 'R' before line number 11. This also indicates that the object code does not have Þnal
values. It warns that the code includes a relocatable symbol whose value will be resolved when linked.
Finally, notice that the list begins from location 000000. The start addresses of section format
programs are speciÞed with the linker. Here the assembler uses relative values beginning from 000000
as location counter values.
38
Assembling And Linking Multiple Sections
Chapter 3 Introduction To Operation
The contents of the list Þle PROGRAM4.LST are as follows.
A>TYPE PROGRAM4.LST
***
Loc
mn102L00
Object
000000
8A00
000002
000004
F396
E600
000006
000007
000009
00000B
00
D601
D002
EA00
00000D
FE
000000
8A00
000002
000004
000006
F394
B600
EA00
000008
FE
ROM size is
No errors in
No warnings
23 (Hex.
this
in this
*** Symbol
00000000
00000000
00000000
0000000D
00000002
00000000
00000008
Table
A_CODE
A_CODE
T data_
T data_
T data_
T time_
T time_
Cross
Line
1
2
3
4
5
6
7
8
+9
10
11
12
13
R14
15
16
17
18
19
20
21
22
23
24
25
+26
R27
28
29
30
31
PROGRAM4.
Assembler
Source
LST
***
Page1
global
global
data_Set, time_filler
data_set, time_filler
section CODE, PUBLIC, 2
mov
0, D2
cmp
bcc
D1, D2
data_set_end
mov
add
add
bra
D0, (A0)
1, D2
2, A0
data_set_loop
_CODE_01
data_set
data_set_loop
data_set_end
rts
_CODE_00
sectio
n
CODE, PUBLIC, 2
mov
0, D2
loop
cmp
bcc
bra
D1, D0
time_filler_end
time_filler_loop
time_filler
time_filler_
Time_filler_
end
rts
end
00000017)
assembly
assembly
PROGRAM4
***
_00
_01
set
set_
set_
fille
fille
.LST
Page2
end
loop
r
r_end
Assembling And Linking Multiple Sections 39
Chapter 3 Introduction To Operation
00000002
T time_
fille loop
r_
This Þle is deÞned as two sections. The addresses of the starting locations of both sections is assumed
000000.
The 'R' added before '27' on line number 14 has the same meaning as in PROGRAM3.LST. It means
that the code includes a relocatable symbol.
Link
Link the two relocatable object Þles to generate an executable format Þle. Specify the
g option to add debug information to the executable format Þle.
A>LD102L00 -m -g -T_CODE_00=80000 -T_CODE_01=80200 PROGRAM3
PROGRAM4
m option
Option to output map Þle.
g option
Option to add debug information to the executable format Þle.
T option
Option to specify section address.
This will link the two relocatable object Þles (PROGRAM3.RF and PROGRAM4.RF), assigning
80000 (hex.) and 80200 (hex.) respectively as the start addresses of the two sections _CODE_00 and
_CODE_01. This command will generate an executable format Þle PROGRAM3.EX with debug
information added and a map Þle PROGRAM3.MAP, both output to the current directory.
40
Assembling And Linking Multiple Sections
Chapter 3 Introduction To Operation
Parameter file during linking
The following command was input to link.
A>LD102L00 -m -g -T_CODE_00=80000 -T_CODE_01=80200 PROGRAM3
PROGRAM4
Repeated input of lines like this is tedious and prone to errors. For this reason the very convenient @
option is provided with the linker. With an editor create a Þle PFILE (the name can be freely chosen)
with the following contents.
The contents of PFILE are as follows.
-m
-g
-T_CODE_00
-T_CODE_01
PROGRAM3
=80000
=80200
PROGRAM4
This Þle is called a parameter Þle. If the @ option is speciÞed when linking, then the linker will read a
parameter Þle, and will interpret its contents as command options for execution.
The two speciÞcations below will be equivalent.
A>LD102L00 @PFILE
A>LD102L00 -m -g -T_CODE_00=80000 -T_CODE_01=80200 PROGRAM3
PROGRAM4
Assembling And Linking Multiple Sections 41
Chapter 3 Introduction To Operation
Generate final list files
After link processing is complete, generate the Þnal list Þles using the map Þle (PROGRAM3.MAP).
This will show what happens to the previous '+' and 'R' marks.
A>AS102L00 -l -a PROGRAM3 PROGRAM3
A>AS102L00 -l -a PROGRAM3 PROGRAM4
l option
Option to output a list Þle.
a option
Option to use a map Þle.
Specify the map Þle name after the a option, followed by the source Þle name. Based on the link
information written in the map Þle, the assembler will reassemble the source Þle and generate a Þnal
list Þle.
42
Assembling And Linking Multiple Sections
Chapter 3 Introduction To Operation
Let's look at the Þnal list Þles with all addresses resolved.
The contents of the Þnal list Þle PROGRAM3.LST are as follows.
A>TYPE PROGRAM3.LST
***
Loc
mn102L00
Object
080000
080003
080006
080009
08000E
000013
DC0000
F8FF00
F98000
F4E1F20100
F4E1030000
EAEB
08020E
08020F
080210
080211
00
00
00
00
ROM size is
No errors in
No warnings
524818 (Hex.
this assembly
in this
*** Symbol
00000000
00000000
00000000
00000000
00000000
00000000
Table ***
A_CODE_00
A_DATA
T data_set
D data1
T main
T time_filler
Cross
Line
1
2
3
4
5
6
7
8
9
10
11
12
13
14
14
14
14
15
PROGRAM3.
Assembler
Source
_CODE_00
main
_DATA
data1
LST
***
Page1
global
global
main
data_set, time_filler
section
CODE, PUBLIC, 2
mov
mov
mov
jsr
jsr
bra
0, A0
0xff, D0
0x80, D1
data_set
time_filler
main
section
ds
DATA, PUBLIC, 2
4
end
0080212)
assembly
PROGRAM3
.LST
Page2
Assembling And Linking Multiple Sections 43
Chapter 3 Introduction To Operation
Compare this to the list Þle with unresolved addresses. The '+' on line numbers 9 and 10 and the 'R' on
line number 11 have disappeared. Addresses also start from address 80000 (hex) as speciÞed by the T
option.
The contents of the Þnal list Þle PROGRAM4.LST are as follows.
A>TYPE PROGRAM4.LST
***
Loc
mn102L00
Object
080200
8A,,
080202
080204
F396
E607
080206
080207
080209
08020B
00
D601
D002
EAF5
08020D
FE
Cross
Line
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
19
20
21
22
23
24
25
26
27
28
29
30
31
080016
8A00
080018
08001A
08001C
F394
E602
EAFA
000119
FE
ROM size is
No errors in
No warnings
in
524818 (Hex.
this assembly
this assembly
*** Symbol
00080016
00080200
00080200
0008020D
00080000
00080016
Table ***
A_CODE_00
A_CODE_01
T data_set
T data_set_
end
T main
T time_filler
PROGRAM4.
Assembler
Source
_CODE_01
data_set
data_set_
_CODE_00
Assembling And Linking Multiple Sections
Page1
global
data_set, time_filler
section
CODE, PUBLIC, 2
mov
0, D2
loop
cmp
bcc
D1, D2
data_set_end
mov
add
add
bra
D0, (A0)
1, D2
2, A0
data_set_loop
rts
section
CODE, PUBLIC, 2
mov
0, D2
time_filler
time_filler_ loop
cmp
bcc
bra
D1, D0
time_filler_end
time_filler_loop
time_filler_ end
rts
end
0008020E)
PROGRAM4
44
LST
***
.LST
Page2
Chapter 3 Introduction To Operation
0008001E
000800018
T
time_filler_
T
time_filler_
end
loop
In this Þle the 'R' on line numbers 14 and 27 have disappeared, and the start address of the Þrst section
_CODE_01 has been changed to address 80200 (hex.) as speciÞed by the T option. However, the start
address of section _CODE_00 is address 80016 (hex.). This shows that it has been linked after the
same section existing in PROGRAM3.
Program locations after linking
Program locations in the executable Þle after linking as above are shown below.
0X0000
~~
~~
Unused
0X080000
~~
~~
main
0X080016
time_filler
0X08001E
~~
~~
Unused
0X080200
~~
~~
data_set
0X08020E
data1
0X080211
~~
~~
Unused
~~
~~
Figure: 3-2 Program Location
Programs are laid out in accordance with the following rules when multiple sections are speciÞed.
Each section is placed at the starting address speciÞed during linking.
¥ Sections with the same section names are linked in the order speciÞed for linking (in the order
that object Þle names are entered after link option speciÞcations).
¥
Section linking rules:
Link in order of appearance during linking.
Link by attribute.
Link by link format.
For PUBLIC, link all link Þles.
For PRIVATE, link within one Þle.
Assembling And Linking Multiple Sections 45
Chapter 3 Introduction To Operation
3.5
Conditional Assembly And Linking
The MN10200 Series Cross-Assembler provides many assembler directives. Assembler directives are
not converted directly to machine language, but are used to control how the assembler processes.
For example, during the development stage a programmer may want to include a special program only
for debugging. This program must be deleted when the product is complete. That can be accomplished
by editing the source Þle, but if that editing is spread throughout the program, then mistakes will be
easy to make.
It is convenient to use assembler directives in such cases. The conditions for assembly are deÞned at
the start of the program, and programs to be assembled when the conditions are satisÞed or not satisÞed
are written in the source Þle.
Create source file
Using an editor, create the program PROGRAM5.ASM shown below.
The contents of PROGRAM5.ASM are as follows.
#define
*
dat_set
*
_CODE
main
#else
#endif
_DATA
data1
data2
DEBUG
macro
mov
mov
mov
endm
section CODE, PUBLIC,2
DEBUG
dat_set
dat_set
section DATA, PUBLIC, 2
dw
dw
end
adr, dat
adr, A0
dat, D0
D0, (A0)
data1, 0x11
data1, 0x22
0
0
The operation of this program is meaningless. The program will be used instead to explain program
structure as it pertains to conditional assembly.The deÞne DEBUG on the Þrst line selects DEBUG as a
condition by deÞning the identiÞer DEBUG. In the assembly control block starting with #ifdef
DEBUG on line 13, the instructions between #ifdef to #else will be assembled if DEBUG has been
deÞned, and the instructions between #else to #endif will be assembled if DEBUG is undeÞned. In this
example DEBUG was deÞned on line 1, so the instructions in the deÞned block will be assembled.
This program also uses a macro control directive. Lines 4 to 8 are the macro deÞnition. The macro's
name is dat_set, and it has two parameters (adr, dat).
46
Conditional Assembly And Linking
Chapter 3 Introduction To Operation
Assemble and link
Assemble and link the program that you have created.
A>AS102L00 -g PROGRAM5
A>LD102L00 -m -g -T_CODE=80000 PROGRAM5
A>AS102L00 -l -a PROGRAM5 PROGRAM5
The Þrst assembly generates the relocatable object Þle PROGRAM5.RF. The second assembly
generates the Þnal list Þle PROGRAM5.LST.
Assembling And Linking Multiple Sections 47
Chapter 3 Introduction To Operation
The contents of the Þnal list Þle PROGRAM5.LST are as follows.
A>TYPE PROGRAM5.LST
***
Loc
mn102L00
Object
080000
080005
080007
F474080008
8011
00
080008
08000A
0000
0000
ROM size is
No errors in
No warnings
524300(Hex.
this assembly
in this
*** Symbol
00080000
00080008
00080008
0008000A
00080000
Table ***
A_CODE
A_DATA
T data1
D data2
T main
Cross
Line
1
2
3
4
5
6
7
8
9
10
11
12
13
M14
14+
14+
14+
15
XX
17
18
19
20
21
22
PROGRAM5.
Assembler
Source
#define
*
dat_set
LST
***
Page1
DEBUG
macro
mov
mov
mov
endm
adr, dat
adr, A0
dat, D0
D0, (A0)
section
CODE, PUBLIC, 2
DEBUG
dat_set
mov
mov
mov
data1, 0x11
data1, A0
0x11, D0
D0, (A0)
dat_set
data1, 0x22
section
dw
dw
end
DATA, PUBLIC, 2
0
0
.LST
Page2
*
_CODE
main
#ifdef
#else
#endif
_DATA
data1
data2
0008000C)
assembly
PROGRAM5
Line number 14 extends over four lines. This indicates lines where macro expansion has been
performed. An 'M' is added before the line number where the macro instruction statement is shown,
and a '+' is added after the line numbers where the instruction statements from macro expansion are
shown.DEBUG has been deÞned, so the block between #ifdef-#else was assembled. There is no line
16, which has become XX. This indicates a statement that was not assembled because a condition was
not fulÞlled.
48
Assembling And Linking Multiple Sections
Chapter 3 Introduction To Operation
Select false condition, assemble, and link
Make the deÞne source statement line into a comment line, or just delete it. Then assemble and link
with the same procedure as before.
A>AS102L00 -g PROGRAM5
A>LD102L00 -m -g -T_CODE=80000 PROGRAM5
A>AS102L00 -l -a PROGRAM5 PROGRAM5
Assembling And Linking Multiple Sections 49
Chapter 3 Introduction To Operation
The contents of the Þnal list Þle PROGRAM5.LST are as follows.
A>TYPE PROGRAM5.LST
***
Loc
mn102L00
Object
080000
080005
080007
F474080008
8022
00
080008
08000A
0000
0000
ROM size is
No errors in
No warnings
524300(Hex.
this assembly
in this
*** Symbol
00080000
00080008
00080008
0008000A
00080000
Table ***
A_CODE
A_DATA
T data1
D data2
T main
Cross
Line
1
2
3
4
5
6
7
8
9
10
11
12
13
XX
15
M16
16+
16+
16+
17
18
19
20
21
22
PROGRAM5.
Assembler
Source
#define
*
dat_set
LST
***
DEBUG
macro
mov
mov
mov
endm
adr, dat
adr, A0
dat, D0
D0, (A0)
section
CODE, PUBLIC, 2
DEBUG
dat_set
data1, 0x11
dat_set
mov
mov
mov
data1, 0x11
data1, A0
0x22, D0
D0, (A0)
section
dw
dw
end
DATA, PUBLIC, 2
0
0
.LST
Page2
*
_CODE
main
#ifdef
#else
#endif
_DATA
data1
data2
0008000C)
assembly
PROGRAM5
Line 14 has become XX, and line 16 has been assembled instead.
50
Assembling And Linking Multiple Sections
Page1
Chapter 3 Introduction To Operation
Specify assembly conditions in the command
Until this point the condition has been speciÞed by deÞne in the source Þle, but it has been bothersome
to edit the source Þle each time. The explanation below describes how to directly specify conditions
with command options. This operation is valid only with regards to #ifdef.
In the previous Þle, you either deleted the deÞne line or made it into a comment, so you can use it to
once again select the true condition.
A>AS102L00 -g -D DEBUG PROGRAM5
A>LD102L00 -m -g -T_CODE=80100 PROGRAM5
A>AS102L00 -l -a PROGRAM5 -D DEBUG PROGRAM5
D option
Option to specify an identiÞer (DEBUG), having the same effect as specifying
deÞne DEBUG in the source Þle.
Assembling And Linking Multiple Sections 51
Chapter 3 Introduction To Operation
The contents of the Þnal list Þle PROGRAM5.LST are as follows.
A>TYPE PROGRAM5.LST
***
Loc
mn102L00
Object
080100
080105
080107
F474080008
8011
00
080108
08010A
0000
0000
ROM size is
No errors in
No warnings
524556(Hex.
this assembly
in this
*** Symbol
00080100
00080108
00080108
0008010A
00080100
Table ***
A_CODE
A_DATA
T data1
D data2
T main
Cross
Line
1
2
3
4
5
6
7
8
9
10
11
12
13
M14
14+
14+
14+
15
XX
17
18
19
20
21
22
PROGRAM5.
Assembler
Source
#define
*
dat_set
LST
***
Page1
DEBUG
macro
mov
mov
mov
endm
adr, dat
adr, A0
dat, D0
D0, (A0)
section
CODE, PUBLIC, 2
DEBUG
dat_set
mov
mov
mov
data1, 0x11
data1, A0
0x11, D0
D0, (A0)
dat_set
data1, 0x22
section
dw
dw
end
DATA, PUBLIC, 2
0
0
.LST
Page2
*
_CODE
main
#ifdef
#else
#endif
_DATA
data1
data2
0008010C)
assembly
PROGRAM5
Line number 14 was assembled. Check for yourself that omitting -D DEBUG will assemble line
number 16 instead. This technique enables the programmer to freely choose assembly conditions with
command option speciÞcations.
Other assembly options include suppression of output to the list Þle of source statements in unselected
conditions, and output of the relocatable object Þle to other directories. Refer to chapter 5, "Using The
Assembler",and chapter 6, "Using The linker", for details.
52
Assembling And Linking Multiple Sections
Chapter 3 Introduction To Operation
3.6
Error Correction Using Tag Jumps
This section describes a convenient way to Þx errors. When code mistakes, syntax errors, or other
errors and warnings occur in a source Þle, further development cannot proceed unless they are Þxed.
In long source Þles, it can be a lot of work to Þnd the source statements in which errors and warnings
were detected.
The error correction method described in this section uses the tag jump function of editors such as
MIFESTM, etc.
This assumes the necessity of an error Þle that incorporates tag jumps.
Assembler error messages implement the tag jump function. When the assembler detects an error, it
outputs an error message to the display. It will also output error messages to the list Þle if the l option
was speciÞed.
When the l option has not been speciÞed and the assembler detects errors, you can assemble again such
that errors are not displayed to the screen but are redirected to an error Þle that the assembler generates.
The list Þle will include correct source statements in which errors were not detected, while the Þle
created by redirection will consist only of source statements in which errors were detected. It is
accordingly faster to access the Þle created by redirection when the source Þle is large.
Generate error file
The example below shows the generation of an error Þle (ERROR) by redirection. This example
assembles MAIN.ASM and outputs error messages to the Þle ERROR instead of the screen.
First assemble a Þle that actually includes errors and generate an error Þle. The following source Þle
(MAIN.ASM) includes two errors and one warning.
_CODE
data
main
section
equ
CODE, PUBLIC, 2
-1
mov
move
mov
0x11, D0
0x11, D0
D0, (data)
main
end
The assembler will detect the errors, so it will generate an error Þle by redirection.
A>AS102L00 MAIN > ERROR
Error Correction Using Tag Jumps 53
Chapter 3 Introduction To Operation
The contents of the generated error Þle are as follows.
A>TYPE ERROR
PanaX Series
(c)Copyright
MAIN.ASM
MN102L00 Assembler
1994 Panasonic/KWC
for linear Version3.1 Release1.1.1
MAIN.ASM(7):
5
Error
2000:
F440FFFFFF 6
Warning 2054:
7
Error
2003:
move
Incorrect assembler
mov
Illegal RAM address
main
Symbol defined
ROM size is 7
2 errors in
1 warnings in
(Hex. 00000007)
this assembly
this assembly
MAIN. ASM(5):
000002
MAIN.ASM(6):
0x11, D0
syntax.
D0, (data)
used
twice
This example assumes use of MIFES with a PC-9800 series computer. Start up MIFES and open two
Þles.
A>MI
MAIN.ASM ERROR
The contents of the Þle ERROR will be displayed on the screen.
PanaX Series
(c)Copyright
MAIN.ASM
MN102L00 Assembler
1994 Panasonic/KWC
for linear Version3.1 Release1.1.1
MAIN.ASM(7):
5
Error
2000:
F440FFFFFF 6
Warning 2054:
7
Error
2003:
move
Incorrect assembler
mov
Illegal RAM address
main
Symbol defined
ROM size is 7
2 errors in
1 warnings in
(Hex. 00000007)
this assembly
this assembly
MAIN. ASM(5):
000002
MAIN.ASM(6):
54
Error Correction Using Tag Jumps
0x11, D0
syntax.
D0, (data)
used
twice
Chapter 3 Introduction To Operation
Tag jumps
The Þrst error message matches this display on the screen.
MAIN. ASM(5): Error 2000: Incorrect assembler syntax.
This line works with tag jumps regardless of the character positions on screen.
Look at the display of function key F10 on the CRT screen. It should be [Tag JP]. This key speciÞes a
tag jump, so try pressing F10. The screen will switch, and the cursor will be placed at the source Þle
statement in which the error was detected.
_CODE
data
main
section
equ
CODE, PUBLIC, 2
-1
mov
move
mov
0x11, D0
0x11, D0
D0, (data)
main
end
Fix errors
The cursor will be located on the Þfth line. Fix the error here.
Change move to mov. That alone Þxes the line. Switch the screen again to the error Þle.
Return to error file
To return to the error Þle, press the HOME CLR key (above and to the left of the period key).
When the screen switches to the error Þle, the cursor will move to the next error line.
MAIN.ASM(6):Warning 2054:Illegal RAM address used.
This is a warning, not an error. You can see the problem by looking at the machine language code
generated in the list Þle. The assembler processed assuming an address of 0. Tag jumps are valid here
as well.
Press F10 for the source screen.
By repeating this procedure, you can Þx all the errors.
Error Correction Using Tag Jumps 55
Chapter 3 Introduction To Operation
Uncorrectable errors
Some errors cannot be easily corrected. In some cases there are too many labels, exceeding the label
registrations provided by the assembler. This kind of error must be Þxed by changing an initial value of
the assembler or by deleting labels.
Use the PAINST.EXE installer to change initial values of the assembler. You can avoid errors by
customizing the assembler. Refer to chapter 1, "Installation," regarding customization.
Supplemental Explanation:
You can use other editors that support tag jumps (VZ EditorTM, RED++TM).
56
Error Correction Using Tag Jumps
Chapter 4
Optimization
4
Chapter 4 Optimization
4.1
Purpose Of This Chapter
The assembler and linker evaluate source statements coded as conditional branch instructions,
unconditional branch instructions, subroutine call instructions, data move instructions, arithmetic
instructions, and comparison instructions, and then select the optimal instructions that shorten
instruction codes to the maximum possible extent. This is called optimization.
This chapter uses examples to explain what optimization is.
NOTE:
58
Purpose of This Chapter
The assembler and linker make changes to object code, not instruction
mnemonics. Pay close attention to this point when viewing list files. When an @
is displayed before a line number in the list file, it indicates that the statement has
been optimized.
Chapter 4 Optimization
4.2
Rules Of Usage
To use the optimization function, optimization must be turned on by using the Ot option or by placing
an opt directive at the start of the source Þle.
opt
on
NOTE:
Optimization is off by default.
Rules of Usage
59
Chapter 4 Optimization
4.3
Usage Example
Optimization Instructions
The conditional branch instructions, unconditional branch instructions, subroutine call instructions,
move instructions, arithmetic instructions, and comparison instructions shown below will be objects of
optimization.
Table 4-1 Optimized Conditional Branch Instructions
Instruction
BLT LABEL
BGT LABEL
BGE LABEL
BLE LABEL
BCS LABEL
BHI LABEL
BCC LABEL
BLS LABEL
BEQ LABEL
BNE LABEL
BVC LABEL
BVS LABEL
BVC LABEL
BNS LABEL
BLTX LABEL
BGTX LABEL
BLEX LABEL
BCSX LABEL
BHIX LABEL
BCCX LABEL
BLSX LABEL
BEQX LABEL
BNEX LABEL
BVCX LABEL
BVSX LABEL
BVSX LABEL
BNCX LABEL
BNSX LABEL
60
Usage Example
Type
Relative branch
instruction
Branch Range
Branch within -128 to +127 bytes of the PC.
Chapter 4 Optimization
Table 4-2 Optimized Unconditional Branch Instructions
Instruction
BRA LABEL
JMP LABEL
JSR LABEL
Type
Branch Range
Relative branch
instrction
Absolute branch
instruction
Branch within -128 to +127 bytes of the PC
Branch within the 16M-byte memory space.
Table 4-3 Optimized Data Move Instructions
Instruction
MOV An, (abs)
MOV Dn, (abs)
MOV (abs), An
MOV (abs), Dn
MOVB Dn, (abs)
MOVBU (abs), Dn
MOV An, (d, An)
MOV Dn,(d, An)
MOV (d, An), An
MOV (d, An), Dn
MOVB Dn, (d, An)
MOVB (d, An),Dn
MOVBU (d, An), Dn
MOVX Dn, (d,An), Dn
MOVX (d, An), Dn
MOV imm, An
MOV imm, Dn
Type
Absolute addressing
Branch Range
16M-byte memory space
Register relative indirect
addressing
16M-byte memory space.
Immediate addressing
24-bit immediate data.
Table 4-4 Optimized Arithmetic Instructions
Instruction
ADD
ADD
SUB
SUB
imm, An
imm, Dn
imm, An
imm, Dn
Type
Immediate addressing
Branch Range
24-bit immediate data
Table 4-5 Optimized Comparison instructions
Instruction
CMP imm, An
CMP imm, Dn
Type
Immediate addressing
Branch Range
24-bit imediate data.
Usage Example
61
Chapter 4 Optimization
Optimixation processing
The assembler informs the linker about all instructions to be optimized. Based on the information from
the assembler, the linker outputs instruction codes with the smallest code size.
Optimization processing of conditional branch instructions
The linker resolves address values for labels when linking multiple Þles. In the example below, the
linker will determine whether or not the LABEL coded as an operand is within the allowable range of
the current instruction. If not in range, then the linker will replace it with instructions for a wider
branch range.
Take the BEQ instruction for example.
BEQ
LABEL
......
LABEL
The destination label of the BEQ instructions must be in the range -128 to +127. However, the
assembler cannot make that determination, so the following determinations are made during assembly
and linking.
Assembler processing
The assembler outputs information about instructions to be optimized to the linker.
Linker processing
1. The linker inputs information from the assembler.
2. The linker determines if the branch destinations of conditional branches are in range.
3. If determined to be in range, then the linker generates the normal code.
4. If determined to be not in range, then the linker will substitute code that can branch correctly.
The substitution for the above example would be as follows.
BNE
*+5
JMP
LABEL
......
LABEL
62
Usage Example
Chapter 4 Optimization
Table 4-6 Substituted Instructions For Conditional/Unconditional Branch Instructions
Source Instrudtion
Candidate instruction 1
Candidate instruction 2
BLT LABEL
BRA LABEL
BGT LABEL
BGT LABEL
BGE LABEL
BGE LABEL
BLE LABEL
BLE LABEL
BCS LABEL
BCS LABEL
BHI LABEL
BHI LABEL
BCC LABEL
BCC LABEL
BLS LABEL
BLS LABEL
BEQ LABEL
BEQ LABEL
BNE LABEL
BNE LABEL
BVC LABEL
BVC LABEL
BVS LABEL
BVS LABEL
BNC LABEL
BNC LABEL
BNS LABEL
BNS LABEL
BLTX LABEL
BLTX LABEL
BGTX LABEL
BGTX LABEL
BGEX LABEL
BGEX LABEL
BLEX LABEL
BLEX LABEL
BCSX LABEL
BCSX LABEL
BHIX LABEL
BHIX LABEL
BCCX LABEL
BCCX LABEL
BLSX LABEL
BLSX LABEL
BEQX LABEL
BEQX LABEL
BNEX LABEL
BNEX LABEL
BVCX LABEL
BVCX LABEL
BGE *+5
JMP LABEL
BLE *+5
JMP LABEL
BLT *+5
JMP LABEL
BGT * +5
JMP LABEL
BCC *+5
JMP LABEL
BLS *+5
JMP LABEL
BCS *+5
JMP LABEL
BHI *+5
JMP LABEL
BNE *+5
JMP LABEL
BEQ *+5
JMP LABEL
BVS *+6
JMP LABEL
BVC *+6
JMP LABEL
BNS *+6
JMP LABEL
BNC *+6
JMP LABEL
BGEX *+6
JMP LABEL
BLEX *+6
JMP LABEL
BLTX *+6
JMP LABEL
BGTX *+6
JMP LABEL
BCCX *+6
JMP LABEL
BLSX *+6
JMP LABEL
BCSX *+6
JMP LABEL
BHIX *+6
JMP LABEL
BNEX *+6
JMP LABEL
BEQX *+6
JMP LABEL
BVSX *+6
JMP LABEL
Candidate instruction 3
BGE *+7
JMP LABEL
BLE *+7
JMP LABEL
BLT *+7
JMP LABEL
BGT *+7
JMP LABEL
BCC *+7
JMP LABEL
BCC *+7
JMP LABEL
BCS *+7
JMP LABEL
BHI *+7
JMP LABEL
BNE *+7
JMP LABEL
BEQ *+7
JMP LABEL
BVS *+8
JMP LABEL
BVC *+8
JMP LABEL
BNS *+8
JMP LABEL
BNC *+8
JMP LABEL
BGEX *+8
JMP LABEL
BLEX *+8
JMP LABEL
BLTX *+8
JMP LABEL
BGTX *+8
JMP LABEL
BCCX *+8
JMP LABEL
BLSX *+8
JMP LABEL
BCSX *+8
JMP LABEL
BHIX *+8
JMP LABEL
BNEX *+8
JMP LABEL
BEQX *+8
JMP LABEL
BVSX *+8
JMP LABEL
Usage Example
63
Chapter 4 Optimization
Table 4-6 Substituted Instructions For Conditional/Unconditional Branch Instructions
Source Instrudtion
Candidate instruction 1
Candidate instruction 2
BVSX LABEL
BVSX LABEL
BNCX LABEL
BNCX LABEL
BNSX LABEL
BNSX LABEL
BVCX *+6
JMP LABEL
BNSX *+6
JMP LABEL
BNCX *+6
JMP LABEL
Candidate instruction 3
BVCX *+8
JMP LABEL
BNSX *+8
JMP LABEL
BNCX *+8
JMP LABEL
Optimization processing of unconditional branch instructions
If the branch destination of a JMP LABEL unconditional branch instruction is within the range of the
relative branch instruction BRA LABEL, then it will be replaced by BRA LABEL.
Therefore, regardless of whether the JMP instruction or BRA instruction is used, the linker will output
the optimal unconditional branch.
Table 4-7 Substituted Instructions For Unconditional Branch Instructions.
Source Instruction
BRA
JMP
JSR LABEL
64
Usage Example
Candidate Instruction1
BRA D8
BRA D8
JSR LABEL
Candedate Instruction2
JMP d16
JMP d16
JSR LABEL
Candidate Instruction3
JMP d24
JMP d24
Chapter 4 Optimization
Optimization of data move, arithmetic and comparison instructions
Data move, arithmetic, and comparison instructions will be replaced by instructions of the optimal bit
length when operating on immediate data, memory addresses, and relative data. In this manner optimal
code will be output without the user distinguishing between each instruction variation.
Table 4-8 Substituted Instructions For Data Move, Arithmetic, Comparison Instructions
Source instruction
Candidate instruction 1
Candidate instruction 2
Candidate instruction 3
ADD imm, An
ADD imm8, An
ADD imm16, An
ADD imm24, An
ADD imm, Dn
ADD imm8, Dn
ADD imm16, Dn
ADD imm24, Dn
SUB imm, An
SUB imm16, An
SUB imm24, An
SUB imm, Dn
SUB imm 16, Dn
SUB imm24, Dn
CMP imm, An
CMP imm16, An
CMP imm24, An
CMP imm, Dn
CMP imm8, Dn
CMP imm16, Dn
MOV An, (abs)
MOV An, (abs16)
MOV An, (abs24)
MOV Dn, (abs)
MOV Dn, (abs16)
MOV Dn, (abs24)
MOV (abs), An
MOV (abs16), An
MOV (abs)24, An
MOV (abs), Dn
MOV (abs16), Dn
MOV (abs)24, Dn
MOV An, (d, An)
MOV An, (D8, An)
MOV An, (d16, An)
MOV An, (d24, An)
MOV Dn, (d, An)
MOV Dn, (D8, An)
MOV Dn, (d16, An)
MOV Dn, (d24, An)
MOV (d, An), An
MOV (D8, An), An
MOV (d16, An), An
MOV (d24, An), An
MOV (d, An), Dn
MOV (D8, An), Dn
MOV (d16, An), Dn
MOV (d24, An), Dn
MOVB Dn, (abs)
MOVB Dn, (abs16)
MOVB Dn, (abs24)
MOVB Dn, (d, An)
MOVB Dn, (D8, An)
MOVB Dn, (d16, An)
MOVB Dn, (d24, An)
MOVB (d, An), Dn
MOVB (d8, An), Dn
MOVB (d16, An), Dn
MOVB (d24, An), Dn
MOVBU (abs), Dn
MOVBU (A8), Dn
MOVBU (abs16), Dn
MOVBU (abs24), Dn
MOVBU (d, An), Dn
MOVBU (D8, An), Dn
MOVBU (d16, An), Dn
MOVBU (d24, An), Dn
MOV imm, Dn
MOV imm16, An
MOV imm24, An
MOV imm, Dn
MOV imm8, Dn
MOV imm16, Dn
MOV imm24, Dn
MOVX Dn,(d, An)
MOVX Dn, (D8, An)
MOVX Dn,(d16, An)
MOVX Dn, (d24, An)
movx (d, An), Dn
MOVX (D8, An), Dn
MOVX (d16, An),Dn
MOVX (d24, An), Dn
CMP imm24, Dn
Usage Example
65
Chapter 4 Optimization
Example: Branch Destination of Conditional Branch Instruction Within Range
This example shows a branch in the permitted range (-128 to 127 of PC) of a BCC LABEL conditional
branch instruction.
The source list is as follows.
_CODE
opt
on
section
CODE, PUBLIC,2
mov
0, D2
cmp
D1, D2
bcc
func_end
org
addr_set+127
sub_func
addr_set
func_end
rts
end
The final list file after assembly is shown next. The start address during linking is assumed to be 1000
(hex). The @ mark on line number 6 indicates that the instruction was the object of optimization. Here
the branch of BCC LABEL is within range, so the code has not been changed.
***
Loc
mn102L00
081000
081002
081004
Object
8A00
F396
E67F
Cross
Line
1
2
3
4
5
@6
7
8
9
10
11
PROGRAM4.
Assembler
Source
_CODE
sub_func
FE
ROM size is
No errors in
No warnings
528522
this
in this
(Hex. 0008108A)
assembly
assembly
*** Symbol
00081000
00081006
00081085
00081000
Table
A_CODE
T addr_
T func_
T sub_
***
Usage Example
section
CODE, PUBLIC, 2
mov
cmp
bcc
0, D2
D1, D2
func_end
org
addr_set+127
func_end
rts
end
OPT2
66
Page1
addr_set
081089
set
end
func
LST
***
.LST
Page2
Chapter 4 Optimization
Example: Unconditional Branch Instruction Converted To Relative Branch
This example shows a branch outside the permitted range (-128 to +127 of PC) of a BCC LABEL
conditional branch instruction.
The source list is as follows.
_CODE
opt
on
section
CODE, PUBLIC,2
jmp
func_end
org
addr_set+127
sub_func
addr_set
func_end
rts
end
The final list file after assembly is shown next. LABEL exceeds the permitted branch range of BCC
LABEL, so the code has been converted to BCS *+5, JMP LABEL. Note that the mnemonics and object
code are different.
***
Loc
mn102L00
Object
081000
EA7F
081081
FE
ROM size is
528514
Cross
Line
1
2
3
@4
5
6
7
8
9
PROGRAM4.
Assembler
Source
LST
***
Page1
opt
on
section
_CODE
sub_func
CODE, PUBLIC, 2
jmp
func_end
org
addr_set+127
addr_set
func_end
rts
end
00081082)
(Hex.
No errors in
No warnings
in
this
this
***
Table
***
A_CODE
T addr_
T func_
T sub_
assembly
assembly
OPT3
Symbol
00081000
00081006
00081085
00081000
.LST
Page2
set
end
func
Usage Example
67
Chapter 4 Optimization
Example: Unconditional Branch Instruction Converted To Absolute Branch
This example shows the branch destination of a JMP LABEL unconditional branch instruction within
the permitted range (-128 to +127 of PC) for relative branching.
The source list is as follows.
_CODE
opt
on
section
CODE, PUBLIC,2
bra
func_end
org
addr_set+128
sub_func
addr_set
func_end
rts
end
The final list file after assembly is shown next. The branch destination of the JMP LABEL instruction
on line number 4 is in the permitted range for relative branching, so it has been converted to BRA
LABEL. Note that the mnemonics and object code are different.
***
Loc
mn102L00
Object
081000
FC8000
081083
FE
ROM size is
528516
Cross
Line
1
2
3
@4
5
6
7
8
9
PROGRAM4.
Assembler
Source
LST
***
Page1
opt
on
section
_CODE
sub_func
bra
func_end
org
addr_set+128
addr_set
func_end
rts
end
00081084)
(Hex.
No errors in
No warnings
in
this
this
***
Table
***
A_CODE
T addr_
T func_
T sub_
assembly
assembly
OPT4
Symbol
00081000
00081003
00081083
00081000
68
Usage Example
set
end
func
CODE, PUBLIC, 2
.LST
Page2
Chapter 4 Optimization
Optimization of complex branch instructions
For the complex branch instructions, optimizations of both conditional branch and comparison
instructions are performed simultaneously. That is, the source instructions will be replaced by
instructions of the optimal branch range and the optimal bit length.
Table 4-9 Substituted Instructions for Complex Branch Instructions
Source instruction
CBEQ
imm8,(abs),LABEL
CBNE
imm8,(abs),LABEL
TBZ
(abs)bp,LABEL
Candidate
instruction 1
Candidate
instruction 2
CBEQ
imm8,(abs8),LABE
L
(LABEL=d8+PC)
CBEQ
imm8,(abs8),LABE
L
(LABEL=d12+PC)
CBNE
imm8,(abs8),LABE
L
(LABEL=d8+PC)
TBZ
(abs8)bp,LABEL
(LABEL=d8+PC)
CBNE
imm8,(abs8),label
JMP LABEL
label:
(LABEL=abs18)
CBEQ
CBEQ
imm8,(abs16),LABE imm8,(abs16),LABE
L
L
(LABEL=d12+PC)
(LABEL=d8+PC)
CBEQ
imm8,(abs8),label
JMP LABEL
label:
(LABEL=abs18)
CBNE
CBNE
imm8,(abs16),LABE imm8,(abs16),LABE
L
L
(LABEL=d12+PC)
(LABEL=d8+PC)
TBNZ
(abs8)bp,LABEL
(LABEL=d8+PC)
Candidate
instruction 4
CBNE
imm8,(abs16),label
JMP LABEL
label:
(LABEL=abs18)
CBNE
imm8,(abs8),LABE
L
(LABEL=d12+PC)
TBZ
(abs8)bp,LABEL
(LABEL=d12+PC)
CBEQ
imm8,(abs16),label
JMP LABEL
label:
(LABEL=abs18)
TBNZ
(abs8)bp,LABEL
(LABEL=d12+PC)
TBNZ (abs8)bp,label
JMP LABEL
label:
(LABEL=abs18)
TBZ
TBNZ
(abs16)bp,LABEL
(abs16)bp,label
(LABEL=d12+PC)
JMP LABEL
label:
(LABEL=abs18)
TBZ (abs8)bp,label
JMP LABEL
label:
(LABEL=abs18)
TBNZ
(abs16)bp,LABEL
(LABEL=d8+PC)
TBNZ
(abs16)bp,LABEL
(LABEL=d12+PC)
TBZ
(abs16)bp,LABEL
(LABEL=d8+PC)
TBNZ
(abs)bp,LABEL
Candidate
instruction 3
TBNZ
(abs16)bp,label
JMP LABEL
label:
(LABEL=abs18)
Usage Example
69
Chapter 4 Optimization
Optimization of subroutine call instructions
The linker converts subroutine calls (JSR) to the 16 subroutines with the highest frequencies of
appearance to their vector indirect versions (JSRV). Normally this form of optimization automatically
applies to all JSR instructions, but it is also possible to modify the process to force conversion for
speciÞc functions with vecton directives and prohibit conversion for other functions with vectoff
directives. Conversion to the vector indirect versions is limited to functions called a minimum of three
times. When there are multiple functions with the same frequency of appearance eligible for the 16th
position in the vector table, the one with the highest address takes precedence.
NOTE:
The frequencies represent counts based on a static analysis of the source code.
Thus the linker counts a JSR instruction inside a loop only once even though a
dynamic analysis would indicate that the same instruction would be repeated
multiple times during actual execution of the loop.
70
Usage Example
Chapter 4 Optimization
4.3.1
Usage Example
Branch destination of conditional branch instruction within range
This example shows a branch in the permitted range (-1024 to +1023.5 of PC) of a BCC LABEL
conditional branch instruction.
The source list is as follows.
_CODE
opt
on
section
CODE, PUBLIC, 0
mov
0, D2
cmp
D1, D2
bcc
func_end
org
addr_set+1023.5
sub_func
addr_set
func_end
rts
end
Usage Example
71
Chapter 4 Optimization
The Þnal list Þle after assembly is shown next. The start address during linking is assumed to be 4100
(hex). The @ mark on line number 6 indicates that the instruction was the object of optimization. Here
the branch of BCC LABEL is within range, so the code has not been changed.
OPT1LST
***
mn101C101d0 Cross
0
Loc
Object
Line
Assembler
***
Source
1
2
_CODE
3
sub_func
opt
on
section
CODE, PUBLIC,0
004100
AA00
4
mov
0,D2
004102
326
5
cmp
D1, D2
004103_
9CFF7
@6
bcc
func_end
org
addr_set+1023.5
7
addr_set
8
9
004505_
01
func_end
10
rts
11
end
ROM size is
1031
No error in
this
(Hex.
00000407)
assembly
No warning
in this
this assembly
opt1.LST
72
Page1
*** Symbol
Table
00004100
T _CODE
00004106
T addr_set
00004505_
T func_end
00004100
T sub_func
Usage Example
***
Page 2
Chapter 4 Optimization
Branch destination of conditional branch instruction out of range
This example shows a branch outside the permitted range (-1024 to +123.5 of PC) of a BCC LABEL
conditional branch instruction.
The source list is as follows.
_CODE
opt
on
section
CODE, PUBLIC, 0
mov
0, D2
cmp
D1, D2
bcc
func_end
org
addr_set+1024
sub_func
addr_set
func_end
rts
end
Usage Example
73
Chapter 4 Optimization
The Þnal list Þle after assembly is shown next. LABEL exceeds the permitted branch range of BCC
LABEL, so the code has been converted to BCS *+5, JMP LABEL. Note that the mnemonics and
object code are different.
OPT2LST
***
mn101C101d00
Loc
Object
Cross
Assembler
Line
Source
1
opt
2
_CODE
3
sub_func
004100
AA00
4
004102
326
5
004103_
8D7039090547 @6
7
section
cmp
D1, D2
func_end
org
addr_set+1023.5
addr_set
func_end
01
10
rts
11
end
ROM size is
1034
(Hex. 0000040A)
No error in
this
assembly
No warning
in this
assembly
*** Symbol
Table
00004100
T _CODE
00004109
T addr_set
00004509
T func_end
00004100
T sub_func
opt2.LST
74
Usage Example
0,D2
bcc
004509
***
on
CODE, PUBLIC,0
mov
8
9
Page1
***
Page 2
Chapter 4 Optimization
Unconditional branch instruction converted to relative branch
This example shows the branch destination of a JMP LABEL unconditional branch instruction within
the permitted range (-1024 to +1023.5 of PC) for relative branching.
The source list is as follows.
_CODE
opt
on
section
CODE, PUBLIC, 0
jmp
func_end
cmp
D1, D2
bcc
func_end
org
addr_set+1023.5
sub_func
addr_set
func_end
rts
end
The Þnal list Þle after assembly is shown next. The branch destination of the JMP LABEL instruction
on line number 4 is in the permitted range for relative branching, so it has been converted to BRA
LABEL. Note that the mnemonics and object code are different.
Usage Example
75
Chapter 4 Optimization
OPT3LST
***
mn101C101D0 Cross
0
Loc
Object
Line
Assembler
Source
1
004100
99FF7
2
_CODE
3
sub_func
@4
5
01
8
ROM size is
1027
(Hex.
No error in
this
assembly
No warning
in this
assembly
*** Symbol
Table
00004100
T _CODE
00004102_
T addr_set
00004502
T func_end
00004100
T sub_func
9
jmp
func_end
cmp
D1, D2
org
addr_set+1023.5
rts
org
end
00000403)
opt3.LST
76
on
CODE, PUBLIC,0
func_end
004502
***
opt
section
addr_set
6
7
Page1
***
Page 2
addr_set+1023.5
Chapter 4 Optimization
Unconditional branch instruction converted to absolute branch
This example shows the branch destination of a BRA LABEL unconditional branch instruction outside
the permitted range (-1024 to +1023.5 of PC) for relative branching.
The source list is as follows.
_CODE
opt
on
section
CODE, PUBLIC, 0
bra
func_end
org
addr_set+1024
sub_func
addr_set
func_end
rts
end
The Þnal list Þle after assembly is shown next. The branch destination of the BRA LABEL instruction
on line number 4 is outside the permitted range for relative branching, so it has been converted to JMP
LABEL. Note that the mnemonics and object code are different.
OPT4LST
***
mn101C101D0 Cross
0
Loc
Object
Line
Assembler
Source
1
004100
3913054
2
_CODE
3
sub_func
@4
5
004503_
01
No warning
in this
assembly
(Hex.
T addr_set
T func_end
00004100
T sub_func
org
addr_set+1024
00000405)
opt4.LST
00004503_
func_end
end
assembly
00004103_
bra
rts
this
T _CODE
CODE, PUBLIC,0
9
1029
Table
section
8
No error in
00004100
on
func_end
ROM size is
*** Symbol
opt
addr_set
6
7
Page1
***
Page 2
***
77
Chapter 4 Optimization
78
Chapter 5
Using Assembler
5
Chapter 5 Using Assembler
5.1
Purpose of This Chapter
This chapter explains operation of the Cross-Assembler. Many options are provided by the assembler.
This chapter includes examples to aid its explanations.
Assembler operation can be classiÞed into three target uses.
¥
Normal assembly
¥
Generation of Þnal list Þle with resolved addresses
¥
Display of help screen for assembler operation
The appropriate object is decide by specifying options.
80
Purpose of This Chapter
Chapter 5 Using Assembler
5.2
Starting Assembler
The assembler is started by entering a command name and parameters, just as for other MS-DOS
external commands.
General format of commands
Below is the general format of the command to use when starting the assembler.
AS102L [options] source_filename
Contents of brackets [ ] may be omitted.
Specifying options
An option starts with a slash (/) or hyphen (-) as the options speciÞer, followed by a character that
indicate the particular option.
/l or -l
Option speciÞcations are case sensitive, so upper case and lower case letters must be speciÞed
correctly.
-Lc
Single-character options not accompanied by parameters can be speciÞed as multiple characters
following the slash (/) or hyphen (-) option speciÞer. The order is optional.
/lcgrj or -crjgl
When an option is accompanied by a parameter and other options are to follow, add a space after the
parameter, and then follow with the slash (/) or hyphen (-) option speciÞer.
-IA:\USER\SOURCE
-Li -Lc
Parameters can be speciÞed right after the option character or separated by one space.
/w100 or -w
100
When options are omitted, assembly will be performed in accordance with the default interpretations
built in to the assembler. Refer to section 3.3, "Command Options", for default interpretations.
Starting Assembler
81
Chapter 5 Using Assembler
82
NOTE:
When path names are not specified, the assembler will assume that files are in
the current directory on the current drive. When only a source file path name and
file name are specified, the assembler will generate the list file and relocatable
object file in the source file's directory.
When the source file extension is omitted, the assembler will assume .ASM. The
following example will cause the source file name to be SAMPLE.ASM. The
assembler will generate the list file (SAMPLE.LST) and relocatable object file
(SAMPLE.RF) in the directory of the source file.
A>AS102L -l SAMPLE
When the source file is specified with a path name, the assembler will also
generate the list file and relocatable object file in the same directory as the
source file.
A>AS102L -l B:\USR\SAMPLE
By using the o option, you can generate the relocatable file in a directory other
than that of the source file.
A>AS102L -l -o B:\USER\BIN\SAMPLE.RF SAMPLE.ASM
The above example will assemble the source file (SAMPLE.ASM) in the current
directory, will output the list file (SAMPLE.LST) in the current directory, and will
output the relocatable object file (SAMPLE.RF) in the B drive's \USER\BIN
directory.
NOTE:
Windows 9X will be hung up if specifying a file name including a drive name which
is not connected to your computer under MS-DOS mode of Windows 9X.
C: >AS102L
-l
-0t
B: SAMPLE.ASM
( in case the drive B does not exist.)
Starting Assembler
Chapter 5 Using Assembler
Below is a list of options
.
Table 5-1 Assembler Options
Option Type
Symbol
Output Þle Options O Þle_name
l
c
Li
Lm
Ls
Lc
a map_Þle name
Xl
Error message
options
j
e
W number
Preprocessor
options
Wall
I path_name
D identiÞer
Program generation g Þle.
options
r
Other
Od
Ot
h
Description
Specify the relocatable object Þle name to be output.
Output a list Þle.
Append a cross-reference to the list Þle.
Do not output Þles included by include to the list Þle.
Do not output assembler source created by macro expansion
using macro or irp to the list Þle. Output only the machine
language code.
Do not output a symbol table to the list Þle.
Do not output source statements that were not assembled due
Read the map Þle to output a list Þle with resolved
addresses.
Output the list Þle to the same directory as the relocatable
object Þle.
Output error and warning messages in Japanese. Output will
be to the screen and, when a list Þle is speciÞed, to the list
Þle.
Output error and warning messages in English. Output will
be to the screen and, when a list Þle is speciÞed, to the list
Þle.
Do not output warning messages of the speciÞed number.
Output will not be performed to either the screen or list Þle.
Refer to chapter 10, "Error Messages", for warning
messages and their corresponding numbers
Do not output any warning messages.
SpeciÞes the path name of the directory that contains Þles
speciÞed by include.
Specifies an identifier to be used by ifdef during conditional
assembly.
Output debug information to the relocatable object Þle.
Output a relocatable object Þle even if errors are detected in
the source Þle.
Turn off optimization
Turn on optimization
Output help information about assembler options to the
screen
Starting Assembler
83
Chapter 5 Using Assembler
Assembler and linker directories
When the assembler is in the same directory as the source Þle, it can be speciÞed by a direct command.
When in a different directory, the assembler's directory must have been speciÞed with the PATH
command. The examples below assume the following directory hierarchy.
A:
\BIN
AS102L.EXE
LD102L.EXE
\TOOL
EDITOR
\USER
\SOURCE
\SAMPLE.ASM
\SAMPLE.LST
\OBJ
\SAMPLE.RF
Table 5-1 Command Directory Example
Assuming that the current directory is A:\USER\SOURCE, the assembler is started as follows.
A>PATH A:\BIN\102L00 -l -o A: \USER\OBJ\SAMPLE SAMPLE
A>PATH A: \BIN
A>AS102L -l -o A:\USER\OBJ\SAMPLE SAMPLE
84
Starting Assembler
or
Chapter 5 Using Assembler
5.3
Command Options
This section describes the options used by the assembler. The assembler has many options for
controlling assembler processing and Þle output.
Assembler operation can be divided into the three categories below based on the reason for its use.
Normal assembly
With section address format, the addresses of each section are determined by linking. Therefore unless
your intention is to output an error Þle, you cannot debug after assembly even if a list Þle is output by
the l option. The same holds for the c option.
Generation of Þnal list Þle with resolved addresses
When programs are in section address format, addresses are not resolved until after the program has
passed through the linker. To resolve them, you must generate a map Þle with the linker and then reassemble the source Þle using the generated map information, thereby generating a list Þle with
resolved addresses. Use the a and l options to do this.
Display of help screen
The h option will output assembler operation information to the screen.
Thus all options are not valid at the same time. Furthermore, even when some options are not speciÞed
the assembler will use pre-determined default values. The default values have been set to values that
are frequently used, so if the default values are acceptable then you can omit many option
speciÞcations. For details on default interpretations, refer the descriptions of the options in question.
Command Options
85
Chapter 5 Using Assembler
5.3.1
Output File Options
o file_name
Specify the relocatable object file name to be output
Functional description
The o option speciÞes the relocatable object Þle name to be output by the assembler. If the speciÞed
Þle already exists, then its previous contents will be erased. If a path name that does not exist is
speciÞed, then the assembler will display an error message and suspend processing.
If specifying an extension, the extension will be the speciÞed one.
If omitting an extension, the extension will be .RF.
o option type
generated files
-o test
-o test.rf
-o test.obj
test.rf
test.rf
test.obj
NOTE:
Because the @ symbol is used as the character for specifying parameter files, it
cannot be used as the first character of file names
Rules of use
The o option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
lower-case letter 'o', then either immediately followed by the Þle name or a space and the Þle name. If
the Þle is to be output to the current directory, then only the Þle name needs to be speciÞed. If the Þle
is to be output to a different directory, then both a path name and a Þle name must be speciÞed.
AS102L -o A:\USER\OBJ\TEST MAIN
Default speciÞcation
By default the assembler will generate a Þle with the source Þle name and extension .RF in the same
source directory as the source Þle.
If no path name is speciÞed for the source Þle, then the assembler will assume the current directory of
the current drive.
86
Command Options
Chapter 5 Using Assembler
Operation example
This example assembles a source Þle (SAMP1.ASM) in the current directory, and generates a
relocatable Þle with the name SAMP1.RF in the A drive's \USER\OBJ directory.
A>AS102L -o A:\USER\OBJ\SAMP1 SAMP1
PanaX Series MN102L00 Assembler Version 3.1 Release 1.1.1
(c)Copyright 1994 Panasonic/KMC
SAMP1.ASM
ROM size is 11 (Hex. 0000000B)
No error in this assembly
No warning in this assembly
A>DIR A:\USER\OBJ
Volume in
drive A:
Directory of
A:\USER\OBJ
.
is SYSTEM
<DIR>
..
93-06-21
<DIR>
SAMP1
RF
2277376
bytes free
267
11:55
93-06-21
11:55
93-06-21
11:56
3 file(s)
Command Options
87
Chapter 5 Using Assembler
I
Output a list file
Functional description
The l option outputs a list Þle. The Þle name of the list Þle will be the source Þle name with the
extension .LST. The list Þle will be generated in the same directory as the source Þle.
If any assembler errors are detected, then error information will also be written to the list Þle.
Refer to chapter 3, ÒIntroduction To OperationÓ, regarding high-level error correction using an editorÕs
tag jump functions\.
Rules of use
The l option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
lower-case letter 'l'. If multiple options without parameters are to be speciÞed, then they can all be
speciÞed after a single option speciÞcation character. A parameter following the option should be
delimited by a space before the next option starts.
AS102L -l SAMPLE
Default speciÞcation
No list Þle will be output.
88
Command Options
Chapter 5 Using Assembler
Operation example
This example assembles a source Þle (SAMP1.ASM) and generates a list Þle (SAMP1.LST) in the
same directory. You can see that both output Þles are generated in the same directory.
A>AS102L -l SAMP1
PanaX Series MN102L00 Assembler Version 3.2 Release 1.1.1
(c)Copyright 1994 Panasonic/KMC
SAMP1.ASM
ROM size is 11 (Hex. 0000000B)
No error in this assembly
No warning in this assembly
A>DIR SAMP1.*
Volume in
drive A:
is SYSTEM
Directory of
A:
\MN102L00
SAMP1
ASM
209
SAMP1
RF
267
93-06-21
11:54
SAMP1
LST
1144
93-06-21
11:54
93-06-21
11:07
3 file(s)
2269184 bytes free
Command Options
89
Chapter 5 Using Assembler
c
Output a cross-reference
Functional description
The c option outputs symbol reference information during assembly by appending it to the list Þle. If
the c option is speciÞed, then even when the l option is not speciÞed a list Þle will be generated
automatically.
The following information is written in the cross-reference.
¥
symbol names
¥
addresses, values assigned to symbols
¥
symbol types
¥
line numbers of source statements that reference or declare the symbols
If you create a program split between multiple Þles, then specify the cross-reference when you generate
the Þnal list Þle after having generated a map Þle with the linker. This allows you to create a list Þle
and cross-reference table with resolved addresses.
Rules of use
The c option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
lower-case letter 'c'. If multiple options without parameters are to be speciÞed, then they can all be
speciÞed after a single option speciÞcation character. A parameter following the option should be
delimited by a space before the next option starts.
AS102L -c SAMPLE
Default speciÞcation
No cross-reference will be output.
90
Command Options
Chapter 5 Using Assembler
Operation example
This example assembles a source Þle (SAMP1.ASM) with the c option and generates a list Þle
(SAMP1.LST). You can see that a cross-reference table will be appended to the list Þle.
The + before line numbers 4, 6, 7, and 9 indicates that the machine language code is not the Þnal code.
A>AS102L00 -c SAMP1
A>TYPE SAMP1.LST
SAMP1.LST
Page 1
***
mn102L00
Cross
Assembler
***
Loc
object
Line
Source
1
_CODE
2
main
section
CODE, PUBLIC,2
000000
8001
3
mov
1, D0
000002
F4E1000000
+4
mov
data, A0
000007
00
5
mov
D0, (A0)
000008
F4E1000000
+6
jsr
subr
00000D
EA00
R7
bra
main
00000F
F474000000
+9
mov
data, A0
000014
20
10
mov
(A0), D0
000015
8501
11
mov
1, D1
000017
F284
12
addc
D1, D0
000019
00
13
mov
D0, (A0)
00001A
FE
14
rts
8
subr
15
000000
0000
16
_DATA
section
DATA, PUBLIC, 2
17
data
dw
0
18
19
end
20
ROM size
is 29
(HEX.
0000001D)
No error
in this
assembly
No warning
in this
assembly
***
Reference
SAMP1.LST
Cross
Table
Page2
***
_CODE
00000000
ABS
#SAMP1.ASM(1)
_DATA
00000000
ABS
#SAMP1.ASM(16)
data
00000000
DAT
SAMP1.ASM(4)
SAMP1.ASM(4)
SAMP1.ASM(4)
SAMP1.ASM(9)
SAMP1.ASM(9)
SAMP1.ASM(9)
Command Options
91
Chapter 5 Using Assembler
#SAMP1.ASM(17)
main
00000000
TXT
#SAMP1.ASM(2)
SAMP1.ASM(7)
subr
0000000F
TXT
SAMP1.ASM(6)
#SAMP1.ASM(8)
The information output in the cross-reference table lists symbols, their values or addresses, types, and
file names and line numbers where the symbols are coded (the numbers in parentheses).
92
Command Options
Chapter 5 Using Assembler
Li
Do not output files included by include to the list file
Functional description
The Li option suppresses output of source Þle contents included by assembler directive (#include) to
the list Þle. However, the machine language code will be written to the relocatable object Þle.
This option is convenient when you need a listing only for a particular source Þle while debugging.
The Li option speciÞcation will be ignored for source Þles that do not have any #include statements.
Rules of use
The Li option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
upper-case letter 'L' and lower-case letter 'i'. The pair of characters of Li are handled as a single option.
If multiple options without parameters are to be speciÞed, then they can all be speciÞed after a single
option speciÞcation character. A parameter following the option should be delimited by a space before
the next option speciÞcation character starts.
AS102L -Lil SAMPLE
NOTE:
The Li option is used in conjunction with the l option (lower-case 'l', list output).
Default speciÞcation
Source Þles included by include will be output to the list Þle.
Command Options
93
Chapter 5 Using Assembler
Operation example
This example shows two source Þles (SAMP2.H and SAMP2.ASM). SAM2.H is a header Þle that
deÞnes data, and is included in SAMP2.ASM with an include directive.
NOTE:
Files included with include must not terminate with the end directive.
A>TYPE SAMP2.H
DATA1
equ
0x11
DATA2
equ
0x22
DATA2
equ
0x33
A>TYPE SAMP2.ASM
#include
ÒSAMP2.HÓ
_CODE
section
CODE, PUBLIC, 0
movw
data1, A0
mov
1, D0
main
mov
D0, (A0)
movw
data2, A0
mov
2, D0
mov
D0, (A0)
movw
data3, A0
mov
3, D0
mov
D0, (A0)
end
94
Command Options
Chapter 5 Using Assembler
First try assembling without the Li option. The list Þle will be as follows.
Lines where the line number is preceded by a period (.) are statements that were included by include.
A>102L -l SAMP2
A>TYPE SAMP2.LST
SAMP2.LST
Page 1
***
mn102L00
Cross
Assembler
***
Loc
object
Line
Source
1
#include
ÒSAMP2.HÓ
=00000011
.1
data1
equ
0x11
=00000022
.2
data2
equ
0x22
=00000033
.3
data3
equ
0x33
3
_CODE
section
CODE, PUBLIC, 2
4
main
2
000000
DC1100
5
mov
data1, A0
000003
8001
6
mov
1, D0
000005
00
7
mov
D0, (A0)
000006
DC2200
8
mov
data2, A0
000009
8002
9
mov
2, D0
00000B
00
10
mov
D0, (A0)
00000C
DC3300
11
mov
data3, A0
00000F
8003
12
mov
3, D0
000011
00
13
mov
D0, (A0)
14
end
ROM size
is 18
No error
in this
(HEX.
00000012)
assembly
No warning
in this
assembly
SAMP2.LST
***
Symbol
Table
00000000
T _CODE
00000011
A data1
00000022
A data2
00000033
A data3
00000000
T main
NOTE:
Page2
***
Supplemental Explanation
Further include directives can be written within include files. Up to three include
nesting levels are allowed. Refer to section 10.2, "#include", for details
Command Options
95
Chapter 5 Using Assembler
Next, look at part of the list Þle when assembled with the Li option. You can see that source statements
included with include have not been output.
A>AS102L -lLi SAMP2
A>TYPE SAMP2.LST
SAMP2.LST
Page 1
***
mn102L00
Cross
Assembler
***
Loc
object
Line
Source
1
#include
ÒSAMP2.HÓ
3
_CODE
section
CODE, PUBLIC, 2
4
main
2
000000
CD1100
5
mov
data1, A0
000003
8001
6
mov
1, D0
000005
00
7
mov
D0, (A0)
000006
DC2200
8
mov
data2, A0
000009
8002
9
mov
2, D0
00000B
00
10
mov
D0, (A0)
00000C
DC3300
11
mov
data3, A0
00000F
8003
12
mov
3, D0
000011
00
13
mov
D0, (A0)
ROM size
is 18
(HEX.
14
end
00000012)
No error
in this
assembly
No warning
in this
assembly
***
Table
SAMP2.LST
96
Symbol
00000000
T _CODE
00000011
A data1
00000022
A data2
00000033
A data3
00000000
T main
Command Options
***
Page2
Chapter 5 Using Assembler
Lm
Do not output assembler source created by macro expansion to the list file
Functional description
The Lm option suppresses output of assembler source created by macro expansion using macro
directives macro and irp to the list Þle. Only display of machine language instruction mnemonics will
be suppressed; machine language code will be output.
By using names that represent their processing actions, macro names can make listings easier to read.
In such cases, listings without expanded mnemonics will be easier to look at. This is why the Lm
option is provided.
If the l option is not speciÞed, then the Lm option will be ignored even if speciÞed. Source Þles with
no macro expansion will be assembled normally even if assembled with the Lm option.
Rules of use
The Lm option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by
the upper-case letter 'L' and lower-case letter 'm'. The pair of characters of Lm are handled as a single
option. If multiple options without parameters are to be speciÞed, then they can all be speciÞed after a
single option speciÞcation character. A parameter following the option should be delimited by a space
before the next option speciÞcation character starts.
AS102L -Lml SAMPLE
NOTE:
The Lm option is used in conjunction with the l option (lower-case 'l', list output
Default speciÞcation
Source statements expanded from macros will be output to the list Þle.
Command Options
97
Chapter 5 Using Assembler
Operation example
First see part of the source list when the source Þle (SAMP3.ASM) has been assembled without the Lm
option.
Lines where the line number is preceded by 'M' are macro expansion lines.Lines where the line number
is followed by '+' are expanded source statements, where the machine language codes are output in the
Object Þeld and the machine language mnemonics are output in the Source Þeld.
A>AS102L -l SAMP3
A>TYPE SAMP3.LST
***
Loc
98
mn102L0
object
=00000080
=00000090
000000
000002
000005
000006
000008
00000B
8011
DC8000
00
8011
DC8000
00
00000C
00000E
000011
000012
000014
000017
8022
DC9000
00
8022
DC9000
00
ROM size is
No error
No warning
24
in this
in this
***
Table
Symbol
Command Options
Cross
Line
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
M16
16+
16+
16+
17
18
19
M20
20+
20+
20+
21
22
23
24
25
(HEX.
***
SAMP3.LST
Assembler
Source
val1
var2
Page 1
***
equ
equ
0x80
0x90
*macro
dat_set
defenition
macro
mov
mov
mov
endm
------adr, dat
dat, D0
adr, A0
D0, (A0)
section
CODE, PUBLIC, 2
expansion
--------
dat_set
mov
mov
mov
mov
mov
mov
dat_set
mov
mov
mov
mov
mov
mov
end
var1, 0x11
0x11, D0
var1, A0
D0, (A0)
0x11, D0
var1, A0
D0, (A0)
var2, 0x22
0x22, D0
var2, A0
D0, (A0)
0x22, D0
var2, A0
D0, (A0)
*
_CODE
*
*macro
main
00000018)
assembly
assembly
SAMP3.LST
Page2
Chapter 5 Using Assembler
00000000
00000000
00000080
00000090
T
T
A
A
_CODE
main
var1
var2
Command Options
99
Chapter 5 Using Assembler
Next, try assembling the same source file with the Lm option. You can see that the machine language
code of macro expansion lines is output correctly, but the mnemonics are not output.
A>AS102L -lLm SAMP3
A>TYPE SAMP3.LST
***
Loc
mn102L00
object
=00000080
=00000090
000000
000002
000005
000006
000008
00000B
A011
DC8000
00
8011
DC8000
00
00000C
00000E
000011
000012
000014
000017
8022
DC9000
00
8022
DC9000
00
ROM size is
No error
No warning
24
in this
in this
*** Symbol
00000000
00000000
00000080
00000090
Table
T _CODE
T main
A var1
A var2
100 Command Options
Cross
Line
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
M16
16+
16+
16+
17
18
19
M20
20+
20+
20+
21
22
23
24
25
(HEX.
***
SAMP3.LST
Assembler
Source
val1
var2
Page 1
***
equ
equ
0x80
0x90
*macro
dat_set
defenition
macro
mov
mov
mov
endm
------adr, dat
dat, D0
adr, A0
D0, (A0)
section
CODE, PUBLIC, 2
expansion
--------
dat_set
var1, 0x11
mov
mov
mov
dat_set
0x11, D0
var1, A0
D0, (A0)
var2, 0x22
mov
mov
mov
end
0x22, D0
var2, A0
D0, (A0)
*
_CODE
*
*macro
main
00000018)
assembly
assembly
SAMP3.LST
Page2
Chapter 5 Using Assembler
Suppress output source statements of unfulfilled conditions of conditional
assembly to the list file
Lc
Functional description
The Lc option suppresses output of blocks of unsatisÞed conditions with conditional assembly to the
list Þle. It also suppresses output of source statements of conditional directives.
Rules of use
The Lc option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by
the upper-case letter 'L' and lower-case letter 'c'. The pair of characters of Lc are handled as a single
option. If multiple options without parameters are to be speciÞed, then they can all be speciÞed after a
single option speciÞcation character. A parameter following the option should be delimited by a space
before the next option speciÞcation character starts.
NOTE:
The Lc option is used in conjunction with the l option (lower-case 'l', list output).
AS102L -Lcl SAMPLE
Default speciÞcation
UnfulÞlled conditional statements will be output to the list Þle.
Command Options 101
Chapter 5 Using Assembler
Operation example
The example below uses conditional assembly directives (deÞne and ifdef). VERSION has been
deÞned by a deÞne directive, so the block following ifdef (in the example, "mov 0X11,D0") will be
assembled, and the block between else and endif (in the example, "mov 0X22,D0") will not be
assembled.
First, look at the source list when assembled without the Lc option.
A>AS102L -l SAMP4
A>TYPE SAMP4.LST
SAMP4.LST
Page 1
***
***
mn102L00
Cross
Assembler
Loc
object
Line
Source
1
#define
VERSION
3
_CODE
section
4
main
5
#ifdef
2
000000
8011
6
7
2
in this assembly
in this assembly
(HEX.
***
Table
***
00000000
A_CODE
00000000
T main
mov
0x22, D0
end
00000002)
SAMP4.LST
Symbol
0x11, D0
#endif
10
ROM size is
No error
No warning
VERSION
mov
#else
X
9
CODE, PUBLIC, 2
Page2
Lines marked with X for the line number are source statements unexpanded because a condition was not
satisfied, so no machine language code is output.
102 Command Options
Chapter 5 Using Assembler
Next, look at the source list when the same source Þle is assembled with the Lc option. Only the source
statement of the fulÞlled condition is output. You can see that the unfulÞlled statements and the
assembler directives themselves are not output.
A>AS102L -lLc SAMP4
A>TYPE SAMP4.LST
SAMP4.LST
Page 1
***
***
mn102L00
Cross
Assembler
Loc
object
Line
Source
1
#define
VERSION
3
_CODE
section
CODE, PUBLIC,2
4
main
6
mov
0x11, D0
10
end
2
000000
7011
ROM size is
No error
No warning
2
in this assembly
in this assembly
(HEX.
***
Table
***
00000002)
SAMP4.LST
Symbol
00000000
A _CODE
00000000
T main
Page2
Command Options 103
Chapter 5 Using Assembler
Ls
Do not output a symbol table to the list file
Functional description
The Ls option suppresses output of a symbol table when the list Þle is output.
Rules of use
The Ls option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
upper-case letter 'L' and lower-case letter 's'. The pair of characters of Ls are handled as a single option.
If multiple options without parameters are to be speciÞed, then they can all be speciÞed after a single
option speciÞcation character. A parameter following the option should be delimited by a space before
the next option speciÞcation character starts.
AS102L -Lsl SAMPLE
NOTE:
The Ls option is used in conjunction with the l option (lower-case 'l', list output
Default speciÞcation
A symbol table will be output.
104 Command Options
Chapter 5 Using Assembler
a map_filename
Generate a list file with resolved addresses
Functional description
The a option is used to generate a Þnal list Þle with resolved addresses.
First you must have generated a map Þle (.MAP) by specifying the m option with the linker. Then
using this map Þle, reassemble with the a option to generate the Þnal list Þle.
If the wrong map Þle is speciÞed, then the assembler help screen will be displayed on the screen.
Rules of use
The a option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
lower-case letter 'a', then followed by the map Þle name. If no Þle extension is speciÞed, the .MAP will
be assumed. If an extension is included in the speciÞcation, then any extension is allowed.
AS102L -l -a SAMPLE SAMPLE
NOTE:
When specifying the a option, always specify the l option to output a list file. No
list file will be generated if only the a option is specified.
Default speciÞcation
The assembler will not generate a Þnal list Þle with addresses resolved by a map Þle.
Command Options 105
Chapter 5 Using Assembler
Operation example
This example assembles a source Þle (SAMP5.ASM), links it, and then generates a Þnal list Þle.
First, assemble the source Þle with the l option and look at the list Þle at a stage when addresses are not
resolved.
A>AS102L -l SAMP5
A>TYPE SAMP5.LST
SAMP5.LST
Page 1
***
mn102L00
Cross
Assembler
***
Loc
object
Line
Source
=000000AB
1
var
equ
0xab
3
_CODE
section
CODE, PUBLIC, 2
4
main
2
000000
DCAB00
5
mov
var, A0
000003
F4E1000000
+6
jsr
subr
000008
EA00
R7
bra
main
00000A
8011
9
mov
0x11, D0
00000C
00
10
mov
D0, (A0)
00000D
FE
11
rts
12
end
8
ROM size is
No error
No warning
14
in this
in this
(HEX.
***
Table
***
subr
0000000E)
assembly
assembly
SAMP5.LST
Symbol
00000000
A _CODE
00000000
T main
00000008
T subr
000000AB
A var
Page2
The + on line numbers 6 and 7 indicates that the machine language code is not the final value.
The R on line 7 indicates that this line includes a relocatable symbol (a symbol whose value is determined at link time).
Also, the list location starts from 000000. This will be the relative value before linking.
106 Command Options
Chapter 5 Using Assembler
Next, link this Þle located from address 4100 (hex.) and generate a map Þle. Then using that map Þle,
generate a Þnal list Þle with resolved addresses.
A>LD102L -m -T_CODE=4100 SAMP5
A>AS102L -la SAMP5 SAMP5
A>TYPE SAMP5.LST
SAMP5.LST
Page 1
***
mn102L00
Cross
Assembler
***
Loc
object
Line
Source
=000000AB
1
var
equ
0xab
3
_CODE
section
CODE, PUBLIC, 2
4
main
2
080100
DCAB00
5
mov
var, A0
080103
F4E1020000
6
jsr
subr
080108
EAF6
7
bra
main
08010A
8011
9
mov
0x11, D0
08010C
00
10
mov
D0, (A0)
08010D
FE
11
rts
ROM size is
No error
No warning
524558
in this assembly
in this assembly
(HEX.
***
Table
***
8
subr
12
end
0008010E)
SAMP5.LST
Symbol
00080100
A _CODE
00080100
T main
0008010A
T subr
000000AB
T var
Page2
You can verify that the + on line number 6 and the R on line number 7 disappeared once the addresses
were resoloved. Also you can see that the location counter was placed from address 80100(hex.).
Command Options 107
Chapter 5 Using Assembler
For reference, here are the contents of the map file used.
A>TYPE SAMP5.MAP
#MEMORY MAP
INFORMATION
;Address
Length
Class
:0X004100
0x0000000C
CODE
;Address
Length
Section
Class
:0X004100
0X0000000C
_CODE
SAMP5.RF
;
;
;Address
Length
Section
File
:0X004100
0X0000000C
_CODE
SAMP5.RF
#LOCAL SYMBOL
INFORMATION
;(Clas: F=File,
L=Local,
G=Global)
;(Type: TEXT=Text
Type, ABS=Absolute
Type)
Type/Size
Symbol Name
;
;Value
Clas
:0X000000
F
0X000C
SAMP5.RF
:0X004100
L
TEXT
main
:0X004108
L
TEXT
subr
108 Command Options
Count
Chapter 5 Using Assembler
Xl
Output the list file to the same directory as the relocatable object file.
Functional description
The assembled list Þle is output to the same directory as the relocatable object Þle. The list Þle is
named with the .LST extension appended to the relocatable object Þle name.
Rules of use
The Xl option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
letter 'Xl'. 'X' is an upper-case letter and 'l' is a lower-case letter. These two letters, 'Xl', are treated as a
single option character. If multiple options without parameters are to be speciÞed, then they call all be
speciÞed after a single option speciÞcation character. A parameter following the option should be
delimited by a space before the next option speciÞcation character starts.
Default speciÞcation
The list Þle is not output.
Operation example
This example assembles the source Þle (SAMPLE.ASM) and outputs the list Þle (SAMPLE.LST) and
the relocatable object Þle to the C:\USER\OBJ directory.
A>AS102L -Xl -o A:\USER\OBJ\SAMPLE SAMPLE
Command Options 109
Chapter 5 Using Assembler
5.3.2
Error Message Options
j
Output error and warning messages in Japanese
Functional description
The j option displays messages for errors and warnings detected in assembler commands and assembler
processing to the screen and list Þle in Japanese. This option is used when English has been made the
default by user customization.
Rules of use
The j option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
lower-case letter 'j'. If multiple options without parameters are to be speciÞed, then they can all be
speciÞed after a single option speciÞcation character. A parameter following the option should be
delimited by a space before the next option speciÞcation character starts.
AS102L -j SAMPLE
Default speciÞcation
Display will be in Japanese.
By customizing the assembler, the output message default can be changed to English. Refer to section
1.3.5 ,"User Customization".
110 Command Options
Chapter 5 Using Assembler
Operation example
Below is the screen display when a source Þle (SAMP6.ASM) that includes errors is assembled with
the j option.
A>AS102L -j SAMP6
PanaX Series MN102L00 Assembler Version 3.2 Release 1.1.1
(c)Copyright 1994 Panasonic/KMC
SAMP6.ASM
5
move
0x11 ,D0
SAMP6.ASM(5): Error 2000: Syntax error.
000002
F440FFFFFF
6
mov
D0,(data)
SAMP6.ASM(6): Warning 2054: Illegal RAM address.
7
main
SAMP6.ASM(7): Error 2003: Symbol defined twice.
ROM size is 7 (Hex. 00000007)
2 errors in this assembly
1 warning in this assembly
Command Options 111
Chapter 5 Using Assembler
e
Output error and warning messages in English
Functional description
The e option displays messages for errors and warnings detected in assembler commands and
assembler processing to the screen and list Þle in English.
Rules of use
The e option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
lower-case letter 'e'. If multiple options without parameters are to be speciÞed, then they can all be
speciÞed after a single option speciÞcation character. A parameter following the option should be
delimited by a space before the next option speciÞcation character starts.
AS102L -e SAMPLE
Default speciÞcation
Display will be in Japanese.
By customizing the assembler, the output message default can be changed to English. Refer to section
1.3.5, "User Customization".
Operation example
Below is the screen display when a source Þle (SAMP6.ASM) that includes errors is assembled with
the e option.
A>AS102L -e SAMP6
PanaX Series MN102L00 Assembler Version 3.2 Release 1.1.1
(c)Copyright 1994 Panasonic/KMC
SAMP6.ASM
5
SAMP6.ASM(5):
000002
Error 2000:
F440FFFFFF
SAMP6.ASM(6):
Syntax error.
Warning 2054:
Error 2003:
ROM size is 7 (Hex. 00000007)
2 errors in this assembly
No warning in this assembly
112 Command Options
0x11 ,D0
6
7
SAMP6.ASM(7):
move
Illegal RAM address.
main
Symbol defined twice.
Chapter 5 Using Assembler
W number
Do not output warning messages of the specified number
Functional description
The W option suppresses output of speciÞed warnings detected during assembly. Refer to chapter 10,
"Error Messages", for warning numbers and their corresponding messages.
When an unregistered number is speciÞed, it will be ignored.
Rules of use
The W option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
upper-case letter 'W', and then followed by the warning number speciÞcation. When further options are
speciÞed, they should be delimited by a space before the option speciÞcation character.
AS102L -W2054 SAMPLE
Default speciÞcation
Warning messages are output.
Operation example
Below is the screen display when a source Þle (SAMP7.ASM) that includes warnings is assembled
without the W option.
A>AS102L SAMP7
PanaX Series MN102L00 Assembler Version 3.1 Release 1.1.1
(c)Copyright 1994 Panasonic/KMC
SAMP7.ASM
000004
F440FFFFFF
SAMP7.ASM(6):
Warning
6
mov
D0,(data)
2054: Illegal RAM address.
ROM size is 9 (Hex. 00000009)
No error in this assembly
1 warning in this assembly
Warning messages are output to the screen. Next suppress that output by assembling with the W option.
Command Options 113
Chapter 5 Using Assembler
Below is the screen when warning message output is suppressed.
A>AS102L -W2054 SAMP7
PanaX Series MN102L00 Assembler Version 3.1 Release 1.1.1
(c)Copyright 1994 Panasonic/KMC
SAMP7.ASM
ROM size is 9 (Hex. 00000009)
No error in this assembly
No warning in this assembly
You can see that warning messages are not output.
114 Command Options
Chapter 5 Using Assembler
Wall
Do not output any warning messages
Functional description
The Wall option suppresses output of all warnings detected during assembly.
Rules of use
The Wall option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by
the letters 'Wall'. When further options are speciÞed, they should be delimited by a space before the
option speciÞcation character.
AS102L -Wall SAMPLE
Default speciÞcation
Warning messages are output.
Operation example
The Wall option is speciÞed as follows.
A>AS102L -gWall SAMPLE
Command Options 115
Chapter 5 Using Assembler
5.3.3
Preprocessor Options
l path_name
Specifies the path name of the directory that contains files specified by
#include
Functional description
The #include directive causes the assembler to read speciÞed Þles during assembly and assembles them
as part of the source Þle. The I option speciÞes the directory that contains those source Þles as a
command option.
The I option is speciÞed when you want to temporarily change the directive for some reason.
Otherwise specify #include directives with directories.
When #include directives are speciÞed with path names, no error will occur even if a different directory
is speciÞed with the I option. In this case the path name speciÞed with the I option will be ignored.
Rules of use
The I option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
upper-case letter 'I', then either immediately followed by the path name or a space and the path name.
AS102L -I A:\USER\DEFS MAIN
Default speciÞcation
The current directory is speciÞed
116 Command Options
Chapter 5 Using Assembler
Operation example
Assume that the Þle SAMP8.H is speciÞed by an #include directive in SAMP8.ASM, and that
SAMP8.H is in the directory A:\USER\DEFS.
First, here are the contents of the two Þles.
A>TYPE SAMP8.ASM
#include
ÒSAMP8.HÓ
_CODE
section
CODE,PUBLIC,0
movw
data,A0
mov
0x11 ,D0
mov
D0,(A0)
main
end
A>TYPE A:\USER\DEFS\SAMP8.H
data
equ
0xff
Next is the assembled list Þle when the I option is speciÞed for assembly in the directory of
SAM8.ASM.
Command Options 117
Chapter 5 Using Assembler
A>AS102L -lI A:\USER\DEFS SAMP8
A>TYPE SAMP8.LST
SAMP8.LST
Page 1
***
***
mn00
Cross
Assembler
Loc
object
Line
Source
1
#include
ÒSAMP8.HÓ
=000000FF
.1
data
equ
0xff
3
_CODE
section
CODE, PUBLIC, 0
4
main
2
000000
0EFF
5
movw
data, A0
000002
A011
6
mov
0x11, D0
000004
58
7
mov
D0, (A0)
ROM size is
5
(HEX.
8
end
00000005)
No error
in this
assembly
No warning
in this
assembly
***
Table
SAMP8.LST
Symbol
00000000
T _CODE
000000FF
A data
00000000
T main
Page2
***
The period (.) preceding line numbers indicates that the contents were read from an include Þle.
118 Command Options
Chapter 5 Using Assembler
D identifier
Specifies an identifier to be used by ifdef during conditional assembly
Functional description
The assembler directives #ifdef, #else, and #endif select which source statements are to be assembled
depending on whether an identiÞer has been deÞned by a deÞne directive. The D option has the same
function as the deÞne directive, but with direct speciÞcation from the command line.
IdentiÞer speciÞcations by deÞne directives in source statements may be omitted. The statements to be
assembled can instead be selected by specifying identiÞers with the D option as needed.
Thus, the D option allows conditions to be set freely at the assembly stage without Þxing the conditions
with deÞne directives in source statements.
There are four conditional assembly directives that can make use of the D option.
ifdef, ifndef, if, ifn
No error will occur if identiÞers speciÞed by the D option are not used in the source Þle. Assembly will
process as though conditions are unfulÞlled.
Rules of use
The D option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
upper-case letter 'D', then followed by the identiÞer. A space can be inserted between D and the
identiÞer. The identiÞer must exactly match the string speciÞed by #ifdef. Characters are casesensitive. If multiple options without parameters are to be speciÞed, then they can all be speciÞed after
a single option speciÞcation character. A parameter following the option should be delimited by a
space before the next option speciÞcation character starts.
AS102L -D VERSION SAMPLE
Default speciÞcation
UnfulÞlled conditions will be selected. The #elseÐ#endif blocks will be assembled.
Command Options 119
Chapter 5 Using Assembler
Operation example
This example is the simplest source Þle that includes #ifdef,#else and #endif. The identiÞer is
VERSION. VERSION is not declared in the source Þle with a deÞne directive. If assembly is
performed as is, then the #elseÐ#endif block (here "mov 0x22,D0") will always become the object of
assembly.
A>TYPE SAMP9.ASM
_CODE
section
CODE, PUBLIC, 0
main
#ifdef
VERSION
mov
0x11, D0
mov
0x22, D0
#else
#endif
end
120 Command Options
Chapter 5 Using Assembler
Below is the list Þle assembled without the D option.
A>AS102L -l SAMP9
A>TYPE SAMP9.LST
SAMP9.LST
Page 1
***
mn102L00
Cross
Assembler
***
Loc
object
Line
Source
1
_CODE
2
main
3
#ifdef
X
5
000000
8022
2
(HEX.
in this
assembly
in this
assembly
***
Table
SAMP9.LST
T _CODE
00000000
T main
0x11, D0
mov
0x22, D0
end
No warning
00000000
mov
00000002)
No error
Symbol
VERSION
#endif
8
ROM size is
CODE, PUBLIC, 0
#else
6
7
section
Page2
***
VERSION is not declared within the source Þle and it has not been speciÞed with an option, so the
unfulÞlled condition statements have been assembled. The line numbers marked with X indicate lines
that were not assembled.
Command Options 121
Chapter 5 Using Assembler
Next is the list Þle assembled from the same source Þle but with VERSION speciÞed with a D option.
You can see that the result of fulÞlling the condition is that the #ifdefÐ#else block (here "mov
0x11,D0") has been assembled.
A>AS102L -lD VERSION SAMP9
A>TYPE SAMP9.LST
SAMP9.LST
Page 1
***
mn102L00
Cross
Assembler
***
Loc
object
Line
Source
1
_CODE
2
main
3
#ifdef
000000
8011
4
5
2
(HEX.
in this
assembly
in this
assembly
***
Table
SAMP9.LST
00000000
T _CODE
00000000
T main
122 Command Options
0x11, D0
mov
0x22, D0
end
No warning
***
mov
00000002)
No error
Symbol
VERSION
#endif
8
ROM size is
CODE, PUBLIC, 0
#else
X
7
section
Page2
Chapter 5 Using Assembler
5.3.4
Program Generation Options
g
Output debug information to the relocatable object file
Functional description
Assembled programs are debugged using a source code debugger. The g option enables source-level
debugging at the debug stage by adding the information needed for debugging to the relocatable object
Þle (.RF).
Debug information includes the following information.
¥
Names assigned to program addresses
¥
Names assigned to constants and variables
¥
Correspondence between line numbers and addresses
The symbol information includes addresses, so you can specify symbol names instead of addresses
during debugging. This can make debugging efforts much easier.
NOTE:
The g option must also be specified when linking. If the g option is not specified
for either the assembler or linker, then debug information will not be output to
the executable format file (.EX)
Rules of use
The g option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
lower-case letter 'g'. If multiple options without parameters are to be speciÞed, then they can all be
speciÞed after a single option speciÞcation character. A parameter following the option should be
delimited by a space before the next option speciÞcation character starts.
AS102L -g SAMPLE
Default speciÞcation
Debug information will not be output.
Operation example
The g option is speciÞed as follows.
A>AS102L -cg SAMPLE
Command Options 123
Chapter 5 Using Assembler
Output a relocatable object file even if errors are detected in the source
file
r
Functional description
The assembler normally does not output a relocatable object Þle (.RF) when it detects errors in the
source Þle. The r option speciÞed during assembly will generate a relocatable object Þle even when
errors are detected.
NOTE:
If errors are detected, then even when an executable format file is generated it
cannot normally be executed. Therefore the r option is no more than a
temporary measure; it cannot be used when finalizing programs.
The r option is used to see the locations of errors and to start debugging error-free areas in advance.
When the r option is speciÞed, note that a relocatable object Þle will be generated even when there are
errors in machine language instructions.
Rules of use
The r option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
lower-case letter 'r'. If multiple options without parameters are to be speciÞed, then they can all be
speciÞed after a single option speciÞcation character. A parameter following the option should be
delimited by a space before the next option speciÞcation character starts.
AS102L -r SAMPLE
Default speciÞcation
When the assembler detects errors during assembly, it will not generate a relocatable object Þle.
You can change the default using customization to force output of relocatable object Þles. Refer to
section 1.6, "User Customization".
Operation example
The r option is speciÞed as follows.
A>AS102L -ro TEST.RF TEST
124 Command Options
Chapter 5 Using Assembler
Od
Turn off optimization
Functional description
The assembler and linker evaluate source statements for the instructions to be optimized, and then
select the optimal instructions. The Od option turns this optimization function off.
Rules of use
The Od option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by
the upper-case letter 'O' and lower-case letter 'd'. The pair of characters of Od are handled as a single
option. If multiple options without parameters are to be speciÞed, then they can all be speciÞed after a
single option speciÞcation character. A parameter following the option should be delimited by a space
before the next option speciÞcation character starts.
AS102L -Od SAMPLE
Default speciÞcation
Optimization will not be performed.
You can change the default for optimization to on or off using customization. Refer to section 1.6,
"User Customization".
Operation example
The Od option is speciÞed as follows.
A>AS102L -Od
SAMPLE
Command Options 125
Chapter 5 Using Assembler
Ot
Turn on optimization
Functional description
The assembler and linker evaluate source statements for the instructions to be optimized, and then
select the optimal instructions. The Ot option turns this optimization function on.
Rules of use
The Ot option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
upper-case letter 'O' and lower-case letter 't'. The pair of characters of Ot are handled as a single option.
If multiple options without parameters are to be speciÞed, then they can all be speciÞed after a single
option speciÞcation character. A parameter following the option should be delimited by a space before
the next option speciÞcation character starts.
AS102L -Ot SAMPLE
Default speciÞcation
Optimization will not be performed.
You can change the default for optimization to on or off using customization. Refer to section 1.6,
"User Customization".
Operation example
The Ot option is speciÞed as follows.
A>AS102L -Ot
126 Command Options
SAMPLE
Chapter 5 Using Assembler
5.3.5
Other Options
h
Output help information to the screen
Functional description
The h option displays assembler command options and their descriptions to the screen. The h option is
used alone.
Rules of use
Specify a lower case 'h' after a slash (/) or hyphen (-).
AS102L -h
NOTE:
Even if the h option is not specified, input of ÒAS102L00 Ò alone will also display
the help screen.
Default speciÞcation
Help information will not be displayed to the screen.
Command Options 127
Chapter 5 Using Assembler
Operation example
The speciÞcation of the h option and the screen displayed are shown below.
A>AS102L00 -h
PanaX Series MN102L00 Assembler Version 3.2 Release 1.1.1
(c)Copyright 1994 Panasonic/KMC
Command format:
ASXXXX
[Options]
SRC-file
Options:
/I dir. = Set include files directory
/D str. = Define 'string'
/L{imc} = Control listing process
/Ls
= Stop Symbol Table
/a file = Output fixed location list
/c
= Output cross reference
/e
= English messages
/g
= Output debug information
/j
= Japanese messages
/l
= Output listing file
/o file = Specify output file name
128 Command Options
/r
= Ignore error and output RF file
/W num
= Stop warning message
/Wall
= Stop all warning messages
/O{td}
= Optimize on/off
/h
= Show this menu
Chapter 5 Using Assembler
5.4
Operation example
There are three steps to perform when you need a Þnal list Þle with resolved addresses.
With the assembler, generate a relocatable object Þle (.RF).
With the linker, generate an executable format Þle (.EX) and map Þle (.MAP).
With the assembler again, use the map Þle to generate a Þnal list Þle (.LST) with addresses resolved by
the linker.
Program assembly
Generation of a list Þle with the l option on the Þrst assembly will not resolve addresses, so you would
not do so unless you have some special purpose. For the same reason, the c, Li, Lm, and Lc options are
also not used.
A>AS102L -g SAMPLE
The above command assembles the source Þle (SAMPLE.ASM) in the current directory, and generates
a relocatable object Þle (SAMPLE.RF) with debug information in the current directory.
A>AS102L -LcgD VERSION -o TEST.RF A:\USER\SOURCE\MAIN
The above command assembles the source Þle (MAIN.ASM) in the A drive's \USER\SOURCE
directory. For conditional assembly of the source Þle, assembly will proceed as though VERSION
were deÞned.
The above command also generates a relocatable object Þle named TEST.RF with debug information in
the current directory.
A>AS102L -go TEST.RF -IA:\USER\LIB SAMPLE
The above example assembles the source Þle (SAMPLE.ASM) in the current directory. Files speciÞed
by include will be read from the A drive's \USER\LIB directory.
The above command also generates a relocatable object Þle named TEST.RF with debug information in
the current directory.
A>AS102L -I A:\USER\DEFS -o B:\BIN\SAMPLE.RF -D TYPE FILE
The above example assembles the source Þle (FILE.ASM) in the current directory. For conditional
assembly (ifdef), assembly will proceed as though TYPE were declared. Also, Þles speciÞed by
include directives will be taken from the A drive's \USER\DEFS directory.
The above example will store the relocatable object Þle with name SAMPLE.RF in the B drive's \BIN
directory with debug information.
Command Options 129
Chapter 5 Using Assembler
Generation of Þnal list Þle with resolved program addresses
The Þnal list Þle is generated as follows.
1. First use the assembler to generate a relocatable object Þle.
2. Next use the linker to generate an executable format Þle by specifying the start address of each section and linking multiple Þles. Specify the linker's m option to generate the map Þle. Refer to
chapter 4, "Using The Linker", for details.
3. Use the assembler once more to assemble the source Þle. This time read the map Þle generated by
the linker with the assembler's a option. Specify the same options as those of the Þrst assembly.
The following descriptions assume that a map Þle has already been generated.
A>AS102L00 -la MAIN.MAP SUB
In the above example all Þles exist in or are output to the current directory. The source Þle (SUB.ASM)
is assembled using a map Þle (MAIN.MAP), generating a list Þle (SUB.LST).
A>AS102L00 -lLcLma MAIN -D MODE PROG1
The above example assembles the source Þle (PROG1.ASM) in the current directory using a map Þle
(MAIN.MAP), generating a list Þle (PROG1.LST). Assembly will be performed assuming that the
identiÞer MODE has been deÞned for conditional assembly directives (ifdef). Source statements of
unfulÞlled conditions and macro expansion source will not be output.
130 Command Options
Chapter 6
Using Linker
6
Chapter 6 Using Linker
6.1
Purpose Of This Chapter
This chapter explains how to use all the options provided by the linker. The linker reads relocatable
object Þles output by the assembler, outputs an executable format Þle, and if speciÞed by option
outputs a map Þle containing link information. If optimization was speciÞed at the assembly stage,
then the linker will also adjust code such that it outputs optimal code for conditional and unconditional
branch instructions. In addition, the linker also resolves forward references.
For programs in section address format, the start address of each section is speciÞed when linking. The
linker links relocatable object Þles by section in the order speciÞed by the link command, and then
outputs an executable format Þle.
Relocatable Object Files
Executable Format File
000
sectionA
sectionA
Start Addresses
sectionA=000
sectionB=200
sectionC=500
PROGRAM1.RF
PROGRAM1
sectionA
sectionB
PROGRAM3
200
sectionB
sectionC
PROGRAM2.RF
PROGRAM1
Linker
sectionB
PROGRAM2
sectionB
sectionB
PROGRAM3
sectionB
500
PROGRAM3.RF
sectionC
sectionA
PROGRAM2
Figure 6-1 Link Model of Section Address Format
132 Purpose of This Chapter
Chapter 6 Using Linker
6.2
Starting Linker
The linker is started by entering a command name and parameters, just as for other MS-DOS external
commands. The parameters are linker options and names of Þles to be linked.
The command name differs depending on the device being used. This chapter uses the terminology of
LD102L00 as is general format.
General format of commands
Below is the general format of the command to use when starting the linker.
LD102L [options] relocatable_object_filename ...
[library_filename]
Contents of brackets [ ] may be omitted.
Ellipses (...) indicate item may be repeated.
Specifying options
Except for the @ option, an option starts with a slash (/) or hyphen (-) as the options speciÞer, followed
by a character that indicate the particular option.
/g or -g
The @ option is not preceded by a slash or hyphen.
Option speciÞcations are case sensitive, so upper case and lower case letters must be speciÞed
correctly.
-Eg
Single-character options not accompanied by parameters can be speciÞed as multiple characters
following the slash (/) or hyphen (-) option speciÞer. The order is optional.
/jmEgr or -jmEgr
If you want to separate multiple options, delimit them with spaces.
/j /m /g or -j -m -g
When an option is accompanied by a parameter and other options are to follow, add a space after the
parameter, and then follow with the slash (/) or hyphen (-) option speciÞer.
-o A:\USER\MAIN.EX
-gm
Starting Linker 133
Chapter 6 Using Linker
Parameters can be speciÞed right after the option character or separated by one space.
/T_CODE=80000 or /T _CODE=80000
When options are omitted, assembly will be performed in accordance with the default interpretations
built in to the assembler. Refer to section 6.3, "Command Options," for default interpretations
NOTE:
When multiple files are specified, the must be delimited by single spaces. When
path names are not specified, the linker will assume that files are in the current
directory on the current drive. When only relocatable object file path names and
file names are specified, the linker will generate the map file and executable
format file in the relocatable object files' directory.
A>LD102L -mj MAIN PROG1 SUB
When a relocatable object file extension is omitted, the linker will assume .RF.
The above example will cause the relocatable object files MAIN.RF, PROG1.RF,
and SUB.RF in the current directory to be linked, generating an executable
format file also in the current directory.
When the output file name is omitted, the name of the first relocatable object file
after the options will be output with the extension .EX (extension .MAP for the
map file).
A>LD102L -mj MAIN PROG1 SUB
The above example will generate an executable format file (MAIN.EX) and map
file (MAIN.MAP).
By using the o option, you can generate the executable format file in a directory
other than that of the relocatable object files.
A>LD102L -m -o A:\USER\OBJ\MAIN.EX MAIN SUB
The above example links relocatable object files (MAIN.RF and SUB.RF) in the
current directory, and outputs an executable format file (MAIN.EX) and map file
(MAIN.MAP) in the A drive's \USER\OBJ directory.
NOTE:
Windows 9X will be hung up if specifying a filename including a drive name which
is not connected to your computer under MS-DOS mode of Windows 9x.
C: LD102L
-m
B: SAMPLE.RF
(in case the drive B does not exist)
134 Starting Linker
Chapter 6 Using Linker
Below is a list of options.
Table 6-1 Linker options
Option Type
Output Þle options
Symbol
Description
o Þlename
Specify the path name and Þle name
of the executable format Þle to be
output.
m
Output a map Þle
Xm
Output an extended format map Þle.
Error message options j
Output error and warning messages in
Japanese.
e
Output error and warning messages in
English.
W number
Do not output warning messages of
the speciÞed number.
Refer to chapter 10, "Error Messages,"
for warning messages and their
corresponding numbers.
Wall
Do not output any warning messages.
g
Output debug information to the
executable format Þle.
Tesction_name[,section_name] start
address [,end address]
Specify the start/end addresses of a
start address [,end address]section
(section group).
T@section_attribute start address
[,end address]
Specify the start/end addresses of a
section start address [,end address]
attribute.
r
Output an executable format Þle even
if errors are detected.
En
Do not output symbol table within the
executable format Þle.
l library_Þlename
Specify a library Þle.
L path_name
Specify a path name for library Þles.
@Þlename
Specify a parameter Þle.
h
Output help information to the screen.
Program generation
options
Library Þle options
Other
Starting Linker 135
Chapter 6 Using Linker
6.3
Command Options
This section describes the options used by the linker. The linker has many options for controlling
output Þle speciÞcations and the information written to Þles. The linker reads multiple relocatable
object Þles, links them into one, and creates an executable format Þle.
If optimization was selected at the assembly stage, then the linker will output the optimal machine
language code for conditional and unconditional branch instructions, regardless of the mnemonics
deÞned in the source Þle.
In addition, the linker resolves the values of forward-referenced symbols and undeÞned operands.
136 Command Options
Chapter 6 Using Linker
6.3.1
Output File Options
o filename
Specify the path name and file name of the executable format file
to be output
Functional description
The o option speciÞes the directory and Þle name of the executable format Þle to be output by the
linker.
If the directory is omitted, then the Þle will be output to the current directory. If a Þle name that already
exists is speciÞed, then that Þle will be overwritten with new contents.
If a directory that does not exist is speciÞed, then an error message will be displayed.
If specifying an extension, the extension will be the speciÞed one.
If omitting an extension, the extension will be .EX.
o option type
generated files
-o test
test.ex
-o test.ex
test.ex
-o test.out
test.out
NOTE:
Because the @ symbol is used as the character for specifying parameter files, it
cannot be used as the first character of file names.
Rules of use
The o option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
lower-case letter 'o', then either immediately followed by the Þle name or a space and the Þle name.
LD102L -o B:\USER\OBJ\MAIN -T_CODE=80100 PROG1 PROG2
Command Options 137
Chapter 6 Using Linker
Default speciÞcation
The executable format Þle will be output to the current directory with the name of the Þrst speciÞed Þle
and the extension .EX.
LD102L -T_CODE=80100 MAIN SUB
In the above example the Þrst Þle name speciÞed for linking in MAIN, so the executable format Þle
will be MAIN.EX.
Operation example
The example below links two relocatable object Þles (PROG1.RF and PROG2.RF) in the current
directory from start address 4100 (hex) for section _CODE, and generates an executable format Þle
(MAIN.EX) in the B drive's \USER\OBJ directory.
A>LD102L -o B:\USER\OBJ\MAIN -T_CODE=80100 PROG1 PROG2
The next example links two relocatable object Þles (PROG1.RF and PROG2.RF) in the current
directory from start address 4100 (hex) for section _CODE, and generates an executable format Þle
(PROG1.EX) and map Þle (PROG1.MAP) in the same current directory.
A>LD102L -T_CODE=80100 -m PROG1 PROG2
138 Command Options
Chapter 6 Using Linker
m
Output a map file
Functional description
The m option writes to a map Þle all symbols linked and their values, identifying information for local
and global symbols, symbol types (text and absolute), size, etc.
In any programs the values of symbols assigned to addresses will not be resolved until after linking.
The linker outputs a list of symbols with resolved values to the map Þle.
To create a Þnal list Þle, reassemble the source Þle using the map Þle.
Rules of use
The m option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
lower-case letter 'm'. The map Þle name will be the name of the Þrst Þle speciÞed in the link command
with the extension .MAP. The map Þle will be output to the same directory as the directory where the
executable format Þle is generated.
LD102L00 -m MAIN SUB
Default speciÞcation
A map Þle will not be output.
The default can be changed to output a map Þle by using customization. Refer to section 1.6, "User
Customization".
Command Options 139
Chapter 6 Using Linker
Operation example
The example below links two relocatable object Þles (PROG1.RF and PROG2.RF) in the current
directory from start address 0000 (hex.) for section _DATA, and generates an executable format Þle
(PROG1.EX) and map Þle (PROG1.MAP) in the current directory.
A>LD102L00 -m -T_DATA=0000 PROG1 PROG2
The next example links two relocatable object Þles (PROG1.RF and PROG2.RF) in the current
directory from start address 4200 (hex.) for section _PRO and 4400 (hex) for section _SUB, and
generates an executable format Þle (MAIN.EX) and map Þle (MAIN.MAP) in the B drive's
\USER\OBJ directory.
A>LD102L00 -m -T_PRO=80200 -T_SUB=80400 -o B:\USER\OBJ\MAIN.EX
PROG1 PROG2
The next example links a relocatable object Þle (PROG1.RF) in the A drive's \USER\TEST directory
and a relocatable object Þle (SUB.RF) in the A drive's \USER\LIB library, and generates an executable
format Þle (PROG1.EX) and map Þle (PROG1.MAP) in the A drive's \USER\TEST directory.
A>LD102L00 -m A:\USER\TEST\PROG1 A:\USER\LIB\SUB
140 Command Options
Chapter 6 Using Linker
Xm
Output the extended format map file.
Functional description
An extended map Þle will be output.
With the extended map Þle, the information for each symbol is rearranged in the address order and then
output.
Global symbols are collectively output as a single item.
Rules of use
Enter an upper case letter ÔXÕ and a lower case letter ÔmÕ after the option speciÞer character slash(/) or
hyphen(-).
This Þle retains the base name of the Þrst Þle supplied to the linker, but changes the extension to .Xm.
It is created in the same directory in which the executable format Þle is generated.
This option can be speciÞed alone or with the m option. Specifying both options creates a regular map
Þle and an extended one.
Default speciÞcation
An extended map Þle will not be output.
Operation example
The example below links two relocatable object Þles (PROG1.RF and PROG2.RF) in the current
directory from start address 0000 (hex.) for section_DATA, and generates an executable Þle
(PROG1.EX) and extended map Þle (PROG1.XM) in the current directory.
A>LD102L00 -Xm -T_DATA=0000 PROG1 PROG2
The example below links two relocatable object Þles (PROG1.RF and PROG2.RF) in the current
directory from start address 4000 (hex.) for section_CODE, and generates an executable Þle
(PROG1.EX), extended map Þle (PROG1.XM), and standard map Þle simultaneously in the current
directory.
A>LD102L00 -m -Xm -T_CODE=4000 PROG1 PROG2
Command Options 141
Chapter 6 Using Linker
6.3.2
Error Message Options
j
Output error and warning messages in Japanese
Functional description
The j option displays messages for errors and warnings detected in link commands and link processing
in Japanese. This option is used when English has been made the default by user customization.
Rules of use
The j option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
lower-case letter 'j'.
LD102L00 -j PROG1 PROG2
Default speciÞcation
Display will be in Japanese.
By customizing the linker, the output message default can be changed to English. Refer to section 1.6,
"User Customization".
Operation example
The j option is speciÞed as follows.
A>LD102L00 -j PROG1
142 Command Options
Chapter 6 Using Linker
Output error and warning messages in English.
Output will be to the screen and, when a list file is specified, to the list file
e
Functional description
The e option displays messages for errors and warnings detected in link commands and link processing
to the screen and list Þle in English.
Rules of use
The e option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
lower-case letter 'e'.
LD102L00 -e PROG1 PROG2
Default speciÞcation
Display will be in Japanese.
By customizing the linker, the output message default can be changed to English. Refer to section 1.6,
"User Customization".
Operation example
The e option is speciÞed as follows.
A>LD102L00 -e PROG1
Command Options 143
Chapter 6 Using Linker
W number
Do not output warning messages of the specified number
Functional description
The W option suppresses output of speciÞed warnings detected during linking. Unlike errors, warnings
are not fatal, so the W option is used when you understand their meanings sufÞciently and need to
suppress their output. Specifying Wall will suppress output of all warnings. Refer to chapter 10, "Error
Messages", for warning numbers and their corresponding messages.
Rules of use
The W option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
upper-case letter 'W', and then followed by the warning number speciÞcation. A space may or may not
be inserted between the 'W' and the warning number. This option is provided for future expansion of
functions.
LD102L00 -Wmmm PROG1 PROG2
Here 'mmm' speciÞes the linker warning number.
Default speciÞcation
Warning messages are output.
144 Command Options
Chapter 6 Using Linker
Wall
Do not output any warning messages
Function description
The Wall option suppresses output of all warnings detected during linking.
Ruels of use
The Wall option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by
the letters 'Wall'. When further options are speciÞed, they should be delimited by a space before the
option speciÞcation character.
LD102L00 -Wall SAMPLE
Default speciÞcation
Warning messages are output.
Option example
The Wall option is speciÞed as follows.
A>LD102L00 -gWall SAMPLE
Command Options 145
Chapter 6 Using Linker
6.3.3
Program Generation Options
g
Output debug information to the executable format file
Functional description
In order to use symbols during program debugging, the g option outputs the executable format Þle with
debug information added. The source code debugger can then read the debug information at the same
time it reads the executable format Þle. Debug information includes symbol names and their values, so
during debugging you can use symbols to specify start addresses and breakpoints and to reference
memory.
NOTE:
The g option must also be specified when assembling. If the g option is not
specified for either the assembler or linker, then debug information will not be
output to the executable format file (.EX). If files assembled with the g option and
files not assembled with the g option are linked with the g option, then debug
information will be output only for the files assembled with the g option.
Rules of use
The g option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
lower-case letter 'g'.
LD102L00 -g MAIN SUB
Default speciÞcation
Debug information will not be output.
The default can be changed to output debug information using customization. Refer to section 1.3.5,
"User Customization".
Operation example
The example below links two relocatable object Þles in the current directory (MAIN.RF and SUB.RF),
and generates and executable format Þle with debug information (MAIN.EX) and map Þle in the
current directory.
A>LD102L00 -mg MAIN SUB
146 Command Options
Chapter 6 Using Linker
Tsection_name
[,section_name]=
addresses
Specify section (section group) start
Functional description
The T option speciÞes a section start address and a section end address. It will change the start address
of the speciÞed section where it exists in relocatable object Þles deÞned after the T option.The linker
will check that the speciÞed ranges for start address values. SpeciÞcations cannot exceed the range of
ROM area of the target device.
LD102L00 -TTEXT1=80000, -T
Sample 2
TEXT3=0x83000 sample.rf
Object assignment
after linking
TEXT1 section code
0x8000
TEXT1 section code
TEXT2 section code
TEXT2 section code
TEXT3 section code
0x83000
TEXT3 section code
Figure: 6-2 functional description(2)
Command Options 147
Chapter 6 Using Linker
Rules of use
The T option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
upper-case letter 'T', and then the section name, start address. The start address is speciÞed in
hexadecimal. A space may be inserted between the T and the section name. The start address will be
taken as hexadecimal without modiÞcation. For example, "-T_CODE=abc" will indicate the hex
address 0xABC.
LD102L00 -T_CODE=80000
PROG1 PROG2
LD102L00 -T_TEXT=80000 MAIN -T_CODE=80100 SUB
When multiple Þles are linked, the individual sections will be linked in the order that the Þles are
speciÞed. Be aware of the order of speciÞcation.
The start addresses of the CODE attribute and DATA attribute can be speciÞed by the
T@section_attribute=address option.
LD102L00 -T@CODE=80000 PROG1 PROG2
Default speciÞcation
The Þrst Þle is assigned from address 0. For second and further Þles that are omitted, the assigned
address will be the next address after the last address of the previous object Þle that was deÞned by
linker argument.
148 Command Options
Chapter 6 Using Linker
r
Output an executable format file even if errors are detected
Functional description
The r option is used in conjunction with the assembler's r option.
The assembler's r option is used when you know where errors are located, but want to start debugging
the error-free areas in advance. To link Þles that include errors generated this way, specify the r option
for linking as well.
As a result the r option will forcibly generate an executable format Þle.
Rules of use
The r option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
lower-case letter 'r'.
LD102L00 -r PROG1
Default speciÞcation
An executable format Þle will not be generated.
You can change the default using customization to force output of an executable format Þle even when
errors occur. Refer to section 1.6, "User Customization".
Operation example
The r option is speciÞed as follows.
A>LD102L00 -r PROG1
Command Options 149
Chapter 6 Using Linker
En
Do not output symbol table within the executable format file
Functional description
The En option suppresses output of a symbol table in the executable format Þle. Only executable code
will be output to the executable format Þle.
Rules of use
The En option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by
the upper-case letter 'E' and lower-case letter 'n'. The pair of characters of En are handled as a single
option.
LD102L00 -En
MAIN SUB
Default speciÞcation
The entire symbol table (local and global symbols) will be output.
Operation example
The En option is speciÞed as follows.
A>LD102L00 -En PROG1 PROG2 PROG3
150 Command Options
Chapter 6 Using Linker
Ed
Output the DATA-attribute section into the EX file.
Functional description
Output the DATA-attribute section other than CODE-attribute section into the EX Þles.
Rules of use
The Ed option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by
the upper-case letter 'E' and lower-case letter 'd'. The pair of characters of En are handled as a single
option.
LD102L00 -Ed
SAMPLE
Default speciÞcation
The CODE-attribute section will be output in the EX Þles.
Operation example
The Ed option is speciÞed as follows.
A>LD102L00 -m -Ed -T@DATA=100
SAMPLE
Command Options 151
Chapter 6 Using Linker
6.3.4
Library File Options
l library_filename
Specify a library file
Functional description
The l options speciÞes a library Þle.
Rules of use
The l option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
lower-case letter 'l', then either immediately followed by the path name and Þle name or a space and the
path name and Þle name. The l option must be coded end of the command line.
LD
PROG1 PROG2 -lB: \USER\OBJ\SAMPLE.lib
Default speciÞcation
No library files will be read.
152 Command Options
Chapter 6 Using Linker
L path_name
Specify a directory containing library files
Functional description
The L option speciÞes a directory that contains library Þles.
Library Þles following the L option speciÞcation will be searched for in the speciÞed directory.
Searching will be performed Þrst in the current directory and then in the directories speciÞed by L.
When the L option is deÞned multiple times, the search will be performed in the order of deÞnition.
Rules of use
The L option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
lower-case letter 'L', then either immediately followed by the path name or a space and the path name.
LD102L00 -LB:\USER\OBJ -lsample.lib -lsample2.lib PROG1 PROG2
The Þles sample.lib and sample2.lib will be searched for in the directory B:\USER\OBJ.
Default speciÞcation
Library Þles speciÞed by the l option will be read.
Command Options 153
Chapter 6 Using Linker
6.3.5
Other Options
@filename
Specify a parameter file
Functional description
By writing various option used by the linker in a Þle, the @ option lets you specify just that Þle during
execution, and the linker will replace it with the option speciÞcations.
All options other than the @ option can be written in a parameter Þle.
If a parameter Þle that does not exist is speciÞed, then the linker will display an error message.
Rules of use
The @ option does not use the slash (/) or hyphen (-) option speciÞcation character. It speciÞed alone,
followed by the parameter Þle name.
LD102L00 @PFILE
Default speciÞcation
None.
-o MAIN.EX
-gm
-T_CODE=80100 PROG1
-T_DATA=F000 PROG2
Operational example
Assume the following contents for PFILE.
Then specifying the following two commands is equivalent.
A>LD102L00 @PFILE
A>LD102L00 -o MAIN.EX -gm
PROG2
154 Command Options
-T_CODE=80000 PROG1 -T_DATA=F000
Chapter 6 Using Linker
h
Output help information to the screen
Functional description
The h option displays linker command options and their descriptions to the screen. The h option is
used alone.
Rules of use
The h option is speciÞed with the slash (/) or hyphen (-) option speciÞcation character, followed by the
lower-case letter 'h'.
LD102L00 -h
NOTE:
Even if the h option is not specified, input of LD102L00 alone will also display
the help screen
Default speciÞcation
Help information will not be displayed to the screen.
Command Options 155
Chapter 6 Using Linker
Operation example
The speciÞcation of the h option and the screen displayed are shown below.
A>LD102L00 -h
PanaX
Series MN102L00
(c)Copyright
1994
Linker
Version3.1 Release1.1.1
Command
format:
LDXXXX
[Options]
@file
=
Read parameter-file
/g
=
Output debug information
/En
=
Stop output symbol into EX-file
/Ed
=
Output data section into EX-file
/e
=
English messages
/j
=
Japanese messages
Panasonic/KWC
RF-files...
Options:
156 Command Options
/m
=
Output a map-file
/o file
=
Specify output EX-name
/r
=
Ignore error and make EX-file
/T sec=addr
=
Specify section start address
(hexadecimal)
/l file
=
Specify a library file
/L file
=
Set library file direction
/W num
=
Stop output warning message
/Wall
=
Stop output all warning messages
/b
=
EMS memory enable
/h
=
Show this menu
Chapter 6 Using Linker
6.4
Operation Examples
The following examples of linker operation assume that there are three relocatable object Þles
(MAIN.RF, PROG.RF, and SUB.RF) in the current directory.
These three relocatable object Þles will be linked. Debug information will be added to the executable
format Þle.
The start addresses of the sections deÞned in these Þles will have the following values.
_CODE
80000
_SUB
80200
_DATA
F000
First, link the Þles in the current directory (MAIN.RF, PROG1.RF, SUB.RF), and generate an
executable format Þle with debug information (MAIN.EX) in the same directory.
A>LD102L00 -g -T_CODE=80000 -T_SUB=80200 -T_DATA=F000 MAIN PROG1
SUB
Next, link the same Þles, but generate just the executable format Þle in a separate directory.
A>LD102L00 -go A:\USER\BIN\MAIN.EX -T_CODE=80000 -T_SUB=80200
-T_DATA=F000 MAIN PROG1 SUB
The above example will generate an executable format Þle (MAIN.EX) in the A drive's \USER\BIN
directory.
Command Options 157
Chapter 6 Using Linker
158
Chapter 7
Types Of Source Statement
7
Chapter 7 Types Of Source Statements
7.1
Purpose of This Chapter
Programs used by the Cross-Assembler are collections of source statements. There are Þve types of
source statements, classiÞed by their purpose.
¥
Machine language instruction statements and directive statements
¥
Assembler control statements
¥
Macro control statements
¥
Comment statements
¥
Blank statements
This chapter describes these Þve types of statements, and at the same time explains their position and
use when constructing a program.
160 Purpose Of This Chapter
Chapter 7 Types Of Source Statements
7.2
Program Format
A program is text created to assemble as machine language instructions in order to operate a
microprocessor. The assembler translates the text into machine language code, while the linker joins
that code to make an executable format Þle.
One line of text is called a source statement. There are Þve types of source statements, with the type
determining how a source statement is written.
Basic program format is shown below.
* Comment statement
#include
#deÞne
deÞnitions of constants, macros, globals
Write comments as needed
#include speciÞcations
DeÞne #deÞne identiÞers
Statements to deÞne constants and macros andto
declare and deÞne globals
section name
.
.
.
program body
Declare start of section
.
.
.
end
section
Machine language instructions, conditional assembly
directives, macro expansions
End of program
Program Format 161
Chapter 7 Types Of Source Statements
There are several points to be aware of when writing programs.
¥ Always declare an attribute and link type for a section name the Þrst time it appears in a Þle.The
same section name cannot be set to a different attribute or link type.
¥
The effective scope of a section is until the line preceding the next section
¥
Assembler instructions and dc, dw, ds and da directives cannot be coded before a section.
¥
The end of a program is indicated by end.
NOTE:
If the last line of an assembler source file does not have a return before the EOF,
then the following error will occur. Always code a return at the end of the last line.
Error
Error 2026:
No return code at end of line.
Example code causing error
RET[EOF]
(No return after RET)
Example code fixing error
RET
[EOF]
(Return after RET)
Below is an example source Þle.
; comment
;include a Þle
;deÞne identiÞer for conditional assembly
;deÞne a constant
; SAMPLE
#include
#define
KEYBORD
PROGRAM
"FILE1.H
equ
0x32
data_set
macro
movw
mov
mov
endm
section
data
data, A0
0x12, D0
D0, (A0)
_CODE
;end of macro
CODE,
PUBLIC,0
main
#ifdef
;deÞne a macro
mov
TYPE
data_set
0x10,
KEYBORD
mov
0,
D1
;blank statement
;statement with label only
;machine language instruction statement
;conditional assembly directive
;expand macro
#else
D1
#endif
end
162 Program Format
;end of program
Chapter 7 Types Of Source Statements
7.3
Machine Language Instruction Statements
And Directive Statements
Machine language instruction statements
Machine language instructions are instructions that the microprocessor directly executes on its own
hardware. Each machine language code has a corresponding mnemonic.
Machine language instruction statements are statements that code these mnemonics. The assembler
will convert them into machine language code (called object code). After the program has been
converted to ROM, these statements will be executed by the microprocessor.
The instructions have the following features.
¥
Memory-oriented instruction set(all calculations performed throughout memory)
¥
Single and double-operand instructions
¥
Minimized instruction set and instruction codes
¥
Supports common instruction space and data space expandable to 16MB with bank switching.
¥
Six addressing formats
The example below shows machine language instruction statements.
mov
mov
mov
add
rts
0xff , D0
data1, A0
D0, (A0)
1, D0
Directive statements
Directive statements are not converted to machine language code. Within programs they specify
assembler attributes to modify program structure and addresses, select radices, deÞne constants, and
control list Þle style.
The example below shows directive statements.
CONST
_CODE
MESG
global
equ
section
org
dc
end
save
0x12
CODE, PUBLIC, 2
100
ÔSÕ
Machine Language Instruction Statements And Directive Statements 163
Chapter 7 Types Of Source Statements
7.4
Assembler Control Statements
Assembler control statements are source statements that control how the assembler processes.
The assembler provides include directives that include Þles and conditional assembly directives that
specify conditions for changing which instructions are assembled.
The example below shows assembler control statements.
#include
ÒFILE1
#define
MODE
.ASM
;include a Þle
;deÞne an identiÞer
MODE
.
.
.
mov
0x22, D0
;begin conditional assembly
;block to assemble if condition is fulÞlled
mov
0x11, D0
;block to assemble if unfulÞlled
#ifdef
#else
#endif
.
.
.
164 Assembler Control Statements
Chapter 7 Types Of Source Statements
7.5
Macro Control Statements
Macro control statements reduce coding effort by replacing strings coded in source statements with
other strings. This enables low-level assembly language for a program block to be abstracted as a
macro name.
Macros are coded in two formats: macro deÞnitions and macro calls.
A macro deÞnition deÞnes a macro name and macro body. The macro body uses multiple machine
language instructions to construct a single program process.
A macro call is just a macro name coded as a source statement. The assembler will replace it with all
the machine language instructions coded in the macro body. This process is called macro expansion.
The basic difference between a macro call and a subroutine call is that a macro call actually outputs
machine language instructions as source statements, with arguments used to output different machine
language instructions for each call.
The example below shows macro control statements.
*macro deÞnition-------
------------------
-------
adr_set
macro data, reg
movw
reg, A0
mov
data, D0
mov
D0, (A0)
endm
.
.
.
---------------
--------
*macro call--------------
adr_set
.
.
.
adr_set
.
.
.
data1, reg1
data2, reg2
Macro Control Statements 165
Chapter 7 Types Of Source Statements
7.6
Comment Statements
Comments start with an asterisk in column one or a semicolon in any column. All text from the starting
character through to the end of the line is ignored, so does not affect program operation or function. Use
this space to document data structures, algorithms and other relavant information.
Comment statements are an important structural element of documentation. You should add comments
that are detailed as possible to enhance program maintenance.
The example below shows comment statements.
**********************
******************
MN10200 Series
Sample Program
Cross-Assembler
**********************
******************
***************************
#include
Òram.hÓ
;RAM deÞnition Þle
;macro deÞnition Þle
;conditional assembly deÞnition
#include
Òmacro.hÓ
#define
VERSION
* Program Start
main
.
.
166 Comment Statements
***************************
Chapter 7 Types Of Source Statements
7.7
Blank Statements
A blank statement consists of a single carriage return. Blank statements are used to make printed lists
easier to read.
Blank Statements 167
Chapter 7 Types Of Source Statements
168
Chapter 8
Writing Source Statements
8
Chapter 8 Writing Source Statements
8.1
Purpose of This Chapter
This chapter explains common information for writing source statements. Source statements include
machine language instruction statements, assembler control statements, and macro control statements.
This chapter explains how to code the characters and numbers that can be used when writing source
statements, and it describes how to write character constants, address constants, location counters, and
expressions.
170 Purpose of This Chapter
Chapter 8 Writing Source Statements
8.2
Permitted Characters
There are four types of characters that can be coded in source statements for the MN101C00 Series
Cross-Assembler.
Digits
0123456789
Letters
Upper-case
A B C D E F G H I J K L M N O P Q R S T UV W XY Z
Lower-case
abcdefghijklmnopqrstuvwxyz
Control characters
space
tab
carriage return
line feed
!Ó # $ % & Õ ( ) * + Ð . , / ; : < = > ? @ \ ^ [ ] Ð
_ (underscore)
Can be used in names, labels, mnemonics, operands, and comments.
Permitted Characters 171
Chapter 8 Writing Source Statements
8.3
Numbers
The Cross-Assembler provides three coding formats for use in numbers and (single) character
constants (refer to section 8.4, "Character Constants").
¥
Extended C language format
¥
Intel format
¥
Matsushita format
One of these formats is selected by using the notation directive. The default is extended C language
format.
Four radices can be used.
¥
Radix 2 (binary)
¥
Radix 8 (octal)
¥
Radix 10 (decimal)
¥
Radix 16 (hexadecimal)
Any radix can be selected by using the radix directive (but only decimal is allowed in extended C
language format). The default is decimal, regardless of coding format.
To code numbers with a radix other than the default, a Þxed sufÞx indicating the radix is appended to
the digits.
Radices and allowed digits
Radix 2(binary)
Radix 8(octal)
Radix 10(decimal)
Radix 16(hexadecimal)
0
0
0
0
A
10
1
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 A B C D E F or
B C D E F are hexadecimal digits that correspond to decimal
11 12 13 14 15. Lower case letters can also be used.
The next page shows how the various radices and formats are coded.
172 Numbers
Chapter 8 Writing Source Statements
Extended C language format
Radix
Binary
Octal
Decimal
Hexadecimal
Current default
radix
Binary
Octal
Decimal
Hexadecimal
-----
-----
0B101
0765
789
0XDEF
-----
Coding rules:
Binary
Start with '0' (zero) and letter 'B' (or 'b'), followed by binary digits.
Octal
Start with '0' (zero), followed by octal digits.
Decimal
Code decimal number as is.
Hexadecimal
Start with '0' and letter 'X' (or 'x'), followed by hexadecimal digits.
Intel format
Radix
Binary
Octal
Current default
radix
Binary
Octal
Decimal
Hexadecimal
101B
101
567O
567Q
101B
101B
101B
567O
567Q
567O
567Q
789D
789
0defH
789D
Decimal
789D
567O
567Q
567
789D
Hexadecimal
0defH
0defH
0defH
0def
Coding rules:
Binary
Follow binary digits with letter 'B' (or 'b'). When the default is binary, the sufÞx
'B' may be omitted.
Octal
Follow octal digits with letter 'O' (or 'o') or 'Q' (or 'q'). When the default is octal,
the sufÞx 'O' or 'Q' may be omitted.
Decimal
Follow decimal digits with letter 'D' (or 'd'). When the default is decimal, the
sufÞx 'D' may be omitted.
Hexadecimal
Follow hexadecimal digits with letter 'H' (or 'h'). If the digits begin with a letter A
Ð F, then they must be preÞxed with the digit '0' (zero). When the default is
hexadecimal, the sufÞx 'H' may be omitted.
Numbers 173
Chapter 8 Writing Source Statements
Matsushita format
Radix
Binary
Octal
Current default
radix
Binary
Octal
Decimal
Hexadecimal
567O
567Q
567O
567Q
567O
567Q
789D
789
0defH
789D
Decimal
789D
567O
567Q
567
789D
Hexadecimal
0defH
0defH
0defH
0def
Coding rules:
174 Numbers
Binary
Start with letter 'B' (or 'b'), and enclose binary digits in single quotation marks ( '
). When the default is binary, code the binary number as is.
Octal
Start with letter 'O' (or 'o'), and enclose octal digits in single quotation marks ( ' ).
When the default is octal, code the octal number as is.
Decimal
Start with letter 'F' (or 'f'), and enclose decimal digits in single quotation marks ( '
). When the default is decimal, code the decimal number as is.
Hexadecimal
Start with letter 'X' (or 'x'), and enclose hexadecimal digits in single quotation
marks ( ' ). When the default is hexadecimal, code the hexadecimal number as is.
When the number begins with a letter, preÞx it with '0' (zero).
Chapter 8 Writing Source Statements
8.4
Character Constants
Displayable ASCII characters can be coded as character constants or string constants. The characters
that can be used for constants are as follows.
¥
Digits
¥
Letters (upper or lower case)
NOTE:
String constants can use underscores and control characters (other than
carriage returns or line feeds).
Character constants
A character constant is stored as an ASCII code in the space of a single character. The method for
specifying character constants differs depending on the coding format.
The coding format is selected using the notation directive. The default is extended C language format.
NOTE:
The coding format also applies to numbers. Refer to section 8.3, "Numbers", for
details.
Coding rules:
In extended C format and Intel format, character constants are speciÞed just with the character enclosed
in single quotation marks ( ' ). In Matsushita format, the enclosed character is preceded by the letter 'C'
(or 'c').
The character 'A' (ASCII code 042) is speciÞed in each coding format as follows.
Coding Format
Extended C language format
Matsushita format
Intel format
Character Constant
ÔAÕ
CÕAÕ or cÕAÕ
ÔAÕ
When more than one character is speciÞed (such as C'FEDCBA' or 'FEDCBA'), only the that last
character will be valid (in this case the letter 'A' (ASCII code 042) will be valid.
NOTE:
To specify a single quotation mark for a character constant, precede the mark by
a backslash (\):
CÕ\ÕÕ
Specifies "Õ".
Character Constants 175
Chapter 8 Writing Source Statements
String constants
String constants are strings of one or more characters stored as ASCII code. When a string constant is
one character it will be the same as a character constant.
Coding rules:
String constants are speciÞed by enclosing the string in double quotation marks ( " ).
"ABCDEFG"
SpeciÞes the string ABCDEFG as ASCII code.
"+-[&%$#@!,.;:'"
SpeciÞes the string +-[&%$#@!,.;:' as ASCII code.
NOTE:
To specify a double quotation mark in a character constant, precede the mark by
a backslash (\):
"\""
Specifies """ in ASCII code.
NOTE:
Note that string constants are specified the same regardless of coding format.
The coding format has no effect even when a single-character string constant is
specified.
176 Character Constants
Chapter 8 Writing Source Statements
8.5
Address Constants
Address constants return particular bits from expressions that can be evaluated as addresses.
They are written as follows.
address_speciÞer (expression)
An address constant is written as an expression enclosed in parentheses following an address speciÞer.
An expression consists of names, self-reference address symbols, and constants linked by operators,
with the result representing a single value (refer to section 6.7, "Expressions", for details).
The address speciÞers are shown below.
A or a
Return the whole 18 bits of the expression value (bits 0 Ð 23).
AL or al
Return the lower 16 bits of the expression value
excluding a half byte (bits 1 Ð 15).
AH or ah
Return the upper 2 bits of the expression value (bits 16 Ð 23).
Example:
Assume that the following address is assigned to the label with the name MESSAGE.
address =
001110010101011011101001(binary)
a(MESSAGE) represents
1001110010101011011101001
al(MESSAGE) represents
0101011011101001
ah(MESSAGE) represents
100111001
Address Constants 177
Chapter 8 Writing Source Statements
8.6
Location Counter
The assembler contains an variable for counting addresses of instructions. This variable is called the
location counter. Each time the assembler converts an instruction to machine language, it increments
the location counter by the number of words in that instruction.
Location counter values are Þrst set during linking for each section deÞned by the section directive, so
location counter values during assembly will not necessarily match the addresses assigned to
instructions during execution. Location counter values during execution will be offset values from the
start of each section.
The address of the current instruction can be coded as an asterisk (*). This asterisk is called the selfreference address symbol. By using a self-reference address symbol in the operand Þeld of a source
statement, you can reference the address assigned to that statement during execution.
The self-reference address symbol is also used to specify the operand of equ directives.
Example:
main
equ
*
This assigns the current address value to main.
178 Location Counter
Chapter 8 Writing Source Statements
8.7
Expressions
Expressions are symbols, self-reference address symbols, and constants linked by operators, with the
result representing a single value. When an expression is coded as an operand, its result will be a
number or an address depending on the type of instruction.
When a symbol or self-reference address included in an expression is a forward referenced symbol, a
relocatable symbol, or an undeÞned symbol, the result of the expression cannot be resolved by the
assembler. It will then be resolved by the linker.
Expressions 179
Chapter 8 Writing Source Statements
8.7.1
Operators
There are three types of operators.
¥
Arithmetic operators
¥
Shift operators
¥
Logical operators
Arithmetic operators
Arithmetic operators perform the four standard arithmetic calculations.
Operator
*
/
%
+
+
-
Meaning
Multiplication
Division
Modulo operator (remainder)
Addition
Subtraction
Unary plus (positive)
Unary minus (negative)
Formats:
180 Expressions
Example:
operand1
*
operand2
123 * LABEL
operand1
/
operand2
123 / 10
operand1
%
operand2
COUNT % 4
operand1
+
operand2
SATRT + 0x10
operand1
Ð
operand2
STACK Ð 16
+ operand
+SIGN
Ð operand
-SIGN
Chapter 8 Writing Source Statements
Shift operators
The shift operators shift to the left or right in bit units.
Operator
Meaning
>>
<<
logical right shift
Logical left shift
Formats:
operand>>count
ADDRESS >> 3
3-bit right shift
operand<<count
ADDRESS << 4
4-bit left shift
Binary 0(zero) will be shifted in. Shifted out bits will be lost.
Logical operators
Logical operators perform calculation in bit units.
Operator
Meaning
&
^
|
-
Logical AND
Exclusive OR
Logical OR
Unary negation (1Õs complement)
Formats:
Example:
operand1
&
operand2
ADDRESS & MASK
operand1
^
operand2
CONST ^ 0b11110000
operand1
|
operand2
VECT | 0b11110000
- operand
MAIN
Expressions 181
Chapter 8 Writing Source Statements
8.7.2
Expression Evaluation
There are seven levels of operator precedence. The order of precedence can be changed using
parentheses ( ). Operators with the same precedence are evaluated in order from left to right.
Table 8-1 Operator Precedence
Precedence
Operator
Highest
+ * / %
+ << >>
&
^
|
Lowest
182 Expressions
Description
Unary negation, unary plus, unary minus
Multiply, divide, remainder
Add, subtract
Left shift, right shift
Logical AND
Exclusive OR
Logical OR
Chapter 8 Writing Source Statements
An example of operator is hown below.
***mn102L00
Loc
Cross
Object
=0000000A
=0000006E
000000
000001
000002
000003
000004
000005
000006
000007
000008
000009
15
07
92
91
1B
28
00
27
03
6F
000100
F470000000
ROM size is
261
(HEX.
No error in
this assembly
No warning in this assembly
Assembler
line
1
2
3
4
5
6
7
8
9
10
11
12
+13
14
15
16
17
+18
19
00000105)
SIKI.LST
***
Source
global
c2
c1
c2
equ
equ
10
0b01101110
_CODE
d1
d2
d3
d4
d5
d6
d7
d8
d9
d10
section
dc
dc
dc
dw
dc
dc
dc
dc
dc
dc
org
mov
end
CODE, PUBLIC,2
c1/3 * (3+4)
c1%3 * (3+4)
-c2
~c2
c2>>2
c1<<2
main>>2
c2>>2^0b00111100
(c2&0b00001111)>>2
c2|0b00001111
0x100
c2 & 0b00001111,D0
main
SIKI.LST
***Symbol
00000000
0000000A
0000006E
00000000
00000009
00000001
00000002
00000003
00000004
00000005
00000006
00000007
00000008
00000100
Page 1
Page2
Table***
A _CODE
A c1
*U c2
T d1
T d10
T d2
T d3
T d4
T d5
T d6
T d7
T d8
T d9
T main
An asterisk * is used as both the self-reference address symbol and the multiplication operator, so take
care in its use. The expression *** will be multiplication of the self-reference address symbol by itself.
Expressions 183
Chapter 8 Writing Source Statements
8.7.3
Expression Syntax
Below is an expression syntax diagram
(
expression
expression
binary operator
)
expression
unary operator
symbol
constant
*
Figure 8.1 Expression Syntax
NOTE:
Example:
mov
mov
mov
184 Expressions
When the expressions starting with parenthsis are coded to the operands of
Machine language instructions, it will be regarded as an address-referene. To be
proceeded as expressions, put 0+ before the parenthsis and distinguish them
from others.
(10+5), d0
(0+(10+5), d0
(10+5)+2, d0
; move the value of address 15 to D0 equal to mov(15), d0
; move the value of constant 15 to d0 equal to mov 15, d0
; Error. "(10+5)" is regarded as an address-reference. It is
syntax error.
Chapter 8 Writing Source Statements
8.7.4
Expression Attributes
When expression operands are connected by an operator, the calculated result of the expression will
have attributes of the operands and the operator.
The most important attributes for expression evaluation are as follows.
¥
UndeÞned
(undeÞned
-UND)
¥
Absolute
(absolute
-ABS)
¥
External
(external
-EXT)
¥
Relative
(relocate
-REL)
Operation result attributes
The operation result attributes for the label itself or the labels are following four.
UND: undeÞned attributes
the label is undeÞned at the reference.
ABS: absolute attributes
The label is undeÞned with equ pseud instruction. The value is not changed.
The constant value written directly will be regarded as an absolute attribute.
REL: relative attributes
The label is already deÞned in the same Þle at the reference (the label referring forward).
EXT: external reference attrobites
The label is declared with global pseud instruction and deÞned by another Þle.
The rules for connecting attributes are as follows.
For Ð, +, Ð (unary) operators
Attribute Of Operand
Attribute Of Result
UND
ABS
REL
EXT
UND
ABS
REL
EXT
Expressions 185
Chapter 8 Writing Source Statements
For + (addition) operator
operand1 + operand2
+ (addition)
Operand 1
Operand 2
UND
ABS
REL
EXT
UND
ABS
REL
EXT
UND
UND
UND
UND
UND
ABS
REL
EXT
UND
REL
REL
EXT
UND
EXT
EXT
EXT
For - (subtraction) operator
operand1 - operand2
-(SUBTRACTION)
Operand 2
UND
ABS
REL
EXT
Operand 1
UND
ABS
REL
EXT
UND
UND
UND
UND
UND
ABS
REL
EXT
UND
REL
REL
EXT
UND
EXT
EXT
EXT
For *, /, %, <<, >>, &, ^ , | operators
operand1 operator operand2
*,/,%,<<,>>,&,
Operand 1
NOTE:
^,|
UND
ABS
REL
EXT
Operand 2
UND
ABS
REL
EXT
UND
UND
UND
UND
UND
ABS
REL
EXT
UND
REL
REL
EXT
UND
EXT
EXT
EXT
The expressions writing in the operands of pseud instructions and Assembler
Control instruction must result in ABS. However, unlike the other pseud
instructions, the expressions written in the operands of org pseud instruction
and equ pseud instruction may write the instructions of operands other then
ABS.
[Reference: 9.4.6 org and 9.4.14 equ for details. ]
186 Expressions
Chapter 8 Writing Source Statements
8.8
Reserved Words
The assembler gives special meanings to the symbols listed below, so they cannot be used for other
purposes. These symbols are called reserved words.
Either all upper-case or all lower-case letters may be used to code reserved words, but they cannot be
mixed within one reserved word.
¥
Machine language instruction mnemonics
¥
Port names
¥
Register names
¥
Address constants
¥
Directives
¥
Assembler control instructions
¥
Macro control instructions
Except for machine language instruction mnemonics and port names, the reserved words are listed
below.
Register name
D0, D1, D2, D3, A0, A1,A2, A3,
Address constants
ah, al, a
PSW,
MDR
Assembler control
instructions
align, dc, dd, ds, dw, end, equ, global, listoff,
liston, xlistoff, xliston, notation, org, opt,
page, radix, section, tit
define, if, ifb, ifdef, ifeq, ifge, ifgt, fle,
iflt, ifn, ifnb, ifndef, ifneq, include, undef
Macro control
instructions
back, endm, exitm, front, irp, irpc, instructions,
local, macro, purge, rept
Directives
Reserved Words 187
Chapter 8 Writing Source Statements
188
Chapter 9
Writing Machine Language Instruction
Statements And Directive Statements
9
Chapter 9 Writing Machine Language Instructions And Directive Statements
9.1
Purpose Of This Chapter
This chapter explains how to write machine language instructions and directives.
There are five source statement formats
¥
Instruction statements that code machine language instructions and directives.
¥
Assembler control statements that code assembler control instructions
¥
Macro control statements that code macro control instructions
¥
Comment statements
¥
Blank statements
Each is coded differently.
This chapter explains in detail the code syntax and usage examples of machine language instructions
and directives.
Refer to chapter 8, "Writing Source Statements", regarding address constants, numeric constants,
expressions, and the syntax rules for numbers and characters.
Refer to the "Instruction Manual" for detailed descriptions of machine language instructions.
190
Purpose Of This Chapter
Chapter 9 Writing Machine Language Instruction Statements And Directive Statements
9.2
Instruction Statement Fields
Source statements that code machine language instructions and directives are built from four Þelds.
[label] [operation [operand [, operand]]] [comment]
Contents of brackets [ ] can be omitted.
Coding rules
Source statements may contain a label Þeld only.
Depending on the operation, source statements may contain no operand.
Fields are delimited by at least one space or tab. Two operands are delimited by a comma (,).
A statement with an LF only, omitting all Þelds, is a blank statement.
Statements are terminated by the LF character (line feed = 0x0A).
The maximum number of characters on one line is 256.
Instruction Statement Fields 191
Chapter 9 Writing Machine Language Instructions And Directive Statements
9.2.1
Writing Label Field
Labels are called both symbols and names. The assembler assigns a label the value of the location
counter at the point it is deÞned.
Coding rules
Labels can use upper-case and lower-case letters, digits, underscores (_).
Labels are coded in the Þrst column.
The Þrst character of a label must not be a digit.
The Þrst through 64th characters will be registered as the label.
Labels are case sensitive.
The same label name cannot be deÞned twice.
When the label is omitted, it must be replaced with at least one space or tab.
Terminology:
* Column
This is a column on the display or printer paper. One character takes one
column. Columns are counted from the left as column 1, 2, etc.
Coding examples
LABEL
LONGLABELLONGLABELLONGLABELLONGLAB
main
start_cont
The following examples are incorrect.
1LABEL
@START
START
192
Instruction Statement Fields
; Starts with a digit
; Uses a prohibited character
; Does not start from the Þrst column
Chapter 9 Writing Machine Language Instruction Statements And Directive Statements
9.2.2
Writing Operation Field
The operation Þeld is written with a machine language instruction mnemonic or directive.
Coding rules
The operation Þeld can be coded using upper-case and lower-case labels.
Coding examples
CONST1
_CODE
start
equ
tit
section
mov
rts
10
ÒCalculation ProgramÓ
CODE, UBLIC, 2
CONST1, D0
Instruction Statement Fields 193
Chapter 9 Writing Machine Language Instructions And Directive Statements
9.2.3
Writing Operand Field
The operand Þeld coding is determined by the machine language instruction or directive in the
operation Þeld. Refer to the "Instruction Manual" for details on coding machine language instructions.
Coding rules
Operands are written with expressions and reserved words (register names, etc.).
Operands cannot include spaces, except for character constants and string constants.
When two operands are coded, they must be delimited by a comma (,).
Coding examples
ROR
mov
jsr
194
Instruction Statement Fields
D0
CONST+3, D0
PRINT
;One operand
;Operands are aregister and expression
;Operand is an address
Chapter 9 Writing Machine Language Instruction Statements And Directive Statements
9.2.4
Writing Comment Field
The Þeld that starts from a semicolon (;) after the operands is called the comment Þeld. Comments
coded in this position are called end-of-line comments, as opposed to comment statements where the
entire line is a comment.
Coding rules
Comments being with a semicolon (;) and end with a line feed (LF).
Comment Þelds may be written with letters, digits, special characters, and control characters other than
carriage return and line feed.
Coding examples
mov
0x10, D0
;Set count value
Instruction Statement Fields 195
Chapter 9 Writing Machine Language Instructions And Directive Statements
9.3
Writing Machine Language Instruction
Statements
Each machine language instruction is deÞned by speciÞc mnemonics. Mnemonics are formed from
operations and operands accurately coded in the statement Þelds previously described.
Both upper-case and lower-case letters may be used.
Refer to the "Instruction Manual" for details of machine language instructions.
Coding rules
When coding a label, insert at least one space or tab between it and the operation Þeld.
When the label Þeld is omitted, replace it with at least one space or tab.
Both upper-case and lower-case letters may be used.
Insert at least one space or tab between the operation Þeld and operand Þeld.
The assembler and linker optimization function will adjust conditional and unconditional branch
instructions to generate the optimal code.
When a relative address is speciÞed in an operand and only labels with speciÞc addresses are coded, the
assembler will calculate and set the relative values.
Coding examples
START
indirect
mov
D0, (A0)
;src=register, dst=register indirect
mov
0x11, D0
;src=immediate data
not
rol
ror
and
or
xor
add
sub
mul
divu
cmp
bra
jmp
indirect)
jsr
rts
D0
D0
D0
0x0f, D0
0x30, D0
D0, D1
D1, D0
D1, D0
D1, D0
D1, D0
0x05, D0
SUBR
(A0)
;negate
;rotate left
;rotate right
;logical AND
;logical OR
;exclusive OR
;add
;subtract
;multiply
;divide
;compare
;unconditional branch
;unconditional branch
SUBR
;subroutine call
;return from subroutine
dst=register
(register
196
Writing Machine Language Instruction Statements
Chapter 9 Writing Machine Language Instruction Statements And Directive Statements
9.4
Writing Directive Statements
Directives differ from machine language instructions in that they only have effect on the assembler.
Directives specify program structure and start addresses, set constants and radices, and specify options
and label attributes.
List of directives
Below is a list of directives.
Directive
section
align
end
listoff
liston
notation
org
opt
page
radix
dc
ds
dw
dd
equ
global
tit
xlistoff
xliston
Function
SpeciÞes a section
Aligns the location counter value to a multiple of an expression.
Indicates the end of the program.
Stops list output from the line following this directive.
Starts list output from this directive.
Selects the coding format for numbers.
Changes the program address.
Enables/disables optimization functions.
SpeciÞes the number of columns and rows on one page of the list Þle.
Selects the radix to be speciÞed by default.
Stores an 8-bit constant in a memory area.
Reserves an 8-bit data area in a memory area.
Stores a 16-bit constant in a memory area.
Stores a 32-bit constant in a memory area.
DeÞnes a name as the value of an operand expression.
Declares external references with external declarations.
SpeciÞes the header name of the list Þle.
Stops list output including this directive.
Starts list output from the line following this directive.
Writing Direcrive Statements 197
Chapter 9 Writing Machine Language Instructions And Directive Statements
Document conventions
Symbols used in this chapter have the following meanings.
[]
( )...
|
Contents of brackets [ ] may be omitted.
Contents of parentheses ( ) may be repeated.
Specify one or the other of the terms delimited by a vertical bar |.
NOTE:
198
Writing Directive Statements
The blank in the colums of "label" and 'operand" means that you can not write the
label or operand.
Example:
label
operation operand
notation
CLANG|INTEL|PANA
The "label" is not coded in the same line as notation directives.
Chapter 9 Writing Machine Language Instruction Statements And Directive Statements
9.4.1
section
Syntax
label
operation
operand
section_name
section
[deÞnition1 [,deÞnition2 [,expression]]]
definition1 Section attribute (CODE|DATA)
definition2 Link type (PUBLIC|PRIVATE)
expression Location counter boundary value (power of 2, or 0)
Default settings
When deÞnition1, deÞnition2, or expression are omitted, they will inherit the current section type.
Functional description
The section directive speciÞes a section name, as well as its attribute, link type, and location boundary.
During linking the linker gathers sections with the same name and links them together by attribute. The
order of linking is determined by the link type and the order in which the linker encounters the sections.
Section linking rules
1. Link sections in order of appearance.
2. Link by attribute.
3. Link by link type.
PUBLIC(PRIVATE)
Link across all linked Þles.
Writing Directive Statements
199
Chapter 9 Writing Machine Language Instructions And Directive Statements
Operand coding rules
When the Þrst section name encountered in a Þle is deÞned, deÞnition1, deÞnition2, and expression
cannot be omitted. If omitted, then the assembler will generate an error and ignore this directive.
Only speciÞc strings can be deÞned for deÞnition1 and deÞnition2. If some other string is deÞned, then
the assembler will generate an error and ignore this directive.
The value of expression must be a power of 2 between 1 and 32768, or 0. If its value is outside this
range, then the assembler will assume the closest valid value instead. If the value is 0, the location
counter boundary value is 0.5 bytes.
The attribute, link type, and location boundary of sections with the same name must be either identical
or omitted. If a different attribute, link type, or location boundary is deÞned, then actual value will be
inherited from the setting of the very Þrst section.
If there is the same section name in a Þle with a different attribute, link type, or location boundary, then
the linker will locate the section using the attribute, link type, and location boundary of the Þrst
occurrence that it encounters.
Directive coding rules
The section directive has no restrictions on where in the source Þle it can be deÞned.
Usage example
Below is an example use of the section directive.
*
_CODE
main
comment
section
jsr
.
.
.
200
CODE, PUBLIC, 2
INIT
NOTE:
Assembler instructions and dc, dd, ds and dw directives must be coded after a
section has been defined. If used before a section has been defined, then the
assembler will generate an error and ignore that assembler instruction or directive.
NOTE:
The value for the section name will be the starting address in the same section
after link
Writing Directive Statements
Chapter 9 Writing Machine Language Instruction Statements And Directive Statements
9.4.2
align
Syntax
label
operation
operand
align
expression
Default settings
The current location counter value will be inherited.
Functional description
The align directive adjusts the location counter to be a multiple of the value indicated by expression.
The expression must be a power of 2 in the range 1 to 215.
When the expression value is 4, the multiples of 4 will be the following series.
4, 8, 12, 16, 20, 24, 28, 32, ...
When the location counter value is 13, then the statement after align 4 will have its location counter
changed to 16. When the location counter is 23, the statement will have its location counter changed to
24. When the location counter is 30, the statement counter will have its location counter changed to 32.
Thus, the align directive rounds up the current location counter value up to the next greater multiple of
the expression value.
Operand coding rules
The attribute of the calculated result of the expression coded in the operand must be abs (absolute).
Refer to Section 6.7.4, "Expression Attributes", regarding expression attributes.
The expression value must be a power of 2 in the range 1 to 215.
2, 4, 8, 16, 32, 64, 128, 256, ...
If the expression value is not a power of 2, then the assembler will generate an error and round up to the
next greater power of 2. In such a case, if the assembler's r option has been speciÞed, then the
assembler will generate a relocatable object Þle even with the error.
NOTE:
When the expression value is between 5 to 7, it can be round up to 8. Also,When the
expression value is between 17to 31,it can be round up to 32.
Writing Directive Statements 201
Chapter 9 Writing Machine Language Instructions And Directive Statements
Usage example
Below is an example use of the align directive.
***mn102L00
Loc
Cross
Object
000000
000001
000002
00
00
00
ALIGN.ASM(6)
000008
000009
00000A
:Error2002:
00
00
00
000010
000011
00
00
000020
000021
00
00
ROM size is
34
(HEX.
1 error in
this assembly
No warning in this assembly
ALIGN
Assembler
Line
1
2
3
4
5
6
Illegal
7
8
9
10
11
12
13
Page 1
section
CODE, PUBLIC, 2
mov
D0, (A0)
mov
D0, (A0)
mov
D0, (A0)
align
6
operand
value.
mov
mov
mov
align
mov
mov
14
15
16
17
00000022)
ALIGN
***Symbol
00000000
00000000
.LST
***
Source
_CODE
main
.LST
D0, (A0)
D0, (A0)
D0, (A0)
8
D0, (A0)
D0, (A0)
align
16
mov
mov
end
D0, (A0)
D0, (A0)
Page2
Table***
A_CODE
T main
In the align 6 directive on line 6, the expression value 6 is not a power of 2, so the assembler will convert
it to align 8.
The series of multiples of 8 is shown below. Numbers in parentheses are hexadecimal.
8(8) 16(10) 24(18) 32(20) 40(28) 48(30) 56(38) 64(40)
The location counter value at the line of align 6 is 0003 (hex.), which is between 0000 and 0008 (hex.).
Therefore the next line will start from location 0008 (hex.).
The same series applies to the align 8 on line 10. The location counter there is 000B (hex.), which is
between 0008 and 0010 (hex.). Therefore the next line will start from location 0010 (hex.).
Similarly, the align 16 on line 13 uses the series 16 (10), 32 (20), 48 (30)... The location counter there
is 0012 (hex.), which is between 0010 and 0020 (hex.). Therefore the next line will start from location
0020 (hex.).
202
Writing Directive Statements
Chapter 9 Writing Machine Language Instruction Statements And Directive Statements
9.4.3
end
Syntax
label
operation
[name]
end
operand
Default settings
If the end directive is omitted, then the assembler Þle will assume that the end of the Þle is the end of
the program.
Functional description
The end directive is coded once at the end of a program. All text coded after the end directive will be
ignored by the assembler (but it will be output to the source list).
When a name is coded in the label Þeld, the current location counter value will be assigned to it.
Operand coding rules
The end directive takes no operands. If operands are coded, they will cause an assembler syntax error.
Usage example
Below is an example use of the end directive.
_CODE
main
section
CODE, PUBLIC, 2
jsr
mov
.
.
end
data_move
0, D0
Writing Directive Statements 203
Chapter 9 Writing Machine Language Instructions And Directive Statements
9.4.4
listoff, liston
Syntax
label
operation
[name]
listoff
operand
.
.
.
[name]
liston
Functional description
The listoff and liston directives are used in pairs. Statements from the statement following the listoff
directive until the statement preceding the liston directive will not be output to the list Þle. These
directives are used when you do not want to output an already debugged program to the list Þle.
NOTE:
The listoff and liston directives themselves are output.
Only output to the list Þle will be suppressed. Output of object code will not be suppressed at all.
Operand coding rules
These directives take no operands.
Usage example
Below is an example use of the listoff and liston directives. The mov 0x22,D0 is a statement that
should not be output to the list Þle.
_CODE
main
204
Writing Directive Statements
section
CODE, PUBLIC, 2
mov
listoff
mov
liston
mov
end
0x11,D0
0x22, D0
0x33, D0
Chapter 9 Writing Machine Language Instruction Statements And Directive Statements
The list file created by the assembler is shown below. The mov 0x22,D0 statement between the listoff
and liston directives has not been output. The listoff and liston directives themselves are shown on two
consecutive lines in the list file.
***mn102L00
Loc
Cross
Object
000000
8011
000004
8033
ROM size is
6
(HEX.
No error in
this assembly
No warning in this assembly
LISTON
Assembler
Line
1
2
3
4
6
7
8
00000006)
.LST
***
Source
_CODE
main
Page 1
section
CODE, PUBLIC, 2
mov
listoff
liston
mov
end
0x11, D0
0x33, D0
Writing Directive Statements 205
Chapter 9 Writing Machine Language Instructions And Directive Statements
9.4.5
notation
Syntax
label
operation
operand
notation
CLANG | INTE | PANA
Default settings
CLANG will be selected.
Functional description
The notation directive selects the format of numbers and character constants (single character).
The Cross-Assembler provides three numeric formats.
¥
Extended C language format
¥
Intel format
¥
Matsushita format
Each format gives a speciÞc way to represent binary, octal, decimal, and hexadecimal numbers, as well
as character constants.
The notation directive selects which format numbers and character constants will be coded with. This
directive can be coded any number of times in a program.
Refer to section 6.3, "Numbers", for details about numeric formats, and to section 6.4, "Character
Constants", for details about character constant formats
Operand coding rules
The strings that can be speciÞed in the operand and the format that they select are listed below.
operand
CLANG
INTEL
PANA
Format
Extended C language format
Intel format
Matsushita format
If other strings are speciÞed, then the assembler will generate an error and ignore this directive.
206
Writing Directive Statements
Chapter 9 Writing Machine Language Instruction Statements And Directive Statements
Usage example
Below is an example use of the notation directive.
***mn102L00
Loc
Cross
Object
000000
000003
000006
000009
00000C
F8FF00
F8FF00
F8FF00
F8FF00
F8FF00
00000F
000012
000015
000018
F8FF00
F8FF00
F8FF00
F8FF00
00001B
00001E
000021
000024
F8FF00
F8FF00
F8FF00
F8FF00
NOTATION
Assembler
Line
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
.LST
***
Source
_CODE
Page 1
section
notation
mov
mov
mov
mov
mov
notation
mov
mov
mov
movw
notation
mov
mov
mov
mov
end
CODE, PUBLIC, 2
INTEL
11111111b, D0
377q, D0
377o, D0
255d, D0
0ffh, D0
CLANG
0b11111111, D0
0377, D0
255, D0
0xff, DW0
PANA
bÕ11111111Õ, D0
oÕ377Õ, D0
fÕ255Õ, D0
xÕffÕ, D0
Writing Directive Statements 207
Chapter 9 Writing Machine Language Instructions And Directive Statements
9.4.6
org
Syntax
label
operation
operand
[name]
org
expression
expression
label_name + constant, constant + label_name, label_name or constant
Default settings
The current location counter value will be inherited.
Functional description
The org directive sets the location counter to the address value speciÞed by expression.
Operand coding rules
The expression coded in the operand is speciÞed in the form of label_name + constant, constant +
label_name, label_name or a constant alone. The attribute of the calculation result must be rel
(relative). If the label is a forward reference or an external label that exists in a later position, then it
will cause an error.
Even when both of the operand formata and the value are correct, it will cause an error if an another
code already exists in the address after the location counter setting.
If specifying the constants, it will be regarded as offset of the starting in the section. If the expression
consists the labels, set the location counter in the address value speciÞed with the expressions.
Refer to section 8.7.4, "Expression Attributes", regarding attributes of expressions.
When a name is coded with the org directive, that name will be set the current location counter value.
208
Writing Directive Statements
Chapter 9 Writing Machine Language Instruction Statements And Directive Statements
NOTE:
If the expressions written in the operands are label name + constant,
constant+label name, label name or in non-constant format, the error will occur
no matter what the constant value is. Even if the expressions are in the
adequate format, they will cause an error when the constant value is in negative
number.
Example 1: Expression format is incorrect.
org label-10
; error (inadequate format)
org abel-(-10)
; error (inadequate format)
Example 2: Format is correct but Constant Value is in negative number.
org label+(-10)
; error (negative constant value)
org -10`
; error (negative constant value)
Example 3: Format is correct but Constant Value result is positive.
org -(-10)
; correct coded
org -(-10)+label
; correct coded
Usage example
Below is an example use of the org directive.
_CODE
sec_adr
sec_fnc
section
equ
.
instructions
.
org
equ
.
instructions
.
org
.
.
.
end
CODE, PUBLIC, 2
*
sec_adr+0x20
*
sec_fnc+0x10
Writing Directive Statements 209
Chapter 9 Writing Machine Language Instructions And Directive Statements
9.4.7
opt
Syntax
label
operation
operand
opt
on | off
Default settings
If omitted, then opt off will be assumed.
Functional description
The opt directive enables and disables the optimization functions of the assembler and linker.
Optimization applies only to conditional and unconditional branch instructions. The optimization
function evaluates how the source statements are coded, and then converts them to the optimal code
with the linker.
When a program split into multiple Þles is assembled, the assembler at this stage cannot determine if
the branch destinations of conditional branch instructions are within the speciÞed range or if
unconditional branch instructions can be replaced with relative branch instructions. The purpose of the
optimization function is to solve this problem. The assembler informs the linker of the instructions
subject to optimization.
While the linker is linking multiple Þles, it outputs the instructions with the smallest possible code size
for the instructions subject to optimization.
Refer to chapter 2, "Optimization", for details.
NOTE:
The -Od assembler option disables the optimization function, however,
optimization will be enabled if opt on is coded in the source file
Operand coding rules
The strings that can be coded for the operand and their meanings are as follows.
210
opt on
Enables optimization.
opt off
Disables optimization.
Writing Directive Statements
Chapter 9 Writing Machine Language Instruction Statements And Directive Statements
Usage example
Below is an example use of the opt directive.
opt
opt
on
off
Writing Directive Statements 211
Chapter 9 Writing Machine Language Instructions And Directive Statements
9.4.8
page
Syntax
label
operation
operand
page
lines_expression, columns_expression
Default settings
Number of lines = 60
Number of columns = 132
Functional description
The page directive speciÞes the number of lines and columns per page. At the line where the page
directive itself is speciÞed the assembler will output a carriage return and then apply the newly set
values.
Operand coding rules
The expressions coded in the operand must result in the attribute abs (absolute). Refer to section 8.7.4,
"Expression Attributes", regarding attributes of expressions.
Specify the number of lines in the range 10 Ð 255. Specify the number of columns in the range 60 Ð
255.
If a value outside the allowable range is speciÞed, then the assembler will generate an error and ignore
this directive.
Usage example
Below is an example use of the page directive.
page
page
212
Writing Directive Statements
24, 80
LINE_NO, COLUMN_NO
Chapter 9 Writing Machine Language Instruction Statements And Directive Statements
9.4.9
radix
Syntax
label
operation
operand
radix
expression
Default settings
Radix 10 (decimal).
Functional description
The radix directive speciÞes the radix that will be used by default. The Cross-Assembler provides
three coding formats for numbers.
¥
Extended C language format
¥
Intel format
¥
Matsushita format
The format is selected with the notation directive. Refer to the description of the notation directive.
The default is extended C language format.
The radix directive speciÞes the default radix for numbers in these coding formats by the expression in
the operand. Select one from radix 2 (binary), radix 8 (octal), radix 10 (decimal), and radix 16
(hexadecimal).
NOTE:
In extended C language format, the default radix cannot be specified by the radix
directive. The default is fixed as radix 10 (decimal), and it cannot be changed to
another radix
Operand coding rules
The expression coded in the operand must result in the attribute abs (absolute). Refer to section 8.7.4,
"Expression Attributes", regarding attributes of expressions.
The calculated result of the expression coded in the operand must be either 2, 8, 10, or 16. The radix of
the expression in the operand is always 10 (decimal), regardless of the current default radix. If the
expression results in a number that does not specify a radix, then the assembler will generate an error
and ignore this directive.
Writing Directive Statements 213
Chapter 9 Writing Machine Language Instructions And Directive Statements
Usage example
Below is an example use of the radix directive.
radix
radix
214
Writing Directive Statements
16
BINARY
Chapter 9 Writing Machine Language Instruction Statements And Directive Statements
9.4.10 dc
Syntax
label
operation
operand
[name]
dc
constant | expression (, constant | expression )...
Functional description
The dc directive is used to deÞne constants in a memory area. The 8-bit constant speciÞed by the
operand will be stored at the location of the statement specifying this directive.
When a name is coded for the label, the assembler will assign the current location counter value to that
name.
Operand coding rules
The expression coded in the operandmust result in the attribute abs(absolute).
Refer to section 8.7.4 ÒExpression AttributesÓ, regafding attributes of expressions.
Specify one of the following constants or the operand.
¥
character constant
¥
string constant
¥
address constant
The operands are delimited with commas (,). Any number of operands can be coded.
If data that exceeds 8 bits is speciÞed, then the lower 8 bits will be valid, and the upper bits will be lost.
The assembler will output a warning message in such cases.
When the speciÞed data has fewer than 8 bits, those bits will Þll the lower bits, and the upper bits will
be padded with zeroes.
Writing Directive Statements 215
Chapter 9 Writing Machine Language Instructions And Directive Statements
Usage example
Below is an example use of the dc directive.
***
Loc
216
mn102L00
Object
000000
000001
000002
000003
000004
000005
000006
000007
000008
000009
00000A
41
41
42
43
3F
0E
FF
FF
FE
FF
FF
00000B
F470000000
Writing Directive Statements
DC.LST
***
Page 1
_CODE
d0
d1
radix
section
dc
dc
10
CODE, PUBLIC, 2
ÔAÕ
ÒABCÓ
d2
d3
d4
d5
dc
dc
dc
dc
255>>2
(12+3)/2*2
0b11111111
0377,0376
d6
d7
main
dc
dc
255
0xff
+12
mov
d7, D0
13
end
end
Cross
Line
1
2
3
4
4
4
5
6
7
8
8
9
10
11
Assembler
Source
Chapter 9 Writing Machine Language Instruction Statements And Directive Statements
9.4.11 ds
Syntax
label
operation
operand
[name]
ds
expression1 [, expression2 [, expression3]]
expression1
Number of bytes of memory to reserve
expression2
Initial value
expression3
Number of iterations
Default settings
expression2 (initial value) If omitted, the assembler will assume 0.
expression3 (iterations) If omitted, the assembler will assume 1.
Functional description
The ds directive reserves a memory area of the number of bytes speciÞed by expression1 of the
operand. When expression2 (initial value) is speciÞed, that memory area will be Þlled with the initial
value. Note that expression2 can be speciÞed only when the value of expression1 is 4 or less. When
expression3 (iterations) is speciÞed, the same speciÞcation will be repeated for the number of
iterations. For example, if the operand is 4, 0, 3, then a 4-byte area will be Þlled with 0 three times.
Thus, a 12-byte area will be reserved.
When a name is coded for the label, the assembler will assign the current location counter value to that
name.
Operand coding rules
The expression1 (bytes), expression2 (initial value), and expression3 (iterations) coded in the operand
must result in the attribute abs (absolute). Refer to section 6.7.4, "Expression Attributes", regarding
attributes of expressions.
NOTE:
When expression2 is omitted, expression3 cannot be specified.
Usage example
Below is an example use of the ds directive.
DC.LST
***
mn102L00
Cross
Assembler
Loc
Object
Line
Source
1
_CODE
000000
00
2
Page 1
***
section
CODE, PUBLIC, 2
ds
1
Writing Directive Statements 217
Chapter 9 Writing Machine Language Instructions And Directive Statements
000001
11
3
000002
22
3
000003
33
4
000004
44
4
000005
55
4
000006
33
4
000007
44
4
000008
55
4
5
218
Writing Directive Statements
ds
2, 0x1122
ds
3, 0x334455, 2
end
Chapter 9 Writing Machine Language Instruction Statements And Directive Statements
9.4.12 dw
Syntax
label
operation
operand
[name]
dw
expression (, expression )...
Functional description
The dw directive is used to deÞne 16-bit constants in a memory area. The 16-bit constant speciÞed by
the operand will be stored at the location of the statement specifying this directive.
When a name is coded for the label, the assembler will assign the current location counter value to that
name.
Operand coding rules
The operands are delimited with commas (,). Any number of operands can be coded.
If data that exceeds 16 bits is speciÞed, then the lower 16 bits will be valid, and the upper bits will be
lost. The assembler will output a warning message in such cases.
When the speciÞed data has fewer than 16 bits, those bits will Þll the lower bits, and the upper bits will
be padded with zeroes.
Writing Directive Statements 219
Chapter 9 Writing Machine Language Instructions And Directive Statements
Usage example
Below is an example use of the dw directive.
***
Loc
mn102L00
Object
=00000000
000000
0000
000004
0000
000006
0000
000008
0000
000100
000105
000107
000108
00010A
00010B
000110
000112
000113
F474000000
8022
21
F281
01
F474000000
8011
00
FE
000000
220
0000
Writing Directive Statements
DW>LST
Cross Assembler
Line Source
1
_CODE
R2
start
3
+4
5
+6
7
+8
9
+10
11
+12
main
13
14
15
16
+17
no_int
18
19
20
21
22
_DATA
23
data
24
Page 1
***
section
equ
org
dw
org
dw
org
dw
org
dw
org
mov
mov
mov
addc
mov
mov
mov
mov
rts
CODE, PUBLIC, 2
*
start+0x0
a(main)
start+0x4
a(no_int)
start+0x6
a(no_int)
start+0x8
a(main)
0x100
data, A0
0x22, D0
(A0), D1
D0, D1
D1, (A0)
data, A0
0x11, D0
D0, (A0)
section DATA, PUBLIC, 2
dw
0
end
Chapter 9 Writing Machine Language Instruction Statements And Directive Statements
9.4.13 dd
Syntax
labeloperationoperand
[name]ddexpression(, expression)...
Functional description
The dd directive is used to define 32-bit constants in a memory area. The 32-bit constant specified by
the operand wil be stored at the location of the statement specifying this directive.
When a name is coded for the label, the assembler will assign the current location counter value to that
name.
Operand coding rules
The operands are delimited with commas(,). Any number of operands can be coded.
When the specified data has fewer than 24 bits, those bits will fill the lower bits and the upper bits will
be padded with zeros.
Usage example
Below is an example use of the dw directive.
***
Loc
mn102L00
Object
=00000000
000000
00000000
000006
00000000
00000C
00000000
0000012
00000000
000100
000105
000107
000108
00010A
00010B
F474000000
8022
21
F281
01
F474000000
DD.LST
Cross Assembler
Line Source
1
_CODE
R2
start
3
+4
5
+6
7
+10
9
+10
11
+12
main
13
14
15
16
+17
no_int
Page 1
***
section
equ
org
dd
org
dd
org
dd
org
dd
org
mov
mov
mov
addc
mov
mov
CODE, PUBLIC, 2
*
start+0x0
a(main)
start+0x6
a(no_int)
start+0xc
a(no_int)
start+0x12
a(main)
0x100
data, A0
0x22, D0
(A0), D1
D0, D1
D1, (A0)
data, A0
Writing Directive Statements 221
Chapter 9 Writing Machine Language Instructions And Directive Statements
000110
000112
000113
000000
8011
00
FE
18
19
20
21
22
23
24
0000
mov
mov
rts
_DATA
data
0x11, D0
D0, (A0)
section DATA, PUBLIC, 2
dw
0
end
9.4.14 equ
Syntax
label
operation
operand
name
equ
expression
Functional description
The equ directive deÞnes the name to be the value of the expression coded in the operand. When that
name is coded in the operand of machine language instructions, the assembler will reference the name's
value.
System constants often used in programs (memory size, clock frequency, etc.) can be assigned to
names that describe those values.
MEMORY
equ
0x20
MOTOR
equ
10
STOP
equ
0b00001000
BASE
equ
0x1000
This allows numbers used in programs to be coded as descriptive names instead, making programs
easier to read. Furthermore, values can be changed just by modifying the equ directive, which in turn
changes the data wherever it is used. This makes programs easier to maintain.
Operand coding rules
Names deÞned in other programs cannot be speciÞed within expression.
Names deÞned once with the equ directive cannot be deÞned again.
No memory area is reserved when an equ directive statement is executed.
A 0.5-byte unit value is acceptable for the constant.
Only the ezpressions of ABS can be coded in operands of equ pseud instruction. However, the self
address symbol "*" can be coded. the label deÞned with equ will be the label of REL.
Example:
Label1 will be deÞned as label of REL consisting of location counter value.
222
Writing Directive Statements
Chapter 9 Writing Machine Language Instruction Statements And Directive Statements
label 1
equ
*
;can be coded
Operand, "*" is not coded alone, which causes an error.
lagel 2
equ
*+1
error
Writing Directive Statements 223
Chapter 9 Writing Machine Language Instructions And Directive Statements
NOTE:
Symbols with unresolved values cannot be coded in the operand. In the
following example, the value of ram1 is not resolved at the point where the value
of ram2 is to be resolved, so the assembler will generate an error.
Error example:
ram2
equ
ram1+0x1
ram1
equ
0x10
By changing the order such that the value of ram1 is resolved first, no error will
occur.
No error example:
ram1
equ
0x10
ram2
equ
ram1+0x1
Usage example
Below is an example use of the equ directive.
***
Loc
000000
000002
000005
00000A
00000C
00000E
00000F
000011
000013
000000
224
mn102L00
Object
=00000064
=00000020
8000
DC2000
F471000000
D864
E600
01
D002
EA00
FE
0000
Writing Directive Statements
Cross
Line
1
2
3
4
5
6
+7
8
+9
10
11
+12
13
14
15
16
17
BQU.LST
Assembler
Source
count
memory
Page 1
***
equ
equ
100
0x20
_CODE
step
section
mov
mov
mov
cmp
bcc
mov
add
bra
rts
CODE, PUBLIC, 2
0, D0
memory, A0
data, D1
count, D0
step_end
D1, (A0)
2, A0
step_loop
step_loop
step_end
_DATA
data
section DATA, PUBLIC, 2
dw
0
end
Chapter 9 Writing Machine Language Instruction Statements And Directive Statements
9.4.15 global
Syntax
label
operation
operand
[name]
global
name(, name)...
Default settings
External reference when omitted = external label
External declaration when omitted = undeÞned label error during linking
Functional description
The global directive declares external references and external declarations.
For external references, the global directive declares that the names coded in the operand are from other
Þles.
For external declarations, the global directive declares that the names coded in the operand can be
referenced externally.
The global directive can be coded anywhere in a source programs.
Operand coding rules
Write the name coded in the label Þeld as an operand. Generally this will be a program name.
The names are delimited with commas (,). Any number of operands can be coded.
When a speciÞed name has been coded in a label Þeld within the program, it will be considered an
external declaration. When it has been coded as operands, it will be considered an external reference.
Writing Directive Statements 225
Chapter 9 Writing Machine Language Instructions And Directive Statements
Usage example
Below is an example use of the global directive.
global
global
main
SUB1
226
jsr
.
.
jsr
.
.
mov
.
.
rts
end
Writing Directive Statements
SUB1
READ,
WRITE
READ
WRITE
0x11, D0
;external declaration
;external reference
Chapter 9 Writing Machine Language Instruction Statements And Directive Statements
9.4.16 tit
Syntax
label
operation
operand
tit
["string"]
Default settings
No header will be output to the list Þle.
Functional description
The tit directive speciÞes that the string coded as its operand is to be output as the header of the list Þle.
Typically the string is written with the program name, function, author, version, company, date, etc.
Operand coding rules
The operand is written with any string enclosed by double quotation marks ("). A double quotation
mark itself cannot be included in the string.
Usage example
Below is an example use of the tit directive.
TIT.LST
Title of
Practice
Program
Loc
Object
Line
Source
1
programÓ
000000
54
2
3
Page 1
tit ÒTitle Practice ProgramÓ
main
mov
end
(xp), (yp)
(a0), d0
4
Writing Directive Statements 227
Chapter 9 Writing Machine Language Instructions And Directive Statements
9.4.17 xlistoff, xliston
Syntax
label
operation
[name]
xlistoff
operand
.
.
.
[name]
xliston
Functional description
The xlistoff and xliston directives are used in pairs. Statements from the xlistoff directive until the
xliston directive will not be output to the list Þle. These directives are used when you do not want to
output an already debugged program to the list Þle.
NOTE:
The xlistoff and xliston directives themselves are not output.
Only output to the list Þle will be suppressed. Output of object code will not be suppressed at all.
Operand coding rules
These directives take no operand.
Usage example
Below is an example use of the xlistoff and xliston directives. The range from xlistoff to xliston will be
suppressed
.
_CODE
main
228
section
CODE, PUBLIC, 0
mov
xlistoff
mov
xliston
mov
end
0x11, D0
Writing Directive Statements
0x22, D0
0x33, D0
Chapter 9 Writing Machine Language Instruction Statements And Directive Statements
The list Þle created by the assembler is shown below. The directive statements are not included in the
output. The xlistoff and xliston directives themselves are hidden from the list Þle by having their
output suppressed
***
Loc
000000
000004
mn102L00
Object
8011
8033
Cross
Line
1
2
3
7
8
XLISTON
.LST
Assembler ***
Source
_CODE
section
main
mov
mov
end
Page 1
CODE, PUBLIC, 2
0x11, D0
0x33, D0
Writing Directive Statements 229
Chapter 9 Writing Machine Language Instructions And Directive Statements
230
Chapter 10
Writing Assembler Control Statements
10
Chapter 10 Writing Assembler Control Statements
10.1 Purpose Of This Chapter
Assembler control statements are statements that control assembler processing. They specify include
Þles and control conditional assembly.
Include Þles are used to place deÞnitions of constants, memory areas, I/O ports, and bit assignments
common to the entire program in separate Þles. They are read in during assembly.
Conditional assembly allows the assembler to evaluate conditions, and then to select a block of
statements to assemble depending on whether the conditions are fulÞlled or not.
This chapter describes these functions and how to code them, and provides examples of actual use.
Many directives used in conditional assembly are used only within macro deÞnitions. Refer to chapter
9, "Writing Macro Statements", as needed.
Common coding rules
Here are some rules common to coding of all assembly control statements.
The assembler directive should be coded from the Þrst column of its statement. Both upper and lower
case letters can be used.
The characters that can be used as identiÞers are upper and lower case letter, digits, and underscores
( _ ). However, the first character must not be a digit.
Further conditional assembly directives can be used within a block of conditional assembly directives.
Up to 255 nesting levels are allowed.
The #else directive and the second block can be omitted. Refer to section 8.5, "Conditional Assembly",
for details about the second block.
An expression combines symbols, self-reference address symbols, and constants with operators into an
equation that returns a single value as its result. The value must have the attribute abs (absolute). Refer
to section 8.7, "Expressions", regarding attributes of expressions.
Document conventions
Symbols used in this chapter have the following meanings.
[]
232
Purpose Of This Chapter
Contents of brackets [ ] may be omitted.
Chapter 10 Writing Assembler Control Statements
10.2 #include
Syntax
#include
ÓfilenameÓ
Functional description
The #include directive causes the assembler to read in the source Þle with the speciÞed name at the
location of the directive.
NOTE:
The included file will be assembled and output to the relocatable object file and
list file. In order for the list file to show that lines were included as part of an
include file, a period (.) will be prefixed before the line number.
By specifying the assembler's Li option, you can suppress output of include Þles to the list Þle.
Coding rules
The Þle is speciÞed by the Þle name enclosed in double quotation marks ("). If the Þle is in a different
directory, then the Þle name speciÞcation must include the path name. The assembler will assume an
.ASM extension if the extension is omitted.
NOTE:
By adding the I option when starting the assembler, you can specify a path name
for include files. However, even in this case the option will be ignored if a specific
path name is coded within "filename".
Usage example
This example will show an include Þle speciÞed in a different directory. Here is the contents of the Þle
INCL.H in the directory A:\USER\DEFS.
data
equ
0x12
#include 233
Chapter 10 Writing Assembler Control Statements
Here are the contents of the Þle to be assembled, which is in the current directory.
#include
ÒA:\USER\
DEFS\INCL.H
_CODE
section
CODE, PUBLIC, 2
movw
data, A0
mov
0x34, D0
mov
D0, (A0)
main
end
This example includes Þle INCL.H from the directory A:\USER\DEFS.
The results of assembly are shown below in the list Þle. Line number 1 of the list Þle was written
within an #include directive, so the next line number .1 shows the contents of the included Þle INCL.H.
INCLUDE
.LST
***
Page1
***
mn102L00
Cross
Assembler
Loc
Object
Line
Source
1
#include ÒA: \USER\DEFS
\INCL.HÓ
=00000012
.1
data
equ
0x12
3
_CODE
section
code,public,2
4
main
2
000000
DC1200
5
mov
data, A0
000003
8043
6
mov
0x34, D0
000005
00
7
mov
d0, (A0)
ROM
size is 6
(Hex.
No
error
in this
assembly
No
warning
in this
assembly
***
Symbol
Table
***
00000000
A_CODE
00000012
A data
00000000
T main
8
end
00000006)
INCLUDE
234
#include
.LST
Page2
Chapter 10 Writing Assembler Control Statements
10.3 #deÞne
Syntax
#define
identiÞer [replacement_string] [; comment]
Functional description
The #deÞne directive causes the assembler to replace the identiÞer with the replacement_string on all
further lines.
The #deÞne directive differs from the #equ directive in that a string can be speciÞed. Furthermore,
when used in conjunction with the #undef directive, redeÞnition is possible.
Coding rules
Any string can be coded for the replacement_string. The string can include spaces and tabs. If the
replacement_string is omitted, then the identiÞer will be deÞned as a null character.
Everything after a semicolon (;) is considered a comment. Therefore semicolons cannot be included in
the replacement_string.
The same identiÞer cannot just be redeÞned with another #deÞne directive. When used in conjunction
with the #undef directive, redeÞnition is possible. Refer to section 10.4, "#undef", for details.
If the replacement_string is omitted, then the identiÞer will be deÞned as a null character.
Usage example
Source Þle contents are shown below. The Þrst line replaces data with the character 5. The next line is
an example of changing a mnemonic, so mov data,D0 can be coded as load.
#define
data
5
#define
load
mov
_CODE
section
CODE, PUBLIC, 2
mov
data, D0
data, D0
main
load
end
#define 235
Chapter 10 Writing Assembler Control Statements
The assembled list Þle is shown below. Line number 6 and 7 show that the same machine language
code was generated.
DEF.LST
Page1
***
mn102L00
Cross
Assembler
Loc
Object
Line
Source
***
1
#define
data
5
2
#define
load
mov
data, D0
3
4
_CODE
5
main
section
000000
8005
6
mov
000002
8005
7
load
8
end
ROM
size is 4
(Hex.
00000004)
No
error
in this
assembly
No
warning
in this
assembly
DEF.LST
236
***
Symbol
00000000
A_CODE
00000000
T
#define
main
Table
***
CODE, PUBLIC, 2
data., D0
Page2
Chapter 10 Writing Assembler Control Statements
10.4 #undef
Syntax
identiÞer
#undef
Functional description
The #undef directive deletes an identiÞer deÞned by a #deÞne directive. The effective range of an
identiÞer is from the line following #deÞne until the line before #undef.
To redeÞne the replacement string of an identiÞer, redeÞne it with #deÞne after performing an #undef.
Coding rules
The identiÞer for an #undef directive must be the same string as the identiÞer for the corresponding
#deÞne directive. The string is case sensitive.
Usage example
A source Þle that uses #undef is shown below.
#define
data1
0x11
#define
data2
0x22
_CODE
section
CODE, PUBLIC, 2
mov
data1, D0
mov
data2, D1
#undef
data1
mov
#undef
data1, D0
data2
#define
#define
data1
0x33
data2
0x44
mov
data1, D0
mov
data2, D1
end
#undef 237
Chapter 10 Writing Assembler Control Statements
The assembled list Þle is shown below. Line number 7 deletes the identiÞer data1, so it is undeÞned (+)
in line number 8.
UNDEF
.LST
***
Page1
***
mn102L00
Cross
Assembler
Loc
Object
Line
Source
1
#define
data1
0x11
2
#define
data2
0x22
_CODE
section
CODE, PUBLIC, 2
3
4
000000
8011
5
mov
data1, D0
000002
8522
6
mov
data2, D1
7
000004
#undef
F470000000 +8
9
#undef
10
#define
11
#define
mov
data1, D0
data2
data1
data2
0x33
0x44
000009
8033
12
mov
data1, D0
00000B
8544
13
mov
data2, D1
14
end
ROM
size is 13 (Hex.
0000000D)
No
error
in this
assembly
No
warning
in this
assembly
UNDEF
238
data1
***
Symbol
00000000
A_CODE
00000000
+U data1
#undef
Table
***
.LST
Page2
Chapter 10 Writing Assembler Control Statements
10.5 Conditional Assembly
The Cross-Assembler provides conditional assembly capabilities. The directives explained in this
section are provided for this purpose.
By coding conditional assembly directives in a program, the assembler will select which block to
assemble by judging the speciÞed conditions at the time of assembly.
Many conditional assembly directives are used only within macro deÞnitions.
The actual program structure of conditional assembly is shown below.
block1 to be
expression, identiÞer, parameter, etc.
assembled if codition is true
block 2 to be
assembled if condition is false]
#if
[#else
#endif
NOTE:
The contents of brackets [ ] from #else on can be omitted.
The basic function of conditional assembly is for the assembler to evaluate the condition speciÞed by
#if, and then to select the block to assemble based on the result.
Conditional assembly is used for the following purposes.
¥
Different object code for different versions can be output with a single source program.
¥
Machine language instructions differ depending on the device type.
¥
Conditional assembly can be included in programs being debugged.
Conditional Assembly 239
Chapter 10 Writing Assembler Control Statements
The table below lists the directives used for conditional assembly.
Directive
#ifdef
#ifndef
#if
#ifn
#ifeq
(see note)
#ifneq
(see note)
#ißt
#iße
#ifgt
#ifge
#ifb
(see note)
#ifnb
(see note)
NOTE:
240
Conditional Assembly
Condition for selecting block1
IdentiÞer has been deÞned by #deÞne.
IdentiÞer has not been deÞned by #deÞne.
Expression value is not 0.
Expression value is 0.
Parameters 1 and 2 are the same string.
Condition for selecting block2
IdentiÞer has not been deÞned.
IdentiÞer has been deÞned.
Expression value is 0.
Expression value is not 0.
Parameters 1 and 2 are not the same string.
Parameters 1 and 2 are not the same string. Parameters 1 and 2 are the same string.
Expression value is negative.
Expression value is 0 or negative.
Expression value is positive.
Expression value is 0 or positive.
Parameter is the null character.
Expression value is not negative.
Expression value is not 0 and not negative.
Expression value is not positive.
Expression value is not 0 and not positive.
Parameter is not the null character.
Parameter is not the null character.
Parameter is the null character.
These directives can be used only within macro definitions
Chapter 10 Writing Assembler Control Statements
10.5.1 #ifdef,#ifndef
Syntax
Syntax for #ifdef
#ifdef
identiÞer
Syntax for #ifndef
#ifndef
block1
[#else
identiÞer
block1
[#else
block2]
#endif
block2]
#endif
Functional description
#ifdef
If the identiÞer has been deÞned by a #deÞne directive before the #ifdef statement, then block1 will be
assembled. If it has not been deÞned and an #else directive has been coded, then block2 will be
assembled.
#ifndef
If the identiÞer has not been deÞned by a #deÞne directive before the #ifndef statement, then block1
will be assembled. If it has been deÞned and an #else directive has been coded, then block2 will be
assembled.
Coding rules
These directives can be used within macro deÞnitions and wherever machine language instructions can
be coded.
If an identiÞer is deÞned after #ifdef or #ifndef, then it will be considered undeÞned.
IdentiÞers can be speciÞed by the D option when the assembler is started, even if they are not deÞned
with #deÞne directives.
Conditional Assembly
241
Chapter 10 Writing Assembler Control Statements
Usage example
A source Þle that uses #ifdef and #ifndef is shown below.
#define
VERSION
_CODE
section
#ifdef
VERSION
CODE, PUBLIC, 2
mov
0x11, D0
mov
0x11, D0
mov
0x22, D0
#else
#else
#endif
#ifndef
VERSION
mov
0x33, D0
mov
0x44, D0
#else
#endif
end
The assembled list Þle is shown below.
IFDEF.LST
***
mn102L00
Cross
Assembler
Loc
Object
Line
Source
1
#define
VERSION
3
_CODE
section
4
#ifdef
Page 1
***
2
000000
8011
5
6
8
#endif
9
#ifndef
XX
000002
8044
is 4
No error
in
No warning
in
(Hex.
this
this
mov
0x22, D0
VERSION
mov
0x33, D0
mov
0x44, D0
#endif
14
ROM size
0x11, D0
#else
12
13
VERSION
mov
#else
x
11
CODE, PUBLIC, 2
end
00000004)
assembly
assembly
The identifier VERSION is defined in line number 1. The replacement string is a null character. Since
VERSION has been defined, the #ifdef starting from line number 4 will assemble block 1 (line number
5 here), and will not assemble block 2 (shown as line number X).
The #ifndef directive inverts the condition, so block 2 (line number 12) will be assembled.
242
Conditional Assembly
Chapter 10 Writing Assembler Control Statements
10.5.2 #if,#ifn
Syntax
Syntax for #if
#if
expression
Syntax for #ifn
#ifn
expression
block1
[#else
block1
[#else
block2]
#endif
block2]
#endif
Functional description
#if
If the value of expression is not 0, then block1 will be assembled. If it is 0 and an #else directive has
been coded, then block2 will be assembled.
#ifn
If the value of expression is 0, then block1 will be assembled. If it is not 0 and an #else directive has
been coded, then block2 will be assembled.
Coding rules
These directives can be used within macro deÞnitions and wherever machine language instructions can
be coded.
Conditional Assembly 243
Chapter 10 Writing Assembler Control Statements
Usage example
A source Þle that uses #if and #ifn is shown below.
DEVICE
equ
1
_CODE
section
CODE, PUBLIC, 2
#if
DEVICE-1
mov
0x11, D0
mov
0x22, D0
#else
#endif
#ifn
DEVICE-1
mov
0x33, D0
mov
0x44, D0
#else
#endif
end
The assembled list Þle is shown below. The program Þrst sets DEVICE to 1. Therefore the expression
DEVICE-1 will be 0, so the #if directive causes line number 7 to be assembled and the #ifn directive
causes line number 10 to be assembled.
IF1.LST
Page 1
***
mn102L00
Cross
Assembler
***
Loc
Object
Line
Source
=00000001
1
DEVICE
equ
1
3
_CODE
section
CODE, PUBLIC, 2
4
#if
DEVICE-1
2
X
6
000000
000002
8022
8033
7
8
#endif
9
#ifn
10
11
is 4
No error
in
No warning
in
0x22, D0
DEVICE-1
mov
0x33, D0
mov
0x44, D0
end
(Hex.
00000004)
this
assembly
this
mov
#endif
14
ROM size
0x11, D0
#else
XX
13
mov
#else
assembly
IF1.LST
244
***
Symbol
00000001
A
DEVICE
00000000
T
_CODE
Conditional Assembly
Table
***
Page2
Chapter 10 Writing Assembler Control Statements
Next is an assembled list file where the program sets DEVICE to 0. This conversely causes line numbers
5 and 12 to be assembled.
IF1.LST
Page 1
***
mn102L00
Cross
Assembler
***
Loc
Object
Line
Source
=00000000
1
DEVICE
equ
0
3
_CODE
section
CODE, PUBLIC, 2
4
#if
2
000000
8011
5
6
8
#endif
9
#ifn
XX
00002
8044
is 4
(Hex.
this
0x22, D0
DEVICE-1
mov
0x33, D0
mov
0x44, D0
#endif
14
ROM size
mov
#else
12
13
0x11, D0
#else
X
11
DEVICE-1
mov
end
00000004)
No error
in
No warning
in
this
assembly
assembly
***
Symbol
Table
***
00000000
A DEVICE
00000000
A _CODE
IF1.LST
Page2
Conditional Assembly 245
Chapter 10 Writing Assembler Control Statements
10.5.3 #ifeq,#ifneq
Syntax
Syntax for #ifeq
#ifeq
parameter1, parameter2
Syntax for #ifneq
#ifneq
parameter1, parameter2
block1
[#else
block1
[#else
block2]
#endif
block2]
#endif
Functional description
#ifeq
If parameter1 and parameter2 are the same string, then block1 will be assembled. If they are different
and an #else directive has been coded, then block2 will be assembled.
#ifneq
If parameter1 and parameter2 are different strings, then block1 will be assembled. If they are the same
and an #else directive has been coded, then block2 will be assembled.
Coding rules
These directives can only be used within macro deÞnitions.
Either or both of parameter1 and parameter2 may be dummy parameters set up during macro
deÞnition.
246
Conditional Assembly
Chapter 10 Writing Assembler Control Statements
Usage example
A source Þle that uses #ifeq and #ifneq is shown below. The macro named compare uses two dummy
parameters(data1,data2). Within the macro it compares the strings of those dummy parameters. If they
match, then an instruction that sets the A register to 1 will be assembled. If they do not match, then an
instruction that sets the A register to 0 will be assembled. The macro is called by specifying strings to
be passed to the dummy parameters.
compare
macro
#ifeq
data1, data2
data1, data2
mov
1, D0
mov
0, D0
#else
#endif
endm
_CODE
section
CODE, PUBLIC, 2
compare
abcdef, abcdef
compare
abcdef, acbdef
main
end
Conditional Assembly 247
Chapter 10 Writing Assembler Control Statements
The assembled list Þle is shown below. Line number 11 assembles the statements for a match, and line
number 12 assembles the statements for a mismatch.
IFEQ.LST
***
mn102L00
Cross
Assembler
Loc
Object
Line
Source
1
compare
macro
2
#ifeq
data1,data2
3
4
***
data1, data2
mov
1, D0
mov
0, D0
#else
5
6
Page 1
#endif
7
endm
8
9
_CODE
10
main
M11
11+
000000
8001
#ifeq
11+
11+
#ifeq
XX+
12+
000002
8000
is 4
(Hex.
this
mov
1, D0
mov
0, D0
Compare
abcdef, acbdef
abcdef, acbdef
mov
1, D0
mov
0, D0
#endif
13
ROM size
abcdef, abcdef
#else
12+
12+
compare
abcdef, abcdef
#endif
M12
12+
CODE, PUBLIC, 2
#else
XX+
11+
section
end
00000004)
No error
in
No warning
in
this
assembly
assembly
***
Symbol
Table
***
00000000
A _CODE
00000000
T main
IFEQ.LST
Page2
Next is an example where parameter1 is a dummy parameter, but parameter2 is a string specified within
the macro. The source file is shown below. The macro defines only one dummy parameter (data).
Therefore the assembler will evaluate the #ifeq directive assuming that parameter2 is the string
"abcdef."
248
Conditional Assembly
Chapter 10 Writing Assembler Control Statements
compare
macro
#ifeq
data1, abcdef
data
mov
1, D0
mov
0, D0
#else
#endif
endm
_CODE
section
CODE, PUBLIC, 2
compare
abcdef
compare
acbdef
main
end
Conditional Assembly 249
Chapter 10 Writing Assembler Control Statements
The assembled list Þle is shown below.
IFEQ2.LST
***
mn102L00
Cross
Assembler
Loc
Object
Line
Source
1
compare
macro
2
#ifeq
data1,abcdef
3
4
***
data
mov
1, D0
mov
0, D0
#else
5
6
Page 1
#endif
7
endm
8
9
_CODE
10
main
M11
11+
#ifeq
XX+
11+
000000
8000
#ifeq
XX+
12+
000002
8000
is 4
(Hex.
this
mov
1, D0
mov
0, D0
Compare
acbdef
data1, abcdef
mov
1, D0
mov
0, D0
#endif
13
ROM size
abcdef
#else
12+
12+
compare
data1,abcdef
#endif
M12
12+
CODE, PUBLIC, 2
#else
11+
11+
section
end
00000004)
No error
in
No warning
in
this
assembly
assembly
***
Symbol
Table
***
00000000
A _CODE
00000000
T main
IFEQ2.LST
250
Conditional Assembly
Page2
Chapter 10 Writing Assembler Control Statements
10.5.4 #ißt,#iße
Syntax
Syntax for #iflt
Syntax for #ifle
expression
#iflt
#ifle
block1
expression
block1
[#else
[#else
block2]
block2]
#endif
#endif
Functional description
#iflt
If the value of expression is negative, then block1 will be assembled. If it is not negative and an #else
directive has been coded, then block2 will be assembled.
#ifle
If the value of expression is 0 or negative, then block1 will be assembled. If it is positive and an #else
directive has been coded, then block2 will be assembled.
Usage example
The Þrst example will be of #ißt. A source Þle is shown below. The "size-16" expression of the #ißt is
not negative, so block 2 is assembled
MN10200
equ
16
MAX
equ
0xff
romsize
macro
size
#iflt
size-16
movw
(MAX-0x20), DW0
movw
MAX, DW0
#else
#endif
endm
_CODE
section
CODE, PUBLIC, 2
main
romsize
MN10200
end
Conditional Assembly 251
Chapter 10 Writing Assembler Control Statements
The assembled list Þle is shown below.
IFLT.LST
Page 1
***
mn102L00
Cross
Assembler
***
Loc
Object
Line
Source
=00000010
1
MN102L00
equ
16
=000000FF
2
MAX
equ
0xff
4
romsize
macro
size
5
#iflt
size-16
3
6
7
8
9
mov
(MAX-0x20), D0
mov
MAX, D0
#else
#endif
10
endm
11
12
_CODE
13
main
M14
14+
#iflt
XX+
14+
000000
F8FF00
size is 3
romsize
MN10200
MN10200-16
mov
(MAX-0x20), D0
mov
MAX, D0
#endif
15
ROM
CODE, PUBLIC, 2
#else
14+
14+
section
end
(Hex.
00000003)
this
assembly
No error
in
No warning
in
this
assembly
***
Symbol
Table
***
000000FF
A MAX
00000010
A MN10200
00000000
T _CODE
00000000
T main
IFLT.LST
Page2
Next the program's #iflt is changed to #ifle. The result of the #ifle directive's expression will be 0, so
block 1 will be assembled.
252
Conditional Assembly
Chapter 10 Writing Assembler Control Statements
MN10200
equ
16
MAX
equ
0xff
romsize
macro
size
#ifle
size-16
mov
(MAX-0x20), D0
mov
MAX, D0
#else
#endif
endm
_CODE
main
section
romsize
CODE, PUBLIC, 2
MN10200
end
Conditional Assembly 253
Chapter 10 Writing Assembler Control Statements
The assembled list Þle is shown below. You can see that block 1 was assembled.
IFLE.LST
Page 1
***
mn102L00
Cross
Assembler
Loc
Object
Line
Source
***
=00000010
1
MN10200
equ
16
=000000FF
2
MAX
equ
0xff
4
romsize
macro
size
5
#ifle
size-16
3
6
7
(MAX-0x20), D0
mov
MAX, D0
#else
8
9
mov
#endif
10
endm
11
12
_CODE
13
main
M14
14+
000000
C8DF00
#ifle
14+
14+
size is 3
No error
in
No warning
in
MN10200
MN10200-16
mov
(MAX-0x20), D0
mov
MAX, D0
end
(Hex.
00000003)
this
assembly
this
romsize
#endif
15
ROM
CODE, PUBLIC, 2
#else
XX+
14+
section
assembly
IFLE.LST
254
***
Symbol
000000FF
A MAX
00000010
A MN10200
00000000
T _CODE
00000000
T main
Conditional Assembly
Table
***
Page2
Chapter 10 Writing Assembler Control Statements
10.5.5 #ifgt,#ifge
Syntax
Syntax for #ifgt
#ifgt
Syntax for #ifge
expression
#ifge
block1
expression
block1
[#else
[#else
block2]
block2]
#endif
#endif
Coding rules
#ifgt
If the value of expression is positive, then block1 will be assembled. If it is not positive and an #else
directive has been coded, then block2 will be assembled.
#ifge
If the value of expression is 0 or positive, then block1 will be assembled. If it is negative and an #else
directive has been coded, then block2 will be assembled.
Note that 0 is not included in positive numbers.
Usage example
A source Þle that uses #ifgt is shown below. The value of the dummy parameter passed to the macro
type is 0, so block 2 will be assembled.
device
equ
0
type
macro
id
#ifgt
id
mov
1, D0
mov
2, D0
#else
#endif
endm
_CODE
section
CODE, PUBLIC, 2
type
device
main
end
Conditional Assembly
255
Chapter 10 Writing Assembler Control Statements
The assembled list Þle is shown below. You can see that the expression's value is 0, so block 2 was
assembled.
IFGT.LST
Page 1
***
mn102L00
Cross
Assembler
Loc
Object
Line
Source
***
=00000000
1
device
equ
0
3
type
macro
id
4
#ifgt
id
2
5
6
7
8
mov
1, D0
mov
2, D0
#else
#endif
9
endm
10
11
_CODE
12
main
M13
13+
000000
8001
#ifgt
13+
13+
14
size is 2
CODE, PUBLIC, 2
type
device
device
mov
1, D0
mov
2, D0
#else
XX+
ROM
section
end
(Hex.
00000002)
this
assembly
No error
in
No warning
in
this
assembly
***
Symbol
Table
***
00000000
A _CODE
00000000
A device
00000000
T main
IFGT.LST
Page2
Next the program's #ifgt is changed to #ifge. The dummy parameter's value is 0, so this time block 1
will be assembled.
256
Conditional Assembly
Chapter 10 Writing Assembler Control Statements
device
equ
0
type
macro
id
#ifge
id
mov
1, D0
mov
2, D0
#else
#endif
endm
_CODE
section
CODE, PUBLIC, 2
type
device
main
end
Conditional Assembly
257
Chapter 10 Writing Assembler Control Statements
The assembled list Þle is shown below. You can see that block 1 was assembled.
IFGE.LST
Page 1
***
mn102L00
Cross
Assembler
***
Loc
Object
Line
Source
=00000000
1
device
equ
0
3
type
macro
id
4
#ife
id
2
5
6
1, D0
mov
2, D0
#else
7
8
mov
#endif
9
endm
10
11
_CODE
12
main
M13
13+
000000
8001
#ifge
13+
13+
size is 2
No error
in
No warning
in
device
device
mov
1, D0
mov
2, D0
end
(Hex.
00000002)
this
assembly
this
type
#endif
14
ROM
CODE, PUBLIC,2
#else
XX+
13+
section
assembly
IFGE.LST
258
***
Symbol
00000000
T _CODE
00000000
A device
00000000
T main
Conditional Assembly
Table
***
Page2
Chapter 10 Writing Assembler Control Statements
10.5.6 #ifb,#ifnb
Syntax
Syntax for #ifb
#ifb
dummy_parameter
Syntax for #ifnb
#ifnb
block1
[#else
dummy_parameter
block1
[#else
block2]
#endif
block2]
#endif
Functional description
#ifb
If the dummy_parameter is a null character, then block1 will be assembled. If it is not a null character
and an #else directive has been coded, then block2 will be assembled.
#ifnb
If the value of expression is not a null character, then block1 will be assembled. If it is a null character
and an #else directive has been coded, then block2 will be assembled.
Coding rules
These directives can only be used within macro deÞnitions.
The parameter must be a dummy parameter.
Conditional Assembly
259
Chapter 10 Writing Assembler Control Statements
Usage example
A source Þle that uses #ifb is shown below. If the dummy parameter para to the macro debug is a null
character, then the program will execute next_cycle. If it is not a null character, then the program will
execute test and then execute next_cycle. In this example, the identiÞer MODE is passed to the macro
debug. When a replacement string has been speciÞed, the call is without a null character.
debug
macro
#ifb
para
para
jsr
next_cycle
jsr
test
jsr
next_cycle
#else
#endif
endm
_CODE
section
CODE, PUBLIC, 2
#define
MODE
debug_on
debug
MODE
main
#undef
MODE
#define
MODE
debug
end
260
Conditional Assembly
MODE
Chapter 10 Writing Assembler Control Statements
The assembled list Þle is shown below. Where the characters debug_on have been speciÞed, block 2 is
assembled. Where the null character has been speciÞed, block 1 is assembled
.
IFB.LST
***
mn102L00
Cross
Assembler
Loc
Object
Line
Source
1
debug
macro
2
#ifb
para
3
4
para
isr
next_cycle
jsr
test
jsr
next_cycle
#else
5
6
7
Page 1
***
#endif
8
endm
9
10
_CODE
section
CODE, PUBLIC, 2
11
#define
MODE
debug_on
12
main
debug
MODE
M13
13+
#ifb
XX+
13+
000000
F4E100000
+13+
000005
F4E100000
+13+
size is 15
No warning
in
jsr
next_cycle
#undef
MODE
15
#define
MODE
debug
MODE
jsr
next_cycle
XX+
jsr
test
XX+
jsr
next_cycle
#ifb
+16+
#else
#endif
17
in
test
14
16+
No error
jsr
#endif
16+
ROM
next_cycle
13+
16+
F4E1000000
jsr
#else
M16
00000A
debug_on
end
(Hex.
0000000F)
this
assembly
this
assembly
IFB.LST
***
Symbol
00000000
00000000
Table
Page2
***
A _CODE
T main
00000000
+U next_cycle
00000000
+U test
Next the program's #ifb is changed to #ifnb. Now the test routine for debugging will be assembled if a
null character has not been specified.
Conditional Assembly 261
Chapter 10 Writing Assembler Control Statements
debug
macro
#ifnb
para
para
jsr
next_cycle
jsr
test
jsr
next_cycle
#else
#endif
endm
_CODE
section
CODE, PUBLIC, 2
#define
MODE
debug_on
debug
MODE
main
#undef
MODE
#define
MODE
debug
end
262
Conditional Assembly
MODE
Chapter 10 Writing Assembler Control Statements
The assembled list Þle is shown below.
IFNB.LST
***
mn102L00
Cross
Assembler
Loc
Object
Line
Source
1
debug
macro
2
#ifnb
para
3
Page 1
***
para
isr
next_cycle
5
jsr
test
6
jsr
next_cycle
4
7
#else
#endif
8
endm
9
10
_CODE
section
CODE, PUBLIC, 2
11
#define
MODE
debug_on
12
main
debug
MODE
M13
13+
000000
F4E1000000
#ifnb
+13+
jsr
next_cycle
XX+
jsr
test
XX+
jsr
next_cycle
13+
#else
13+
#endif
14
#undef
MODE
15
#define
MODE
M16
16+
16+
000005
F4E1000000
+16+
00000A
F4E1000000
+16+
16+
MODE
jsr
next_cycle
jsr
test
jsr
next_cycle
#else
#endif
17
size is 15
debug
#ifnb
XX+
ROM
debug_on
end
(Hex.
0000000B)
this
assembly
No error
in
No warning
in
this
assembly
***
Symbol
Table
***
IFNB.LST
00000000
A _CODE
00000000
T main
00000000
+U next_cycle
00000000
+U test
Page2
Conditional Assembly
263
Chapter 10 Writing Assembler Control Statements
264
Chapter 11
Writing Macro Control Statements
11
Chapter 11 Writing Macro Control Statements
11.1 Purpose Of This Chapter
Macros consist of two parts: macro deÞnitions and macro calls. A macro that has been deÞned can be
coded as a macro call in any source statement after that.
When a macro without parameters is called, it becomes a simple text substitution. When a macro with
parameters is called, part of the text to be substituted will be modiÞed by the strings speciÞed as the
parameters.
This chapter explains how deÞne and call macros. It also describes the directives used for macros.
Common coding rules
The characters that can be used for macro names, dummy parameters, parameters, and identiÞers are
upper and lower case letters, digits, and underscores (_). The Þrst character must not be a digit.
Symbols used in expressions must have been previously deÞned.
The following directives cannot be coded within macro blocks.
#include directive
macro definitions
Refer to section 11.2, "Macro DeÞnitions", regarding macro deÞnitions and blocks.
The rept and irp directives and macro calls can be coded within macro blocks. Up to 20 nesting levels
are allowed.
Document conventions
Symbols used in this chapter have the following meanings.
[]
()
266
Purpose of This Chapter
Contents of brackets [ ] may be omitted.
Contents of parentheses ( ) may be repeated.
Chapter 11 Writing Macro Control Statements
11.2 Macro DeÞnitions (macro, endm)
Syntax
macro_name
macro
[dummy_parameter (, dummy_parameter)...]
macro_body
endm
NOTE:
10 dummy parameters can be specified.
Functional description
A macro assigns a name to a single process that is used repeatedly in a program, simplifying the coding
of source statements. Macros must be deÞned before they are called.
The macro body is coded with multiple machine language instructions, directives, macro control
instructions, and conditional assembly control instructions. A macro deÞnition is the assignment of a
name to the single process in the macro body.
A macro is called by coding its name in the operation Þeld of a source statement. The assembler then
inserts the text of the macro body at that position. This is called macro expansion.
Macro deÞnitions can have up to 10 dummy parameters. Dummy parameters are used within the
macro body to allow the caller to modify some of the expanded text.
Reference:
Subroutines have similar functions, but macros and subroutines differ on the following
points.
1) Macro expansion actually writes the macro body's machine language code in the
object file each time the macro is called at that call's position. For subroutines the
subroutine body exists at one location in the program.
2) By using parameters, macro expansion allows the programmer to change the
expanded machine language instructions each time the macro is called. For
subroutines the process cannot be changed.
Macro Definition (macro, endm) 267
Chapter 11 Writing Macro Control Statements
Coding rules
The following instructions cannot be used within macro deÞnitions.
¥
include directive
¥
macro directive Ñ within a macro deÞnition another different macro cannot be deÞned
¥
purge directive Ñ within a macro deÞnition macros cannot be purged
The symbols used in the label Þelds within a macro deÞnition must be declared with the local directive
or passed from the outside using dummy parameters. Refer to section 11.5, "Local Symbol Declaration
(local)", for details.
A macro can be redeÞned. The new deÞnition will be effective from the following line on.
The purge directive can purge a macro deÞnition. The macro will be recognized as an instruction or
symbol from the following line on.
The same mnemonic as a machine language instruction can be used as a macro name. Which receives
priority at assembly time can be speciÞed using front and back directives.
When the same mnemonic as a machine language instruction is deÞned as a macro, the default is as
though the back directive had been speciÞed, which causes assembly as a machine language
instruction. Lines after a front directive will give the macro deÞnition priority. Refer to section 9.11,
"front / back", for details.
The assembler does not perform syntax checks when a macro is deÞned. If there are errors or
warnings, then they will be output when the macro is expanded.
Usage example
An example macro deÞnition is shown below.
xchg
macro
mov
D2, D0
mov
D1, D2
mov
D0, D1
endm
268
Macro Definition (macro, endm)
Chapter 11 Writing Macro Control Statements
11.3 Macro Calls And Expansion
Syntax
macro_name
NOTE:
[parameter (, parameter)... ]
10 parameters can be specified.
Functional description
A macro is called by coding its name in the operation Þeld of a source statement. The assembler then
inserts the text of the macro body at that position.
When parameters are speciÞed, their values are passed in the same order as the dummy parameter when
the macro was deÞned.
mac1
macro
para1, para2, para3
;macro deÞnition
address, data, count
;macro call
.
.
endm
main
mac1
In this example para1, para2, and para3 are dummy parameters. The parameters of the macro call are
passed to the dummy parameters as follows.
para1 = address
para2 = data
para3 = count
Macro Calls And Expansion
269
Chapter 11 Writing Macro Control Statements
Coding rules
Any string can be speciÞed as a parameter. To specify a string that includes commas or spaces, use the
macro operator <>. Refer to section 9.4, "Macro Operators", for details.
If there are more parameters than there were dummy parameters in the macro deÞnition, then an error
will occur.
If there are fewer parameters than there were dummy parameters in the macro deÞnition, then the
assembler will process the remaining parameters as though null characters were speciÞed.
In the list Þle, the line numbers of source statements with macro calls will be preÞxed by the letter 'M'.
The source statements resulting from macro expansion will have a '+' appended to the line number.
Usage example
A source Þle is shown below. The macro add_adr has one dummy parameter. The dummy parameter is
used as the operand of an add machine language instruction within the macro body. Take note whether
a macro name is the same as a machine language instruction.
The macro is called with var1 and var2 as parameters.
var1
equ
0x10
var2
equ
var1+2
add_adr
macro
adr
add
adr, A0
endm
_CODE
section
CODE, PUBLIC, 2
add_adr
var1
add_adr
var2
main
end
Reference:
By adding the Lm option when the assembler is started, you can suppress the output
of mnemonics of macros expanded by the assembler.
270
Macro Calls And Expansion
Chapter 11 Writing Macro Control Statements
The assembled list Þle is shown below.
***
Loc
mn102L00
Object
=00000010
=00000012
000000
D010
000002
D012
ROM size
No
No
is 4(Hex.
error in
warning in
00000000
00000000
00000010
00000012
A
T
A
A
Cross
Line
1
2
3
4
5
6
7
8
9
M10
10+
M11
11+
12
this
this
INC_MAC
Assembler
Source
var1
var2
.LST
***
Page1
equ
equ
0x10
var1+2
add_adr
macro
add
adr
adr,A0
endm
_CODE
main
00000004)
assembly
assembly
INC_MAC
section
CODE, PUBLIC, 2
add_adr
add
add_adr
add
end
var1
var1, A0
var2
var2, A0
.LST
Page2
_CODE
main
var1
var2
Macro Calls And Expansion 271
Chapter 11 Writing Macro Control Statements
11.4 Macro Operators
Macro operators are used in macro bodies to operate on parameters of macro calls. Macro operators
are listed below.
Operator
&
Description
Concatenates strings.
Macro deÞnition dummy parameters
p1&p2&p3
®
p1&p2&p3
®
Escape characters for including normally
(<, >, &, \) in parameters of macro calls.
Macro deÞnition dummu parameters
p1&p2&\>\>&p3\&0x0f
®
Passes the enclosed string as a single
Macro deÞnition dummy parameters
p1
®
\
<>
Macro call
abc, def,ghi ®
data, 1, 3
®
unusable
Macro expansion
abcdefghi
data13
characters
Mcro calll
var. 3. 2 ®
parameter of a
Macro call
<ÒabcÓ, 1> ®
Macro expansion
var3>>2&0x0f
macro call.
Macro expansion
ÒabcÓ, 1
Usage example
The following example uses the operators \, <>, and &. The & characters in the body of macro mac1
are used with two different meanings. The & before the dummy parameters is a macro operator. The &
before the hexadecimal 0x0f indicates a logical AND.
mac1
mac2
_CODE
main
macro
mov
endm
macro
p1
endm
section
mac1
mac2
end
272
Macro Oprators
p1, p2, p3
p1&p2\>\>&p3\&0x0f, D0
p1, p2
p2
CODE, PUBLIC, 2
1,2,3
<add>, <1, D0>
Chapter 11 Writing Macro Control Statements
The assembled list Þle is shown below.
***
Loc
mn102L00
Object
000000
8001
000002
D401
ROM size
No
No
is 4 (Hex.
error in
warning in
00000000
00000000
A _CODE
T main
NOTE:
Cross
Line
1
2
3
4
5
6
7
8
9
10
M11
11+
M12
12+
13
this
this
MAC
Assembler
Source
mac1
.LST
***
Page1
macro
mov
endm
p1, p2, p3
p1&p2\>\>&p3\&0x0f, D0
mac2
p1
endm
_CODE
main
00000004)
assembly
assembly
MAC
macro p1, p2
p2
section
CODE, PUBLIC, 0
mac1
mov
mac2
add
end
1,2,3
12>>3&0x0f, D0
<add>, <1,D0>
1, D0
.LST
Page2
< > can be nested at a macro call.
Macro Operators
273
Chapter 11 Writing Macro Control Statements
Example:
mac2
NOTE:
1, <<10, 20>, <30, 40>>
Be sure to use < > in pairs for nesting. The parameter cannot be passed to
macro, if < > are not used in pairs.
Be sure to know the followings when you describe shift operators (<<, >>) in the
parameter enclosed with < >.
Left shift (<<) in the parameter enclosed with < > may be assumed as < of macro
operator, so that the pairs of < > cannot be recognized correctly. In this case,
macro expansion cannot be performed correctly. (Example(1)).
Right shift (>>) in the < > does not prevent the correct expansion because > of
macro operator is processed prior to shift operators (Example(2)).
If you describe shift operators in the < >, append backslash(\) just before < or > to
clarify it as not macro operator (Example(3), (4)).
Example:
mac3 <1<<2>, 3
mac3 <1>>2>, 3
mac3 <1\<\<2>, 3
mac3 <1\>\>2>, 3
274
Macro Operators
;(1)
;(2)
;(3)
;(4)
leads wrong expansion result
processed correctly
processed correctly
processed correctly
Chapter 11 Writing Macro Control Statements
11.5 Local Symbol Declaration (local)
Syntax
macro_name
symbol
macro
parameter
local
symbol (, symbol)...
.
.
.
endm
NOTE:
30 symbols can be specified.
Functional description
The local directive declares local symbols used in a macro body. When local symbols are expanded,
the are expanded in the form ??XXXXX, where XXXXX is in the range starting 00001 to 99999.
Coding rules
Symbols speciÞed with the local directive should not be used outside the macro deÞnition.
The local directive can be used only within macro deÞnitions.
Local symbols should be used after they have been declared by the local directive.
If the local symbol ??XXXXX used by the local directive is not undeÞned, then an error will occur.
Local Symbol Declaration (local)
275
Chapter 11 Writing Macro Control Statements
Usage example
An example using the local directive is shown below.
loc
lab1
lab2
macro
p1
local
lab1, lab2, lab3
mov
p1, D0
mov
0, D1
cmp
D1, D0
bcc
lab2
mov
(A0), D2
add
1, D1
bra
lab2
lab3
nop
_CODE
section
CODE, PUBLIC, 2
loc
3
loc
2
endm
main
end
The assembled list file is shown next. You can see that each time the local symbol is expanded it is
changed to ??00001, ??00002, ...
***
Loc
000000
000002
000004
276
mn102L00
Object
A030
A500
324
Local Symbol Declaration (local)
Cross
Line
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
M18
18+
18+
18+
LOCAL
Assembler
Source
loc
local
mov
mov
lab1
bcc
lab2
add
mov
addw
add
bra
lab3
endm
.LST
***
Page1
macro
lab1, lab2
p1, D0
0, D1
cmp
lab2
mov
1, D2
D2, (A0)
2, A0
1, D1
lab2
nop
p1
lab3
_CODE
main
section
CODE, PUBLIC, 0
loc
mov
mov
cmp
3
3, D0
3, D1
D1, D0
??00001
D1, D0
(A0), D2
Chapter 11 Writing Macro Control Statements
000005_
000008
000009
00000A_
00000B_
00000D
00000E_
000011
9C000
4A
821
5A
EC2
811
99000
00
000012
000014
000016
000017_
00001A
00001B
000001C_
000001D_
000001F
000020_
000023
A020
A500
324
9C000
4A
821
5A
EC2
811
99000
00
ROM size
No
No
is 36 (Hex.
error in
warning in
***
00000004
00000008
00000011
00000016
0000001A
00000023
00000000
00000000
Symbol
T ??00001
T ??00002
T ??00003
T ??00004
T ??00005
T ??00006
T _CODE
T main
+18
18+
18+
18+
18+
18+
+18+
18+
M19
19+
19+
19+
+19+
19+
19+
19+
19+
19+
+19+
19+
20
this
this
??00002
??00003
loc
??00004
??00005
??00006
bcc
mov
add
mov
addw
add
bra
nop
2
mov
mov
cmp
bcc
mov
add
mov
addw
add
bra
nop
end
00000024)
assembly
assembly
LOCAL .LST
Table
***
??00002
(A0), D2
1, D2
D2, (A0)
2, A0
1, D1
??00002
2, D0
0, D1
D1, D0
??00005
(A0), D2
1, D2
D2, (A0)
2, A0
1, D1
??00005
Page2
Local Symbol Declaration (local)
277
Chapter 11 Writing Macro Control Statements
11.6 Forced Termination Of Macro Expansion
(exitm)
Syntax
macro_name
macro
#ifndef
identiÞer
parameter
exitm
#endif
.
.
.
endm
Functional description
The exitm directive forcibly terminates macro expansion at the point it appears. Used in conjunction
with an #ifndef directive, it can end macro expansion if an identiÞer is undeÞned. If the identiÞer has
been deÞned, then expansion beyond #endif will be performed. (The conditions are reversed when
#ifdef is used.)
Coding rules
In addition to #ifdefÐ#endif, all directives listed in section 8.5, "Conditional Assembly", can be used.
The exitm directive can be used at any location. The assembler will terminate macro expansion after it
appears.
The exitm directive can only be used within macro deÞnitions.
Usage example
Usage example with #ifb directive
A source Þle is shown below. The identiÞer TEST is used for the condition. In main the Þrst macro
call is made with TEST undeÞned. This causes exitm to be executed, so jsr debug will not be
expanded.
TEST is deÞned before the second macro call, so here the statements after #endif will be assembled.
278
Local Symbol Declaration (local)
Chapter 11 Writing Macro Control Statements
extm
macro
#ifndef
TEST
mov
1, D0
exitm
#endif
jsr
debug
endm
_CODE
section
CODE, PUBLIC, 2
main
extm
#define
TEST
extm
end
Forced Termination Of Macro Expansion (exitm)
279
Chapter 11 Writing Macro Control Statements
The list Þle is shown below. The second macro call has been expanded after #endif.
***
Loc
000000
mn102L00
Object
8001
Cross
Line
1
EXITM .LST
Assembler
***
Source
extm
macro
2
3
#ifndef
4
5
6
7
8
9
10
M11
11+
11+
11+
11+
11+
12
000002
280
8001
000004
F4E1000000
ROM size
No
No
is 9 (Hex.
error in
warning in
***
00000000
00000000
00000000
Symbol
A _CODE
+U debug
T main
M13
13+
13+
XX+
13+
+13+
14
this
this
Forced Termination Of Macro Expansion (exitm)
mov
Page1
1, D0
TEST
exitm
#endif
_CODE
main
#ifndef
jsr
endm
debug
section
CODE, PUBLIC, 2
extm
mov
1, D0
TEST
exitm
#endif
jsr
#define
TEST
extm
mov
#ifndef
debug
1, D0
TEST
exitm
#endif
jsr
end
00000009)
assembly
assembly
EXITM .LST
Table
***
debug
Page2
Chapter 11 Writing Macro Control Statements
Usage example with #ifeq directive
A source Þle is shown below. The macro call parameter is passed to the expression used as the #ifeq
condition. If #ifeq has two different parameters, then expansion will terminate. In this example,
p1=off for the Þrst macro expansion, so the statements after #endif will be expanded.
In the second macro expansion p1=on, so statements after #endif will not be expanded.
extm
macro
#ifeq
p1, 0ff
p1
exitm
#else
jsr
debug
endm
_CODE
section
CODE, PUBLIC, 2
extm
off
extm
on
main
end
Forced Termination Of Macro Expansion (exitm)
281
Chapter 11 Writing Macro Control Statements
The assembled list Þle is shown below.
***
Loc
mn102L00
Object
Cross
Line
1
2
3
4
5
6
7
8
9
10
M11
11+
000000
282
F4E1000000
ROM size
No
No
is 5 (Hex.
error in
warning in
***
00000000
00000000
00000000
Symbol
A _CODE
+U debug
T main
11+
11+
11+
11+
M12
12+
XX+
12+
+12+
12+
13
this
this
Forced Termination Of Macro Expansion (exitm)
EXITM1 .LST
Assembler
***
Source
extm
macro
#ifeq
Page1
p1
p1, off
exitm
#else
jsr
debug
#endif
endm
_CODE
main
#ifeq
section
CODE, PUBLIC, 2
extm
off
off, off
exitm
#else
jsr
debug
extm
on, off
exitm
on
jsr
debug
#endif
#ifeq
#else
#endif
end
00000005)
assembly
assembly
EXITM1 .LST
Table
***
Page2
Chapter 11 Writing Macro Control Statements
11.7 Purging Macro DeÞnitions (purge)
Syntax
macro_name (, macro_name)...
purge
Functional description
The purge directive purges the deÞnitions of the speciÞed macro names.
Coding rules
The macro names speciÞed with the purge directive are valid for previously deÞned macro names.
After the purge directive, purged macros will not be expanded even if they are called. They will be
processed as instructions or symbols.
The purge directive cannot be used within macro deÞnitions.
When multiple macro names are speciÞed, they are delimited by commas (,).
Usage example
This example deÞnes the macro name rts, which is the same as a machine language instruction. The
Þrst rts will be taken as a macro call and expanded. The rts after purge has been executed will not be
recognized as a macro name, but will be taken as a return instruction.
front
rts
macro
nop
endm
_CODE
section
CODE, PUBLIC, 2
main
rts
purge
rts
rts
end
Forced Termination Of Macro Expansion (exitm)
283
Chapter 11 Writing Macro Control Statements
The assembled list Þle is shown below.
***
Loc
000000
F6
000001
FE
ROM size
No
No
is 2 (Hex.
error in
warning in
***
00000000
00000000
284
mn102L00
Object
Symbol
A _CODE
T main
Purging Macro Definitions (purge)
Cross
Line
1
2
3
4
5
6
7
M8
8+
9
10
11
this
this
PURGE .LST
Assembler
***
Source
Page1
front
rts
macro
nop
endm
_CODE
main
section
CODE, PUBLIC, 2
rts
nop
purge
rts
end
rts
00000002)
assembly
assembly
PURGE .LST
Table
***
Page2
Chapter 11 Writing Macro Control Statements
11.8 rept
Syntax
expression
rept
block
endm
Functional description
The rept directive repeatedly expands the speciÞed block the speciÞed number of times. It is used for
simple repeating without parameters. The rept directive can be coded anywhere in a program or even
within a macro deÞnition.
Coding rules
Symbols cannot be used within a block. If used, then a double deÞnition error will occur. The local
directive cannot be used either.
Further rept and ipt directives and macro calls can be coded within a block. Up to 20 nesting levels are
allowed.
Usage example
In the following example, the rept directive is in a macro deÞnition that is used twice in the program
main.
repeat
macro
p1
rept
p1
add
1, D0
endm
endm
_CODE
section
CODE, PUBLIC, 2
repeat
5
main
rept
3
repeat
2
endm
end
rept
285
Chapter 11 Writing Macro Control Statements
The assembled list Þle is shown below.
***
Loc
000000
000002
000004
000006
000008
286
rept
mn102L00
Object
D401
D401
D401
D401
D401
00000A
00000C
D401
D401
00000E
000010
D401
D401
0000012
0000014
D401
D401
ROM size
No
No
is 22 (Hex.
error in
warning in
***
00000000
Symbol
A _CODE
Cross
Line
1
2
3
4
5
6
7
8
M9
M9+
9+
9+
9+
9+
9+
9+
9+
M10
11
12
M12+
M12+
12+
12+
12+
12+
M12+
M12+
12+
12+
12+
12+
M12+
M12+
12+
12+
12+
12+
13
this
this
REPT .LST
Assembler
***
Source
repeat
macro
rept
add
endm
endm
_CODE
main
00000016)
assembly
assembly
REPT
Table
Page1
p1
p1
1, D0
section
CODE, PUBLIC, 2
repeat
rept
add
endm
add
add
add
add
add
rept
repeat
endm
repeat
rept
add
endm
add
add
repeat
rept
add
endm
add
add
repeat
rept
add
endm
add
add
end
5
5
1, D0
.LST
***
1,
1,
1,
1,
1,
3
2
D0
D0
D0
D0
D0
2
2
1, D0
1, D0
1, D0
2
2
1, D0
1, D0
1, D0
2
2
1, D0
1, D0
1, D0
Page2
Chapter 11 Writing Macro Control Statements
00000000
T main
The first call of the repeat macro expands to five add instructions. The next repeat macro call is within
a rept that repeats three times, so it will expand to three sets of two add instructions each.
rept
287
Chapter 11 Writing Macro Control Statements
11.9 irp
Syntax
irp
dummy_parameter, parameter (, parameter) ...
block
endm
NOTE:
10 dummy parameters can be specified.
Functional description
The irp directive repeatedly expands the speciÞed block the speciÞed number of times. The dummy
parameter is used within the block. The macro expansion replaces the dummy parameter with each
parameter in turn, repeated for the number of parameters.
Coding rules
Symbols cannot be used within a block. If used, then a double deÞnition error will occur. The local
directive cannot be used either.
If a comma (,) delimiters in a row are speciÞed, then the corresponding parameter will be processed as
though a null character had been speciÞed.
To specify strings that include commas and spaces, use the macro operator <>.
288
rept
Chapter 11 Writing Macro Control Statements
Usage example
In the following example, the irp directive is in a macro deÞnition that is used twice in the program
main.
init
_CODE
main
_DATA
data
macro
irp
mov
mov
endm
endm
section
init
irp
mov
endm
section
dw
opr, <data\& 0x0f>
opr, D0
opr, D1
CODE, PUBLIC, 0
reg, D2, D3
0, reg
DATA, PUBLIC, 2
0
end
irp
289
Chapter 11 Writing Macro Control Statements
The assembled list Þle is shown below.
***
Loc
290
irp
mn102L00
Object
000000
000002
F470000000
F470000000
000004
000006
AA00
AF00
000000
0000
ROM size
No
No
is 16(Hex.
error in
warning in
***
00000000
00000000
00000000
00000000
Symbol
A _CODE
A _DATA
D data
T main
Cross
Lne
1
2
3
4
5
6
7
8
9
M10
M10+
10+
10+
10+
+10+
+10+
M11
12
13
13+
13+
14
15
16
17
18
this
this
IRP .LST
Assembler
***
Source
init
macro
irp
mov
mov
endm
endm
Page1
_CODE
main
CODE, PUBLIC, 2
section
init
irp
mov
mov
endm
mov
mov
irp
mov
endm
mov
mov
_DATA
data
section
dw
end
00000010)
assembly
assembly
IRP .LST
Table
***
opr,<data\&0x0f>
opr, D0
opr, D1
opr,<data&0x0f>
opr, D0
opr, D1
data&0x0f, D0
data&0x0f, D1
reg, D2, D3
0, reg
0, D2
0, D3
DATA, PUBLIC, 2
0
Page2
Chapter 11 Writing Macro Control Statements
11.10 irpc
Syntax
dummy_parameter, "string"
irpc
block
endm
Functional description
The irpc description repeatedly replaces the dummy parameter with each character in the speciÞed
string one at a time. The dummy parameter can be used in the block. The macro expansion replaces
the dummy parameter with each character in turn, repeated for the number of characters.
Coding rules
The string cannot include the characters &, \, ', and ".
Symbols cannot be used within a block. If used, then a double deÞnition error will occur. The local
directive cannot be used either.
Usage example
The following example uses the irpc directive
.
_CODE
section
irpc
dc
endm
irpc
dc
irpc
dc
endm
irpc
dc
end
CODE, PUBLIC, 2
dummy, ÒA1!Ó
ÔdummyÕ
dummy, Ò#$%( ) = ! @ ~ [ Ò
ÔdummyÕ
dummy, Ò1234567890Ó
ÔdummyÕ
dummy, Ò?_Ó
ÔdummyÕ
irpc
291
Chapter 11 Writing Macro Control Statements
The assembled list Þle is shown below.
***
Loc
292
irpc
mn102L00
Object
IRPC .LST
Assembler ***
Source
_CODE
section
irpc
dc
endm
Page1
000000
41
Cross
Lne
1
M2
3
4
4+
000001
31
4+
dc
000002
20
4+
dc
000003
21
4+
dc
000004
20
4+
dc
000005
20
4+
dc
ÔAÕ
Ô1 Ô
Ô Õ
Ô!Õ
Ô Ô
Ô Ô
M5
6
7
irpc
dc
dummy, Ò#$%( )=!@~[
ÔdummyÕ
7+
7+
7+
7+
7+
7+
7+
7+
7+
7+
M8
9
10
10+
10+
10+
10+
10+
10+
10+
10+
10+
10+
M11
12
13
13+
13+
14
dc
dc
dc
dc
dc
dc
dc
dc
dc
dc
irpc
dc
endm
dc
dc
dc
dc
dc
dc
dc
dc
dc
dc
irpc
dc
endm
dc
dc
end
0000001C)
000006
000007
000008
000009
00000A
00000B
00000C
00000D
00000E
00000F
23
24
25
28
29
3D
21
40
7E
5B
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
31
32
33
34
35
36
37
38
39
30
00001A
00001B
3F
5F
ROM size
No
is 28
error in
this
dc
CODE, PUBLIC, 2
dummy, ÒA1 ! Ò
ÔdummyÕ
endm
(Hex.
assembly
Ô#Õ
Ô$Õ
Ô%Õ
Ô(Ô
Ô)Ô
Ô=Õ
Ô!Ô
Ô@Ô
Ô~Ô
Ô[
dummy, Ò1234567890Ó
ÔdummyÕ
Ô1Õ
Ô2Õ
Ô3Õ
Ô4Õ
Ô5Õ
Ô7Õ
Ô8Õ
Ô9Õ
Ô9Õ
Ô0Õ
dummy, Ò?_Ó
ÔdummyÕ
Ô?Õ
Ô_Õ
Chapter 11 Writing Macro Control Statements
No
warning in
***
00000000
Symbol
A _CODE
this
assembly
IRPC .LST
Table
***
Page2
irpc
293
Chapter 11 Writing Macro Control Statements
11.11 front / back
Syntax
front
.
.
back
.
.
Functional description
The front and back directives change the look-up sequence of machine language instructions and macro
names. They are used when deÞning macros with the same names as machine language instructions.
The assembler maintains two tables: one that registers machine language instructions and one that
registers macro instructions. Normally (in the default state) the assembler processes the table that
registers machine language instructions Þrst. That means macros with the same name as machine
language instructions will not be expanded.
The front directive changes the table look-up sequence so that the assembler searches the table that
registers macro instructions Þrst. When a macro has the same name as a machine language instruction,
the macro expansion will have priority.
front
First search table that registers macro instructions.
back
First search table that registers machine language instructions.
Coding rules
The front and back directives can be coded at any statement position in a program.
The look-up sequence will change from the next line after the front/back directive.
294
front / back
Chapter 11 Writing Macro Control Statements
Usage example
A source Þle is shown below. It deÞnes the macro rts, which has the same name as a machine language
instruction.
front
rts
macro
nop
endm
_CODE
section
CODE, PUBLIC, 2
main
rts
purge
rts
rts
back
rts
macro
nop
endm
rts
purge
rts
rts
end
front/back
295
Chapter 11 Writing Macro Control Statements
The assembled list Þle is shown below.
***
Loc
000000
F6
000001
FE
000002
FE
000003
FE
ROM size
No
No
is4
error in
warning in
***
00000000
00000000
296
mn102L00
Object
front/back
Symbol
A _CODE
T main
Cross
Lne
1
2
3
4
5
6
7
M8
8+
9
10
11
12
13
14
15
16
17
18
this
this
FRONT .LST
Assembler
***
Source
front
rts
macro
nop
endm
Page1
_CODE
main
section
CODE, PUBLIC, 2
rts
nop
purge
rts
back
rts
rts
macro
nop
endm
rts
purge
rts
end
00000004)
(Hex.
assembly
assembly
FRONT .LST
Table
***
rts
Page2
Chapter 12
List Of Machine Language Instructions
12
Chapter 12 List of Machine Language Instructions
12.1 Purpose Of This Chapter
The chapter lists machine language instructions of the microcomputers.
This comprehensive list of addressing modes and mnemonics for every instruction can be quite useful
when you are coding machine language instruction statements.
If you need to know about the detailed operation of individual instructions, then refer to the Instruction
Manual.
298
Purpose Of This Chapter
12.2 Addressing Modes
The microcomputers support four addressing modes for memory accesses.
The following four address formats are methods for accessing an address speciÞed as an address
register's contents or as the sum of an address register's contents and a displacement.
¥
Register indirect addressing
¥
Register relative indirect addressing
¥
Absolute addressing
¥
Index addressing
Register indirect addressing
Register indirect addressing
Register indirect addressing is speciÞes the address to access with the address register An.
0
23
An
RAM
Address specification
Addressing Modes 299
Chapter 12 List of Machine Language Instructions
Register relative indirect addressing
1. Register relative indirect addressing determines the address to access using the following three
combinations.
Address register An with a sign-extended 8-bit or 16-bit displacement
0
16
d16/d8
0
23
23
An
0
sign-extended
+
0
23
RAM
Address specification
300
Addressing Modes
2. Address register An with a 24-bit displacement
0
23
23
0
An
d24
+
0
23
RAM
Address specification
3. Program counter PC with a sign-extended 8-bit or 16-bit displacement
0
16
d16/d8
0
23
PC
23
0
sign-extended
0
23
RAM
Address specification
Addressing Modes 301
Chapter 12 List of Machine Language Instructions
Absolute addressing
Absolute addressing speciÞes the address to be accessed as a 24-bit or 16-bit displacement.
0
23
abs24/abs16
RAM
Address specification
Index addressing
Index addressing extends the offset of register indirect addressing, adds address register An and data
register Dn, and takes the resulting value as the offset.
0
23
15
0
An
Dn
+
0
23
RAM
Address specification
302
Addressing Modes
12.3 List Of Machine Language Instructions
Symbol
An, Am
Dn, Dm
imm8
imm16
imm24
d8
d16
d24
MDR
PSW
CF
ZF
NF
VF
CXF
ZXF
NXF
VXF
()
Description
Address register (n, M=3 to 0)
Data register (n, M = 3 to 0)
8-bit immediate data speciÞed with an instruction
16-bit immediate data speciÞed with an instruction
24-bit immediate data speciÞed with an instruction
8-bit offset data speciÞed with an instruction
16-bit offset data speciÞed with an instruction
24-bit offset data speciÞed with an instruction
Multiply/divide register
Program status word
Carry ßag
Zero ßag
Negative ßag
Overßow ßag
Extended carry ßag
Extended zero ßag
Extended negative ßag
Extended overßow ßag
Indicates an indirect address
List Of Machine Language Instructions 303
Chapter 12 List of Machine Language Instructions
12.3.1 Data Move Instructions
MOVE source to destination
Mnemonic
Register
Direct
Immediate
Value
Register
Indirect
MOV Dn, Am
MOV An, Dm
MOV Dn, Dm
MOV an, Am
MOV DBRn, Dn
MOV Dn, DBRn
MOV MDR, Dn
MOV Dn, MDR
MOV PSW, Dn
MOV Dn, PSW
MOV SCBR, Dn
MOV Dn, SCBR
MOV imm8, Dn
MOV imm16, Dn
MOV imm24, Dn
MOV imm16, An
MOV imm24, An
MOV (An),Dm
MOV Dn, (Am)
MOV (An), Am
MOVB(An), Dm
MOVB Dn, (Am)
MOVBU (An), Dm
Register
Relative
Indirect
304
MOV (d8, An), Dm
MOV Dn, (d8, Am)
MOV (d16, An), Dm
Description of operation
Moves contents of Dn to Am.
Moves contents of An to Dm
Moves contents of Dn to Dm
Moves contents of An to Am
Moves sign-extended contents of DBRn to Dn
Moves lower 8 bits of Dn to DBRn
Moves contents of MDR to Dn
Moves contents of Dn to MDR
Moves contents of PSW to Dn
Moves contents of Dn to PSW
Moves sign-extended contents of SCBR to Dn
Moves lower 8 bits of Dn to SCBR
Moves sign-extended 8-bit immediate data speciÞed by the
instruction to Dn
Moves 16-bit immediate data speciÞed by the instruction to Dn
Moves 24-bit immediate data speciÞed by the instruction to Dn
Moves 16-bit immediate data speciÞed by the instruction to An
Moves 24-bit immediate data speciÞed by ghe instruction to An
Moves contents of memory speciÞed by An to Dm
Moves contents of Dn to memory speciÞed by Am
Moves contents of An to memory speciÞed by Am
Moves sign-extended 8-bit contents of memory speciÞed by An
to Dm
Moves lower 8 bits of contents of Dn to memory speciÞed by Am
Moves zero-extended 8-bit contents of memory speciÞed by An
to Dm
Moves contents of memory speciÞed by An, d8 to Dm
Moves contents of Dn to memory speciÞed by Am, d8
Moves contents of Dn to memory specified by Am, d24
MOV Dn, (d16, Am) Moves contents of Dn to memory speciÞed by Am, d16
MOV (d24, An), Dm Moves contents of Dn to memory speciÞed by Am, d24
MOV Dn,(d24, Am) Moves contents of memory speciÞed by Am, d24
MOV (d8, An), Am
Moves contents of memory speciÞed by An,d8 to Am.
MOV An, (d8, Am)
Moves contents of An to memory speciÞed by Am,d8.
MOV (d16, An), Am Moves contents of memory speciÞed by An,d16 to Am
MOV An, (d16, Am) Moves contents of An to memory speciÞed by Am,d16
MOV (d24, An), Am Moves contents of memory speciÞed by An,d24 to Am
MOV An, (d24, Am) Moves contents of An to memory speciÞed by Am,d24
MOVB (d8, An), Dm Moves sign-extended 8-bit contents of memory speciÞed by
An,d8 to Dm.
List Of Machine Language Instructions
Mnemonic
(Register
Relative
Indirect)
Index
Absolute
Description of operation
MOVB Dn, (d8, Am)
Moves lower 8 bits of contents of Dn to memory speciÞed by
Am,d8.
MOVB (d16, An),
Moves sign-extended 8-bit contents of memory speciÞed by
Dm
An,d16 to Dm.
MOVB Dn, (d16,
Moves lower 8 bits of contents of Dn to memory speciÞed by
Am)
Am,d16.
MOVB (d24, An),
Moves sign-extended 8-bit contents of memory speciÞed by
Dm
An,d24 to Dm.
MOVB Dn, (d24,
Moves lower 8 bits of contents of Dn to memory speciÞed by
Am)
Am,d24.
MOVBU (d8, An),
Moves zero-extended 8-bit contents of memory speciÞed by
Dm
An,d8 to Dm
MOVBU (d16, An),
Moves zero-extended 8-bit contents of memory speciÞed by
Dm
An,d16 to Dm
MOVBU (d24, An),
Moves zero-extended 8-bit contents of memory speciÞed by
Dm
An,d24to Dm
MOVX (d8, An)), Dm Moves contents of memory speciÞed by An,d8 to Dm.
MOVX Dn, (d8, An) Moves contents of Dn to memory speciÞed by Am,d8
MOVX (d16, An)),
Moves contents of memory speciÞed by An,d16to Dm
Dm
MOVX Dn, (d16, An) Moves contents of Dn to memory speciÞed by Am,d16
MOVX (d24, An)),
Moves contents of memory speciÞed by An,d24 to Dm
Dm
MOVX Dn, (d24,
Moves contents of Dn to memory speciÞed by Am,d24
Am)
MOV (Dn, An), Dm Moves contents of memory speciÞed by Dn,An to Dm
MOV Dn, (Dm, An) Moves contents of Dn to memory speciÞed by Dm,An
MOV (Dn, An), Am
Moves contents of memory speciÞed by Dn,An to Am
MOV An, (Dn, Am)
Moves contents of Dn to memory speciÞed by Dm,Am
MOVB (Dn, An), Dm Moves sign-extended 8-bit contents of memory speciÞed by
An,Dn to Dm
MOVB Dn, (Dm, An) Moves lower 8 bits of contents of Dn to memory speciÞed by
An,Dm
MOVBU (Dn, An),
Moves zero-extended 16-bit contents of memory speciÞed by
Dm
An,Dn to Dm
MOV (abs16), Dn
Moves contents of memory speciÞed by abs16 to Dn
MOV (abs24), Dn
Moves contents of memory speciÞed by abs24 to Dn
MOV Dn, (abs16)
Moves contents of Dn to memory speciÞed by abs16
MOV Dn, (abs24)
Moves contents of Dn to memory speciÞed by abs24
MOV (abs16), An
Moves contents of memory speciÞed by abs16 to An
MOV (abs24), An
Moves contents of memory speciÞed by abs24 to An
MOV An, (abs16)
Moves contents of An to memory speciÞed by abs16
MOV An, (abs24)
Moves contents of An to memory speciÞed by abs24
MOVB (abs16), Dn
Moves sign-extended 8-bit contents of memory speciÞed by
abs16 to Dn
MOVB Dn, (abs16)
Moves lower 8 bits of contents of Dn to memory speciÞed by
abs16
List Of Machine Language Instructions 305
Chapter 12 List of Machine Language Instructions
Mnemonic
(Absolute)
Description of operation
MOVB (abs24), Dn
Moves sign-extended 8-bit contents of memory speciÞed by
abs24 to Dn
MOVB Dn, (abs24)
Moves lower 8 bits of contents of Dn to memory speciÞed by
abs24
MOVBU (abs16), Dn Moves zero-extended 8-bit contents of memory speciÞed by
abs16 to Dn
MOVBU (abs24), Dn Moves zero-extended 8-bit contents of memory speciÞed by
abs24 to Dn
EXTEND Sign
Mnemonic
EXT Dn
EXTX Dn
EXTU Dn
EXTXB Dn
EXTXBU Dn
306
Description of operation
Sign-extends contents of Dn to 32 bits, and moves the extended upper 16 bits
to MDR
Sign-extends the lower 16 bits of Dn to 24 bits, and stores in Dn.
Zero-extends the lower 16 bits of Dn to 24 bits, and stores in Dn.
Sign-extends the lower 8 bits of Dn to 24 bits, and stores in Dn
Zero-extends the lower 8 bits of Dn to 24 bits, and stores in Dn
List Of Machine Language Instructions
12.3.2 Arithmetic Instructions
ADD
Mnemonic
Register
ADD Dn, Dm
ADD Dn, An
ADD An, Dn
ADD An, Am
ADD imm8, Dn
Immediate
ADD imm16, Dn
Value
ADD imm24, Dn
ADD imm8, An
ADD imm16, An
ADD imm24, An
Description of operation
Adds contents of Dn and Dm, and stores result in Dm
Adds contents of Dn and An, and stores result in An
Adds contents of An and Dn, and stores result in Dn
Adds contents of An and Am, and stores result in Am
Adds sign-extended 8-bit immediate data speciÞed by the
instruction to Dn, and stores the result in Dn
Adds 16-bit immediate data speciÞed by the instruction to
Dn, and stores the result in Dn
Adds 24-bit immediate data speciÞed by the instruction to
Dn, and stores the result in Dn
Adds sign-extended 8-bit immediate data speciÞed by the
instruction to An, and stores the result in An
Adds 16-bit immediate data speciÞed by the instruction to
An, and stores the result in An
Adds 24-bit immediate data speciÞed by the instruction to
An, and stores the result in An.
ADD with CARRY
Mnemonic
ADDC Dn, Dm
Description of operation
Adds contents of Dn and Dm with the carry, and stores the result in Dm
ADD without FLAG
Mnemonic
ADDNF imm8, An
Description of operation
Sign-extends the 8-bit immediate data speciÞed by the instruction, adds this
to the contents of An, and stores the result in An.
List Of Machine Language Instructions 307
Chapter 12 List of Machine Language Instructions
SUBTRACT
Mnemonic
Register
Immediate
SUB Dn, Dm
SUB Dn, An
SUB An, Dn
SUB An, Am
SUB imm16, Dn
Value
SUB imm24, Dn
SUB imm16, An
SUB imm24, An
Description of operation
Subtracts contents of Dm from Dn, and stores result in Dm
Subtracts contents of An from Dn, and stores result in An
Subtracts contents of Dn from An, and stores result in Dn
Subtracts contents of Am from An, and stores result in Am
Subtracts 16-bit immediate data speciÞed by the instruction
from Dn, and stores the result in Dn
Subtracts 24-bit immediate data speciÞed by the instruction
from Dn, and stores the result in Dn
Subtracts 16-bit immediate data speciÞed by the instruction
from An, and stores the result in An
Subtracts 24-bit immediate data speciÞed by the instruction
from An, and stores the result in An
SUBTRACT with BORROW
Mnemonic
SUBC Dn, Dm
Description of operation
Subtracts contents of Dm from Dn with the carry, and stores the result in Dm
MULTPLY
Mnemonic
Signed
MUL Dn, Dm
Unsigned
MULU Dn, Dm
Description of operation
Multiplies contents of Dn (a signed 16-bit integer) and Dm
(a signed 16-bit integer), and stores upper 16 bits of the 32-bit
product in MDR and lower 16 bits in Dm
Multiplies contents of Dn (an unsigned 16-bit integer) and
Dm (an unsigned 16-bit integer), and stores upper 16 bits of the
32-bit product in MDR and lower 16 bits in Dm
DIVIDE
Mnemonic
Unsigned
308
DIVU Dn, Dm
List Of Machine Language Instructions
Description of operation
Divides contents of Dm (an unsigned 16-bit integer) into
contents of the 32-bit unsigned integer formed by
concatenating MDR (the upper 16 bits) and DN (the lower 16
bits), and stores the 16-bit quotient in Dm. If VF=1, then MDR
and Dm will be undeÞned
COMPARE source with destination
Mnemonic
Register
CMP Dn, Dm
CMP Dn, An
CMP An, Am
CMP An, Dn
Immediate
Value
CMP imm8, Dn
CMP imm16, Dn
CMP imm24, Dn
CMP imm16, An
CMP imm24, An
Description of operation
Subtracts contents of Dn from Dm, and reßects the result in the
ßags
Subtracts contents of Dn from An, and reßects the result in the
ßags
Subtracts contents of Am from An, and reßects the result in the
ßags
Subtracts contents of An from Dn, and reßects the result in the
ßags
Subtracts sign-extended 8-bit immediate data speciÞed by the
instruction from contents of Dn, and reßects the result in the
ßags
Subtracts 16-bit immediate data speciÞed by the instruction
from contents of Dn, and reßects the result in the ßags
Subtracts 24-bit immediate data speciÞed by the instruction
from contents of Dn, and reßects the result in the ßags
Subtracts 16-bit immediate data speciÞed by the instruction
from contents of An, and reßects the result in the ßags
Subtracts 24-bit immediate data speciÞed by the instruction
from contents of An, and reßects the result in the ßags
List Of Machine Language Instructions 309
Chapter 12 List of Machine Language Instructions
12.3.3 Logical Instructions
AND source with destination
Mnemonic
AND Dn, Dm
AND imm8, Dn
AND imm16, Dn
AND imm16, PSW
Description of operation
Performs logical AND of Dn and Dm, and stores result in Dm
Performs logical AND of Dn and zero-extended 8-bit
immediate data speciÞed by the instruction, and stores the
result in Dn
Performs logical AND of Dn and 16-bit immediate data
speciÞed by the instruction, and stores the result in Dn
Performs logical AND of PSW and 16-bit immediate data
speciÞed by the instruction, and stores the result in PSW
OR source with destination
Mnemonic
OR Dn, Dm
OR imm8, Dn
OR imm16, Dn
OR imm16, PSW
Description of operation
Performs logical OR of Dn and Dm, and stores result in Dm.
Performs logical OR of Dn and zero-extended 8-bit immediate
data speciÞed by the instruction, and stores the result in Dn.
Performs logical OR of Dn and 16-bit immediate data speciÞed
by the instruction, and stores the result in Dn
Performs logical OR of PSW and 16-bit immediate data
speciÞed by the instruction, and stores the result in PSW
EXCLUSIVE-OR source with destination
Mnemonic
Register
Immediate
Value
XOR Dn, Dm
XOR imm16, Dn
Description of operation
Performs exclusive OR of Dn and Dm, and stores result in Dm.
Performs exclusive OR of Dn and 16-bit immediate data
speciÞed by the instruction, and stores the result in Dn
NOT destination
Mnemonic
NOT Dn
310
List Of Machine Language Instructions
Description of operation
Inverts all bits of Dn and stores the result in Dn.
ARITHMETIC SHIFT RIGHT
Mnemonic
ASR Dn
Description of operation
Performs a 1-bit arithmetic shift right on contents of Dn and stores the
result in Dn. The LSB of Dn from before the calculation will be stored in
the C ßag
LOGICAL SHIFT RIGHT
Mnemonic
LSR Dn
Description of operation
Performs a 1-bit logical shift right on contents of Dn and stores the result in
Dn. The LSB of Dn from before the calculation will be stored in the C ßag.
The MSB of Dn will be set to 0
ROTATE RIGHT
Mnemonic
ROR Dn
Description of operation
Concatenates Dn and the C ßag, rotates it 1-bit to the right,and stores the
result in Dn
ROTATE LEFT
Mnemonic
ROL Dn
Description of operation
Concatenates Dn and the C ßag, rotates it 1 bit to the left, and stores the
result in Dn
List Of Machine Language Instructions 311
Chapter 12 List of Machine Language Instructions
12.3.4 Subroutine Call Instructions
CALL Subroutine
Mnemonic
JSR (An)
JSR label
RTS
RTI
Description of operation
After pushing the next instruction address on the stack (low byte Þrst), sets
PC to the contents of An and jumps to the subroutine.
After pushing the next instruction address on the stack (low byte Þrst),
jumps to the subroutine indicated by label
Pops the address that was pushed on the stack, sets the PC to that address,
and returns from the subroutine
Performs the following to return from an interrupt routine
¥ Pops the stack to restore the PSW.
¥ Pops the caller address from the stack, and sets the PC to it.
¥ Sets the contents of SCBR to CBR
12.3.5 Unconditional Branch Instructions
Unconditional BRANCH
Mnemonic
JMP (An)
JMP label
312
List Of Machine Language Instructions
Description of operation
Branches unconditionally to the address speciÞed by the contents of An
Branches unconditionally to the address speciÞed by label (branch range is
0 to 0xFFFFFF)
12.3.6 Conditional Branch Instructions
Conditional BRANCH
Mnemonic
Meaning
BEQ label
ZF set
BNE label
ZF clear
BGT label
<(signed)
BGE label
£(signed)
BLE label
³ (signed)
BLT label
> ( signed )
BHI label
< ( unsigned )
BCC label
£ ( unsigned )
CF clear
BLS label
³ ( unsigned )
BCS label
> ( unsigned )
CF set
BVC label
VF clear
BVS label
VF set
BNC label
NF clear
BNS label
NF set
Description of operation
If ZF=1, branches to the relative address speciÞed by label (branch
range is -128 to +127).
If ZF=0, executes the next instruction.
If ZF=0, branches to the relative address speciÞed by label (branch
range is -128 to +127).
If ZF=1, executes the next instruction.
If ZF=0 and NF=VF, branches to the relative address speciÞed by
label (branch range is -128 to +127).
If ZF=1 or NF<>VF, executes the next instruction.
IF NF=VF, branches to the relative address speciÞed by label (branch
range is -128 to +127).
IF NF¹VF, executes the next instruction.
If CF=1 or ZF=1, branches to the relative address speciÞed by label
(branch range is -128 to +127).
If CF=0 and ZF=0, executes the next instruction.
If NF=1 and VF=1, or if NF=0 and VF=0, branches to the relative
address speciÞed by label (branch range is -128 to +127).
If NF=1 and VF=0, or if NF=0 and VF=1, executes the next
instruction.
If CF=0 and ZF=0, branches to the relative address speciÞed by label
(branch range is -128 to +127).
If CF=1 or ZF=0, executes the next instruction.
If CF=0, branches to the relative address speciÞed by label (branch
range is -128 to +127).
If CF=1, executes the next instruction.
If CF=1 or ZF=1, branches to the relative address speciÞed by label
(branch range is -128 to +127).
If CF=0 and ZF=0, executes the next instruction.
If CF=1, branches to the relative address speciÞed by label (branch
range is -128 to +127).
If CF=0, executes the next instruction.
If VF=0, branches to the relative address speciÞed by label (branch
range is -128 to +127).
If VF=1, executes the next instruction.
If VF=1, branches to the relative address speciÞed by label (branch
range is -128 to +127).
If VF=0, executes the next instruction.
If NF=0, branches to the relative address speciÞed by label (branch
range is -128 to +127).
If NF=1, executes the next instruction.
If NF=1, branches to the relative address speciÞed by label (branch
range is -128 to +127).
If NF=0, executes the next instruction.
List Of Machine Language Instructions 313
Chapter 12 List of Machine Language Instructions
Mnemonic
BRA label
314
Meaning
l
List Of Machine Language Instructions
Description of operation
Unconditionally branches to the relative address speciÞed by the
operand label (branch range is -128 to +127).
Extended Conditional BRANCH
Mnemonic
Meaning
BEQX label
=
ZXF set
BNEX label
¹
ZXF clear
BGTX label
<(signed)
BGEX label
£(signed)
BLEX label
³ (signed)
BLTX label
> ( signed )
BHIX label
< ( unsigned )
BCCX label
£ ( unsigned )
CXF clear
BLSX label
³ ( unsigned )
BCSX label
> ( unsigned )
CFX set
BVCX label
VXF clear
BVSX label
VXF set
BNCX label
NXF clear
BNSX label
NXF set
Description of operation
If ZXF=1, branches to the relative address speciÞed by label (branch
range is -128 to +127).
If ZXF=0, executes the next instruction.
If ZXF=0, branches to the relative address speciÞed by label (branch
range is -128 to +127).
If ZXF=1, executes the next instruction.
If ZXF=0 and NXF=VXF, branches to the relative address speciÞed
by label (branch range is -128 to +127).
If ZXF=1 or NXF¹VXF, executes the next instruction.
IF NXF=VXF, branches to the relative address speciÞed by label
(branch range is -128 to +127).
IF NXF¹VXF, executes the next instruction.
If CXF=1 or ZXF=1, branches to the relative address speciÞed by
label (branch range is -128 to +127).
If CXF=0 and ZXF=0, executes the next instruction.
If NXF=1 and VXF=1, or if NXF=0 and VXF=0, branches to the
relative address speciÞed by label (branch range is -128 to +127). If
NXF=1 and VXF=0, or if NXF=0 and VXF=1, executes the next
instruction.
If CXF=0 and ZXF=0, branches to the relative address speciÞed by
label (branch range is -128 to +127).
If CXF=1 or ZXF=0, executes the next instruction.
If CFX=0, branches to the relative address speciÞed by label (branch
range is -128 to +127).
If CFX=1, executes the next instruction.
If CXF=1 or ZXF=1, branches to the relative address speciÞed by
label (branch range is -128 to +127).
If CXF=0 and ZXF=0, executes the next instruction.
If CXF=1, branches to the relative address speciÞed by label (branch
range is -128 to +127).
If CXF=0, executes the next instruction.
If VXF=0, branches to the relative address speciÞed by label (branch
range is -128 to +127).
If VXF=1, executes the next instruction.
If VXF=1, branches to the relative address speciÞed by label (branch
range is -128 to +127).
If VXF=0, executes the next instruction.
If NXF=0, branches to the relative address speciÞed by label (branch
range is -128 to +127).
If NXF=1, executes the next instruction.
If NXF=1, branches to the relative address speciÞed by label (branch
range is -128 to +127).
If NXF=0, executes the next instruction.
List Of Machine Language Instructions 315
Chapter 12 List of Machine Language Instructions
12.3.7 Bit Manipulation Instructions
BIT Operation
Mnemonic
BTST imm8, Dn
BTST imm16, Dn
BSET Dn, (Am)
BCLR Dn, (Am)
Description of operation
Performs a logical AND of the contents of Dn and the zero-extended 8-bit
immediate data speciÞed by the instruction, and reßects the result in the ßags.
Performs a logical AND of the contents of Dn and the 16-bit immediate data
speciÞed by the instruction, and reßects the result in the ßags.
Loads a 16-bit internal temporary register with the zero-extended 8-bit
contents of the memory indicated by Am, performs a logical AND with the
contents of Dn, and reßects the ßag results in the PSW. Also performs a
logical OR of the contents of the temporary register and Dn, storing the lower
8 bits of the result in the memory indicated by Am. Bus clocks and interrupts
are disabled while all operations of this instruction are executed.
Loads a 16-bit internal temporary register with the zero-extended 8-bit
contents of the memory indicated by Am, performs a logical AND with the
contents of Dn, and reßects the ßag results in the PSW. Also performs a
logical OR of the contents of the temporary register and the inverted contents
of Dn, storing the lower 8 bits of the result in the memory indicated by Am.
Bus
12.3.8 Other Instructions
NO OPERATION
Mnemonic
NOP
316
Description of operation
Performs no processing. Consumes a Þxed amount of time.
List Of Machine Language Instructions
Chapter 13
Error Messages
13
Chapter 13
Error Messages
13.1 Purpose Of This Chapter
There are three types of errors
¥
Warnings
¥
Errors
¥
Fatal errors
This chapter lists the error messages that may occur during assembly and linking.
How to read
The meanings of each entry in the error message tables are as shown below.
error_number
318 Purpose Of This Chapter
displayed_message
cause
solutions
Chapter 10 Error Messages
13.2 Assembler Errors
The assembler has three types of messages: warning messages, error messages, and fatal error
messages.
13.2.1 Error Messages
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
Syntax error
This line has a syntax error.
Refer to the instruction guidelines in this manual.
Operand error
An incorrect type of operand was used for a machine language instruction
Check whether or not the operand type and value are incorrect.
Illegal operand value
The operand value is not a legal value.
Change the operand value to a legal value.
Symbol multiple defined
This is a symbol double-deÞnition error.
Change the symbol.
Symbol undefined
This is an undeÞned symbol error.
DeÞne the symbol or declare it as an external reference.
Can't output to listing file
The columns per line in the list Þle is too small.
Make the columns per line larger with the page directive.
Operand type should be absolute
The operand value is not an absolute address.
Specify an absolute address for the operand valu
Illegal address mode
An illegal address mode was used.
Check the address mode.
Illegal symbol type
An illegal address mode was used.
Check the symbol type.
Define symbol multiple defined
This is a symbol double-deÞnition error.
Change the #deÞne identiÞer or use the #undef directive.
ROM or RAM table over flow
The ROM or RAM check table is full.
Contact Matsushita Electronics Corporation.
Assembler Errors 319
Chapter 13
Error Messages
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
320
Assembler Errors
Use map file value
The map Þle and assembly results are different.
Check the map Þle value.
Expression oveflow
A value outside the allowed range was speciÞed for a dc directive operand.
Make the value fall within range.
Eliminated instruction
A value outside the allowed range was speciÞed for a dc directive operand.
Make the value fall within range.
Branch address out of range
The branch address exceeds the allowed range.
Check the branch address.
Unterminated conditional assemble
There is no #endif.
Specify an #endif.
Operand value should be 0 -15
The operand value is not a legal value.
Change the operand value to a legal value.
Operand value should be -128 -255.
The operand value is not a legal value.
Change the operand value to a legal value.
Operand value should be 0 - 255.
The operand value is not a legal value.
Change the operand value to a legal value.
Too many "#if" or "#endif"
The numbers of #if and #endif directives do not match.
Check the #if and #endif speciÞcations.
Too many "#else"
There are too many #else directives.
Check the #else speciÞcations.
No optimizing information
There is no optimization information in the map Þle.
Check the map Þle.
Illegal constant
The coding of an expression is illegal.
Check the expression coding.
Change PADIX equal 10
The radix for expressions in extended language is not 10.
Change the radix to using the radix directive.
Ignore RADIX
When expression format is extended language, te fadix directive is ignored.
Remove the radix directive.
Chapter 10 Error Messages
2025
2026
2030
Define symbol recursive defined
A #deÞne directive identiÞer is recursively deÞned.
Check the deÞnition of the #deÞne directive identiÞer.
Can't find newline at EOF
The source Þle ended without a carriage return character.
Add a carriage return character at the end of the line.
Write code at code section
An instruction is coded outside the code section.
Code instructions in the code section.
Assembler Errors 321
Chapter 13
Error Messages
13.2.2 Warning Messages
2002
2011
2050
2051
2052
2053
2054
2055
2056
322
Assembler Errors
Illegal operand value
The operand value is not a legal value.
Change the operand value to a legal value.
Use map file value
The map Þle and assembly results are different.
Check the map Þle value.
Operand value must be 0 - X'FF'
The operand value is not a legal value.
Change the operand value to a legal value.
Operand value must be 0 - XÕFFFFÕ
The operand value is not a legal value.
Change the operand value to a legal value.
Relative branch far -128 - 127.
The operand value is not a legal value.
Change the operand value to a legal value.
Illegal rom address
The operand value is not a legal value.
Chante the operand value to a legal value.
Illegal ram address
The operand value is not a legal value.
Change the operand value to a legal value.
Operand value must be -128 - 127
The operand value is not a legal value.
Change the operand value to a legal value.
Operand value must be -32768 - 32767
The operand value is not a legal value.
Change the operand value to a legal value.
Chapter 10 Error Messages
13.2.3 Fatal Error Messages
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
Memory full
The RAM size of the personal computer is insufÞcient.
Check that the RAM size is correctly set using the CHKDSK command of MSDOS.
Can't write to output file
Disk space is insufÞcient or there is a disk defect.
Perform a disk check using the CHKDSK command of MS-DOS.
Line too long ( MAX 256 char/line )
One line of a source statement exceeds 256 characters.
Edit the source statement so each line has 256 characters or fewer.
Can't open output file
The output Þle speciÞcation is incorrect, or disk space is insufÞcient, or there is
a disk defect.
For the former case, check that the Þle name is speciÞed correctly. For the latter
cases, perform a disk check using the CHKDSK command of MS-DOS.
Label buffer full
There are too many labels.
Split up the source Þle, or reduce the number of labels, or increase the label
registration areas using the install program (PAINST.EXE).
Can't open tmp file
Not enough Þles can be opened simultaneously.
Check the CONFIG.SYS setting.
Illegal option
The option speciÞcation is illegal.
Check the option speciÞcation.
Input file error
The input Þle speciÞcation is incorrect, or disk space is insufÞcient, or there is a
disk defect.
For the former case, check that the Þle name is speciÞed correctly. For the latter
cases, perform a disk check using the CHKDSK command of MS-DOS.
Cross reference buffer full
The RAM size of the personal computer is insufÞcient.
Check that the RAM size is correctly set using the CHKDSK command of MSDOS.
Directory name too long
A speciÞed directory name is too long.
Keep the directory name to 60 characters or fewer.
File name too long
A speciÞed Þle name is too long.
Keep the Þle name to 60 characters or fewer.
Assembler Errors 323
Chapter 13
Error Messages
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
324
Assembler Errors
Illegal file name
There is no Þle name speciÞcation for an option.
Specify a Þle name.
Include nesting error ( max 3 level )
There are more than 3 include nesting levels.
Keep the include nesting levels to 3 or fewer.
Symbol tmp buffer full
There is too much debug information.
Simplify the structure deÞnition
Member tmp buffer full
There is too much debug information.
Simplify the structure deÞnition.
Macro buffer full
There are too many macros.
Split up the source Þle, or reduce the number of labels.
Missing endm
There is no endm to correspond to a macro directive.
Check the macro and endm directives.
Macro nesting error ( max 15 level )
There are more than 15 macro nesting levels.
Keep the macro nesting levels to 15 or fewer.
Local label buffer full
There are too many labels.
Split up the source Þle, or reduce the number of labels.
Define buffer full
There are too many #deÞne directives.
Split up the source Þle, or reduce the number of #deÞne directives.
Tmp file I/O error
Disk space is insufÞcient or there is a disk defect.
Perform a disk check using the CHKDSK command of MS-DOS.
Illegal warning number
A warning number speciÞcation is illegal.
Check the warning number speciÞcations.
Can't unlink tmp file
Disk space is insufÞcient or there is a disk defect.
Perform a disk check using the CHKDSK command of MS-DOS
.
Can't open include file
The Þle name speciÞcation is incorrect, or disk space is insufÞcient, or there is a
disk defect.
For the former case, check that the Þle name is speciÞed correctly. For the latter
cases, perform a disk check using the CHKDSK command.
Chapter 10 Error Messages
2525
2526
2527
2528
2529
2530
Can't open reserve file
The directory that contains the assembler is too deep, or there is a disk defect.
For the former case, keep the directory speciÞcation to 60 characters fewer.
For the latter case, perform a disk check using the CHKDSK command.
Illegal I/O file name
The speciÞed Þle name is the same as another input/output Þle.
Change the Þle name.
Illegal map file format
The map Þle format is illegal.
Check the map Þle.
Too long #define line ( MAX 256 char/line )
The result of #deÞne expansion exceeds 256 characters.
Change deÞnitions such that #deÞne expansion is 256 characters or fewer.
Install a CPU-Type with the ASINS-TOOL
There has been an internal failure.
Contact Matsushita.
Section buffer full.
There are too many distinct section labels.
Reduce the number of section labels.
Assembler Errors 325
Chapter 13
Error Messages
13.3 Linker Errors
The linker has three types of messages: warning messages, error messages, and fatal error messages.
3300
3301
3302
3303
3304
3305
3306
326
Assembler Errors
Global label multiple define
A global label is deÞned twice.
Check the label deÞnition.
Undefined label
The label is undeÞned.
Check the label deÞnition.
/t option is used in absolute-File
A ROM address has been changed in an absolute address format program.
Check the ROM address.
Bad option switch
An option speciÞcation is in error.
Check the option speciÞcation.
Not warning message number
A warning number of the W option is in error.
Check the W option warning numbers.
ROM size overflow
The ROM size exceeds the maximum value.
Reduce the ROM size, or change the maximum value of ROM using the install.
Illegal section operand
An operand speciÞcation of the section directive is in error.
Make the operand of the section directive the same as the section name.
Chapter 10 Error Messages
13.3.1 Warning Messages
3050
3051
3052
3053
3054
3055
3056
3067
Operand value must be 0 - X'FF'
The operand value is not a legal value.
Change the operand value to a legal value.
Operand value must be 0 - X'FFFF'
The operand value is not a legal value.
Change the operand value to a legal value.
Relative branch far -128 - 127
The operand value is not a legal value.
Change the operand value to a legal value.
Illegal rom address
The operand value is not a legal value.
Change the operand value to a legal value.
Illegal ram address
The operand value is not a legal value.
Change the operand value to a legal value.
Operand value must be -128 - 127
The operand value is not a legal value.
Change the operand value to a legal value.
Operand value must be -32768 - 65535
The operand value is not a legal value.
Change the operand value to a legal value.
The line of map file exceeds 256 letters.
Since more than 256 letters are coded in one line of the map Þle, the Þnal list Þle
is not created.
Reduce the letters of the Þlename or sectionname.
Assembler Errors 327
Chapter 13
Error Messages
13.3.2 Fatal Error Messages
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
328
Cannot open RF-file
An input Þle does not exist.
Check that the Þle exists.
No RF-file
An input Þle is not an RF Þle.
Check that the input Þle is not in error.
File can't load
An input Þle has a problem.
Assemble the Þle again and check that the disk being used has not problems.
Bad file search
An input Þle has a problem.
Assemble the Þle again and check that the disk being used has not problems.
Operator not supported
An RF Þle has a problem.
Assemble the Þle again.
No memory space
Memory size of your personal computer is insufÞcient.
Check that memory size is adequate.
Disk full
Disk space on your personal computer is insufÞcient.
Check that disk space is adequate.
Invalid hex-data
A hexadecimal number is coded incorrectly.
Check the coding of the hexadecimal number.
Output-file can't open
The output Þle has a problem.
Check that the coding of the output Þle name is correct.
Address overlay
ROM addresses overlay each other.
Check ROM address settings.
3510
Cannot open Parameter-file
The parameter Þle has a problem.
Check that the coding of the parameter Þle name is correct.
3513
Operand error
An operand is in error.
Check that the coding of the operand is correct.
Assembler Errors
Chapter 10 Error Messages
3700
Internal error
An error occurred in internal processing.
Contact Matsushita Electronics Corporation.
Linker Errors
329
Chapter 13
330
Error Messages
Chapter 14
Readinig List Files
14
Chapter 14 Reading List Files
14.1 Purpose Of This Chapter
This chapter explains how to read the list Þles output during assembly.
There are three types of information output in a list Þle.
¥
Machine language code
¥
Symbol table
¥
Cross-reference table
This chapter also explains how to read the information added by individual options and the meanings of
special symbols.
332
Purpose Of This Chapter
Chapter 14 Reading List Files
14.2 Reading List Files
Adding the l (letter) option when the assembler is invoked will generate the list Þle in the current
directory. List Þle contents are entirely in text format, so the can be viewed with the TYPE command
of MS-DOS or by using an editor.
Reading List Files
333
Chapter 14 Reading List Files
14.2.1 Output Format Of Machine Language Code
The output format of the machine language code section is shown below.
Location
Loc
Machine
Language Code
Supplemental
Information
Object
R
*
+
M
@
Line
Number
Supplemental
Information
Source
Statement
+
Line
Source
.
Each of these Þelds is described below.
Location (Loc)
The location Þeld shows the location counter values during assembly.
For section address format programs, the location Þeld shows the relative value from the start of the
section. However, if the assembly is to output the Þnal list by incorporating the map Þle from linking,
then the location Þeld will match the execution addresses.
Machine language code (Object)
This Þeld shows machine language code.
The eight bits of one byte are shown as two hexadecimal digits. These are 1-byte, 2-byte, 3-byte and 4byte instrucions.
334
Reading List Files
Chapter 14 Reading List Files
Machine language code supplemental information
The characters R, *, +, M, and @ may be added to the machine language code as supplemental
information. The meaning of each character is as follows.
R
This line includes a relocatable symbol whose value will be determined during linking. The
machine language code does not indicate the Þnal values.
*
This line includes an externally deÞned symbol whose value will be determined during
linking. The machine language code does not indicate the Þnal values.
+
This line includes an undeÞned symbol that was automatically changed to an external
deÞnition. The machine language code does not indicate the Þnal values.
M
This line is a result of macro expansion.
@
This line includes an instruction whose value will be the object of optimization during
linking. The machine language code does not indicate the Þnal values.
Line number (Line)
The assembler adds a line number to each source statement.
Line number supplemental information
Sometimes the line number will be shown as X. Sometimes it will be preceded by a period (.), and
sometimes it will be followed by a plus sign (+).
X
Line numbers shown as X indicate that the line will not be processed by the assembler.
During conditional assembly this is used for lines in the block of the unfulÞlled condition.
If the Lc option is added when the assembler is invoked, then output of blocks of unfulÞlled conditions
will be suppressed.
.Line numbers preceded by a period indicate that the line was included by an include directive. The
number of periods indicate the nesting levels of include directives. For example ".." means the line was
included by an include directive that itself was within an include Þle.
.10
..10
...10
#include
#include, #include
#include, #include, #include
If the Li option is added when the assembler is invoked, then output of lines included by include
directives will be suppressed.
+
Line numbers followed by a plus sign indicate the line was a result of macro expansion. In
addition to macro expansions deÞned by macro directives, a plus sign is added to expansions
by irp and rept directives.
Reading List Files
335
Chapter 14 Reading List Files
Source statement
The source statements of the source Þle are output as is.
If the Lm option is added when the assembler is invoked, then output of source statements resulting
from macro expansion will be suppressed.
Below are example of source statement.
***
Loc
mn102L00
Object
=00001100
336
000000
000001
000002
000004
000006
000007
000008
00000A
20
04
D002
D102
20
04
D002
D102
00000C
00000B
F4E10000000
EA00
ROM size
No
No
is 19 (Hex.
error in
warning in
***
00000000
00001100
00000000
00000000
Symbol
A _CODE
A data
T main
*U move
Reading List Files
Cross
Line
1
.1
2
3
4
5
6
7
8
9
10
11
12
13
14
XX
XX
17
M18
18+
18+
18+
18+
19
20
21
22
23
+24
R25
26
this
this
***
OUTLIST
Assembler
Source
#include
data
load
_CODE
main
#ifdef
.lst
***
Page1
Òoutlist.hÓ
equ
0x1100
global
move
macro
mov
mov
add
add
endm
(A0), D0
D0, (A1)
2, A0
2, A1
section
CODE, PUBLIC, 2
mov
mov
VERSION
data, D0
D0, (A0)
load
mov
mov
add
add
mov
mov
add
add
(A0), D0
D0, (A1)
2, A0
2, A1
(A0), D0
D0, (A1)
2, A0
2, A1
#else
#endif
00000013)
assembly
assembly
OUTLIST
jsr
bra
move
main
end
.LST
Page2
Chapter 14 Reading List Files
14.2.2 Symbol Table
If only the l (letter) option is speciÞed, and not the c or s options, when the assembler is invoked, then
the assembler will output a symbol table to the list Þle after the machine language code section.
If the c option is speciÞed, then a cross-reference table will be output instead of the symbol table.
The symbol table outputs the name, value, and type of every symbol in the source Þle. It has the
following format.
Symbol Value
Supplemental
Inforamtion
*
Symbol Type
00000000
+
A
T
U
Symbol Name
XXXXXX
Symbol Value
The symbol's value is shown as eight hexadecimal digits.
Supplemental Information
The symbol type may be preceded by a * or +.
*
This indicates an externally deÞned symbol.
+
This indicates an undeÞned symbol that was automatically changed to an externally deÞned
symbol.
Symbol Type
This indicates the type of symbol. All symbols can be classiÞed into three types: A, U, and T.
A
This indicates that the symbol value is absolute.
T
This indicates a text format symbol. The symbol value is an address value.
U
This indicates that the symbol was not deÞned in the source Þle. It is an undeÞned symbol.
Reading List Files
337
Chapter 14 Reading List Files
Symbol Name
Symbol names are shown up to 64 characters.
An output example of a symbol table is shown below.
OUtLIST.LST
*** Symbol
00001100
00000000
00000000
338
Reading List Files
Table
***
A data
T main
*U move
Page2
Chapter 14 Reading List Files
14.2.3 Cross-Reference Table
If the c option is added when the assembler is invoked, then a cross-reference table will be output
instead of a symbol table. The format of the cross reference table is shown below.
Symbol Name
Symbol Value
XXXXX
00000000
Supplemental
Information
Symbol Type
*
+
ABS
EXT
TXT
UND
Reference List
XXXXXX
Symbol Name
Symbol names are shown up to 64 characters.
Symbol Value
The symbol's value is shown as eight hexadecimal digits.
Supplemental Information
The symbol type may be preceded by a * or +.
*
This indicates an externally deÞned symbol.
+
This indicates an undeÞned symbol that was automatically changed to an externally deÞned
symbol.
Symbol Type
The symbol type shows the attribute of a symbol.
ABS
This indicates that the symbol value is absolute.
EXT
This indicates that the symbol is deÞned in another Þle. It is an externally deÞned symbol.
TXT
This indicates a text format symbol. The symbol value is an address value.
UND
This indicates that the symbol was not deÞned in the source Þle. It is an undeÞned symbol.
Reading List Files
339
Chapter 14 Reading List Files
Reference List
This reference list shows the Þle names and line numbers where the symbol was deÞned and
referenced.
An example of a cross-reference table is shown below.
OUTLIST.LST
***
_CODE
data
main
Cross Reference
00000000
00001100
00000000
Table ***
TXT
ABS
TXT
move
00000000
*EXT
340 Reading List Files
#OUTLIST.ASM(2)
#OUTLIST.H(1)
#OUTLIST.ASM(10)
OUTLIST.ASM(22)
OUTLIST.ASM(22)
OUTLIST.ASM(3)
OUTLIST.ASM(21)
Page2
Chapter 15
Using Library Manager
15
Chapter 15 Using Library Manager
15.1 Purpose Of This Chapter
A library Þle is a collection of relocatable object Þles which you can pull out as needed. Library Þles
are convenient for placing frequently used modules.
When a module is called from within a program, the linker searches the library Þle, extracts only the
required relocatable object Þle, and loads it in the executable format Þle.
The library manager is a utility for managing library Þles. It can create library Þles and add, delete,
replace, and search for relocatable object Þles.
This chapter explains how to use the library manager.
342
Purpose Of This Chapter
Chapter 15 Using Library Manager
15.2 Starting Library Manager
The library manager is started by entering a command name and parameters, just as for other MS-DOS
external commands.
General format of commands
Below is the general format of the command to use when starting the library manager.
SLIB102L
library_Þle_name
[options] (relocatable_object_Þle_name) ...
Contents of brackets [ ] may be omitted.
Table 15-1 Library Manager Options
Option
-a
-c
-d
-e
-f
-h
-p
-r
-t
-x
@Þlename
Description
Add the speciÞed relocatable object Þle to the library Þle.
Create a library Þle.
If a library Þle of the same name already exists, then a message conÞrming the Þle update
will be output.
Delete the speciÞed relocatable object Þle from the library Þle.
Output messages in English. Messages will be output in Japanese unless this option is
speciÞed.
Force creation of a library Þle.
Output help information about library manager options on the screen.
Output information about externally deÞned symbols in the library Þle.
Replace the speciÞed relocatable object Þle in the library Þle.
Output a list of the relocatable object Þles that make up the library Þle.
Extract the speciÞed relocatable object Þle from the library Þle.
Specify a parameter Þle.
Starting Library Manager
343
Chapter 15 Using Library Manager
15.3 Command Options
a
Add the specified relocatable object file to the library file
Functional description
The -a option is used to add relocatable object Þles to the library Þle.
Operation example
>slib102L test.lib
-a test1.rf
This example adds the relocatable Þle test1.rf to the library Þle test.lib.
Multiple Þles can be added with one -a option. To add test1.rf, test2.rf, and test3.rf to test.lib, specify
the following.
>slib102L test.lib
NOTE:
344
Command Options
-a test1.rf test2.rf test3.rf
If any of the relocatable object files to add already exists in the library file, then the
library manage will output an error message and terminate without performing
any processing.
Chapter 15 Using Library Manager
c
Create a library file
Functional description
If a Þle with same name of the speciÞed library Þle already exists, the library manager will inquire if
the Þle should be modiÞed. Based on the response, the library manager will determine whether or not
to create the library Þle.
Operation example
>slib102L test.lib -c test1.rf test2.rf test3.rf test4.rf
This example will create a library Þle called test.lib from the four relocatable object Þles test1.rf,
test2.rf, test3.rf, and test4.rf.
NOTE:
With slib102L, files that mutually reference symbols cannot be placed in library
files with the same name.
d
Delete the specified relocatable object file from the library file
Functional description
The -d option is used to delete relocatable object Þles from the library Þle.
If a speciÞed Þle does not exist in the library Þle, then the library manager will output a warning
message and continue processing.
Operation example
>slib102L test.lib -d test1.rf
This example deletes the relocatable Þle test1.rf from the library Þle test.lib.
Multiple Þles can be deleted with one -d option. To delete test1.rf, test2.rf, and test3.rf from test.lib,
specify the following.
>slib102L test.lib
-d test1.rf test2.rf test3.rf
Command Options
345
Chapter 15 Using Library Manager
Output messages in English. Messages will be output in Japanese
unless this option is specified
e
Functional description
The default for slib101c is to output messages in Japanese, but the -e option makes the library manager
switch to English messages.
Operation example
>slib102L test.lib -f -e test1.rf test2.rf test3.rf
f
Force creation of a library file
Functional description
The -f option forces creation of the library Þle. If a Þle with the same name as the speciÞed library Þle
already exists, then the library manager will overwrite it.
Operation example
>slib102L test.lib -f test1.rf test2.rf test3.rf test4.rf
This example will create a library Þle called test.lib from the four relocatable object Þles test1.rf,
test2.rf, test3.rf, and test4.rf.
NOTE:
346
Command Options
With slib102L, files that mutually reference symbols cannot be placed in library
files with the same name
Chapter 15 Using Library Manager
h
Output help information about library manager options on the screen
Functional description
The -h option is used when you want information about options or the slib101c version number.
Operation example
When the library manager is started with the -h option as shown below, it will output a description of its
version number and options.
>slib102L -h
NOTE:
If the -h option is not used, then input of slib101c will also display help
information.
p
Output information about externally defined symbols in the library file
Functional description
The -p option is used when you want know the externally deÞned symbol names that exist in the library
Þle.
When a relocatable object Þle name is speciÞed following the -p option, and a Þle with the same name
exists in the library Þle, the externally deÞned symbol names in that relocatable object Þle will be
output. If the Þle does not exist, then the library manager will output a warning message and continue
processing.
When no relocatable object Þle name is speciÞed, the externally deÞned symbols in all relocatable
object Þles that exist in the library Þle will be output.
Operation example
>slib102L test.lib -p test1.rf
>slib102L test.lib -p
The Þrst example checks whether or not the Þle test1.rf exists in test.lib, and if it does, outputs the
externally deÞned symbols within it. The second example outputs the externally deÞned symbols in all
relocatable object Þles in test.lib.
Command Options
347
Chapter 15 Using Library Manager
r
Replace the specified relocatable object file in the library file
Functional description
The -r option is used to replace relocatable object Þles in the library Þle.
If a speciÞed Þle does not exist in the library Þle, then the library manager will output a message add
the relocatable object Þle.
Operation example
Specify the following to replace the relocatable object Þle test1.rf in the library Þle test.lib.
>slib102L test.lib -r test1.rf
Multiple Þles can be replaced with one -r option. To delete test1.rf, test2.rf, and test3.rf from test.lib,
specify the following.
>slib102L test.lib -r test1.rf test2.rf test3.rf
This example replaces the relocatable object Þles test1.rf, test2.rf, and test3.rf in test.lib.
t
Output a list of the relocatable object files that make up the library file.
Functional description
The -t option is used when you want to know the names of the relocatable object Þles that exist in the
library Þle.
When a relocatable object Þle name is speciÞed following the -t option, and a Þle with the same name
exists in the library Þle, that Þle name will be output. If the Þle does not exist, then the library manager
will output a warning message and continue processing.
When no relocatable object Þle name is speciÞed, the names of all relocatable object Þles that exist in
the library Þle will be output.
Operation example
>slib102L test.lib -t test1.rf
>slib102L test.lib -t
The Þrst example checks whether or not the Þle test1.rf exists in test.lib. The second example outputs
the names of all relocatable object Þles in test.lib.
348
Command Options
Chapter 15 Using Library Manager
x
Extract the specified relocatable object file from the library file
Functional description
The -x option is used when you want to extract relocatable object Þles that exist in the library Þle.
When a relocatable object Þle name is speciÞed following the -x option, and a Þle with the same name
exists in the library Þle, that relocatable object Þle will be extracted into the speciÞed Þle name. If the
Þle does not exist, then the library manager will output a warning message and continue processing.
When no relocatable object Þle name is speciÞed, all relocatable object Þles that exist in the library Þle
will be extracted.
Operation example
>slib102L test.lib -x test1.rf
>slib102L test.lib -p
The Þrst example checks whether or not the Þle test1.rf exists in test.lib, and if it does, extracts test1.rf.
The second example extracts all relocatable object Þles in test.lib.
NOTE:
When slib102Lis used to group relocatable object files into libraries, it will store
them with debug information in the relocatable object files deleted if such debug
information exists.
Therefore, when an ordinary relocatable object file is placed in a library, it will be
the same as that file when extracted from the library. However, if there will be
differences if the relocatable file was generated with the -g option.
Also, be aware that when an object file is extracted, it will overwrite any file of the
same name existing in the current directory.
Command Options
349
Chapter 15 Using Library Manager
@filename
Specify a parameter file.
Functional description
The options you will use with slib101c can be written to a Þle, so instead of specifying all those options
for execution, you can specify just that Þle name.
Every option other than the @ option can be written in a parameter Þle.
If a parameter Þle that doesn't exist is speciÞed, then the library manager will display an error message.
Operation example
>slib102L @PFILE
350
Command Options
Chapter 15 Using Library Manager
15.4 Error/Warning Messages
Below is a list of error messages and warning messages displayed by the library manager.
How to read
The meanings of each entry in the error message tables are as shown below.
error_number
displayed_message
cause
solutions
Error/Warning Messages
351
Chapter 15 Using Library Manager
Error messages
1
2
3
4
5
6
7
8
9
10
11
12
352
Error/Warning Messages
Illegal option.(string)
An option that is not provided by the library manager was input.
Check the option again.
Library file name not found.
No library Þle name was speciÞed for processing, or it was speciÞed in an
incorrect position.
Check how to specify the library Þle name.
Multiply specified library file name.(filename)
More than one library Þle names were speciÞed for processing.
Check how to specify the library Þle name.
Multiply specified object file name.(filename)
An object Þle with the same name was speciÞed more than once, or an object
Þle with the same name already exists in the library Þle.
Check how to specify object Þles, and change any necessary Þles.5
Memory allocation error.
Memory could not be allocated.
Check memory size.
Cannot open file.(filename)
The Þle with the name Þlename could not be opened.
Check that the Þle exists, and check its access rights.
Premature EOF.(filename)
The contents of the Þle with the name Þlename are incorrect.
The Þle contents are possibly corrupted, so generate the Þle again.
Cannot read file.(filename)
The Þle with the name Þlename could not be read.
Check that the Þle exists, and check its access rights.
Interrelated file exist.
There are Þles with mutual reference relationships.
Fix the source program.
Cannot make temporary file name.
The temporary Þle could not be generated correctly.
Check memory size.
Cannot create library file.(filename)
The library Þle could not be generated.
Check the size of the Þle system.
This file is not object file.(filename)
The Þle Þlename was not correctly speciÞed as an object Þle.
Check again whether an object Þle for MN101C00 was correctly speciÞed. If it
was, then the object Þle contents are possibly corrupted, so generate the object
Þle again.
Chapter 15 Using Library Manager
13
14
15
16
This file is not library file.(filename)
The Þle Þlename was not correctly speciÞed as a library Þle.
Check again whether a library Þle was correctly speciÞed. If it was, then the
library Þle contents are possibly corrupted, so generate the object Þle again.
Cannot write file.(filename)
Data could not be output to the output Þle Þlename.
Check the size of the Þle system.
Illegal offset for symbol name strings.(filename)
The offset to a symbol name string in the Þle with the name Þlename is not
correct.
The Þle contents are possibly corrupted, so generate the Þle again.
Object file name not found.
An option that was used needs an object Þle speciÞcation, yet not object Þle
name was speciÞed.
Check again how to specify the option.
Error/Warning Messages
353
Chapter 15 Using Library Manager
Warning messages
17
354
Error/Warning Messages
Filename not found
The speciÞed object Þle Þlename does not exist in the library Þle.
Check again the names of the object Þles in the library Þle.
Chapter 16
EWS Version
16
Chapter 16 EWS Version
16.1 Purpose of This Chapter
This chapter is for users of the engineering workstation (EWS) version. It mainly describes the
differences between the MS-DOS version and the EWS version.
This chapter also explains the environment settings for using the EWS version, the installation method,
and customization of the conÞguration Þle.
356
Purpose of This Chapter
Chapter 16 EWS Version
16.2 Installation
This section describes the engineering workstations that can use the EWS version of the assembler and
linker, their environments, and installation.
16.2.1 Hardware Environment
Engineering workstations
The engineering workstations that can be used and the corresponding operating system versions are as
follows.
¥
SPARC station
SunOS 4.0 or later
and upward compatible machines
Installation 357
Chapter 16 EWS Version
16.2.2 File Organization
The contents of the EWS version cross-assembler are as follows.
Instead of PAINST.EXE, the EWS version has .as102L00rc and .ld102L00rc.
%ls-a
as102L00
ld102L00
excv102
.as102L00rc .ld102L00r slib102l
c
Each Þle is used for the following purpose
as102L00 (assembler)
This is the assembler executable Þle.
ld102L00 (linker)
This is the linker executable Þle.
.as102L00rc (assembler configuration)
This Þle deÞnes customization of the assembler.
.ld102L00rc (linker configuration)
This Þle deÞnes customization of the linker.
excv102 (file conversion utility)
This utility converts the EX format executable Þles of this assembler (Ver. 3.0) to Intel HEX format.
slib102l(library manager)
This utility manages library Þles.
358
Installation
Chapter 16 EWS Version
16.2.3 Installation
To install, Þrst copy all Þles from the media you were sent to the EWS work directory that you will use.
Next, copy the executable Þles (as102L00, ld102L00, slib102l, and excv102) to the appropriate
directory. Copy the conÞguration Þles (.as102L00rc and .ld102L00rc) to the user's home directory.
NOTE:
The configuration files are referenced when the assembler and linker execute.
The directory to be reference will be the user's home directory as set by the
environment variable HOME.
NOTE:
If the assembler or linker executable file names are changed, then the
configuration file names must also change. Change their names to the
executable file name prefixed by a period (.) and suffixed by "rc".
Installation 359
Chapter 16 EWS Version
16.3 Differences With MS-DOS Version
Except for the following points, all MS-DOS version functions explained in this manual apply to the
EWS version assembler and linker.
Functions removed from MS-DOS version
¥
Slashes (/) cannot be used as the option speciÞcation character.
¥
The installed work area cannot be changed.
Functions in addition to the MS-DOS version
¥
Initial settings of the options and kanji codes can be set by the conÞguration Þle.
Refer to section 16.4, "ConÞguration", for details.
360
Difference With MS-DOS Version
Chapter 16 EWS Version
16.4 ConÞguration
The EWS version assembler and linker read the conÞguration Þles (.as102L00rc or .ld102L00rc) in the
user's home directory, allowing the user to change initial settings of options and kanji codes. In the
English mode, the setting for Þle kanji codes is ignored.
16.4.1 ConÞguration
If there is no conÞguration Þle in the user's home directory, then execution will be with the following
initial settings.
Assembler settings
Item
Purpose
Initial Setting
Range of Settings
Display kanji codes
Used to change kanji
codes displayed on the
screen. (Ignore in the
English mode.)
EUC
EUC code
SJIS code
New JIS 7-bit code
New JIS 8-bit code
Old JIS 7-bit code
Old JIS 8-bit code
File kanji codes
Used to change kanji
codes output to Þles.
Output Þles are list
Þles. (Ignore in the
English mode.)
EUC
EUC code
SJIS code
New JIS 7-bit code
Old JIS 7-bit code
Old JIS 8-bit code
Notation types
Used to change the
radix format type.
Extended C language
format
Matsushita, Intel,
Extended C language
English
Japanese, English
OFF
ON, OFF
OFF
ON, OFF
Output messages
Optimize
Ignore error and output
RF Þle
Used to change the
default settings of start
options.
Configuration 361
Chapter 16 EWS Version
Linker settings
Item
Initial Setting
Range of Settings
Display kanji codes
Used to change kanji
codes displayed on the
screen. (Ignore in the
English mode.)
EUC
EUC code
SJIS code
New JIS 7-bit code
New JIS 8-bit code
Old JIS 7-bit code
Old JIS 8-bit code
File kanji codes
Used to change kanji
codes output to Þles.
Output Þles are list
Þles. (Ignore in the
English mode.)
EUC
EUC code
SJIS code
New JIS 7-bit code
Old JIS 7-bit code
Old JIS 8-bit code
Output messages
English
Japanese, English
Output debug
information
OFF
ON, OFF
OFF
ON, OFF
Output map Þle
OFF
ON, OFF
Output EX Þle
OFF
ON, OFF
Suppress output
symbol into EX-Þle
362
Purpose
Configuration
Used to change the
default settings of start
options.
Chapter 16 EWS Version
16.4.2 ConÞguration File Contents
This section describes the contents of the assembler and linker conÞguration Þles.
Assembler configuration file
%cat .as102L00rc
#Configuration
#
#Display kanji
DISPKANJI
For
Assembler
code
EUC
for
...
...
...
...
...
...
screen output
EUC #Kanji code
Shift JIS code
New JIS 7-bit code
New JIS 8-bit code
Old JIS 7-bit code
Old JIS 8-bit code
#output file
FILEKANJI
kanji
EUC
setting
#Kanji code
#EUC
#SJIS
#NEWJIS7
#NEWJIS8
#OLDJIS7
#OLDJIS8
code setting
#Kanji code
#EUC
#SJIS
#NEWJIS7
#NEWJIS8
#OLDJIS7
#OLDJIS8
for
...
...
...
...
...
...
file output
EUC kanji code
Shift JIS code
New JIS 7-bit code
New JIS 8-bit code
Old JIS 7-bit code
Old JIS 8-bit code
#Options
NOTATION
setting
CLANG
#Notation
#PANA
#CLANG
type
...
...
MESSAGE
OPTIMIZE
r-OPTION
ENGLISH
OFF
OFF
#
#INTEL
#Output
messages
#JAPANESE
#ENGLISH
#Optimize
#Ignore error
and
(Ver. 3.0)
...
Matsushita format
Extended C
language
format
Intel format
...
...
(ON/
output
Japanese
English
OFF)
RF-file(ON/OFF)
Configuration 363
Chapter 16 EWS Version
Linker configuration file
%cat
#Configuration
#
#Display kanji
DISPKANJI
For
Linker
code
EUC
setting
#Kanji code
#EUC
#SJIS
#NEWJIS7
#NEWJIS8
#OLDJIS7
#OLDJIS8
setting
for
...
...
...
...
...
...
screen output
EUC #Kanji code
Shift JIS code
New JIS 7-bit code
New JIS 8-bit code
Old JIS 7-bit code
Old JIS 8-bit code
#Kanji code
#EUC
#SJIS
#NEWJIS7
#NEWJIS8
#OLDJIS7
#OLDJIS8
for
...
...
...
...
...
...
file output
EUC kanji code
Shift JIS code
New JIS 7-bit code
New JIS 8-bit code
Old JIS 7-bit code
Old JIS 8-bit code
#JAPANESE
#ENGLISH
#Output debug
...
...
Japanese
English
#Suppress output
symbol into EX-file
#output file
kanji
FILEKANJI
EUC
#Options
MESSAGE
setting
ENGLISH
g-OPTION
En-OPTION
m-OPTION
r-OPTION
364
.ld102L00rc
Configuration
code
OFF
OFF
OFF
OFF
(Ver. 3.0)
#Output messages
#(ON/OFF)
#Output map file
#Output EX file
information (ON/OFF)
(ON/OFF)
(ON/OFF)
Chapter 16 EWS Version
16.5 Kanji Use
The EWS version assembler and linker make use of the multiple kanji codes available in the EWS.
For multiple kanji codes, the assembler automatically determines the kanji code input and processes it.
The defaults for screen display and Þle output are EUC code. However, these can be changed by the
conÞguration Þle.
Screen display and Þle output for the linker are handled the same as for the linker.
Input kanji codes
¥
EUC code
¥
SJIS code
¥
New JIS 7-bit code
¥
New JIS 8-bit code
¥
Old JIS 7-bit code
¥
Old JIS 8-bit code
The assembler automatically distinguishes between the above kanji codes.
Output kanji codes
¥
EUC code
¥
SJIS code
¥
New JIS 7-bit code
¥
New JIS 8-bit code
¥
Old JIS 7-bit code
¥
Old JIS 8-bit code
The default is EUC code. The above kanji codes can be selected by the conÞguration Þle.
NOTE:
If half-size Japanese characters(Katakana) or secondary standard kanji codes are
encountered before any full-size characters(Kanji or Hiragana) in a file, then kanji
codes might not be processed correctly. This is also true if multiple kanji codes
are used within a single file.
Kanji Use 365
Chapter 16 EWS Version
366
Chapter 17
Appendix
17
Chapter 13 Appendix
17.1 Numeric Restrictions
This section shows the numeric restrictions on the cross-assembler. Be sure not to exceed these values
when writing programs.
17.1.1 Restrictions
Assembler restrictions
Item
Numeric Restriction
Label characters
64 characters
If a label exceeds 64 characters, the 65th and further characters will
be ignored
Characters per line
256 characters
Lines per Þle
No restriction
Number of labels
30,000 labels
Linker restrictions
Item
Numeric Restriction
Number of externally
referenced labels
15,000 labels
Number of link Þles
No restriction
Directive restrictions
Item
section directives
368
Numeric Restrictions
Numeric Restriction
255 directives
Chapter 13 Appendix
Assembler control directive restrictions
Item
Numeric Restriction
include directives
No restriction
deÞne directives
4,096 directives
include nesting levels
3 levels
if XX nesting levels
255 levels
Macro directive restrictions
Item
Numeric Restriction
Number of macros
1,024 macros
Macro nesting levels
20 levels
Macro local symbols
30 symbols (within one macro deÞnition)
Numeric Restrictions
369
Chapter 13 Appendix
17.1.2 Numeric Value in Assembler
Assembler has the area of 32-bit to save the numeric value. The numeric value exceeding 32-bit is disabled. If the value exceeds 32-bit, only the value below 32-bit will be abled.
370
Numeric Restrictions
Chapter 13 Appendix
17.2 List Of Command Options
How to read
The entries in the command option tables below and their meanings are as follows.
option_name
functional_description
speciÞcation_example
List Of Command Options
371
Chapter 13 Appendix
17.2.1 List Of Assembler Command Options
Assembler command general format
Below is the general format of the command to use when starting the assembler.
AS102L
[options] source_filename
Contents of brackets [ ] may be omitted.
Output Þle options
o Þlename
l
c
Li
Lm
Lc
Ls
a map_Þlename
Xl
372
List Of Command Options
Specify the relocatable object Þle name to be output.
AS102L -o A:\USER\OBJ\TEST SAMPLE
Output a list Þle.
AS102L -l SAMPLE
Append a cross-reference to the list Þle.
AS102L -c SAMPLE
Do not output Þles included by include to the list Þle.
AS102L -Lil SAMPLE
Do not output assembler source created by macro expansion using
macro or irp to the list Þle. Output only the machine language code.
AS102L -Lml SAMPLE
Do not output source statements that were not assembled due to
unfulÞlled conditions of conditional assembly to the list Þle.
AS102L -Lcl SAMPLE
Do not output a symbol table to the list Þle.
AS102L -Lsl SAMPLE
Read the map Þle to output a list Þle with resolved addresses.
AS102L -l -a SAMPLE SUB
Output the list Þle to the same directory as the relocatable object Þle.
AS102L -Xl SAMPLE
Chapter 13 Appendix
Error message options
j
e
W number
Wall
Output error and warning messages in Japanese.
Output will be to the screen and, when a list Þle is speciÞed, to the list Þle.
AS102L -j SAMPLE
Output error and warning messages in English. Output will be to the
screen and, when a list Þle is speciÞed, to the list Þle.
AS102L -e SAMPLE
Do not output warning messages of the speciÞed number. Output will not be
performed to either the screen or list Þle. Refer to chapter 10,
Error Messages", for warning messages and their corresponding
numbers.
AS102L -W 2016 SAMPLE
Do not output any warning messages.
AS102L -Wall SAMPLE
Preprocessor options
I path_name
D identiÞer
SpeciÞes the path name of the directory that contains Þles speciÞed by include.
AS102L -I A:\USER\DEFS SAMPLE
SpeciÞes an identiÞer to be used by ifdef during conditional assembly.
AS102L -D VERSION SAMPLE
Program generation options
g
r
Od
Ot
Output debug information to the relocatable object Þle.
AS102L -g SAMPLE
Output a relocatable object Þle even if errors are detected in the source Þle.
AS102L -r SAMPLE
Turn off optimization.
AS102L -Od SAMPLE
Turn on optimization.
AS102L -Ot SAMPLE
Other
h
Output help information about assembler options to the screen.
AS102L -h
List Of Command Options
373
Chapter 13 Appendix
17.2.2 List Of Linker Command Options
Linker command general format
Below is the general format of the command to use when starting the linker.
LD102L [options] (filename)...
Contents of brackets [ ] may be omitted.
Ellipses (...) indicate item may be repeated.
Output Þle options
o Þlename
m
Xm
Specify the path name and Þle name of the executable format Þle to be output.
LD102L -o B:\USER\OBJ\MAIN PROG1 PROG2
Output a map Þle.
LD102L -m PROG1 PROG2
Output a extended format map Þle.
LD102L -Xm PROG1
Error message options
j
e
W number
Wall
374
List Of Command Options
Output error and warning messages in Japanese.
LD102L -j PROG1 PROG2
Output error and warning messages in English.
LD102L -e PROG1 PROG2
Do not output warning messages of the speciÞed number. Refer to
chapter 10, "Error Messages", for warning messages and their corresponding
numbers.
LD102L -W100 PROG1 PROG2
Do not output any warning messages.
LD102L -Wall PROG1 PROG2
Chapter 13 Appendix
Program generation options
g
Tsection_name[,section_n
ame]=start address [,end
address]
T@section_attribute=addr
ess [,address]
r
En
Output debug information to the executable format Þle.
LD102L -g PROG1 PROG2
Specify a section start address and a section eend address.
LD102L -T_CODE=80000-T_SRC=80300 PROG1 PROG2
SpeciÞes the start and end addresses of a section attribute.
LD102L -T@CODE=80000 PROG1
Output an executable format Þle even if errors are detected.
LD102L -r PROG1
Do not output symbol table within the executable format Þle.
LD102L -En PROG1 PROG2
Library Þle options
l library_Þlename
L path_name
Specify a library Þle.
LD102L -lB:\SAMPLE.LIB
Specify a path name for library Þles.
LD -LB:\LIB -lSAMPLE.LIB PROG1
Other
@Þlename
h
Specify a parameter Þle.
LD102L @PFILE
Output help information to the screen.
LD102L -h
List Of Command Options
375
Chapter 13 Appendix
17.3 List Of Assembler Directives
This section provides a list of assembler directives.
Directives for program contro
Syntax
symbol
instruction
Function & Notes
operand
align
expression
[name]
[name]
end
org
expression
[name]
section
[deÞnition1[,deÞnition2[,expression]]]
opt
on|off
Adjusts the location counter to be a
multiple of the value indicated by
expression. The expression must be
a power of 2 in the range 1 to 215.
Indicates the end of the program.
Changes the program address to the
value speciÞed by expression.
expression = label_name + constant
ets the start of a section. deÞnition1:
section attribute
(CODE | DATA)
deÞnition2: link type
(PUBLIC | PRIVATE)
expression: location counter
boundary value (power of 2).
Enables/disables optimization.
Directives for symbols
376
Syntax
operand
symbol
instruction
name
equ
operand
global
name(, name)...
List Of Assembler Directives
Function & Notes
DeÞnes a name as the value of the
expression coded in the operand.
Declares global declarations and
global references
Chapter 13 Appendix
Directives for data area allocation
symbol
instruction
[name]
[name]
[name]
[name]
dc
dw
dd
ds
Syntax
operand
constant | expression(, constant | expression)..
expression (, expression)...
expression (,expression)..
expression1[, expression2[, expression3]]
Function & Notes
Allocates 8-bit data areas
Allocates 16-bit data areas
Allocates 32-bit data areas.
Allocates the number of bytes
speciÞed by expression1 to a
data area.
If expression2 (initial value) is
speciÞed, then the data area
will be Þlled with that initial
value.
If expression3 (repeat count)
is speciÞed, then this operation
will be repeated for the
speciÞed number of times.
List Of Assembler Directives
377
Chapter 13 Appendix
Directives for list control
symbol
instruction
[name]
tit
listoff
[name]
liston
[name]
xlistoff
[name]
xliston
Syntax
operand
[ÒstringÓ]
Function & Notes
SpeciÞes the header for the list Þle.
Suppresses list output from the next line
after this directive.
Resumes list output from the line of this
directive.
Suppresses list output from the line of this
directive.
Resumes list output from the next line
after this directive.
Other directives
symbol
378
Syntax
operand
instruction
notation
format
radix
expression
List Of Assembler Directives
Function & Notes
Selects the coding format of numbers.
format(CLANG | INTEL | PANA)
CLANG: Extended C language format
(default
INTEL: Intel format
PANA: Matsushita format
SpeciÞes the radix to be used by default.
The result of expression must be either 2,
8, 10, or 16. If the default is 10 and if
extended C language format has been
selected, then the radix will always be 10
regardless of the speciÞcation.
Chapter 13 Appendix
17.4 List Of Assembler Control Statements
This section provides a list of assembler control statements.
Syntax
#include
#deÞne
ÒÞle_nameÓ
identiÞer [replacement_string]
#undef
identiÞer
#ifdef
identiÞer
block1
[#else
block2]
#ifndef
#endif
identiÞer
block1
[#else
block2]
#endif
#if
expression
block1
[#else
#ifn
block2]
#endif
expression
block1
[#else
Function & Notes
Reads in the source Þle speciÞed by Þle_name.
Replaces the identiÞer with the
replacement_string.
Purges the identiÞer previously deÞned by
#deÞne.
Assembles block1 if the identiÞer was deÞned
before the #ifdef statement.
Assembles block2 if it was not deÞned (nothing
will be assembled if there is no #else).
Assembles block1 if the identiÞer was deÞned
before the #ifdef statement.
Assembles block2 if it was not deÞned (nothing
will be assembled if there is no #else).
Assembles block1 if the identiÞer was not
deÞned before the #ifndef statement.
Assembles block2 if it was deÞned (nothing will
be assembled if there is no #else).
Assembles block1 if the expression is not 0.
Assembles block2 if it is 0 (nothing will be
assembled if there is no #else)
block2]
#endif
#ifeq
parameter1, parameter2
block1
[#else
block2]
#endif
#ifneq
parameter1, parameter2
block1
[#else
block2]
#endif
Assembles block1 if parameter1 and parameter2
are equal. Assembles block2 if
they are not equal (nothing will be assembled if
there is no #else). At least one or the other of
parameter1 and parameter2 must be a dummy
parameter within a macro deÞnition. #ifeq can
only be used within macro deÞnitions.
Assembles block1 if parameter1 and parameter2
are not equal.
Assembles block2 if they are equal (nothing will
be assembled if there is no #else). At least one or
the other of parameter1 and parameter2 must be a
dummy parameter within a macro deÞnition.
#ifeq can only be used within macro deÞnitions.
List Of Assembler Control Statements
379
Chapter 13 Appendix
Syntax
#ißt
expression
block
[#else
#iße
block2]
#endif
expression
block1
[#else
#ifgt
block2]
#endif
expression
block1
[#else
#ifge
block2]
#endif
expression
block1
[#else
#ifb
block2]
#endif
dummy_parameter
block1
[#else
#ofnb
block2]
#endif
dummy_parameter
block1
[#else
block2]
#endif
380
List Of Assembler Control Statements
Function & Notes
Assembles block1 if the expression is negative.
Assembles block2 if it is not negative (nothing
will be assembled if there is no #else).
Assembles block1 if the expression is zero or
negative.
Assembles block2 if it is positive (nothing will be
assembled if there is no #else).
Assembles block1 if the expression is positive.
Assembles block2 if it is not positive (nothing
will be assembled if there is no #else).
Assembles block1 if the expression is zero or
positive.
Assembles block2 if it is negative (nothing will
be assembled if there is no #else)
Assembles block1 if the dummy_parameter is a
null character.
Assembles block2 if it is not (nothing will be
assembled if there is no #else). #ifb can only be
used within macro deÞnitions.
Assembles block1 if the dummy_parameter is
not a null character.
Assembles block2 if it is (nothing will be
assembled if there is no #else). #ifnb can only be
used within macro deÞnitions.
Chapter 13 Appendix
17.5 Program Example
This section provides an example of the use of the cross-assembler.
This example utilizes the following programming techniques.
Modular assembly
The program is divided into two files: MAIN.ASM and SUB.ASM. The program SUB is used from the
program MAIN, so the start of each program is declared as global.
File include
The constants used by both MAIN.ASM and SUB.ASM are collected in one file with the name
EQUTBL.H. This file is read in at the start of the MAIN.ASM and SUB.ASM programs by specifying
an #include directive.
Macro definitions
Sequences of instructions used repeated in the programs are defined as macros.
Iterated macros
The irp directive is used to define constants.
Use of #ifdef assembler control statement
NOTE:
This example is provided only to show the coding and program structure of
assembly programs. It is not guaranteed to operate in actual use.
Program Example 381
Chapter 13 Appendix
17.5.1 Source File
This section shows the contents of the source file.
EQUTBL.H file
**************
*************** *************** **************
MN10200
assember
sample
program
*************** *************** *************** **************
Special
Register MAP
for
MN10200
*************** **************
*************
***************
cpum
equ
0xfc00
mcr
equ
0fc02
iagr
equ
0xfc0e
icr1
equ
0xfc42
irc2
equ
0xfc44
icr4
equ
0xfc48
icr8
equ
0xfc50
**************
*************** *************** ******************
Communication
Terminal:
Equation
*************** *************** *************** *****************
port table
382
*************** *************** *************
*****************
port_tx
equ
0xfe00
;TX
port_rx
equ
0xfe01
;RX
port_cmd
equ
0xfe02
;Command (OUT)
port_sts
equ
0xfe02
;Status(IN)
port_dip_sw
equ
0xfe08
;DIP Switch
port_speed
equ
0xfe09
;Baud Rate Generator(BRG)
port_cyc_h
equ
0xfe10
;Cyclic LED
port_cyc_l
equ
0xfe11
port_alarm
equ
0xfe12
;Alarm LED
port_lcd
equ
0xfe20
;LCD
Program Example
Chapter 13 Appendix
**************
*************** *************** **************
Command/
Status
Definition
*************** *************** *************** **************
Special
for
MN10200
*************** **************
Register MAP
*************
***************
c_init
equ
0x00
;Initial value
c_reset
equ
0x40
;Hard reset
c_err_rest
equ
0x10
;RX Error reset
c_cmd_inst
equ
0x7a
;Command instruction
c_tx_rdy
equ
0x01
;TX ready
c_rx_rdy
equ
0x02
;Rx ready
c_line_con
equ
0x80
;Line connected
c_err_bit
equ
0x28
;RX error bits
*************
*************
**************
******************
Speed
Definition
**************
**************
*************** *********************
s_1200
equ
0x80
s_2400
equ
0x40
s_4800
equ
0x20
s_9600
equ
0x10
brg_1200
equ
0x80
brg_2400
equ
0x40
brg_4800
equ
0x20
;Dip switch image
;BRG image
brg_9600
equ
0x10
**************
*************
**************
********************
**************
**************
*******************
buffer_size
equ
16
**************
*************** **************
System
define
**************
**************
*************** *******************
MCR_WAIT
equ
0x0101
CPU_MODE
equ
0x0000
STACKTOP
equ
0xf400
PSW_OFF
equ
0x0000
PSW_SET
equ
0x0f00
Buffer Size
**************
*******************
Program Example 383
Chapter 13 Appendix
MAIN.ASM file
*************
*************
*************
MN102L00
assembler
sample
*************** *************** **************
Communication
Terminal:
**************
*************** **************
#include
Òequtbl.hÓ
if_clear
macro
icr_reg
mov
icr_reg, a0
mov
(a0), d0
or
0xff0f, d0
mov
d0, (a0)
********************
program
*****************
Main
******************
endm
_CODE
section
CODE, PUBLIC,
2
_DATA
section
DATA, PUBLIC,
2
_CODE
section
CODE, PUBLIC,
2
global
rx_proc,
tx_proc, cyc_proc
global
time_filler
*************
*************** **************
start up
routine
**************
*************** **************
********************
********************
_start
jmp
_main
nop
;*---start
interrupt
routine (64KB
org
_start+0x0008
model)---*
add
-14, A3
mov
D0, (12, A3)
;D0 Register PUSH
mov
D1, (10, A3)
;D1 Register PUSH
mov
D2, (8, A3)
;D2 Register PUSH
mov
D3, (6, A3)
;D1 Register PUSH
mov
A0, (4, A3)
;A0 Register PUSH
mov
A1, (2, A3)
; A1 Register PUSH
mov
A2, (A3)
; A2 Register PUSH
mov
(iagr), D0
and
D0, D0
_irg
384
Program Example
Chapter 13 Appendix
mov
D0, A0
add
_irg_vec_tbl, A0
mov
(0, A0, D0)
mov
D0, A0
nop
;*---interrupt
return
operation---*
mov
(12, A3), D0
;D0 Register POP
mov
(10, A3), D1
;D1 Register POP
mov
(8, A3), D2
;D2 Register POP
mov
(6, A3), D3
;D3, Register POP
mov
(4, A3), A0
;A0 Register POP
mov
(2, A3), A1
;A1 Register POP
mov
(A3), A2
;A1 Register POP
add
14, A3
_irq_end
rti
;*---interrupt
vector
table---*
dd
_irq_end
;NMI, WDT irq
dd
_ad_irq
;A/D irq
dd
_asci_irq
;SIF irq
dd
_irq_end
dd
_timer_irq
dd
_irq_end
dd
_irq_end
dd
_irq_end
_irq_vec_tbl
;*---program
;Timer irq
dd
_ext_irq
initialize
routine---*
; External irq
mov
MCR_WAIT, D0
mov
D0, (mcr)
;(Non wait cycle)
mov
CPU_MODE,D0
;clear WDT irq
mov
D0, (cpum)
;(disable WDT)
mov
STACKTOP, A3
Interrupt
Disable Flag
mov
PSW_OFF, D0
mov
D0, PSW
jmp
_main
bra
_loop1
interrupt
routine---*
_main
;*---set
;set External Bus cycle
---*
_loop
*---program
Program Example 385
Chapter 13 Appendix
*---A/D
interrupt
operation---*
if_clear
icr
_ad_irq
*---SIF
jmp
-irq
interrupt
operation---*
if_clear
icr2
jmp
-irq
-end
_asci_irq:
-end
*--TM interrupt operation---*
_timer_irq:
*---EXIRQ
if_clear
icr4
sub
d0, d0
mov
d0, (time_flg)
jmp
-irq
interrupt
operation---*
if_clear
icr8
imp
-irq
-end
_ext_irq:
386
Program Example
-end
Chapter 13 Appendix
**************
*************** *************
**********************
main
routine
**************
**************
*************** **********************
jsr
init_irq
; initialize IRQ
jsr
clear_memory
;clear memory
jsr
init_speed
;initialize BRG
jsr
init_trx
;initialize TRX
jsr
rx_proc
;Rx process
cmp
1, D0
bne
main_skip
jsr
tx_proc
jsr
rx_proc
cmp
1, D0
bne
main_skip
jsr
tx_proc
jsr
cyc_proc
;Cyclic process
bra
main_loop
;goto main loop
_main
main_loop
;if not received, skip Tx process
main_loop
;RX process
;if not received, skip Tx process
main_skip
*************** **************
*************** ********************
initialize IRQ
*************
*************** *************** *******************
init_irq
mov
0x0100, d0
mov
icr1, a0
mov
d0, (a0)
mov
0x0200, d0
mov
icr2, a0
mov
d0, (a0)
mov
0x0400, d0
mov
icr4, a0
mov
d0, (a0)
mov
0x0100, d0
mov
icr8, a0
mov
d0, (a0)
Program Example 387
Chapter 13 Appendix
mov
PSW_SET, D0
mov
D0, PSW
rts
388
Chapter 13 Appendix
*************
**************
**************
********************
clear
memory
*************
**************
*************
******************
mov
tx_buffer, A0
;set initial value
mov
rx_buffer, A1
mov
buffer_size, D0
mov
buffer_size, D1
mov
0, D2
movb
D2, (A0)
sub
1, D0
beq
memory_loop1
add
1, A0
bra
memory_loop0
movb
D2, (A1)
sub
1, D1
beq
memory_exit
add
1, A1
bra
memory_loop1
clear_memory
memory_loop0
;clear end
memory_loop1
;clear end
memory_exit
rts
**************
*************** *************
initialize Baud rate
**************
*********************
Generator
*************** ************
********************
init_speed
mov
port_dip_sw, A0
movbu
(A0), D0
mov
brg_1200, d1
btst
s_1200, D0
beq
speed_exit
mov
brg_2400, D1
btst
s_2400, D0
beg
speed_exit
;get Dip-sw (8 bits)
;1200bps
;2400bps
Program Example 389
Chapter 13 Appendix
mov
brg_4800, D1
btst
s_4800, D1
beq
speed_exit
mov
brg_9600, D1
btst
s_9600, D0
beq
speed_exit
;9600bps
mov
brg_1200, D1
;default...1200bps
mov
port_speed, A0
;set to BRG
movb
D1, (A0)
;4800bps
speed_exit
rts
390
Program Example
Chapter 13 Appendix
**************
**************
*************** ************************
**************
*************
mov
c_init, D0
mov
port_cmp, A0
movb
D0, (A0)
jsr
time_filler
movb
D0, (A0)
jsr
time_filler
movb
D0, (A0)
jsr
time_filler
mov
c_reset, D0
movb
D0, (A0)
jsr
time_filler
mov
c_cmd_inst, D0
movb
D0, (A0)
jsr
time_filler
mov
c_cmd_inst, D0
movb
D0, (A0)
jsr
time_filler
mov
port_sts, A0
movbu
(A0), D0
btst
c_line_con, D0
bne
trx_loop
;if line is not connected
section
DATA, PUBLIC,
2
global
time_flg,
tx_buffer, rx_buffer
initialize TRX
**************
**********************
init_trx
;set initial value x3
;set reset command
;set command inst.
;set mode inst.
trx_loop
rts
_DATA
end
Program Example 391
Chapter 13 Appendix
SUB.ASM file
************
**************
**************
**********************
MN10200
assembler
sample
program
************
**************
*************
********************
Communication
Terminal:
SUB
*************
*************** **************
*******************
#########
##########
###########
#############
Example of
include usage
#########
##########
##########
#############
#include
Òequtbl.hÓ
#define
HI_SPEED
_CODE
section
CODE, PUBLIC,
2
global
rx_proc,
tx_proc, cyc_proc
global
time_filler
#########
##########
##########
Example of
macro
declaration
#########
#########
#########
output
macro
mov
#############
##############
A0, (save_A0)
mov
port_tx, A0
movb
D0, (A0)
mov
(save_a0), A0
endm
time_fill
macro
count
local
fill_loop
mov
D0, (save_D0)
mov
count, D0
;
fill_loop
nop
nop
nop
sub
1, D0
bne
fill_loop
mov
(save_d0), D0
;
rts
endm
*************** **************
392
Program Example
*************** ***********************
Chapter 13 Appendix
Rx process
************
*************
**************
*********************
mov
0, D0
;set ÔNot ReceivedÕ
mov
port_sts, A0
movbu
(A0), D1
btst
c_rx_rdy, D1
beq
rx_exit
and
c_err_bit, D1
bne
rx_error
mov
port_rx, A0
movbu
(A0), D1
mov
rx_buffer, A0
mov
(rx_index), D0
rx_proc
;not received
;Rx error happended
;Rx data
add
D0, A0
movb
D1, (A0)
and
buffer_size-1,
D0
mov
D0, (rx_index)
mov
1, D0
bra
rx_exit
;Normal receiving
mov
port_alarm, A0
;Alarm LED ON
mov
1,D1
movb
D1, (A0)
;set into buffer
;next index
rx_error
rx_exit
rts
************
*************** ************
**********************
*************
*********************
Tx process
*************
*************
tx_proc
mov
0, D0
movb
D0, (cyc_lcd)
mov
(tx_index), D0
mov
(rx_index), D1
cmp
D0, D1
;clear lcd data
Program Example 393
Chapter 13 Appendix
beq
tx_exit
mov
rx_buffer, A1
mov
(rx_index), D1
add
D1, A1
movbu
(A1), D0
;get data in D0
movb
D0, (cyc_lcd)
;set lcd data
mov
tx_buffer, A1
mov
(tx_index), D1
add
D1, A1
movb
D0, (A1)
and
buffer_size-a,
D1
;save into buffer
mov
D1, (tx_index)
;next index
##########
###########
#########
###############
Example of
macro
expansion
##########
##########
##########
##############
output
time_fill
10
tx_exit
rts
*************
*************
*************
*******************
**************
*************
******************
cyclic process
**************
cyc_proc
##########
###########
##########
##############
Example of
assembler
control
statements
#########
##########
#########
#############
#ifdef
HI_SPEED
mov
500, D0
mov
port_cyc_h, A0
mov
1000, D0
mov
port_cyc_1, A0
mov
(cyc_count), D1
add
1, D1
cmp
D0, D1
bne
cyc_skip
movbu
(cyc_data), D0
#else
#endif
394
Program Example
Chapter 13 Appendix
xor
1, D0
movb
D0, (cyc_data)
mov
0, D1
mov
D0, (A0)
mov
D1, (cyc_count)
movbu
(cyc_lcd), D0
and
0x007f, D0
cmp
0x20, D0
bcc
cyc_exit
mov
port_lcd, A0
and
0x00ff, D0
mov
D0, D1
mov
D0, D2
lsr
D1
lsr
D1
lsr
D1
lsr
D1
mov
erro_disp, A1
add
D1, A1
movbu
(A1), D0
movb
D0, (A0)
sub
D1, A1
time_fill
10
and
0x000f, D2
add
D2, A1
movbu
(A1), D0
movb
D0, (A0)
;change ON/OFF
cyc_skip
;normal character
;shift right 4 bits
;upper
;lower
cyc_exit
rts
*************
**************
*************** ************************
**************
*************
time_fill
10
time filler
*************
************************
time_filler
rts
##########
##########
##########
Example of
data
definition
##########
#########
##########
###############
##############
Program Example 395
Chapter 13 Appendix
_DATA
section
DATA, PUBlIC,
2
global
time_flg,
tx_buffer, rx_buffer
time_flg
ds
1
tx_buffer
ds
1, 0,
buffer_size
rx_buffer
ds
1, 0,
buffer_size
##########
#########
#########
###############
Example of
iterated macro
use
#########
#########
#########
##############
irp
const,
Ò0123456789ABCDEFÓ
dc
const
erro_disp
endm
_DATA
section
DATA, PUBLIC,
tx_index
ds
2
rx_index
ds
2
save_A0
ds
2
save_D0
ds
2
cyc_count
ds
2
cyc_data
ds
1
cyc_lcd
ds
1
end
396
Program Example
2
Chapter 13 Appendix
17.5.2 Batch File
The batch file used for assembly and linking is shown below.
AS102L00
MAIN
AS102L00
SUB
LD102L00
-m -o
SAMPLE.EX
AS102L00
-a
SAMPLE MAIN
AS102L00
-a
SAMPLE SUB
-T_CODE=800000
-TDATA=F000 MAIN SUB
First, the batch file assembles the two files.
After assembly, it links the files, specifying the start addresses of the sections defined in the two files
(_CODE and _DATA) with the T option. It also specifies the -m option to generate a map
(SAMPLE.MAP) file.
Finally, the files are assembled again using the map file to create final list files.
Program Example 397
Chapter 13 Appendix
17.5.3 Execution Example
The final list files are shown below.
Final list file MAIN.LST
***
Loc
mn102L00
object
=0000FC00
=0000FC02
=0000FC0E
=0000FC42
=0000FC44
=0000FC48
=0000FC50
398
Program Example
MAIN.LST
Cross
Line Source
1
********
2
3
MN10200
4
5
********
6
7
********
8
COMMUNICAT
ION
9
**********
10
11
#include
.1
********
.2
.3
MN10200
.4
.5
*********
.6
.7
*********
.8
Special
.9
*********
.10
.11 cpum
.12 mcr
.13 iagr
.14
.15 icr1
.16 icr2
.17 icr4
.18 icr8
.19
.20 ********
.21
.22 ********
.23
.24 ********
.25
.26 port
Page1
Assembler***
**************
***************
assembler
sample
**************
*************
*************
TERMINAL:
************
MAIN
***************
***************
Òequtbl.hÓ
**************
***************
assembler
sample
program
program
**************** *************
***************
Register MAP
***************
*************
for MN10200
**************
equ
equ
equ
0xfc00
0xfc02
0xfc0e
equ
equ
equ
equ
0xfc42
0xfc44
0xfc48
0xfc50
*************
COMMUNICATION
*************
****************
TERMINAL:
EQUATION
***************
**************
***************
table
Chapter 13 Appendix
=0000FE00
=0000FE01
=0000FE02
=0000FE02
=0000FE08
.27
.28
.29
.30
.31
.32
.33
.34
.35
=0000FE09 .36
*********
**************
***************
port_tx
port_rx
port_cmd
port_sts
equ
equ
equ
equ
0xfe00
0xfe01
0xfe02
0xfe02
;TX
;RX
;Command (OUT)
;Status (IN)
port_dip_s equ
w
port_speed equ
0xfe08
;Dip Switch
0xfe09
;Baud Rate
Generator(BRG)
port_cyc_h equ
0xfe10
;Cyclic LED
port_cyc_
equ
0xfe11
port_alarm equ
0xfe12
;Alarm LED
port_lcd
equ
0xfe20
;LCD
**************
Page 2
Assembler***
***************
Command/Status
Definition
.37
=0000FE10
.38
=0000FE11 .39
.40
=0000FE12 .41
.42
=0000FE20 .43
.44
.45
***
Loc
mn102L00
Object
=00000000
=00000040
=00000010
=0000007A
*******
MAIN.LST
Cross
Line Source
.46 *
.47 *
.48 *
.49 **********
.50
.51 c_init
.52 c_reset
.53 c_err_rest
.54 c_cmd_ins
=00000037 .55
.56
=00000001 .57
=00000002 .58
.59
=00000080 .60
.61
=00000028 .62
.64
.65
.66
.67
.68
.69
*
*
*
**************** ****************
equ
equ
equ
equ
0x00
0x40
0x10
0x7a
;Initial value
;Hard reset
c_mod_inst equ
0x37
c_tx_rdy
c_rx_rdy
equ
equ
0x01
0x02
;Tx ready
;Rx ready
c_line_con equ
0x80
;Line connected
c_err_bit
********
equ
***************
0x28
**************
;Rx error bits
Speed
Definition
********
*************
;Command
instruction
;Mode
instruction
****************
Program Example 399
Chapter 13 Appendix
=00000080 .70
s_1200
equ
0x80
=00000040 .71
=00000020 .72
=00000010 .73
.74
=00000080 .75
=00000040 .76
=00000020 .77
=00000010 .78
.79
.80
.81
.82
.83
.84
.85
=00000010 .86
s_2400
s_4800
s_9600
equ
equ
equ
0x80
0x80
0x80
s_1200
s_2400
s_4800
s_9600
equ
equ
equ
equ
0x80
0x80
0x80
0x80
*********
***************
*************
Buffer
Size
********
*************
=00000101
=00000000
=0000F400
=00000000
=00000F00
***
Loc
400
mn102L00
Object
Program Example
.87
.88
.89
.90
.91
.92
.93
.94
.95
.96
.97
.98
.99
12
13
;DIP swtich
image
;BRG image
***************
buffer_siz equ
e
16
*******
**************
*************
System
define
********
***************
****************
MCR_WAIT
CPU_MODE
STACKTOP
PSW_OFF
PSW_SET
equ
equ
equ
equ
equ
0x0101
0x0000
0xf400
0x0000
0x0f00
macro
Page3
Assembler***
icr_reg
mov
mov
or
mov
endm
icr_reg,a0
(a0),d0
0xff0f, d0
d0, (a0)
section
section
CODE, PUBLIC,
DATA, PUBLIC,
2
2
section
CODE, PUBLIC,
2
global
global
rx_proc,
time_filler
Tx_proc,cyc_proc
if_clear
MAIN.LST
Cross
Line Source
14
15
16
17
18
19
20
_CODE
21
_DATA
22
23
_CODE
24
25
26
Chapter 13 Appendix
27
28
29
30
31
32
33
34
080
F4
080
080
080
080
080
080
080
080
080
080
F47
080
080
080
080
080
F46
000
000
000
E0610000
005
F6
0008
D3f0
000A
4C0E
000C
4D0C
00E
4E0A
010
4F08
012
5C06
014
5D04
016
5E02
018
4310008
01D
5C00
01F
C80EFC
022
F5003E
025
F230
027
4420008
02E
F000
030
F6
*********
***************
start
up routine
*********
***************
****************
jmp
nop
_main
start interrupt
org
routine(64KB
_start+0x0008
41
add
-16, A3
42
mov
D0,(14, A3) ;D0
Register PUSH
43
mov
D1,(12, A3) ;D1
Register PUSH
44
mov
D2,(10, A3) ;D2
Register PUSH
45
46
mov
D3,(8, A3) ;D1
Register PUSH
47
mov
A0,(6, A3) ;A0
48
mov
A1,(4, A3) ;A1
Register PUSH
49
50
mov
!2, (2, A3) ;A2
Register PUSH
51
mov
_irq_end, A0
52
mov
A0, (A3)
53
mov
(iagr), D0
54
and
0x3e, D0
55
mov
D0, A0
56
add
_irq_vec_tbl, A0
58
jmp
(A0)
59
nop
35
36
37
38
39
40
***************
_start
;*---
model)---*
_irg
Register PUSH
Program Example 401
Chapter 13 Appendix
60
61
interrupt
return operation ---*
63
mov
(12, A3), D0 ;D0 Register POP
64
mov
(10, A3), D1
;D1
register POP
65
mov
(8,A3),D2
Register POP
66
mov
(6, A3), D3
;D3 Register POP
67
mov
(4, A3), A0
;A0 Register POP
68
mov
(2, A3), A1
;A1 Register POP
69
mov
Page 4
Assembler ***
(A3), A2
70
add
14, A3
71
72
73
rti
;*---
74
_irq_vec_
62
080
080
080
080
080
080
080
***
Loc
080
080
080
080
080
080
080
080
080
080
080
402
031
6C0C
033
6D0A
035
6E08
037
6F06
039
7C04
03B
7D02
03D
7E00
mn102L00
Object
03F
D30E
041
EB
042
31000800
046
7F000800
04A
89000800
04E
31000800
052
93000800
056
31000800
05A
31000800
05E
31000800
062
A3000800
Program Example
;*--_irq_end
MAIN.LST
Cross
Line Source
;D2
;A2
Register POP
interrupt
vector
tbl
table---*
75
dd
_irq_end
;NMI, WDT irg
76
dd
_ad_irq
;A/D irq
77
dd
_asci_irq
;SIF irq
78
dd
_irq_end
79
dd
_timer_irq
80
dd
_irq_end
81
dd
_irq_end
82
dd
_irq_end
83
84
85
86
dd
_ext_irq
;External irq
program
initialize
routine---*
;*---
;Timer irq
Chapter 13 Appendix
87
080
080
080
080
080
080
080
080
080
080
080
080
080
080
080
080
080
_main
066
F80101
88
mov
MCR_WAIT, D0
069
C002FC
89
mov
D0, (mcr)
;(Non wait
cycle)
90
mov
CPU_MODE,D0
;clear EDT irq
91
mov
D0, (cpum)
;(disable WDT)
92
93
94
mov
STACKTOP, A3
Interrupt
Disable
mov
PSW_OFF, D0
mov
D0, PSW
program
A/D interrupt
interrupt
operation
if_clear
icr1
105+
mov
icr1, a0
105+
mov
(a0), d0
105+
or
0xff0f, d0
105+
mov
d0, (a0)
06C
8000
06E
C000FC
071
DF00F4
074
8000
076
F3D0
07F
DC42FC
082
20
083
F7400FFF
087
00
088
FE
089
DC44FC
08C
20
08D
F74000FFF
091
00
092
FE
;*--- set
95
96
97
100
101
102
103
104
M105
;
setExternal Bus
cycle
Flag ---*
_loop1
*--*--_ad_irq
106
rts
107 *--SIF interrupt
108 _asci_irq:
M109
if_clear
routine---*
---*
operation ---*
icr2
109+
mov
icr2, a0
109+
mov
(a0), d0
109+
or
0xff0f, d0
109+
mov
d0,(a0)
110
rts
Program Example 403
Chapter 13 Appendix
080
080
080
080
***
Loc
080
080
F44
080
080
080
080
080
080
080
080
080
404
093
DC48FC
096
20
097
F74000FFF
09B
00
mn102L00
Object
09C
A0
09D
000F000
0A2
FE
0A3
DC50FC
0A6
20
0AC
FE
0AD
F4E124000
0
0B2
F4E141000
0
0B7
F4E163000
0
0BC
F4E187000
0C1
Program Example
111 *---TM
112 _timer
M113
interrupt
_irq:
if_clear
113+
mov
icr4, a0
113+
mov
(a0), d0
113+
or
0xff0f, d0
113+
mov
Page5
Assembler ***
d0, (a0)
114
sub
d0, d0
115
mov
d0, (time_flg)
116
117 *---EXIRQ
118 _ext_irq:
M119
rts
interrupt
operation ---*
if_clear
icr8
119
mov
icr8,
119+
mov
(a0), d0
120
121
122
123
124
125
126
127
rts
MAIN.LST
Cross
Line Source
operation ---*
icr4
a0
********
**************
main
routine
*******
_main
**************
***************
128
jsr
init_irq
;initialize IRQ
129
jsr
clear_memory
;clear memory
130
jsr
init_speed
;initialize BRG
131
132
133
jsr
init_trx
;initialize TRX
main__loop
****************
Chapter 13 Appendix
080
080
Tx
080
F4
080
F4
080
080
080
080
080
080
080
080
080
080
080
080
F4E1BC000 134
0
0C6
D801
135
0C8
E905
136
process
CA
E1E70000
0CF
E1430100
0D4
EAEB
0D6
F80001
0D9
DC42FC
0DC
00
0DD
F80002
0E0
00
0E4
F80004
0E7
DC48FC
0EA
00
0EB
F80001
0EE
DC50FC
0F1
00
jsr
rx_proc
cmp
1, D0
bne
main_skip
jsr
tx_proc
140
jsr
cyc_proc
;Cyclic process
141
142
143
144
145
146
147
148
bra
main_loop
;goto main loop
137
138
139
;RX process
;if not
received, skip
main_skip
********
**************** ***************
initialize IRQ
*********
init_irq
**************** ****************
149
mov
0x0100, d0
150
mov
icr1, a0
151
152
mov
d0, (a0)
153
mov
0x0200, d0
155
156
mov
d0, (a0)
157
mov
0x0400, d0
158
mov
icr4, a0
159
160
mov
d0, (a0)
161
mov
0x100, d0
162
mov
icr8, a0
163
164
mov
d0, (a0)
Program Example 405
Chapter 13 Appendix
080
***
Loc
080
080
mn102L00
Object
0F5
F3D0
0F7
FE
080
F47
0F8
401F000
080
F47
080
0FD
511F000
102
8010
104
8510
106
8A00
080
080
080
080
F71
080
080
080
080
080
F71
080
080
080
406
0F2
F8000F
108
02
109
C0100
10D
E804
10F
D001
111
EAF5
113
06
114
D0100
118
E804
11A
D101
11C
Program Example
165
mov
Page 6
Assembler
***
166
167
mov
D0, PSW
168
169
170
171
172
173
174
175
rts
MAIN.LST
Cross
Line Source
PSW_SET, D0
********
***************
clear
memory
********
Clear_
**************
memory
****************
176
mov
tx_buffer, A0
177
mov
rx_buffer, A1
178
mov
buffer_size, D0
179
mov
buffer_size, D1
180
181
182
mov
0, D2
memory_
***************
;set initial
value
loop0
183
mov
D2, (A0)
184
sub
1, D0
185
beq
memory_loop1
186
add
1, A0
187
188
bra
memory_loop1
memory_loop0
189
mov
D2, (A1)
190
sub
1, D1
191
beq
memory_exit
192
add
1, A1
;clear end
;clear end
Chapter 13 Appendix
EAF5
080
080
080
11E
FE
11F
DC08FE
122
30
193
194
195
196
197
198
199
200
201
202
203
bra
memory_
memory_loop1
exit
rts
********
***************
initialize Baud
rate
****************
Generator
********* ***************
init_speed
**************
204
mov
port_dip_sw, A0
205
movbu
(A0), D0
207
mov
brg_1200, D1
208
btst
s_1200, D1
209
210
beq
speed_exit
211
mov
brg_2400, D1
212
btst
s_2400, D0
213
214
beq
speed_exit
215
mov
brg_4800, D1
216
btst
s_4800, D0
217
218
beq
speed_exit
219
mov
brg_9600, D1
220
btst
s_9600, D0
221
beq
Page 7
Assembler***
speed_exit
;get Dip-sw (8bit)
206
080
080
080
080
080
080
080
080
080
080
080
080
***
Loc
123
F98000
126
F50480
129
F818
12B
8540
12D
F50440
130
F818
132
8520
134
F50420
137
E80A
139
8510
13B
F50410
013E
E803
MN102L00
Object
MAIN.LST
Cross
Line Source
222
;1200bps
;2400bps
;4800bps
;9600bps
Program Example 407
Chapter 13 Appendix
080
140
F9800
223
mov
brg_1200, D1
;default...1200b
ps
226
mov
port_speed, A0
;set to BRG
227
movb
D1, (A0)
228
229
230
231
232
233
234
235
rts
224
225
080
080
080
080
080
080
080
F4E
080
080
F4E
080
080
F4E
080
080
080
F4E
080
080
408
143
DC09FE
146
11
147
FE
speed_exit
********
**************** ****************
initialize TRX
***************
****************
236
mov
c_init, D0
237
238
mov
port_cmp, A0
239
movb
D0, (A0)
240
jsr
time_filler
241
movb
D0, (A0)
242
jsr
time_filler
243
movb
D0, (A0)
244
245
jsr
time_filler
246
mov
c_reset, D0
247
movb
D0, (A0)
248
249
jsr
time_filler
167
807A
250
mov
c_cmd_inst, D0
169
10
251
movb
D0, (A0)
148
8000
14A
DC02FE
14D
10
14E
1300100
153
10
154
12A0100
159
10
15A
1240100
15F
8040
161
10
162
11C0100
Program Example
*********
init_trx
;set initial
value x3
;set reset
command
;set command
inst.
Chapter 13 Appendix
080
F4E
16A
1140100
080
16F
8037
171
10
172
10C0100
080
080
F4E
080
080
080
080
080
ROM
No
No
177
DC02FE
17A
30
17B
F50480
17E
F9FA
180
FE
size is
erros
warnings
252
253
jsr
time_filler
254
mov
c_mod_inst, D0
255
movb
D0, (A0)
256
257
jsr
time_filler
258
259
260
mov
port_sts, A0
261
movbu
(A0), D0
262
btst
c_line_con, D0
263
bne
trx_loop
264
265
266
267
268
269
270
rts
in
in
;set mode inst
trx_loop
_DATA
524673
this
this
section
DATA, PUBLIC, 2
global
time_flg,tx_buf
;if line is not
connected
fer,rx_buffer
end
(Hex.00080181)
assembly
assembly
Program Example 409
Chapter 13 Appendix
***Symbol
00000000
00000101
00000000
00000F00
0000F400
00080000
0000F000
00080066
0008007F
00080089
000800A3
00080008
00080031
00080042
00080078
000800AD
0080000
00080093
00000080
00000040
00000020
00000010
00000010
0000007A
00000028
00000010
00000000
00000080
00000037
00000040
00000002
00000001
000800F8
0000FC00
00080217
0000FC0E
0000FC42
0000FC44
0000FC48
0000FC50
000800D6
0008011F
00080148
000800C1
000800CF
410
Program Example
Table
T
T
T
T
T
A
A
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
MAIN.LST
***
CPU_MODE
MCR_WAIT
PSW_OFF
PSW_SET
STACKTOP
_CODE
_DATA
_MAIN
_ad_irq
_asci_irq
_ext_irq
_irq
_irq_end
_irq_vec_tbl
_loop1
_main
_start
_timer_irq
brg_1200
brg_2400
brg_4800
brg_9600
buffer_size
c_cmd_inst
c_err_bit
c_err_rest
c_init
c_line_con
c_mod_inst
c_reset
c_rx_rdy
c_tx_rdy
clear_memory
cpum
cyc_proc
iagr
icr1
icr2
icr4
icr8
init_irq
init_speed
init_trx
main_loop
main_skip
Page8
Chapter 13 Appendix
0000FC02
0008011E
00080108
00080113
0000FE12
0000FE02
0000FE10
0000FE11
0000FE08
0000FE20
0000FE01
T
T
T
T
T
T
T
T
T
T
T
*** Symbol
0000FE09
0000FE02
0000FE00
0000F011
00080182
00000080
00000040
00000020
00000010
00080143
00080283
0000F000
0008017A
0000F001
000801B6
T
T
T
D
T
T
T
T
T
T
T
D
T
D
T
mcr
memory_exit
memory_loop0
memory_loop1
port_alarm
port_cmd
port_cyc_h
port_cyc_l
port_dip_sw
port_lcd
port_rx
MAIN.LST
Table ***
Page 9
port_speed
port_sts
port_tx
rx_buffer
rx_proc
s_1200
s_2400
s_4800
s_9600
speed_exit
time_filler
time_flg
trx_loop
tx_buffer
tx_proc
Program Example 411
Chapter 13 Appendix
Final list file SUB.LST
***
Loc
mn102L00
object
SUB.LST
Cross
Line Source
1
********
2
MN10200
3
4
5
********
6
7
8
9
10
11
12
13
=0000FC00
=0000FC02
=0000FC0E
=0000FC42
=0000FC44
=0000FC48
=0000FC50
412
Program Example
14
15
16
.1
.2
.3
.4
.5
.6
.7
.8
.9
.10
.11
.12
.13
.14
.15
.16
.17
.18
.19
.20
.21
.22
.23
.24
Page 1
Assembler
***
************* *************
assembler
sample program
************* **************
*
*********
************* *************
COMMUNICATION TERMIVAL: SUB
********** ************* *************
*
######
###########
###########
Example
of include
usage
######
#include
*********
##########
Òequtbl.hÓ
************
*************
MN10200
assembler
sample program
*********
************* **************
********
Special
********
************ *************
Register MAP for MN10200
************* *************
vpum
mcr
iagr
equ
equ
equ
0xfc00
0xfc02
0xfc0e
icr1
icr2
icr4
icr8
equ
equ
equ
equ
0xfc42
0xfc44
0xfc48
0xfc50
********
COMMUNI
*******
************* ************
CATION
TERMINAL:
************* ************
********
************
###########
************
EQUATION
Chapter 13 Appendix
=0000FE08
.25
.26
.27
.28
.29
.30
.31
.32
.33
.34
.35
=0000FE09
.36
=0000FE10
=0000FE11
.37
.38
.39
.40
=0000FE00
=0000FE01
=0000FE02
=0000FE02
***
Loc
Port
table
*********
************* ************
port_tx
port_rx
port_rx
port_sts
equ
equ
equ
equ
0xfe00
0xfe001
0xfe002
0xfe02
;TX
;RX
;Command(OUT)
;Status (IN)
port_dip_s equ
w
port_speed equ
0xfe08
;Dip Switch
0xfe09
;Baud Rate
Generator(BRG)
port_cyc_h equ
port_cyc_l equ
0xfe10
0xfe11
;Cyclic LED
=00000000
=00000040
=00000010
SUB.LST
Page 2
Cross
Assembler
Line Source
.41 port_alarm equ
.42
.43 port_lcd
equ
.44
.45 ********
************
.46
.47 Command/
Status
Definition
.48
.49 ********* *************
.50
.51 c_init
equ
.52 c_reset
equ
.53 c_err_rest equ
=0000007A
.54
c_cmd_inst equ
0x7a
=00000037
.55
c_mod_inst equ
0x37
c_tx_rdy
c_rx_rdy
equ
equ
0x01
0x02
;Tx ready
;Rx ready
c_line_con equ
0x80
;Line
connected
c_err_bit
equ
0x28
;Rx error bits
*********
************
************
mn102L00
Object
=0000FE12
=0000FE20
=00000001
=00000002
=00000080
=00000028
.56
.57
.58
.59
.60
.61
.62
.63
.64
***
0xfe12
;Alarm LED
0xfe20
;LCD
*************
*************
0x00
0x40
0x10
;Initial value
;Hard reset
;Rx Error
reset
;Command
instruction
;Mode
instruction
Program Example 413
Chapter 13 Appendix
=00000080
=00000040
=00000020
=00000010
=00000010
.71
.72
.73
.74
.75
.76
.77
.78
.79
.80
.81
.82
.83
.84
.85
.86
=00000101
=00000000
=0000F400
.87
.88
.89
.90
.91
.92
.93
.94
.95
.96
=00000080
=00000040
=00000020
=00000010
Loc
414
Program Example
.65
.66
.67
.68
.69
.70
Object
=00000000
=0000F00
speed
Definition
********
***********
************
s_1200
equ
0x80
s_2400
s_4800
s_9600
equ
equ
equ
0x40
0x20
0x10
brg_1200
brg_2400
brg_4800
brg_9600
equ
equ
equ
equ
0x80
0x40
0x20
0x10
********
***********
*************
Buffer
Size
********
************
;BRG image
*************
buffer_siz equ
e
16
*********
************
************
System
define
*********
************* *************
MCR_WAIT
CPU_MODE
STACKTOP
SUB.LST
Line Source
.97 PSW_OFF
.98 PSW_SET
.99
17
18
#define
19
20
_CODE
21
22
23
24
25
#######
26
27
Example
;Dip switch
image
equ
equ
equ
Page 3
0x0101
0x0000
0xf400
equ
equ
0x0000
0x0f00
HI_SPEED
section
CODE, PUBLIC,
2
global
global
rx_proc,tx_pro c, cyc_proc
time_filler
##########
##########
of macro
declaration
Chapter 13 Appendix
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
080182
8000
080184
080187
080188
08018B
DC02FE
31
F50502
E828
08018D
080190
F50028
E91D
60
61
62
63
64
65
66
67
DC01FE
68
69
080192
***mn
080195
080196
102L00
31
70
71
F47411F000 72
######
##########
###########
output
macro
mov
mov
movb
mov
A0,(save_A0)
port_tx, A0
D0, (A0)
(save_A0), A0
endm
time_fill
;
fill_loop
macro
local
mov
mov
nop
nop
nop
sub
bne
count
fill_loop
count, D0
1, D0
fill_loop
;
mov
rts
endm
(save_D0), D0
********
************
************
Rx
process
********
rx_proc
************
*************
mov
0,D0
mov
movbu
btst
beq
port_sts, A0
(A0), D1
c_rx_rdy, D1
rx_exit
and
bne
c_err_bit, D0
rx_error
mov
Page 4
Assembler
movbu
port_rx, A0
***
(A0), D1
mov
rx_buffer, A0
SUB.LST
Cross
;set ÔNot
ReceivedÕ
;not received
;Rx error
happened
;Rx data
Program Example 415
Chapter 13 Appendix
08019B
0801A0
0801A2
F4C034F000 73
F200
74
11
75
mov
add
movb
0801A3
0801A6
F5000F
76
F44034F000 77
78
8001
79
EA06
80
and
mov
(rx_index), D0
D0, A0
D1, (A0)
;set into
buffer
buffer_size_1
,D0
D0, (rx_indes) ;next index
mov
bra
1, D0
rx_exit
mov
mov
movb
port_alarm, A0 ;Alarm LED ON
1, D1
D1, (A0)
0801AB
0801AD
0801AF
0801B2
0801B4
0801B5
0801B6
0801B8
0801BD
0801C2
0801C7
0801C9
F4C032F000
F4C134F000
F391
E84B
0801CB
0801D0
0801D5
0801D7
F47511F000
F4C134F000
F205
34
98
99
100
101
102
103
104
105
106
107
rx_error
rx_exit
*********
rts
************* **************
Tx
process
********
tx_proc
************
*************
mov
movb
0, D0
D0, (cyc_lcd)
mov
mov
cmp
beq
(tx_index), D0
(rx_index), D1
D0, D1
tx_exit
mov
mov
add
movbu
rx_buffer, A1
(rx_index), D1
D1, A1
(A1), D0
;get data in
D0
movb
D0,(cyc_lcd)
mov
mov
mov
add
movb
tx_buffer, A1
tx_buffer, A1
(tx_index), D1
D1, A1
D0, (A1)
;save into
buffer
buffer_size1,D1
D1,(tx_index)
;next index
0801DD
0801E2
0801E2
0801E7
0801E9
108
F4443DF000 109
110
F47501F000 111
F4C132F000 112
F4C132F000 112
F205
113
14
114
0801EA
F5010F
115
and
0801ED
F44132F000 116
mov
0801D8
416
81
82
DC12FE
83
8501
84
11
85
86
87
FE
88
90
91
92
93
94
95
8000
96
F4443DF000 97
Program Example
;Normal
receiving
;clear lcd
data
;set lcd data
Chapter 13 Appendix
0801F2
***
Loc
0801F7
0801FA
0801FB
080205
080207
080208
080209
08020A
08020E
080210
080215
080216
080217
08021A
08021D
080222
080224
080226
117
118 ######
119
120 Example of
121
122 ######
123
M124
F45036F000 124+
SUB.LST
mn102L00
Cross
Object
Line Source
DC00FE
124+
10
124+
F4D036F000 124+
M125
800A
125+
F6
125+ ??00001
F6
125+
F6
125+
F71C0100
125+
E9F7
125+
F4C038F000 125+
FE
125+
126
127 tx_exit
FE
128
129
130 *******
131
132 cyclic
133
134 *******
135 cyc_proc
136
137 ######
138
139 Example of
140
141 ######
142
143 #ifdef
F8F401
144
DC10FE
145
149 #endif
F4C13AF000 150
D501
151
F391
152
E910
153
########
#########
macro
expansion
########
#########
output
mov
Page 5
Assembler
mov
movb
mov
time_fill
mov
nop
nop
nop
sub
bne
mov
rts
A0, (save_A0)
***
port_tx,A0
D0, (A0)
(save_Ao), A0
10
D0, (save_D0)
1,D0
??00001
(save_D0),D0
rts
***********
*************
process
**********
************
#########
#########
assembler
control
#########
##########
HI_SPEED
mov
mov
500,D0
port_cyc_h, A0
mov
add
cmp
bne
(cyc_count),D1
1,D1
D0, D1
cyc_skip
statements
Program Example 417
Chapter 13 Appendix
080228
08022D
080231
080236
080238
080239
08023E
080243
080246
080248
154
155
156
157
158
159
160
00
161
F4413AF000 162
163
F4C83DF000 164
F5007F
165
D820
166
E638
167
F4C83F000
F74C0100
F4443CF000
8500
movbu
xor
movb
mov
(cyc_data), D0
1,D0
D0,(cyc_data)
;change ON/OFF
0,D1
mov
mov
D0,(A0)
D1,(cyc_count)
movbu
and
cmp
bcc
(cyc_lcd), D0
0x007f, D0
0x20, D0
cyc_exit
SUB.LST
Cross
Line Source
Page 6
Assembler
***
169
170
171
172
173
174
mov
and
mov
mov
port_lcd, A0
0x00ff, D0
D0, D1
D0, D2
lsr
D1
lsr
lsr
lsr
mov
add
movbu
movb
D1, A1
D1
D1
D1
error_disp, A1
D1, A1
(A1), D0
D0, (A0)
;upper
time_fill
mov
mov
nop
nop
syb
bne
mov
rts
10
D0,(save_Do)
10,D0
and
add
movbu
movb
0x000f,D2
D2, A1
(A1), D0
D0, (A0)
cyc_skip
;normal
character
168
***
Loc
mn102L00
Object
08024A
08024D
080250
080251
DC20FE
F500FF
81
82
080252
F33D
080254
080256
080258
08025A
08025F
080261
080262
080263
F33D
F33D
F33D
F47521F000
F205
34
10
F215
080265
08026A
08026C
08026D
08026F
080273
080275
08027A
08027B
08027E
080280
080281
418
Program Example
175
176
177
178
179
180
181
182 sub
183
M184
F44038F000 184+
800A
184+
F6
184+ ??00002
F6
184+
F71C0100
184+
E9F7
184+
F4C038F000 184+
FE
184+
185
F5020F
186
F209
187
34
188
10
189
;shift right 4
bits
1,D0
??00002
(save_D0)
;lower
Chapter 13 Appendix
080282
080283
080288
08028A
08028B
08028C
08028D
080291
080293
080298
080299
***
Loc
00F000
00F001
00F002
00F003
00F004
00F005
00F006
00F007
00F008
00F009
00F00A
00F00B
00F00C
00F00D
FE
F44038F000
800A
F6
F6
F6
F71C0100
E9F7
F4C038F000
FE
FE
mn102L00
Object
00
00
00
00
00
00
00
00
00
00
00
00
00
00
190
191
192
193
194
195
196
197
198
199
cyc_exit
rts
*******
************* **************
time
filler
********* ************
time_fille
r
time_fill
mov
mov
??00003
nop
nop
nop
sub
bne
mov
rts
rts
M200
200+
200+
200+
200+
200+
200+
200+
200+
200+
201
202
203 #####
204
205 Example
206
SUB/LST
Cross
Line Source
207 ######
208 _DATA
209
210
211
212 time_flg
213 tx_buffer
213
213
213
213
213
213
213
213
213
213
213
213
*************
10
D0,(save_D0)
10,D0
1,D0
??00003
(save_D0),D0
#########
#########
of data
definition
Page 7
Assembler
***
#########
section
##########
DATA, PUBLIC,
global
time_flg,tx_bu ffer,rx_buffer
ds
ds
1
1, 0, buffer
2
_size
Program Example 419
Chapter 13 Appendix
00F00E
00F00F
00F010
00F011
00F012
00F013
00F014
00F015
00F016
00F017
00F018
00F019
00F01A
00F01B
00F01C
00F01D
00F01E
00F01F
00F020
30
31
32
33
34
35
36
213
213
213
214
214
214
214
214
214
214
214
214
214
214
214
214
214
214
214
215
216
217
218
219
220
221
222
M223
224
225
225+
225+
225+
225+
225+
225+
225+
***
Loc
mn102L00
Object
SUB.LST
Cross
Line Source
00F028
00F029
00F02A
00F02B
00F02C
00F02D
00F02E
00F02F
00F030
37
38
39
41
42
43
44
45
46
225+
225+
225+
225+
225+
225+
225+
225+
225+
00F021
00F022
00F023
00F024
00F025
00F026
00F027
420
Program Example
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
rx_buffer
ds
1,0,buffer_
######
#########
##########
Example
of iterated
macro use
######
#########
error_disp
irp
dc
endm
dc
Page 8
Assembler
size
##########
const,Ó0123456 789ABCDEFÓ
const
Ò0123456789AB
***
CDEFÓ
Chapter 13 Appendix
00F032
00F033
00F034
00F035
00
00
00
00
00F036
00F037
00F038
00F039
00
00
00
00
00F03A
00F03B
00F03C
00F03D
00
00
00
00
ROM
No
No
size is
errors in
warning
***
Symbol
00080207
0008026C
0008028A
00000000
00000101
00000000
00000F00
0000F400
00080182
0000F000
00000080
00000040
00000020
00000010
00000010
0000007A
00000028
00000010
00000000
00000080
00000037
00000040
00000002
T
T
T
T
T
T
T
T STACKTOP
A _CODE
A_DATA
T brg_1200
T brg_2400
T brg_4800
T brg_9600
T buffer_
T c_cmd_
T c_err
T c_err_
T c_init
T c_line_
T c_mod_i
T c_reset
T c_rx_
00000001 T c_tx_
0000FC00 T cpum
226
227
228
229
229
230
230
231
232
232
233
233
234
235
235
236
237
238
in
_DATA
section
DATA, PUBLiC,
tx_index
ds
2
rx_index
ds
2
save_A0
ds
2
save_D0
ds
2
cyc_count
ds
2
cyc_data
cyc_lcd
ds
1
ds
1
end
Hex.0008029A)
assembly
assembly
Page 9
***
524954(
this
this
SUB.LST
Table
2
??0001
??00002
??00003
CPU_MODE
MCR_WAIT
PSW_OFF
PSW_SET
size
inst
_bit
rest
con
nst
rdy
rdy
Program Example 421
Chapter 13 Appendix
422
0000F03A
0000F03C
00080282
0000F03D
00080217
00080238
0000F021
D cyc_coun t
D cyc_data
T cyc_exit
D cyc_lcd
T cyc_proc
Tcyc_skip
disp
D error_
0000FC0E
0000FC42
0000FC44
0000FC48
0000FC50
0000FC02
0000FE12
0000FE02
0000FE10
0000FE11
0000FE08
0000FE20
0000FE01
0000FE09
0000FE02
0000FE00
0000F011
000801AF
000801AF
000801B5
000F034
00080182
00000080
00000040
00000020
T iagr
T icr1
T icr2
T icr4
T icr8
T mcr
T port_al
T port_cmd
T port_cyc
T port_cyc
T port_dip
T port_lcd
T port_rx
T port_sp
T port_sts
T port_tx
rx_buffer
T rx_error
T rx_error
T rx_exit
D rx_index
T rx_proc
T s_1200
T s_2400
T s_4800
***
Symbol
00000010
0000F036
0000F038
00080283
0000F000
00080216
0000F032
000801B6
T
D
D
T
D
T
D
T
Program Example
arm
_h
_l
_sw
eed
s_9600
save_A0
save_D0
time_fil ler
tx_buff er
tx_exit
tx_index
tx_proc
SUB.LST
Table ***
Page 10
Index
Symbols
#define .................................................... 235
#else ........................................................241
#endif .......................................................239
#if ........................................................... 243
#ifb ..........................................................259
#ifdef .......................................................241
#ifeq ........................................................ 246
#ifge ........................................................255
#ifgt ......................................................... 255
#ifle .........................................................251
#iflt ..........................................................251
#ifn .......................................................... 243
#ifnb ........................................................259
#ifndef ......................................................241
#ifneq .......................................................246
#include ....................................................233
#undef ...................................................... 237
&............................................................. 272
.as102L00rc ...............................................358
.ld102L00r ................................................358
@filename ........................................154, 350
A
A .............................................................177
a ..............................................................344
a map_filename .......................................... 105
ABS ......................................................... 185
Absolute ................................................... 185
Addition ................................................... 180
Address Constants ......................................177
address specifiers........................................ 177
Addressing Modes ......................................299
AH .......................................................... 177
AL ........................................................... 177
align ........................................................ 201
Arithmetic Instructions ................................307
Arithmetic operators ................................... 180
as102L00 .................................................. 358
AS102L00.EXE ............................................. 4
assembler ......................................................4
Assembler configuration .............................. 363
Assembler Control Statements ......................164
Assembler Customization .................................9
Assembler Errors ........................................319
Assembler Options ........................................83
Assembling And Linking Multiple Sections ....... 35
assembly language ........................................ 19
AUTOEXEC.BAT ......................................... 8
B
back ......................................................... 294
Bit Manipulation Instructions ....................... 316
Blank Statements ....................................... 167
C
c ....................................................... 90, 345
Character Constants .................................... 175
CLANG ................................................... 206
Command Options ...................................... 344
Comment Field .......................................... 195
Comment Statements .................................. 166
compiler ..................................................... 19
Conditional Assembly ................................. 239
Conditional assembly .................................... 23
Conditional Assembly And Linking ................. 46
Conditional Branch Instructions .................... 313
CONFIG.SYS ............................................... 7
Configuration ............................................ 361
Configuration Options ............................... 9, 11
COPY .......................................................... 6
cross-reference ............................................ 90
Cross-Reference Table ................................ 339
current directory ........................................... 31
D
d ............................................................. 345
D identifier ............................................... 119
Data Move Instructions ............................... 304
dc ............................................................ 215
Debugging information output ........................ 11
DIR ............................................................. 4
Directive statements .................................... 163
Division ................................................... 180
ds ............................................................ 217
dummy_parameter ...................................... 259
dw ........................................................... 219
<Index
1>
E
H
e ............................................. 112, 143, 346
Ed ........................................................... 151
Editor ........................................................ 21
En ........................................................... 150
end .......................................................... 203
endm ....................................................... 267
engineering workstation .............................. 356
equ .......................................................... 222
Error Message Options ................................ 110
Error Messages .......................................... 319
Error messages .......................................... 352
EWS version ............................................. 356
EX fileoutput with errors ............................... 11
EXCV102.EXE ............................................. 4
exitm ....................................................... 278
Expansion ................................................. 269
EXT ........................................................ 185
Extended C language format ........................ 173
External ................................................... 185
external declaration ...................................... 30
external label ............................................. 225
external reference ....................................... 185
external references ....................................... 30
h ..............................................127, 155, 347
Hardware Environment ....................................3
Header files ................................................. 22
I
I ................................................................88
include files .................................................27
Installation ............................................6, 359
installer......................................................... 4
Intel format .......................................173, 206
internal EPROM ...........................................20
irp ............................................................288
irpc ..........................................................291
J
j
......................................................110, 142
L
F
f ............................................................. 346
Factory Setting .............................................. 9
Fatal Error Messages .......................... 323, 328
Fatal Errors ...... 318, 319, 322, 323, 326, 327,
................................................ 328, 351, 352
file conversion utility ...................................... 4
file extensions ............................................. 28
File Organization ................................... 4, 358
Files Used By Assembler And Linker .............. 27
Forced Termination Of Macro Expansion ....... 278
front ........................................................ 294
G
g ..................................................... 123,
global ......................................................
< Index 2 >
146
225
l library_filename .......................................152
L path_name .............................................. 153
l path_name ...............................................116
Label Field ................................................192
Lc ............................................................ 101
ld102L00 ..................................................358
LD102L00.EXE ............................................. 4
Li ..............................................................93
Library File Options ....................................152
Library Manager ......................................... 343
Line .........................................................334
Line number ...............................................335
Line number supplemental information ...........335
Linker configuration ....................................364
Linker Errors .............................................326
Linker options ............................................135
linker) ..........................................................4
listoff .......................................................204
liston ........................................................204
Lm .............................................................97
Loc ..........................................................334
local ......................................................... 275
Local Symbol Declaration ............................275
Location Counter ........................................ 178
Logical AND ............................................. 181
Logical left shift .........................................181
Logical operators ........................................181
Logical OR................................................ 181
logical right shift ........................................181
Ls ............................................................104
M
m .............................................................139
Machine language code ................................334
Machine language code supplemental information
............................................................... 335
Machine language instruction statements .........163
macro ....................................................... 267
Macro Calls ...............................................269
Macro Control Statements ............................ 165
Macro Operators ........................................272
macro_body .............................................. 267
macro_name ......................................267, 269
Macros .......................................................23
MAKE ....................................................... 21
MAP file output ........................................... 11
Matsushita format .......................................174
Memory ........................................................ 3
mnemonics ................................................196
Modulo operator (remainder) ........................180
MS-DOS .......................................................3
Multiplication ............................................ 180
N
notation .................................................... 206
Number formating ..........................................9
Numbers ...................................................172
Numeric Restrictions ...................................368
O
o file_name .................................................86
o filename .................................................137
Object ......................................................334
Od ...........................................................125
Operand Field ............................................194
Operation Field .......................................... 193
Operator Precedence ................................... 182
Operators .................................................. 180
opt ........................................................... 210
Optimization ........................................... 9, 22
optimization ................................................ 58
org .......................................................... 208
Ot............................................................ 126
Output debug information ............................ 362
Output EX file ........................................... 362
Output File Options .............................. 86, 137
P
p ............................................................. 347
page ......................................................... 212
PAINST.EXE ................................................ 4
PANA ...................................................... 206
Parameter file during linking .......................... 41
Permitted Characters ................................... 171
Preprocessor Options .................................. 116
Program Format ......................................... 161
Program Generation Options ................ 123, 146
Program locations after linking ....................... 45
Programming style ....................................... 22
Programming With Assembler ........................ 21
Purging Macro Definitions (purge) ................ 283
R
r .............................................. 124, 149, 348
radix ........................................................ 213
Reading List Files ...................................... 333
Reference List ........................................... 340
Register indirect addressing .......................... 299
Register relative indirect addressing ............... 299
REL......................................................... 185
Relative .................................................... 185
identifier ................................................... 235
rept .......................................................... 285
Reserved Words ......................................... 187
RF file output ................................................ 9
ROM conversion .......................................... 20
ROM writer ................................................ 20
root directory ................................................. 8
<Index
3>
S
X
section ..................................................... 199
self-reference ............................................ 178
settings ........................................................ 9
Shift operators ........................................... 181
SLI102L.EXE ............................................... 4
slib102l .................................................... 358
Source ..................................................... 334
Source code debugger ................................... 19
Starting Assembler ....................................... 81
String constants ......................................... 176
subdirectory .................................................. 8
Subroutine Call Instructions ......................... 312
Subtraction ............................................... 180
Symbol Table ............................................ 337
Symbol table output ...................................... 11
Symbol Type ............................................. 339
x ..............................................................349
Xl ............................................................109
xlistoff ...................................................... 228
xliston ...................................................... 228
Xm ..........................................................141
T
t .............................................................. 348
tit ............................................................ 227
Tsection_name .......................................... 147
TYPE ................................................ 32, 333
U
Unary minus ............................................. 180
Unary negation .......................................... 181
Unary plus ................................................ 180
Unconditional Branch Instructions ........... 61, 312
UND ....................................................... 185
Undefined ................................................. 185
undefined ................................................. 225
User Customization ........................................ 9
W
W number ........................................ 113, 144
Wall ................................................ 115, 145
Warning Messages ............................. 322, 327
Warning messages ...................................... 354
< Index 4 >
102L00Series
Cross-Assembler UserÕs Manual
October, 2000 7th Edition 1st Printing
Issued by Matsuhita Electric Industrial Co., Ltd
Ó Matsushita Electric Industrial Co., Ltd.
Semiconductor Company, Matsushita Electronics Corporation
Nagaokakyo, Kyoto, 617-8520 Japan
Tel: (075) 951-8151
http://www.mec.panasonic.co.jp
SALES OFFICES
■ U.S.A. SALES OFFICE
■ HONG KONG SALES OFFICE
Panasonic Industrial Company
[PIC]
● New Jersey Office:
2 Panasonic Way, Secaucus, New Jersey 07094
Tel: 201-392-6173
Fax: 201-392-4652
● Milpitas Office:
1600 McCandless Drive, Milpitas, California 95035
Tel: 408-945-5630
Fax: 408-946-9063
● Chicago Office:
1707 N. Randall Road, Elgin, Illinois 60123-7847
Tel: 847-468-5829
Fax: 847-468-5725
● Atlanta Office:
1225 Northbrook Parkway, Suite 1-151,
Suwanee, Georgia 30174
Tel: 770-338-6940
Fax: 770-338-6849
● San Diego Office:
9444 Balboa Avenue, Suite 185
San Diego, California 92123
Tel: 619-503-2940
Fax: 619-715-5545
■ CANADA SALES OFFICE
Panasonic Canada Inc.
[PCI]
5700 Ambler Drive Mississauga, Ontario, L4W 2T3
Tel: 905-624-5010
Fax: 905-624-9880
■ GERMANY SALES OFFICE
Panasonic Industrial Europe G.m.b.H.
● Munich Office:
Hans-Pinsel-Strasse 2 85540 Haar
Tel: 89-46159-156
Fax: 89-46159-195
[PIEG]
Panasonic Industrial Europe Ltd.
[PIEL]
● Electric component Group:
Willoughby Road, Bracknell, Berkshire RG12 8FP
Tel: 1344-85-3773
Fax: 1344-85-3853
■ FRANCE SALES OFFICE
[PIEG]
[PSSA]
■ MALAYSIA SALES OFFICE
Panasonic Industrial Company (Malaysia) Sdn. Bhd.
● Head Office:
[PICM]
Tingkat 16B Menara PKNS PJ No.17,Jalan Yong
Shook Lin 46050 Petaling Jaya Selangor Darul Ehsan
Malaysia
Tel: 03-7516606
Fax: 03-7516666
● Penang Office:
Suite 20-17,MWE PLAZA No.8,Lebuh Farquhar,10200
Penang Malaysia
Tel: 04-2625550
Fax: 04-2619989
● Johore Sales Office:
39-01 Jaran Sri Perkasa 2/1,Taman Tampoi
Utama,Tampoi 81200 Johor Bahru,Johor Malaysia
Tel: 07-241-3822
Fax: 07-241-3996
Panasonic SH Industrial Sales (Shenzhen)
Co., Ltd.
[PSI(SZ)]
7A-107, International Business & Exhibition Centre,
Futian Free Trade Zone, Shenzhen 518048
Tel: 755-359-8500
Fax: 755-359-8516
Panasonic Industrial (Shanghai) Co., Ltd.
[PICS]
1F, Block A, Development Mansion, 51 Ri Jing Street,
Wai Gao Qiao Free Trade Zone, Shanghai 200137
Tel: 21-5866-6114
Fax: 21-5866-8000
Panasonic Industrial (Thailand) Ltd.
[PICT]
252/133 Muang Thai-Phatra Complex Building,31st
Fl.Rachadaphisek Rd.,Huaykwang,Bangkok 10320
Tel: 02-6933407
Fax: 02-6933423
[PIEG]
■ TAIWAN SALES OFFICE
Panasonic Industrial Sales Taiwan Co.,Ltd.
[PIST]
● Head Office:
6th Floor, Tai Ping & First Building No.550. Sec.4,
Chung Hsiao E. Rd. Taipei 10516
Tel: 2-2757-1900
Fax: 2-2757-1906
● Kaohsiung Office:
6th Floor, Hsien 1st Road Kaohsiung
Tel: 7-223-5815
Fax: 7-224-8362
 Matsushita Electronics Corporation 2000
Panasonic Semiconductor of South Asia
300 Beach Road # 16-01
The Concourse Singapore 199555
Tel: 390-3688
Fax: 390-3689
■ THAILAND SALES OFFICE
■ ITALY SALES OFFICE
Panasonic Industrial Europe G.m.b.H.
● Milano Office:
Via Lucini N19, 20125 Milano
Tel: 2678-8266
Fax: 2668-8207
■ SINGAPORE SALES OFFICE
■ CHINA SALES OFFICE
■ U.K. SALES OFFICE
Panasonic Industrial Europe G.m.b.H.
● Paris Office:
270, Avenue de President Wilson
93218 La Plaine Saint-Denis Cedex
Tel: 14946-4413
Fax: 14946-0007
Panasonic Shun Hing Industrial Sales (Hong Kong)
Co., Ltd.
[PSI(HK)]
11/F, Great Eagle Centre, 23 Harbour Road,
Wanchai, Hong Kong.
Tel: 2529-7322
Fax: 2865-3697
■ KOREA SALES OFFICE
Panasonic Industrial Korea Co., Ltd.
[PIKL]
Hanil Group Bldg.11th Fl.,191 Hangangro 2ga,
Youngsans-ku,Seoul 140-702,Korea
Tel: 82-2-795-9600
Fax: 82-2-795-1542
■ PHILIPPINES SALES OFFICE
National Panasonic Sales Philippines
[NPP]
102 Laguna Boulevard Laguna Technopark Sta.
Rosa. Laguna 4026 Philippines
Tel: 02-520-3150
Fax: 02-843-2778
080600
Printed in JAPAN