MN1030 Series Cross Assembler User’s Manual
Page
Page
Reference Techniques
Manual Features
Usage note
How to read
Heading
Program example
Related Manuals
Chapter Writing Macro Control Statements
Purpose of This Chapter
Purpose of This Chapter Rules of Usage Usage Example
Chapter Types of Source Statements
Writing Assembler Control Statements
Readinig List Files
Error Correction Using Tag Jumps 306
Chapter
Purpose of This Chapter
98/Me/2000/XP
Operating Environment
Host machine Operating system Version of OS
Solaris Or later
Slib103 library manager
File Organization
As103 assembler
Ld103 linker
Installation
Setting command path
Setup
Start-up files
Keywordparameter
Start-up file format
Option
Keyword Description
Message
Notation
Libdir
En-OPTION
Ed-OPTION
Stdlib
Excv103 options EX format file name
General command format
File Conversion Utility
Options
Rules of output file name
Default specification
Example of specifying options
Program Development Flow
Program Development Flow
Main development flow
Program Development Flow
Assembler and compiler
Source code debugger
Program format
Reference , Using Linker, for details
Programming with Assembler
Required knowledge
Optimization
Programming style
Macros
Conditional assembly
Debugging
Program Development Flow Programming with Assembler
Introduction to Operation
Introduction to Operation
Files Used
Files Used by Assembler and Linker
Introduction to Operation
Create source files
Basic Operation of Assembler and Linker
Assemble
Contents of program2.asm are as follows
Generate final list files
Link
Contents of the final list file program1.lst are as follows
Contents of the final list file program2.lst are as follows
Assembling and Linking Multiple Sections
Assemble and generate list files
Contents of program4.asm are as follows
DATA, PUBLIC,4
Contents of the list file program4.lst are as follows
Parameter file during linking
Following command was input to link
CAE0 Data
Contents of the final list file program4.lst are as follows
Program Location
Program locations after linking
Create source file
Conditional Assembly and Linking
#ifdef
Assemble and link the program that you have created
Assemble and link
Select false condition, assemble, and link
Specify assembly conditions in the command
As103 -D Debug program5.asm
Introduction to Operation Conditional Assembly and Linking
Chapter Optimization
Has been optimized
Rules of Usage
Optimization is off by default
Instruction Type Branch Range
Usage Example
Optimization Instructions
Optimized Conditional Branch Instructions Type Branch Range
Dn, abs Movhu abs, Dn Movhu Dn, abs
Abs, An
Abs, Dn
An, abs
Instruction
Logical Instructions Subject To Optimization
Btst imm, Dn
Optimization processing
BNE*+5
Optimization processing of conditional branch instructions
Assembler processing
Linker processing
Optimization of function calls
Label JMP label Call label Calls label JSR label
Optimization of branches
BRA label
Label JMP label
Optimization
Optimization
Opt
Text
CA7F
Example subroutine call converted to a relative branch
Using Assembler
Using Asssembler
Starting Assembler
General format of commands
Specifying options
Summary of options
Command Options
Operation Example
Output File Options
Functional description
Rules of Use
As103 -l sample.asm
Output a list file
No list file will be output
As103 -Li -l sample.asm
Do not output files included by include to the list file
As103 -l -Li sampl.asm
As103 -l -Lm sampl.asm
As103 -Lm -l sample.asm
As103 -l -Lc sampl.asm
As103 -Lc -l sample.asm
As103 -a sample.map -l sample.asm
Do not output a symbol table to the list file
Symbol table will be output
As103 -Ls -l sample.asm
As103 -j sample.asm
Error Message Options
This option is not available on DOS/V or PC/AT machines
As103 -Je sample.asm
As103 -Js sample.asm
As103 -Jj sample.asm
As103 -e sample.asm
Output error and warning messages in English
As103 -Wall sample.asm
Default is to display all warning messages
As103 -W 2001 sample.asm
Wall Do not output any warning messages
Pathname Specify the trace directory of the include file
Preprocessor Options
As103 -I/user/defs main.asm
As103 -D Version sample.asm
As103 -g sample.asm
Program Generation Options
Output debug information to the relocatable object file
Executable format file .EX
As103 -Od sample.asm
Turn on optimization
As103 -O sample.asm
Turn off optimization
Display the assemblers version number on the console
Other Options
As103 -h
On the screen
As103 -g -o test.rf -I /user/lib sample.asm
Program assembly
Operation Examples
As103 -g -D Version -o test.rf /user/source/main.asm
As103 -l -a main.map sub.asm
As103 -l -Lc -Lm -a main.map -D Mode prog1.asm
Chapter Using Linker
Link Model of Section Address Format
Main.ex -gm
Starting Linker
Ld103 options relocatableobjectfilename Libraryfilename
Jmg
Executable file
Path specifications on the relocatable object files
@CODE=80000000 or -T @CODE=80000000
M103.map, respectively
Linker options Option Type Symbol Description
Command Options
Ld103 -o /usr/tmp/test.ex main.rf sub.rf
Ld103 -m main.rf sub.rf
Output a map file
Ld103 -m -TTEXT=80000000 -TCONST=80005000 prog1.rf prog2.rf
Ld103 -j sample.rf
Ld103 -Je sample.rf
Ld103 -Js sample.rf
Ld103 -Jj sample.rf
Ld103 -e sample.rf
Ld103 -W3001 progr1.rf prog2.rf
Function description
Ld103 -Wall main.rf sub.rf
Ld103 -g main.rf sub.rf
Output debug information to the executable format file
Section =addresses Specify starting address for a section
Section layout rules
Ld103 main.rf sub.rf
Lowest section is referred to the section name
Ld103 -T @CODE=80000000 -T@DATA=0 main.rf sub.rf
Parameter file
Letter
Ld103 -r prog1.rf
Output an executable format file even if errors are detected
Ld103 -Ed main.rf sub.rf
Ld103 -En main.rf sub.rf
En option cannot be used in conjunction with the g option
Output the Data section to the executable file
Message will be appeared
Library File Options
Libraryfilename Specify a library file
Ld103 -l /usr/lib/sample.lib main.rf sub.rf
Library files specified by the l option will be read
Pathname Specify a directory containing library files
@filename Specify a parameter file
Operational example
Ld103 @pfile
Ld103
Ld103 -h
Instruction RAM Support
Structural Elements of an Iram Support Executable
Structure of Iram Support Executable File
Number field to
Layout Image for Instruction RAM and External Memory
These names for ordinary symbols
Using Linker
Same result
Iram Support Options
Starting address in instruction RAM is given in hexadecimal
Overlaytable Irammanage
PUT symbol=address Specify address for extra symbol
Address is in hexadecimal
Assigning to different addresses in instruction RAM
Operation Examples
Assignment to the same address in instruction RAM
Overlaps with actual code
Conflicts and suppresses executable file output
Using Linker Instruction RAM Support
Types of Source Statements
Type of Source Statements
Program Format
Movw Data, A0 0x12 D0, A0 Endm
#include
Equ 0x32
Dataset Macro
Directive statements
Machine language instruction statements
#else Mov 0x22, D0
Assembler Control Statements
Mov 0x11, D0
Adrset Macro data, reg Mov Reg, A0 Data, D0 D0, A0 Endm
Macro Control Statements
Adrset Data1, reg1 Data2, reg2
Comment Statements
Conditional assembly definition
Program Start main
Blank Statements
Type of Source Statements Blank Statements
Writing Source Statements
Writing Source Statements
Letters
Permitted Characters
Digits
2 3 4 5 6 7 8
Re hexadecimal digits that correspond to decimal
Numbers
Radices and allowed digits
C D E F or
Intel format
Extended C language format
Coding rules
’789’
Matsushita format
’101’
’567’
Character constants
Character Constants
Specified
String constants
Specifies the string Abcdefg as Ascii code
+-&%$#@ Specifies the string +-&%$#@!,. as Ascii code
Example
Address Constants
Location Counter
Sec
Expressions
Assembler or linker
Section CODE,PUBLIC,1
Operator Meaning
Operators
Arithmetic operators
Shift operators
Logical operators perform calculation in bit units
Logical operators
Formats Example Operand1 Operand2
Precedence Operator Description
Expression Evaluation
Equ 0b01101110
Mov 10+5+2, d0
Expression Syntax
Mov 10+5, d0
Mov +10+5, d0
Attribute of Operand Attribute of Result
Expression Attributes
Operation result attributes
For ~, +, unary operators
For subtraction operator
For + addition operator
For *, /, %, , , &, , operators
Iflt, ifn, ifnb, ifndef, ifneq, include, undef
Reserved Words
D0, d1, d2, d3, a0, a1,a2, a3, PSW, mdr, sp
Define, if Ifb, ifdef, ifeq, ifge, ifgt, ifle
Page
Purpose of This Chapter
Coding rules
Instruction Statement Fields
Coding examples
Writing Label Field
Label Longlabellonglabellonglabellonglab main Startcont
Equ
Writing Operation Field
Start Mov
Jsr
Writing Operand Field
One operand
Operands are register and expression
Mov 0x10, D0
Writing Comment Field
Set count value
Writing Machine Language Instruction Statements
Below is a list of directives
Writing Directive Statements
List of directives
Document conventions
Section linking rules
Default settings
Section
Syntax
Main Jsr
Operand coding rules
Directive coding rules
Usage example
Label Operation Operand Align Expression
Align
Current location counter value will be inherited
00000000
Below is an example use of the align directive
0x01
Below is an example use of the end directive
3 end
Label
Name end
These directives take no operands
Listoff, liston
Label operation operand Name listoff Name liston
Listoff and liston directives themselves are output
Operand Format
Notation
Label Operation Operand Notation
Clang will be selected
Notation
Below is an example use of the notation directive
Org 0x100 End
6 org
Secadr
Secfnc Org 0x20
Opt on Opt off
7 opt
Number of lines = Number of columns =
Label Operation Operand Linesexpression ,columnsexpression
Below is an example use of the page directive
Below is an example use of the radix directive
Radix
Label Operation Operand Radix Expression
Another radix
10 dc
11 ds
When expression2 is omitted, expression3 cannot be specified
1122
Below is an example use of the ds directive
PanaX Series MN1030 Cross Assembler Loc Object Line Source
Ds0
34127856 Dw1 dw 0x1234
12 dw
Section DATA, Public
3930 Dw0 dw 12345
00000000 Dd0
13 dd
Label Operation Operand Name Expression, expression
78563412 Dd0 0x12345678
Label Operation Operand Name Equ Expression
14 equ
Memory equ Motor equ Stop equ 0b00001000 Base equ
8020 Mov
Equ 0x20
Equ 0b00001000
Equ 0x1000
Label Operation Operand Name Global Name, name
Global
Mov 0x11, D0 Rts End
Below is an example use of the global directive
External declaration
External reference
Loc Object Line Source Tit
16 tit
Label operation operand Titstring
Below is an example use of the tit directive
These directives take no operand
Xlistoff, xliston
Name Xlistoff Xliston
Xlistoff and xliston directives themselves are not output
Funcinfo
Directive Specification Rules
Usage Examples, Optimization of function calls
Stack
Global 0func
Call 0func Global 0func, func
Func Movm D2, SP Add 0func Funcinfo Func, 8, D2 Ret
Assign 0x02 00000002 8002 Mov
Assign
Usage examples
Assign 0x01 00000000 8001 Mov
Page
Writing Assembler Control Statements
Contents of brackets may be omitted
Symbols used in this chapter have the following meanings
Common coding rules
File Inclusion
#include filename
10.2.1 #include
Path name is coded within filename
Main Mov Data, A0 0x34, D0 D0, A0 End
Data equ
File to be assembled consists of the following statements
#include Inc.h
Identifier Definement
Main Mov Data, D0 Load End
#define Replacementstring comment
10.3.1 #define
#define Data Load Mov Data, D0
#define Data1 0x11 Data2 0x22
10.3.2 #undef
#undef identifier
Source file that uses #undef is shown below
Contents of brackets from #else on can be omitted
Conditional Assembly
#if
These directives can be used only within macro definitions
Table below lists the conditional assembly directives
#ifndef
10.4.1 #ifdef, #ifndef
Syntax for #ifdef Syntax for #ifndef
#ifdef Identifier #ifndef Block1 #else Block2 #endif
10X Mov 0x03, D1 #else
#else Mov 0x01, D0 0x02, D0 #endif #ifndef
#else Mov 0x03, D1 0x04, D1 #endif
8001 Mov 0x01, D0 #else 0x02, D0 #endif #ifndef
#if
10.4.2 #if, #ifn
Syntax for #if Syntax for #ifn
#ifn
8002 Mov 0x02, D0 #endif #ifn
#else Mov 0x01, D0 0x02, D0 #endif #ifn
#else Mov 0x03, D0 0x04, D0 #endif
Mov 0x01, D0 #else
#ifeq
10.4.3 #ifeq, #ifneq
#ifneq
Compare Abc, abc Abc, acb
8002 11+ Mov 0x02, D0 #endif
M10 Compare Abc, abc 10+ #ifeq
#iflt
10.4.4 #iflt, #ifle
#ifle
8002 12+ Mov 0x02, D0 #endif
M12 Dsize
12+ #iflt
12X Mov 0x01, D0 12+ #else
#else Mov 0x01, D0 0x02, D0 #endif #ifge
10.4.5 #ifgt, #ifge
#ifgt
#ifge
8002 Mov 0x02, D0 #endif #ifge
#ifb
10.4.6 #ifb, #ifnb
#ifnb
Debugon
M17 Debug
M14 Debug
14+ #ifb Debugon 14X Jsr Check Proc #else 00000000
+14+ Jsr Proc 00000008 00F8FE04 #endif #undef
Writing Macro Control Statements
#include directive Macro definitions
Macrobody
Macro Definitions macro, endm
Macroname
Dummyparameter , dummyparameter
An example macro definition is shown below
Macroname Parameter , parameter
Macro Calls and Expansion
Up to10 dummy parameters can be specified
Var1 Equ 0x10 Var2 Var1+2 Addadr Macro Adr Adr, A0 Endm
Operator Description
Macro Operators
Text Section CODE,PUBLIC,1
Macroname macro parameter Local symbol , symbol Symbol
Local Symbol Declaration local
Up to 30 symbols can be specified
An example using the local directive is shown below
Parameter
Forced Termination of Macro Expansion exitm
#endif Exitm Endm
Test
Purge macroname , macroname
Purging Macro Definitions purge
Reptexpression block
Rept
Assembled list file is shown below
Block
11.9 irp
Irp
Dummyparameter, parameter , parameter
Irp
Following example uses the irpc directive
Irpc
Irpc
Dummyparameter, string
DATA, Public
Writing Macro Control Statements Irpc
List of Machine Language Instructions
List of Machine Language Instructions
Register indirect addressing
Addressing Modes
Register relative indirect addressing
Absolute addressing
Index addressing
List of Machine Language Instructions
Move source to destination
12.3.1 Data Move Instructions
Mnemonic Description of operation
Movhu
Index
Absolute
Extend Sign
ADD with Carry
Arithmetic Instructions
Subtract with Borrow
Compare source with destination
EXCLUSIVE-OR source with destination
Logical Instructions
Source with destination
Or source with destination
Mnemonic Description of operation LSR Dm, Dn
Mnemonic Description of operation ASR Dm, Dn
ASR imm8, Dn
ASR Dn
Bit operations
Bit Manipulation Instructions
Bclr imm8,abs32
Call Subroutine
Branching Instructions
Mnemonic Description of operation JMP An
Unconditional Branch
JMP label
Mnemonic Meaning Description of operation
Conditional Branch
If ZF = 1 or NF != VF, execute next instruction
Conditional Branch for Loop
ZF=1 If ZF = 0, execute next instruction
ZF=0 If ZF = 1, execute next instruction
UDFnn imm, Dn
User-Defined Instructions
User Defined Function
UDFnn Dm, Dn
Do nothing
Other Instructions
Error Messages
Error Messages
Assembler Errors
Illegal operand value
Operand error
Define symbol multiple defined
Define symbol not defined
Symbol name too long
Not guaranteed operand by the instruction allocation
Line of the source file exceed 65535 lines
Error Messages
Illegal operand expression
Debug operand error
Macro symbol is used recursively
Illegal section name
No optimizing information
Error in configure file
Too many arguments
Can’t find Funcinfo directive
Fatal Error Messages
Linker Errors
Address overlay with Iram manager
Extra symbolname address aligned. address
Filename Section not found. This file ignored
Filename Illegal sectionname attribute or align value
Filename Symbolname not defined with FUNCINFO. line lineno
Bad option switch.string
Multiply defined symbol
Undefined symbol
3313
Extra symbolname used as normal symbol
Filename Cannot read file
Filename Invalid symbol detail information type.type
No memory space
Fileneme Cannot open file
Filename Illegal optimize information.line lineno
Filename Referring to symbolname defined in a programID=id
Internal Error.string
Filename Illegal relocation information.line lineno
Error Messages Linker Errors
Readinig List Files
Reading List Files
Reading List Files
Machine language code supplemental information
Output Format of Machine Language Code
Location Loc
Machine language code Object
Supplemental information
Version
Source statement Source
Symbols value is shown as eight hexadecimal digits
Symbol Table
Symbol Value
Symbol Type
Symbol Name
Using Library Manager
Using Library Manager
Starting Library Manager
Slib103 test.lib -f -j test1.rf test2.rf test3.rf
Slib103 test.lib -f -Je test1.rf test2.rf test3.rf
Slib103 test.lib -f -Js test1.rf test2.rf test3.rf
Slig103 test.lib -f -Jj test1.rf test2.rf test3.rf
Rules os use
Slib103 test.lib -f -e test1.rf test2.rf test3.rf
Slib103 test.lib -Wall -c test1.rf test2.rf test3.rf
Slib103 test.lib -W4001 -o test1.rf test2.rf test3.rf
Name
Create a new library file
Slib103 test.lib -c test1.rf
Slib103 test.lib -c test1.rf test2.rf test3.rf test4.rf
Files with the same name
Force creation of a library file
Slib103 test.lib -f test1.rf
Slib103 test.lib -f test1.rf test2.rf test3.rf test4.rf
Path name will be added in the library file
Functional Options
Slib103 test.lib -a test.1.rf
Slib103 test.lib -a test1.rf test2.rf test3.rf
Slib103 test.lib -d test1.rf test2.rf test3.rf
Slib103 test.lib -d test1.rf
Slib103 test.lib -p test1.rf slib103 test.lib -p
Slib103 test.lib -p
Slib103 Test.lib -r test1.rf test2.rf test3.rf
Slib103 test.lib -r test1.rf
File
Slib103 test.lib -t test1.rf slib103 test.lib -t
Slib103 test.lib -t test1.rf
Slib103 test.lib -x test1.rf slib103 test.lib
Slib103 test.lib -x test1.rf
Existing in the current directory
Slib103 @pfile
There is no default specification
Assume that the file pfile contains the following line
Slib103
Default is not to display the version number
Slib103 -h
Display the library manager’s version number on the console
Errornumber Displayedmessage
Error Messages
Cause Solutions
4001 Filename not found
4002 This file has no public symbol information.filename
4003 Filename not found. In addition to library
4302 Premature EOF. filename
4310 This file has redefined public symbol. filename
4312 Symbol name length over. max 66. symbol
4301 Multiply specified object file name.filename
4314 Cannot read parameter-file. filename
4313 Parameter-file already specified. filename
4315 Not warning message number
4503 Multiply specified library file name. filename
4504 Memory allocation error
4501 Illegal option. string
4502 Library file name not found
Page
Purpose of This Chapter
Personal Computer Versions
PC/ATWindows98/2000/Me/XP DOS/VWindows98/2000/Me/XP
Operating Environment
SLIB103.EXE library manager
Files
AS103.EXE Assembler
LD103.EXE linker
Installation
SET PATH=A\usr\local\bin
Environment Settings
New setting will then automatically take effect
Differences From Workstation Versions
Command line differences
Generate error file
Error Correction Using Tag Jumps
Contents of the generated error file Error are as follows
Tag jumps
Fix errors
Contents of the file Error will be displayed on the screen
First error message matches this display on the screen
MAIN.ASM7 Error 2306 Multiple define symbol
Return to error file
Appendix
Numeric Restrictions
List of Command Options
Assembler command general format
List of Assembler Command Options
Output file options
Preprocessor options
Error message options
Program generation options
Display the assembler’s version number on the console
Others
Linker command general format
List of Linker Command Options
Instruction RAM options
Library file options
Display help information on the console
Ld103 @ pfile
Display the linker’s version number on the console
Syntax Function & Notes
Directives for symbols
List of Assembler Directives
Directives for program control
Directives for list control
Directives for data area allocation
Pana Matsushita format
Clang Extended C language format default
Other directives
Intel Intel format
This section provides a list of assembler control statements
List of Assembler Control Statements
Syntax Function & Notes
Symbols
Macroname 207
Libraryfilename 103 Pathname 104 Label Field 148
Machine language code supplemental information
Macro 207
Undefined 142 173 Number Wall 313 289 Xlistoff 176 Xliston
Index
MN1030 Series Cross Assembler User’s Manual
Sales Offices