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