Download Print this page

Panasonic PanaXSeries MN1030 Series User Manual

Panasonic microcomputer user's manual
Hide thumbs

Advertisement

Quick Links

Table of Contents
MICROCOMPUTER
MN1030
MN1030 Series
Cross Assembler
User's Manual
Pub.No.13110-120E

Advertisement

Table of Contents
loading

  Related Manuals for Panasonic PanaXSeries MN1030 Series

  Summary of Contents for Panasonic PanaXSeries MN1030 Series

  • Page 1 MICROCOMPUTER MN1030 MN1030 Series Cross Assembler User’s Manual Pub.No.13110-120E...
  • Page 3 PanaXSeries is a trademark of Matsushita Electric Industrial Co., Ltd. Sun and Sun OS are registered trademarks of Sun Microsystems Inc. of the United States. MS-DOS is a registered trademark of Microsoft Corporation of the United States. VZ Editor is a registered trademark of Village Center, Inc. PC/AT is a registered trademark of the International Business Machines Corporation of the United States.
  • Page 4: Manual Features

    A b o u t T h i s M a n u a l This manual describes the functions and operation of the cross assembler for this series of microcomputers. • Manual Features • Chapters on installation, program development flow, and introductory operation are provided, so first-time users can quickly get an overview and easily master operation.
  • Page 5: How To Read

    • How to read 1.3.4 Environment Settings Before using the Cross-Assembler, verify or change the following two files. CONFIG.SYS If FILES and BUFFERS specifications 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. FILES=20 BUFFERS=20 NOTE:...
  • Page 6 MN1030/MN103S/MN103E Series C Compiler User's Manual: Library Reference <Describes the standard library of the C Compiler> • MN1030 Series C Source Code Debugger for Windows® User's Manual <Describes the use of the C source code debugger for Windows®> • MN1030/MN103S/MN103E Series Onboard Debug Unit Setup Manual <Describes the connection of the Debug Unit and explains about initial settings of the Onboard...
  • Page 7 Chapter 1 Getting Started 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 Writing Source Statements Chapter 9 Writing Machine Language Instruction Statements and Directive Statements Chapter 10 Writing Assembler Control Statements...
  • Page 8: Table Of Contents

    T a b l e o f C o n t e n t s Chapter 1 Getting Started 1.1 Purpose of This Chapter... 2 1.2 Operating Environment ... 3 1.3 File Organization... 4 1.4 Installation... 5 1.5 Setup... 6 1.6 File Conversion Utility...
  • Page 9 6.2 Starting Linker ... 85 6.3 Command Options ... 88 6.3.1 Output File Options ... 89 6.3.2 Error Message Options ... 91 6.3.3 Program Generation Options ... 97 6.3.4 Library File Options... 103 6.3.5 Other Options... 105 6.4 Instruction RAM Support ... 107 6.4.1 Structure of IRAM Support Executable File ...
  • Page 10 9.4.4 listoff, liston ... 159 9.4.5 notation... 160 9.4.6 org ... 162 9.4.7 opt... 163 9.4.8 page ... 164 9.4.9 radix... 165 9.4.10 dc ... 166 9.4.11 ds ... 167 9.4.12 dw ... 169 9.4.13 dd... 170 9.4.14 equ ... 171 9.4.15 global...
  • Page 11 12.3.1 Data Move Instructions... 232 12.3.2 Arithmetic Instructions ... 237 12.3.3 Logical Instructions ... 239 12.3.4 Bit Manipulation Instructions ... 241 12.3.5 Branching Instructions ... 243 12.3.6 User-Defined Instructions... 247 12.3.7 Other Instructions ... 248 Chapter 13 Error Messages 13.1 Purpose of This Chapter ... 250 13.2 Assembler Errors ...
  • Page 12 16.2.6 Error Correction Using Tag Jumps ... 306 Chapter 17 Appendix 17.1 Numeric Restrictions... 310 17.2 List of Command Options ... 311 17.2.1 List of Assembler Command Options... 312 17.2.2 List of Linker Command Options ... 315 17.3 List of Assembler Directives... 318 17.4 List of Assembler Control Statements ...
  • Page 13: Chapter 1 Getting Started

    Chapter 1 Getting Started...
  • Page 14: Purpose Of This Chapter

    Chapter 1 Getting Started Purpose of This Chapter This chapter describes the operating environment for this system and the usage of the file conversion tool. 2 Purpose of This Chapter...
  • Page 15: Operating Environment

    Operating Environment This system runs on the following workstations, personal computers and compatibles. Host machine Sun/Sparc PC/AT DOS/V For the PC/AT and compatibles, because of such differences as the ability to display Japanese, this Manual indicates a machine running the English-only operating system as a PC/AT and one running the Japanese operating system as a DOS/V machine.
  • Page 16: File Organization

    Chapter 1 Getting Started File Organization The installation media for this system contain the following files. as103 (assembler) as103 is the assembler. For a description, see Chapter 5 "Using Assembler." ld103 (linker) ld103 is the linker. For a description, see Chapter 6 "Using Linker." slib103 (library manager) slib103 is the library manager, a utility for creating library files.
  • Page 17: Installation

    Chapter 1 Getting Started Installation For the installation media, installation procedures, and notes on installation, see the Installation Manual. Installation 5...
  • Page 18: Setup

    Chapter 1 Getting Started Setup These procedures are for setting up this system when it has just been installed or for altering basic settings. Setting command path Unix uses the environment variable PATH when searching for executable files. Setting up this variable properly allows users to omit the directory name for commands and run them using their base names only.
  • Page 19 NOTE: Note that the command line is preceded when specifying the option which can be set in an environmental setting file with the command line at starting the assembler and the linker. Refer to the Chapter 5 “Using Assembler” for the assembler and to the Chapter 6 “Using Linker”...
  • Page 20 Outputs messages in Japanese using Shift JIS encoding Outputs messages in Japanese using JIS encoding ENGLISH SJIS ENGLISH Use Panasonic notation Enable optimization Disable optimization Description Outputs messages in Japanese using EUC encoding Outputs messages in Japanese using Shift JIS encoding...
  • Page 21 Keyword This entry controls the output of debugging of the symbol table to the executable file. Either ON or OFF of the parameters comes after the keyword En-OPTION followed by a blank space. These parameters have the following meanings. En-OPTION En-OPTION ON En-OPTION OFF Enable output of the symbol table to the executable file.
  • Page 22: File Conversion Utility

    Chapter 1 Getting Started File Conversion Utility This file conversion utility converts an EX format file produced by the linker into a file in Intel HEX format, or Motorola S format. General command format The general command format used to start the file conversion utility is shown below. excv103 [options] EX format file name Contents of brackets [ ]may be omitted.
  • Page 23 Default specification See the default settings for the following operations. Operation UNIX and PC/AT versions: English Message to output DOS/V version: Conversion method Not with a work file Output format Intel HEX format Padding No padding Output file name The same file name as EX format file but with “.hex” or “.rom” extensions. Conversion range From the start to the end address in EX format file.
  • Page 24 Chapter 1 Getting Started Example of specifying options 1. Specify the range of data conversion. (-R) excv103 -R1000, 1020 sample.ex Converts the data between the address 1000 and the address 1020 in the file of sample.ex. 2. Specify the start address upon format conversion. (-A) excv103 -A1000 sample.ex In the file of sample.ex, the information of start address specified when linking has been set.
  • Page 25 Chapter 2 Program Development Flow...
  • Page 26: Purpose Of This Chapter

    Chapter 2 Program Development Flow 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 flow of development through completion.
  • Page 27: Chapter 2 Program Development Flow

    Program Development Flow Main development flow 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. The software is developed using a source code debugger running the software on a target board which differs from the operating environment for the final application.
  • Page 28 Chapter 2 Program Development Flow Source code debugger The software developed on a workstation or personal computer must be checked using a hardware environment similar to that used by the final product. Nearly all of this series microcomputers will ultimately be incorporated within end products. Therefore, program debugging must also be performed under the same conditions as the end product.
  • Page 29: Programming With Assembler

    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 finished.
  • Page 30 Chapter 2 Program Development Flow Programming style It is important to use a consistent style for program coding from start to finish. 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 fixed style of the Cross Assembler.
  • Page 31: Conditional Assembly

    Conditional assembly If a program for product A is to be created by partially modifying a program for product B, both can be combined into a single program by using conditional assembler control instructions. Conditional assembly is done by defining a single symbol at the start of the program using a define control directive.
  • Page 32 Chapter 2 Program Development Flow 20 Programming with Assembler...
  • Page 33: Chapter 3 Introduction To Operation

    Chapter 3 Introduction to Operation...
  • Page 34: Purpose Of This Chapter

    Chapter 3 Introduction to Operation 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.
  • Page 35: Files Used By Assembler And Linker

    Chapter 3 Introduction to Operation Files Used by Assembler and Linker Figure 3-1 shows the inter-relationships of the files used by the assembler and linker. Map file Source file Include file SAMPLE.MAP SANPLE.ASM SAMPLE.H List file Assembler SAMPLE.LST Library file SAMPLE.LIB Relocatable object files SAMPLE.RF ...
  • Page 36 Chapter 3 Introduction to Operation Depending on the option specifications input for the source file and map file, a list file will be output with fully resolved addresses. The map file is used to output a list file with fully resolved addresses. The linker inputs relocatable object files output by the assembler and, depending on option specifications, library files.
  • Page 37: Basic Operation Of Assembler And Linker

    Basic Operation of Assembler and Linker The Cross-Assembler uses a section address format, in which the start address for each section as defined with the section directive corresponds to its start address when linked. This allows the programmer to freely change the order of linking files. The following explanation illustrates a simple example of only one section.
  • Page 38 Chapter 3 Introduction to Operation The contents of program2.asm are as follows. global __CODE section data_set data_set_loop data_set_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 files.
  • Page 39: Optimization

    Link Link the two relocatable object files to generate an executable format file. A map file will be generated along with the executable format file at this time. ld103 -m -T_CODE=40000000 program1.rf program2.rf m option T option The above command line links two relocatable object files (program1.rf and program2.rf) and creates an executable file (m103.ex) and a map file (m103.map) in the current directory.
  • Page 40 Chapter 3 Introduction to Operation The contents of the final list file program1.lst are as follows. *** PanaX Series MN1030 Cross Assembler *** Object 40000000 40000000 9000 40000002 2CFF00 40000005 2D8000 40000008 F8FEFCFCFF0C0000 40000010 00F8FE04 40000014 CAF2 40000024 00000000 Table...
  • Page 41 The contents of the final list file program2.lst are as follows. *** PanaX Series MN1030 Cross Assembler *** Object 40000016 40000016 8A00 40000018 40000018 40000019 C60A 4000001b 4000001c 2A01 4000001e 2002 40000020 CAF8 40000022 40000022 F0FC Symbol Table 40000016 40000018 40000022 Here is a simple explanation of how to read the list files.
  • Page 42: Assembling And Linking Multiple Sections

    Chapter 3 Introduction to Operation Assembling and Linking Multiple Sections In section 3.3, "Basic Operation of the Assembler and Linker", source files 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.
  • Page 43 The contents of program4.asm are as follows. global _CODE_01 section data_set data_set_ loop data_set_end _CODE_00 section time_filler Time_filler _loop time_filler _end As can be seen from the above two files, these programs are divided as follows. • main, time_filler ..._CODE_00 •...
  • Page 44 Let's take a look at the list files that were created. The contents of the list file program3.lst are as follows. Note that the symbol table is not displayed. *** PanaX series Series MN1030 Cross Assembler *** Object 00000000 00000000...
  • Page 45 The contents of the list file program4.lst are as follows. Note that the symbol table is not displayed. *** PanaX series Series MN1030 Cross Assembler *** Object Line 00000000 00000000 8A00 00000002 00000002 00000003 C600 00000005 00000006 2A01 00000008 2002...
  • Page 46 Chapter 3 Introduction to Operation Link Link the two relocatable object files to generate an executable format file. Specify the g option to add debug information to the executable format file. A>ld103 -m -g -T_CODE_00=800000000 -T_CODE_01=80005000 program3.rf program4.rf m option Option to output map file.
  • Page 47 Let's look at the final list files with all addresses resolved. The contents of the final list file program3.lst are as follows. Note that the symbol table is not displayed. *** PanaX series Series MN1030 Cross Assembler *** Object 8000000...
  • Page 48 Chapter 3 Introduction to Operation The contents of the final list file program4.lst are as follows. Note that the symbol table is not displayed. *** PanaX series Series MN1030 Cross Assembler *** Object 80005000 80005000 8A00 80005002 80005002 80005003 C60A...
  • Page 49 program locations after linking program locations in the executable file after linking as above are shown below. 0X0000 0X080000 0X080016 0X08001E 0X080200 0X08020E 0X080211 If the program contains multiple sections, it is laid out using the following rules. • Each section is assigned the starting address specified to the linker. •...
  • Page 50: Conditional Assembly And Linking

    Chapter 3 Introduction to Operation Conditional Assembly and Linking The 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.
  • Page 51 See the contents of the list file that was generated. The contents of the final list file program5.lst are as follows. Note that the symbol table is not displayed. *** PanaX series Series MN1030 Cross Assembler *** Object 40000000 40000000...
  • Page 52 -m -T_CODE=40000000 program5.rf as103 -l -a m103.map program5.asm The contents of the final list file program5.lst are as follows. Note that the symbol table is not displayed. *** PanaX series Series MN1030 Cross Assembler *** Object 40000000 40000000 FCDC0C000040 16+...
  • Page 53 Option to specify an identifier (DEBUG), having the same effect as specifying define DEBUG in the source file. The contents of the final list file program5.lst are as follows. Note that the symbol table is not displayed. *** PanaX series Series MN1030 Cross Assembler *** Object 40000000 40000000...
  • Page 54 Chapter 3 Introduction to Operation 42 Conditional Assembly and Linking...
  • Page 55: Chapter 4 Optimization

    Chapter 4 Optimization...
  • Page 56: Purpose Of This Chapter

    Chapter 4 Optimization Purpose of This Chapter The assembler and linker examine source statements containing conditional branches, unconditional branches, subroutine calls, data transfer instructions, arithmetic instructions, logical instructions, bit manipulation instructions, and user-defined instructions to determine the shortest possible machine language instruction corresponding to the instruction.
  • Page 57: Rules Of Usage

    Chapter 4 Optimization Rules of Usage To use the optimization function, optimization must be turned on by using the O option or by placing an opt directive at the start of the source file. NOTE: Optimization is off by default. Rules of Usage 45...
  • Page 58: Usage Example

    Chapter 4 Optimization Usage Example Optimization Instructions Optimization covers the following conditional branches, unconditional branches, subroutine calls, data transfer instructions, arithmetic instructions, logical instructions, bit manipulation instructions, and user-defined instructions. Table 4-1 Optimized Conditional Branch Instructions Instruction BLT label BGT label BGE label BLE label BCS label...
  • Page 59 Table 4-3 Data Transfer Instructions Subject To Optimization Instruction (abs), An (abs), Dn An, (abs) Dn, (abs) MOVBU (abs), Dn MOVBU Dn, (abs) Absolute addressing MOVB (abs), Dn MOVB Dn, (abs) MOVHU (abs), Dn MOVHU Dn, (abs) MOVH (abs), Dn MOVH Dn, (abs) (d, An), An...
  • Page 60 Chapter 4 Optimization Table 4-4 Arithmetic Instructions Subject To Optimization Instruction ADD imm, An ADD imm, Dn ADD imm, SP Immediate addressing AND imm, Dn CMP imm, An CMP imm, Dn Table 4-5 Logical Instructions Subject To Optimization Instruction OR imm, Dn Immediate addressing XOR imm, Dn Table 4-6 Logical Instructions Subject To Optimization...
  • Page 61 Table 4-7 Data Transfer Instructions Subject To Optimization Instruction UDF00 imm, Dn UDF01 imm, Dn UDF02 imm, Dn UDF03 imm, Dn UDF04 imm, Dn UDF05 imm, Dn UDF06 imm, Dn UDF07 imm, Dn UDF08 imm, Dn UDF09 imm, Dn UDF10 imm, Dn UDF11 imm, Dn UDF12 imm, Dn UDF13 imm, Dn...
  • Page 62 Chapter 4 Optimization Optimization processing of conditional branch instructions The linker resolves address values for labels when linking multiple files. 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.
  • Page 63 Optimization of function calls This section describes the optimization of function calls by the linker. The assembler provides advanced processing for function calls. This processing uses a combination of the call and ret instructions and the global and funcinfo directives. The following is an example. global _TEXT section...
  • Page 64 Chapter 4 Optimization Table 4-8 Substituted Instructions For Out-Of Range Conditional Branch Instructions Source Instruction Candidate instruction 1 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...
  • Page 65 Optimization of data transfer, arithmetic, logical, bit manipulation and user-defined instructions For data transfer, arithmetic, logical, bit manipulation, and user-defined instructions, the assembler uses the shortest instruction available for expressing the specified immediate data, memory address, or dis- placement data. The user thus obtains optimal code size without having to worry about instruction vari- ants.
  • Page 66 Chapter 4 Optimization Table 4-10 optimization of data transfer, arithmetic, logical bit manipulation... Source instruction MOVH (d,SP),Dn MOVH (d8,SP),Dn MOVH Dn,(abs) MOVH Dn,(abs16) MOVH Dn,(d,An) MOVH Dn,(d8,An) MOVH Dn,(d,SP) MOVH Dn,(d8,SP) ADD imm,An ADD imm8,An ADD imm,Dn ADD imm8,Dn ADD imm,SP ADD imm8,SP AND imm,Dn AND imm8,Dn...
  • Page 67 40000000 (hex.). The @ mark on line number 6 indicates that the instruction was the object of optimi- zation. Since the target address is within the range of a relative jump, the assembler generates a BCC LABEL instruction. PanaX series Series MN1030 Cross Assembler Object 40000000...
  • Page 68 The final list file after assembly is shown next. LABEL exceeds the permitted branch range of BCC LA- BEL, so the code has been converted to BCS *+5, JMP LABEL. Note that the mnemonics and object code are different. PanaX series Series MN1030 Cross Assembler Object 40000000...
  • Page 69 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 LA- BEL. Note that the mnemonics and object code are different. PanaX series Series MN1030 Cross Assembler Object 40000000...
  • Page 70 2-byte relative branch, the assembler replaces it with the CALLS LABEL variant with a 2-byte address field. Note that the mnemonics and object code are different. PanaX series Series MN1030 Cross Assembler Object 40000000...
  • Page 71: Chapter 5 Using Assembler

    Chapter 5 Using Assembler...
  • Page 72: Purpose Of This Chapter

    Chapter 5 Using Asssembler Purpose of This Chapter This Chapter describes assembler operating procedures. Chapter 3 "Introduction to Operation" described the basic operation of the assembler and linker, but this one describes the many options available with the assembler and gives examples. 60 Purpose of This Chapter...
  • Page 73: Starting Assembler

    Starting Assembler The assembler is started by entering the command name and the desired parameters. The command name differs depending on the device being used. This chapter uses the terminology of as103 as its general format. General format of commands Below is the general format of the command to use when starting the assembler.
  • Page 74 Chapter 5 Using Asssembler Summary of options The following Table lists the available command line options. Option Type Symbol o file_name Output file a map_file name Error message options W number Wall I path_name Preprocessor options D identifier Program generation options Others 62 Starting Assembler...
  • Page 75: Command Options

    Chapter 5 Using Assembler Command Options This section describes the options available for the assembler. The assembler has an abundance of options for controlling assembler processing and output files. Not all options are available at the same time. Certain options have default values that are used when the option is not specified.
  • Page 76: Output File Options

    Chapter 5 Using Asssembler 5.3.1 Output File Options o file_name Specify the relocatable object file name to be output Functional description This option specifies the relocatable object file name to be output by the assembler. If the specified file already exists, its previous contents will be erased. If a path name that does not exist is specified, the assembler will display an error message and suspend processing.
  • Page 77: Functional Description

    Output a list file Functional Description This option outputs a list file. The file name of the list file will be the source file name with the extension .lst. The list file will be generated in the same directory as the source file. If any assembler errors are detected, error information will also be written to the list file.
  • Page 78 Chapter 5 Using Asssembler Do not output files included by include to the list file Functional Description This option suppresses output of source file contents included by assembler directive (include) to the list file. However, the machine language code will be written to the relocatable object file. This option is convenient when you need a listing only for a particular source file while debugging.
  • Page 79 Do not output files included by include to the list file Functional Description This option suppresses output of assembler source created by macro expansion using macro directives macro and irp to the list file. Only display of machine language instruction mnemonics will be suppressed;...
  • Page 80 Chapter 5 Using Asssembler Do not output source statements that were not assembled due to unfulfilled conditions of conditional assembly to the list file Functional Description This option suppresses output of blocks of unsatisfied conditions with conditional assembly to the list file.
  • Page 81 Do not output a symbol table to the list file Functional Description This directive suppresses output of a symbol table when the list file is output. Rules of Use This option is specified with the hyphen (-) option specification character, followed by the upper-case letter 'L' and lower-case letter 's'.
  • Page 82: Error Message Options

    Chapter 5 Using Asssembler 5.3.2 Error Message Options Output error and warning messages in Japanese Functional Description This option causes all error and warning messages and help screens sent to the console or the listing file to appear in Japanese. The character coding depends on the host machine and the operating system.
  • Page 83 Output error and warning messages in Japanese using EUC encoding Functional Description This option causes all error and warning messages and help screens sent to the console or the listing file to appear in Japanese using EUC coding. Rules of Use To specify the option, enter the hyphen (-) followed by the upper case letter 'J' and the lower case letter 'e'.
  • Page 84 Chapter 5 Using Asssembler Output error and warning messages in Japanese using Shift JIS encoding Functional Description This option causes all error and warning messages and help screens sent to the console or the listing file to appear in Japanese using Shift JIS coding. Rules of Use To specify the option, enter the hyphen (-) followed by the upper case letter 'J' and the lower case letter 's'.
  • Page 85 Output error and warning messages in Japanese using JIS encoding Functional Description This option causes all error and warning messages and help screens sent to the console or the listing file to appear in Japanese using JIS coding. Rules of Use To specify the option, enter the hyphen (-) followed by the upper case letter 'J' and the lower case letter 'j'.
  • Page 86 Chapter 5 Using Asssembler Output error and warning messages in English Functional Description This option causes all error and warning messages and help screens sent to the console or the listing file to appear in English. Rules of Use To specify the option, enter the hyphen (-) followed by the lower case letter 'e'. as103 -e sample.asm Default Specification The default language used depends on the host machine and the operating system.
  • Page 87 W number Do not output warning messages of the specified number Functional Description This option suppresses output of warning messages generated during assembler operation. For a list of warning messages and their numbers, see Chapter 13 "Error Messages." The assembler ignores specifications for warning numbers that do not have messages assigned to them. Rules of Use To specify the option, enter the hyphen (-) followed by the upper case letter 'W' and the number.
  • Page 88: Preprocessor Options

    Chapter 5 Using Asssembler 5.3.3 Preprocessor Options I path_name Specify the trace directory of the include file. Functional Description Trace from the directory that specifies the include file in the assembler source file. If the absolute path starting with “/” is written, tis option is invalid. Assembler traces the include file from the directory as follows.
  • Page 89 D identifier Specify 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 identifier has been defined by a define directive. The D option has the same function as the define directive, but with direct specification from the command line.
  • Page 90: Program Generation Options

    Chapter 5 Using Asssembler 5.3.4 Program Generation Options Output debug information to the relocatable object file Functional Description This option causes the assembler to include in the relocatable object file information for use in debugging at the source code level. This information includes the following: •...
  • Page 91 Turn on optimization Functional Description This option enables optimization of instructions by the assembler and linker. For the instructions subject to optimization, see Chapter 4 "Optimization Functions." Rules of Use To specify the option, enter the hyphen (-) followed by the upper case letter 'O'. as103 -O sample.asm Default Specification The default is to suppress optimization.
  • Page 92: Other Options

    Chapter 5 Using Asssembler 5.3.5 Other Options Display listing of available assembler option on the console Functional Description This option displays assembler command options and their descriptions to the screen. The -j, -Je, -Js, -Jj, and -e options, if they appear, control the language and the coding scheme used to display this information.
  • Page 93: Operation Examples

    Operation Examples There are three steps to perform when you need a final list file with resolved addresses. 1. With the assembler, generate a relocatable object file (.rf). 2. With the linker, generate an executable format file (.ex) and map file (.map). 3.
  • Page 94 Chapter 5 Using Asssembler Generation of final list file with resolved program addresses The final list file is generated as follows. 1. First use the assembler to generate a relocatable object file. Valid options at this stage are o, I, D, g, and the optimization options (O, Od).
  • Page 95: Chapter 6 Using Linker

    Chapter 6 Using Linker...
  • Page 96: Purpose Of This Chapter

    Chapter 6 Using Linker Purpose of This Chapter This chapter explains how to use all the options provided by the linker. The linker reads relocatable object files output by the assembler, outputs an executable format file, and if specified by option outputs a map file containing link information.
  • Page 97: Starting Linker

    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 files to be linked. The command name differs depending on the device being used. This chapter uses the terminology of ld103 as is general format.
  • Page 98 Chapter 6 Using Linker Parameters can be specified right after the option character or separated by one space. -T@CODE=80000000 or -T @CODE=80000000 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 specifying multiple files, separate them with spaces.
  • Page 99 Summary of Options Option Type Output file options o filename Error message options j W number Wall Program generation options T section=address Library file options l library_filename L path_name Instruction RAM OVL ID_number options section=address PUT extra_symbol=address Other @filename Table 6-1 Linker options Symbol Specify the path name and file name of the executable format file to be output.
  • Page 100: Command Options

    Chapter 6 Using Linker Command Options This section describes the options used by the linker. The linker has many options for controlling output file specifications and the information written to files. The linker reads multiple relocatable object files, links them into one, and creates an executable format file. If optimization was selected at the assembly stage, the linker will output the optimal machine language code for conditional and unconditional branch instructions, regardless of the mnemonics defined in the source file.
  • Page 101: Output File Options

    6.3.1 Output File Options Specify the path name and file name of the executable format file to be o filename output Functional description This option specifies the directory and file name of the executable format file to be output by the linker. If the directory is omitted, the file will be output to the current directory.
  • Page 102 Chapter 6 Using Linker Output a map file Functional description The map file lists the addresses and sizes of all sections linked by the linker plus identifying information and values for local and global symbols. For all programs, the addresses assigned to sections and symbols are not determined until linking. To create a final list file, reassemble the source file using the map file.
  • Page 103: Error Message Options

    6.3.2 Error Message Options Output error and warning messages in Japanese Functional description This option causes all error and warning messages and help screens sent to the console or the listing file to appear in Japanese. The character coding depends on the host machine and the operating system. Host machine Character coding Sun/Parc...
  • Page 104 Chapter 6 Using Linker Output error and warning messages in Japanese using EUC coding Functional description This option causes all error and warning messages and help screens sent to the console or the listing file to appear in Japanese using EUC coding. Rules of use This option is specified with the hyphen (-) option specification character, followed by the upper-case letter “J”...
  • Page 105 Output error and warning messages in Japanese using Shift JIS coding Functional description This option causes all error and warning messages and help screens sent to the console or the listing file to appear in Japanese using Shift JIS coding. Rules of use This option is specified with the hyphen (-) option specification character, followed by the upper-case letter “J”...
  • Page 106 Chapter 6 Using Linker Output error and warning messages in Japanese using JIS coding Functional description This option causes all error and warning messages and help screens sent to the console or the listing file to appear in Japanese using JIS coding. Rules of use This option is specified with the hyphen (-) option specification character, followed by the upper-case letter “J”...
  • Page 107 Output error and warning messages in English. Functional description This option displays messages for errors and warnings detected in link commands and link processing to the screen and list file in English. Rules of use This option is specified with the slash (/) or hyphen (-) option specification character, followed by the lower-case letter 'e'.
  • Page 108: Function Description

    Chapter 6 Using Linker W number Do not output warning messages of the specified number Functional description This option suppresses output of specified warnings detected during linking. Unlike errors, warnings are not fatal, so the W option is used when you understand their meanings sufficiently and need to suppress their output.
  • Page 109: Program Generation Options

    6.3.3 Program Generation Options Output debug information to the executable format file Functional description This option causes the linker to include in the executable file information for use in debugging at the source code level. This information includes the following; •...
  • Page 110 Chapter 6 Using Linker T section Specify starting address for a section =addresses Functional description This option specifies the starting address for the specified section. It changes the starting address for all sections in all relocatable object files specified to the right of this option. The linker checks these specifications for overlap between sections.
  • Page 111 Section layout with -T option specification 0x00000000 _TEXT@CODE ( b.rf ) _CONST@CODE ( b.rf ) 0x20000000 _TEXT@CODE _GCONST@CODE 0xffffffff ld103 a.rf -T_TEST, _CONST-0 b.rf -T_TEST, _GCONST=20000000 c.rf Default specification When there are no address specifications whatsoever, the first section in the first file is assigned to address 0.
  • Page 112 Chapter 6 Using Linker The linker merges the CODE sections from the input files, starting at address 80000000 (hex). It merges the DATA sections from the file sub.rf, starting at address 0. The DATA section from main.rf do not have an address specification, so are merged following the DATA section from sub.rf. NOTE: For specifying a parameter of _T option, a parameter file can not be used because the character @ would not be considered as an attribute specifying...
  • Page 113 Output an executable format file even if errors are detected Functional description The linker normally suppresses the creation of an executable file if it detects errors during linking. This option forces file creation even if there are errors. NOTE: An executable created with known linker errors will not execute properly. The r option is only a temporary measure.
  • Page 114 Chapter 6 Using Linker Do not output symbol table within the executable format file Functional description This option suppresses output of a symbol table in the executable format file. Only executable code will be output to the executable format file. Rules of use This option is specified with the hyphen (-) option specification character, followed by the upper-case letter 'E' and lower-case letter 'n'.
  • Page 115: Library File Options

    6.3.4 Library File Options l library_filename Specify a library file Functional description This option specifies a library file. Rules of use This option is specified with the hyphen (-) option specification character, followed by the lower-case letter 'l', then either immediately followed by the path name and file name or a space and the path name and file name.
  • Page 116 Chapter 6 Using Linker L path_name Specify a directory containing library files Functional description This option specifies a directory that contains library files. Library files following the L option specification will be searched for in the specified directory. First, the current directory is searched. And then, the specified directory is searched. When the L option is used multiple times, the search will be performed in the order of definition.
  • Page 117: Other Options

    6.3.5 Other Options @filename Specify a parameter file Functional description By writing various option used by the linker in a file, the @ option lets you specify just that file during execution, and the linker will replace it with the option specifications. All options other than the @ option can be written in a parameter file.
  • Page 118 Chapter 6 Using Linker Output help information to the screen Functional description This option displays linker command options and their descriptions to the screen. The h option is used alone. Rules of use This option is specified with the hyphen (-) option specification character, followed by the lower-case letter 'h'.
  • Page 119: Instruction Ram Support

    Chapter 6 Using Linker Instruction RAM Support This series includes members with instruction RAM for use in copying program portions to RAM for execution there. The linker therefore supports special options for creating executable files with support for instruction RAM. This section gives the particulars of the instruction RAM format for executable files and the procedures for creating them.
  • Page 120: Structure Of Iram Support Executable File

    Chapter 6 Using Linker 6.4.1 Structure of IRAM Support Executable File Structural Elements of an IRAM Support Executable (A) Fixed program portion This portion resides in external memory and runs using addresses as is in the normal fashion. Normal executable files contain only this portion. (B) Instruction RAM program This portion resides in external memory, but only works properly when transferred to the instruction RAM.
  • Page 121 Executable file created by linker RF file specified by T option RF file specified by OVL option RF file specified by OVL option Automatically- generated table information C.Instruction RAM program management table portion Figure: 6-3 Layout Image for Instruction RAM and External Memory NOTE: When the instruction RAM function is in use, the linker reserves the extra symbol names __overlay_table and __iram_manage for its own use, so do not use...
  • Page 122 Chapter 6 Using Linker File layout and transfer operations for an instruction RAM executable file 1. Use the linker's T and OVL layout options to divide the program into a fixed portion (A) and an instruction RAM portion (B). The linker assigns the latter to a location in external memory immediately following the former.
  • Page 123: Iram Support Options

    6.4.2 IRAM Support Options Using the following options creates an executable file supporting instruction RAM operation. OVL ID_number: Specify address in instruction RAM for a section section=address Functional description This option assigns an address in instruction RAM for the specified section. The linker resolves all addresses to assume that the relocatable object file following the option is running in instruction RAM.
  • Page 124 Chapter 6 Using Linker The starting address in instruction RAM is given in hexadecimal. ld103 -T @CODE=80000000 main.rf sub.rf -OVL 1:@CODE=40000000 seg1.rf -OVL 2:@CODE=40000000 seg2.rf ld103 -T @CODE=80000000 main.rf sub.rf -OVL 1:_TEXT,_CONST=40000000 seg1.rf -OVL 2:_TEXT,_CONST=40000000 seg2.rf ld103 -T @CODE=80000000 main.rf sub.rf -OVL 1:_TEXT@CODE=40000000 seg1.rf -OVL 2:_TEXT@CODE=40000000 seg2.rf Default specification...
  • Page 125 Specify address for extra symbol symbol=address Functional description This option is used to specify addresses for the extra symbols used by the instruction RAM function. NOTE: A PUT option is only valid when there are one or more -OVL options. Rules of use This option is specified with the hyphen (-) option specification character, followed by the upper case letters 'PUT', the name of an extra symbol, an equals sign, and the address for that symbol.
  • Page 126: Operation Examples

    Chapter 6 Using Linker 6.4.3 Operation Examples The following are examples of section layouts using the OVL option for the five relocatable object files, main.rf, sub.rf, prog1.rf, prog2.rf, and prog3.rf, in the current directory. All files contain multiple CODE and DATA sections. Assigning to different addresses in instruction RAM ld103 -T @CODE=80000000 -T @DATA=1000 main.rf sub.rf -OVL 1:_TEXT=40001000 prog1.rf -OVL 2:_TEXT=40002000 prog2.rf...
  • Page 127 NOTE: If multiple sections share the same or overlapping regions in instruction RAM, their code must be mutually exclusive. In other words, in the above example, the files prog1.rf, prog2.rf, and prog3.rf must not contain references to each other's symbols because that would require that they both be in instruction RAM at the same time—a physical impossibility.
  • Page 128 Chapter 6 Using Linker 116 Instruction RAM Support...
  • Page 129: Chapter 7 Types Of Source Statements

    Chapter 7 Types of Source Statements...
  • Page 130: Purpose Of This Chapter

    Chapter 7 Type of Source Statements Purpose of This Chapter Programs used by the Cross Assembler are collections of source statements. There are five types of source statements, classified by their purpose. • Machine language instruction statements and directive statements •...
  • Page 131: Program Format

    Program Format A program is text created to assemble as machine language instructions in order to operate a micropro- cessor. The assembler translates the text into machine language code, while the linker joins that code to make an executable format file. One line of text is called a source statement.
  • Page 132 Chapter 7 Type of Source Statements Below is an example source file. SAMPLE PROGRAM #include "FILE1.H #define KEYBORD data_set macro movw endm _CODE section main #ifdef TYPE data_set #else #endif 120 Program Format ; comment ;include a file ;define identifier for conditional assembly ;define a constant 0x32 ;define a macro...
  • Page 133: Machine Language Instruction Statements And Directive Statements

    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).
  • Page 134: Assembler Control Statements

    Chapter 7 Type of Source Statements Assembler Control Statements Assembler control statements are source statements that control how the assembler processes. The assembler provides include directives that include files and conditional assembly directives that specify conditions for changing which instructions are assembled. The example below shows assembler control statements.
  • Page 135: Macro Control Statements

    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 definitions and macro calls. A macro definition defines a macro name and macro body.
  • Page 136: Comment Statements

    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. ************************************************ MN1030 Series Cross-Assembler Sample Program ************************************************ #include #include...
  • Page 137: Blank Statements

    Chapter 7 Type of Source Statements Blank Statements A blank statement consists of a single carriage return. Blank statements are used to make printed lists easier to read. Blank Statements 125...
  • Page 138 Chapter 7 Type of Source Statements 126 Blank Statements...
  • Page 139: Chapter 8 Writing Source Statements

    Chapter 8 Writing Source Statements...
  • Page 140: Purpose Of This Chapter

    Chapter 8 Writing Source Statements 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.
  • Page 141: Permitted Characters

    Permitted Characters There are three types of characters that can be coded in source statements for the cross assembler of this series. Digits 0 1 2 3 4 5 6 7 8 9 Letters Upper-case A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Lower-case a b c d e f g h i j k l m n o p q r s t u v w x y z Control characters...
  • Page 142: Numbers

    Chapter 8 Writing Source Statements 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.
  • Page 143: Extended C Language Format

    Extended C language format Binary Radix Binary Octal Decimal Hexadecimal 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.
  • Page 144: Matsushita Format

    Chapter 8 Writing Source Statements Matsushita format Binary Radix B’101’ Binary O’567’ Octal F’789’ Decimal X7’def’ Hexadecimal Coding rules: 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 ( ' ).
  • Page 145: Character Constants

    Character Constants ASCII characters ,which can be displayed, 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 cases) • Blank letters • Special characters NOTE: “\”...
  • Page 146: String Constants

    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 specified by enclosing the string in double quotation marks ( " ). "ABCDEFG"...
  • Page 147: Address Constants

    Address Constants Address constants return particular bits from expressions that can be evaluated as addresses. They are written as follows. address_specifier (expression) An address constant is written as an expression enclosed in parentheses following an address specifier. An expression consists of names, self-reference address symbols, and constants linked by operators, with the result representing a single value (refer to section 8.7, "Expressions", for details).
  • Page 148: Location Counter

    Chapter 8 Writing Source Statements 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 first set during linking for each section defined by the section directive, so location counter values during assembly will not necessarily match the addresses assigned to instructions during execution.
  • Page 149: Expressions

    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 undefined symbol, the result of the expression cannot be resolved by the assembler.
  • Page 150: Operators

    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 Formats: operand1 operand1 operand1 operand1 operand1 + operand ~operand Shift operators The shift operators shift to the left or right in bit units.
  • Page 151: Logical Operators

    Logical operators Logical operators perform calculation in bit units. Operator Formats: operand1 & operand1 operand1 ~operand Meaning & Logical AND Exclusive OR Logical OR Unary negation (1’s complement) Example: operand2 ADDRESS & MASK operand2 CONST ^ 0b0011110000 operand2 VECT | 0b0011110000 -MAIN Chapter 8 Writing Source Statements Expressions 139...
  • Page 152: Expression Evaluation

    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. Precedence Operator Highest ~ + -...
  • Page 153: Expression Syntax

    8.7.3 Expression Syntax Below is an expression syntax diagram expression NOTE: When the expressions starting with parenthesis are coded to the operands of Machine language instructions, it will be regarded as an address-reference. To be proceeded as expressions, put 0+ before the parenthesis and distinguish them from others.
  • Page 154: Expression Attributes

    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. •...
  • Page 155 For + (addition) operator + (addition) Operand 1 For - (subtraction) operator -(SUBTRACTION) Operand 1 For *, /, %, <<, >>, &, ^ , | operators *, /, %, <<, >>, &, ^, | Operand 1 NOTE: The expressions writing in directive coding instructions and assembler control instruction must result in absolute attributes(ABS).
  • Page 156: Reserved Words

    Chapter 8 Writing Source Statements 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.
  • Page 157: Chapter 9 Writing Machine Language Instruction Statements And Directive Statements

    Chapter 9 Writing Machine Language Instruction Statements and Directive Statements...
  • Page 158: Purpose Of This Chapter

    Chapter 9 Writing Machine Language Instructions and Directive Statements 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. •...
  • Page 159: Instruction Statement Fields

    Instruction Statement Fields Source statements that code machine language instructions and directives are built from four fields. [label] [operation [operand [, operand]]] [comment] Contents of brackets [ ] can be omitted. Coding rules Source statements may contain a label field only. Depending on the operation, source statements may contain no operand.
  • Page 160: Writing Label Field

    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 defined. Coding rules Labels can use upper-case and lower-case letters, digits, underscores (_). Labels are coded in the first column.
  • Page 161: Writing Operation Field

    9.2.2 Writing Operation Field The operation field is written with a machine language instruction or directive. Coding rules Machine language instructions cannot mix case. They must use either upper or lower case throughout. Coding examples CONST1 _CODE section start Chapter 9 Writing Machine Language Instructions and Directive Statements CODE, PUBLIC, 2 CONST1, D0 Instruction Statement Fields 149...
  • Page 162: Writing Operand Field

    Chapter 9 Writing Machine Language Instructions and Directive Statements 9.2.3 Writing Operand Field The operand field coding is determined by the machine language instruction or directive in the operation field. 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.).
  • Page 163: Writing Comment Field

    9.2.4 Writing Comment Field The field that starts from a semicolon (;) after the operands is called the comment field. 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).
  • Page 164: Writing Machine Language Instruction Statements

    Chapter 9 Writing Machine Language Instructions and Directive Statements Writing Machine Language Instruction Statements Each machine language instruction is defined by specific mnemonics. Mnemonics are formed from operations and operands accurately coded in the statement fields previously described. Both upper-case and lower-case letters may be used. Refer to the "Instruction Manual"...
  • Page 165: Writing Directive Statements

    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 Specifies a section...
  • Page 166: Section

    Chapter 9 Writing Machine Language Instructions and Directive Statements 9.4.1 section Syntax label operation section_name section definition1 definition2 (Note that the words PRIVATE and COMMON are reserved for use in expansion. However, they are treated as PUBLIC for now.) expression Default settings If the section name appears for the first time in the file, the following defaults are used.
  • Page 167 Operand coding rules Only specific strings can be defined for definition1 and definition2. If some other string is defined, 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, the assembler will assume the closest valid value instead.
  • Page 168: Align

    Chapter 9 Writing Machine Language Instructions and Directive Statements 9.4.2 align Syntax label operation align 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 2 When the expression value is 4, the multiples of 4 will be the following series.
  • Page 169 Usage example Below is an example use of the align directive. PanaX Series MN1030 Cross Assembler Object 00000000 00000000 00000001 00000002 align.asm(6) :Warning 2002: Illegal operand value. 00000008 00000009 0000000a 00000010 00000011 00000020 00000021 Errors: 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.
  • Page 170: End

    Chapter 9 Writing Machine Language Instructions and Directive Statements 9.4.3 Syntax label [name] Default settings If the end directive is omitted, the assembler file will assume that the end of the file is the end of the program. Functional description This directive is coded once at the end of a program.
  • Page 171: Listoff, Liston

    9.4.4 listoff, liston Syntax label operation [name] listoff [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 file. These directives are used when you do not want to output an already debugged program to the list file.
  • Page 172: Notation

    Chapter 9 Writing Machine Language Instructions and Directive Statements 9.4.5 notation Syntax label operation notation Default settings CLANG will be selected. Functional description This directive selects the format of numbers and character constants (single character). The Cross-Assembler provides three numeric formats. •...
  • Page 173 Usage example Below is an example use of the notation directive. PanaX Series MN1030 Cross Assembler Object 00000000 00000001 00000002 00000003 00000004 00000005 00000006 00000007 00000008 00000009 0000000a 0000000b 0000000c Chapter 9 Writing Machine Language Instructions and Directive Statements notation.lst page 1...
  • Page 174: Org

    Chapter 9 Writing Machine Language Instructions and Directive Statements 9.4.6 Syntax label operation Default settings The current location counter value will be inherited. Functional description This directive sets the location counter to the address value specified by expression. Operand coding rules For the expression coded in the operand, the attribute of the calculation result must be abs(absolute).
  • Page 175: Opt

    9.4.7 Syntax label operation Default settings If omitted, opt off will be assumed. Functional description This directive enables and disables the optimization functions of the assembler and linker. The optimization applies only to conditional and unconditional branch instructions. The optimization function evaluates how the source statements are coded, and converts them to the optimal code with the linker.
  • Page 176 Chapter 9 Writing Machine Language Instructions and Directive Statements 9.4.8 page Syntax label operation page Default settings Number of lines = 60 Number of columns = 132 Functional description This directive specifies the number of lines and columns per page. At the line where the page directive itself is specified the assembler will output a carriage return and apply the newly set values.
  • Page 177: Radix

    9.4.9 radix Syntax label operation radix Default settings Radix 10 (decimal). Functional description This directive specifies the radix that will be used by default. The Cross-Assembler provides three coding formats for numbers. • Extended C language format • Intel format •...
  • Page 178 When the specified data has fewer than 8 bits, those bits will fill the lower bits, and the upper bits will be padded with zeroes. Usage example Below is an example use of the dc directive. PanaX Series MN1030 Cross Assembler Object 00000000 00000001...
  • Page 179 9.4.11 ds Syntax label operation [name] expression1 expression2 expression3 Default settings expression2 (initial value) If omitted, the assembler will assume 0. expression3 (iterations) If omitted, the assembler will assume 1. Functional description This directive reserves a memory area of the number of bytes specified by expression1 of the operand. When expression2 (initial value) is specified, that memory area will be filled with the initial value.
  • Page 180 Chapter 9 Writing Machine Language Instructions and Directive Statements Usage example Below is an example use of the ds directive. PanaX Series MN1030 Cross Assembler Object 00000000 00 00000001 1122 00000003 3344556633445566 4 168 Writing Directive Statements DC.LST Line Source...
  • Page 181 When the specified data has fewer than 16 bits, those bits will fill the lower bits, and the upper bits will be padded with zeroes. Usage example Below is an example use of the dw directive. PanaX Series MN1030 Cross Assembler Object 00000000 3930...
  • Page 182 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. PanaX Series MN1030 Cross Assembler Object 00000000 78563412...
  • Page 183: Equ

    9.4.14 equ Syntax label operation name Functional description This directive defines 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 or directive instructions, the assembler will reference the name's value.
  • Page 184 Chapter 9 Writing Machine Language Instructions and Directive Statements Usage example Below is an example use of the equ directive. PanaX Series MN1030 Cross Assembler Object 00000000 8020 00000002 800A 00000004 8008 00000006 2C0010 172 Writing Directive Statements equ.lst Page 1...
  • Page 185: Global

    9.4.15 global Syntax label operation [name] global Default settings External reference when omitted = undefined label error External declaration when omitted = undefined label error during linking Functional description This directive declares external references and external declarations. For external references, the global directive declares that the names coded in the operand are from other files.
  • Page 186 Chapter 9 Writing Machine Language Instructions and Directive Statements Usage example Below is an example use of the global directive. global global main SUB1 NOTE: If a section name was referred as an external label, declaration with the section directive, not with the global directive, is necessary. Example: _TEXT 174 Writing Directive Statements...
  • Page 187: Tit

    9.4.16 tit Syntax label operation Functional description This directive specifies that the string coded as its operand is to be output as the header of the list file. 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 (").
  • Page 188: Xlistoff, Xliston

    Chapter 9 Writing Machine Language Instructions and Directive Statements 9.4.17 xlistoff, xliston Syntax label operation [name] xlistoff 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 file. These directives are used when you do not want to output an already debugged program to the list file.
  • Page 189: Funcinfo

    9.4.18 funcinfo Syntax label operation function_namefuncinfo where expression: Stack frame size Functional description This directive provides additional information about a function name specified as the operand to a call instruction. The call instruction branches to the function after saving registers to the stack and setting up the stack frame.
  • Page 190 Chapter 9 Writing Machine Language Instructions and Directive Statements Usage Example The following gives an example of funcinfo usage. global _TEXT section call global _TEXT section _func movm _0func funcinfo NOTE: The ret and retf instructions free the stack frame and restore registers from the stack.
  • Page 191: Assign

    Names defined with the assign directive cannot be declared external references or external declarations. No memory ares is reserved when an assign directive statement is executed. Usage examples The example below is a use of the assign directive. PanaX Series MN1030 Cross Assembler Object 00000000 8001...
  • Page 192 Chapter 9 Writing Machine Language Instructions and Directive Statements 180 Writing Directive Statements...
  • Page 193: Chapter 10 Writing Assembler Control Statements

    Chapter 10 Writing Assembler Control Statements...
  • Page 194: Purpose Of This Chapter

    Chapter 10 Writing Assembler Control Statements 10.1 Purpose of This Chapter Assembler control statements are statements that control assembler processing. They specify include files and refinement of the identifier and control conditional assembly. Include files are used to place definitions of constants, memory areas, I/O ports, and bit assignments common to the entire program in separate files.
  • Page 195: File Inclusion

    Chapter 10 Writing Assembler Control Statements 10.2 File Inclusion The file inclusion is an assembler control instruction that reads the specific file to the source file. It is used for the following purpose. • Using same macro or same declarations variables in several source files File Inclusion 183...
  • Page 196: Include

    Chapter 10 Writing Assembler Control Statements 10.2.1 #include Syntax #include ”filename” Functional description This directive causes the assembler to read in the source file with the specified name at the location of the directive. NOTE: The included file will be assembled and output to the relocatable object file and list file.
  • Page 197 Usage example The following example illustrates the use of an include file. The file inc.h consists of the following statement. data The file to be assembled consists of the following statements. #include “inc.h” _TEXT section main The above file is assembled with the file inc.h included. For this reason, at points after the #include statement, the operand data is interpreted as the numerical value 0x12.
  • Page 198: Identifier Definement

    Chapter 10 Writing Assembler Control Statements 10.3 Identifier Definement Identifier definement names a variable or a set of steps, and replace the name (the identifier) in the source code to the string that has been defined. It is used for the following purposes. •...
  • Page 199: Define

    10.3.1 #define Syntax #define [replacement_string] [; comment] Functional description This directive causes the assembler to replace the identifier with the replacement_string on all further lines. The #define directive differs from the #equ directive in that a string can be specified. Furthermore, when used in conjunction with the #undef directive, redefinition is possible.
  • Page 200: Undef

    Chapter 10 Writing Assembler Control Statements 10.3.2 #undef Syntax identifier #undef Functional description This directive deletes an identifier defined by a #define directive. The effective range of an identifier is from the line following #define until the line before #undef. To redefine the replacement string of an identifier, redefine it with #define after performing an #undef.
  • Page 201: Conditional Assembly

    10.4 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 specified conditions at the time of assembly. Many conditional assembly directives are used only within macro definitions.
  • Page 202 Chapter 10 Writing Assembler Control Statements The table below lists the conditional assembly directives. Directive Condition for selecting block1 #ifdef Identifier has been defined by #define. #ifndef Identifier has not been defined by #define. Identifier has been defined. Expression value is not 0. #ifn Expression value is 0.
  • Page 203: Ifdef, #Ifndef

    10.4.1 #ifdef, #ifndef Syntax Syntax for #ifdef #ifdef identifier block1 [#else block2] #endif Functional description #ifdef If the identifier has been defined by a #define directive before the #ifdef statement, block1 will be assembled. If it has not been defined and an #else directive has been coded, block2 will be assembled. #ifndef If the identifier has not been defined by a #define directive before the #ifndef statement, block1 will be assembled.
  • Page 204 #else #endif #ifndef VERSION #else #endif The assembled list file is shown below. PanaX Series MN1030 Cross Assembler Object 00000000 8001 00000002 8504 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).
  • Page 205: If, #Ifn

    10.4.2 #if, #ifn Syntax Syntax for #if expression block1 [#else block2] #endif Functional description If the value of expression is not 0, block1 will be assembled. If it is 0 and an #else directive has been coded, block2 will be assembled. #ifn If the value of expression is 0, block1 will be assembled.
  • Page 206 The assembled list file is shown below. The program first 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. PanaX Series MN1030 Cross Assembler Object =00000001 1...
  • Page 207: Ifeq, #Ifneq

    10.4.3 #ifeq, #ifneq Syntax Syntax for #ifeq parameter1, parameter2 #ifeq block1 [#else block2] #endif Functional description #ifeq If parameter1 and parameter2 are the same string, block1 will be assembled. If they are different and an #else directive has been coded, block2 will be assembled. #ifneq If parameter1 and parameter2 are different strings, block1 will be assembled.
  • Page 208 Chapter 10 Writing Assembler Control Statements Usage example A source file 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, an instruction that sets the A register to 1 will be assembled.
  • Page 209 The assembled list file is shown below. Line number 11 assembles the statements for a match, and line number 12 assembles the statements for a mismatch. PanaX Series MN1030 Cross Assembler Object Line 00000000 8001 00000002 8002 Chapter 10 Writing Assembler Control Statements ifeq.lst...
  • Page 210: Iflt, #Ifle

    Chapter 10 Writing Assembler Control Statements 10.4.4 #iflt, #ifle Syntax Syntax for #iflt expression #iflt block1 [#else block2] #endif Functional description #iflt If the value of expression is negative, block1 will be assembled. If it is not negative and an #else directive has been coded, block2 will be assembled.
  • Page 211 The assembled list file is shown below. PanaX Series MN1030 Cross Assembler Object 00000000 8002 Chapter 10 Writing Assembler Control Statements iflt.lst Line Source MNXXX dsize macro #iflt size- #else #endif endm _TEXT section dsize #iflt MNXXX- #else #endif Page 1...
  • Page 212: Ifgt, #Ifge

    Chapter 10 Writing Assembler Control Statements 10.4.5 #ifgt, #ifge Syntax Syntax for #ifgt expression #ifgt block1 [#else block2] #endif Coding rules #ifgt If the value of expression is positive, block1 will be assembled. If it is not positive and an #else directive has been coded, block2 will be assembled.
  • Page 213 The assembled list file is shown below. You can see that the expression's value is 0, so block 2 was assembled. PanaX Series MN1030 Cross Assembler Object 00000000 8002 00000002 8503 Chapter 10 Writing Assembler Control Statements ifgt.lst Line Source...
  • Page 214: Ifb, #Ifnb

    Chapter 10 Writing Assembler Control Statements 10.4.6 #ifb, #ifnb Syntax Syntax for #ifb dummy_parameter #ifb block1 [#else block2] #endif Functional description #ifb If the dummy_parameter is a null character, block1 will be assembled. If it is not a null character and an #else directive has been coded, block2 will be assembled.
  • Page 215 Usage example A source file that uses #ifb is shown below. If the dummy parameter para to the macro debug is a null character, the program will execute next_cycle. If it is not a null character, the program will execute test and then execute next_cycle.
  • Page 216 Chapter 10 Writing Assembler Control Statements The assembled list file is shown below. Where the characters debug_on have been specified, block 2 is assembled. Where the null character has been specified, block 1 is assembled. PanaX Series MN1030 Cross Assembler Object 00000000...
  • Page 217: Chapter 11 Writing Macro Control Statements

    Chapter 11 Writing Macro Control Statements...
  • Page 218: Purpose Of This Chapter

    Chapter 11 Writing Macro Control Statements 11.1 Purpose of This Chapter Macros consist of two parts: macro definitions and macro calls. A macro that has been defined 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.
  • Page 219: Macro Definitions (Macro, Endm)

    11.2 Macro Definitions (macro, endm) Syntax macro_name macro macro_body endm NOTE: Up to 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.
  • Page 220 Chapter 11 Writing Macro Control Statements Coding rules The following instructions cannot be used within macro definitions. • include directive • macro directive — within a macro definition another different macro cannot be defined • purge directive — within a macro definition macros cannot be purged The symbols used in the label fields within a macro definition must be declared with the local directive or passed from the outside using dummy parameters.
  • Page 221: Macro Calls And Expansion

    11.3 Macro Calls and Expansion Syntax macro_name [parameter (, parameter)... ] NOTE: Up to10 dummy parameters can be specified. Functional description A macro is called by coding its name in the operation field of a source statement. The assembler then inserts the text of the macro body at that position.
  • Page 222 Chapter 11 Writing Macro Control Statements Usage example A source file 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.
  • Page 223: Macro Operators

    11.4 Macro Operators Macro operators are used in macro bodies to operate on parameters of macro calls. Macro operators are listed below. Operator & Concatenates strings. Macro definition dummy parameters p1&p2&p3 p1&p2&p3 Escape characters for including normally unusable characters (<, >, &, \) in parameters of macro calls.
  • Page 224 Chapter 11 Writing Macro Control Statements The assembled list file is shown below. Panax Series MN1030 Cross Assembler Object 00000000 8001 00000002 2801 212 Macro Operators macexp.lst Line Source mac1 macro endm mac2 macro endm _TEXT SECTION mac1 mac2 Page 1 p1,p2,p3 p1&p2\>\>&p3\&0x0f,D0...
  • Page 225: Local Symbol Declaration (Local)

    11.5 Local Symbol Declaration (local) Syntax macro_name macro local symbol endm NOTE: Up to 30 symbols can be specified. Functional description The local directive declares local symbols used in a macro body. When local symbols are expanded, they will be expanded in the form ??XXXXX, where XXXXX is in the range starting 00001 to 99999. Coding rules Symbols specified with the local directive should not be used outside the macro definition.
  • Page 226 _TEXT section The assembled list file is shown next. You can see that each time the local symbol is expanded, it is changed to ??00001, ??00002, ... Panax Series MN1030 Cross Assembler Object 00000000 8000 00000002 A000 00000004...
  • Page 227: Forced Termination Of Macro Expansion (Exitm)

    11.6 Forced Termination of Macro Expansion (exitm) Syntax macro_name macro identifier #ifndef 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 identifier is undefined. If the identifier has been defined, expansion beyond #endif will be performed.
  • Page 228 00000000 8001 00000002 8001 00000004 F8FEFCFCFF000000 +14+ 0000000c 00F8FE04 216 Forced Termination of Macro Expansion (exitm) debug 1, D0 debug CODE, PUBLIC, 1 exitm.lst Panax Series MN1030 Cross Assembler** * Line Source global extm1 macro #ifndef TEST exitm #endif endm...
  • Page 229: Purging Macro Definitions (Purge)

    11.7 Purging Macro Definitions (purge) Syntax macro_name (, macro_name)... purge Functional description The purge directive purges the definitions of the specified macro names. Coding rules The macro names specified with the purge directive are valid for previously defined macro names. After the purge directive, purged macros will not be expanded even if they are called.
  • Page 230: Rept

    Chapter 11 Writing Macro Control Statements 11.8 rept Syntax rept block endm Functional description The rept directive repeatedly expands the specified block the specified 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 definition.
  • Page 231 The assembled list file is shown below. Panax Series MN1030 Cross Assembler Object Line 00000000 2801 00000002 2801 00000004 2901 00000006 2901 00000008 2901 Chapter 11 Writing Macro Control Statements rept.lst Page 1 Source repeat macro rept 1, D0 endm...
  • Page 232: Irp

    Chapter 11 Writing Macro Control Statements 11.9 irp Syntax dummy_parameter, parameter (, parameter) ... block endm NOTE: Up to10 dummy parameters can be specified. Functional description The irp directive repeatedly expands the specified block the specified number of times. The dummy parameter is used within the block.
  • Page 233 The assembled list file is shown below. Panax Series MN1030 Cross Assembler *** Object Line 00000000 8001 00000002 8A00 00000004 8F00 Chapter 11 Writing Macro Control Statements irp.lst Source init macro endm endm _TEXT section init endm endm Page 1 opr,<p1\&0x0f>...
  • Page 234: Irpc

    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 specified 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.
  • Page 235 The assembled list file is shown below. *** Panax Series MN1030 Cross Assembler *** Object Line 00000000 00000001 00000002 00000003 00000004 00000005 00000006 00000007 00000008 00000009 Chapter 11 Writing Macro Control Statements irpc.lst Source _DATA section irpc endm Page 1 DATA, PUBLIC, 1 dummy, “0123456789”...
  • Page 236 Chapter 11 Writing Macro Control Statements 224 irpc...
  • Page 237: Chapter 12 List Of Machine Language Instructions

    Chapter 12 List of Machine Language Instructions...
  • Page 238: Purpose Of This Chapter

    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, refer to the “MN1030/ MN103S Series Instruction Manual”.
  • Page 239: Addressing Modes

    12.2 Addressing Modes This series of the microcomputers supports four addressing modes for memory accesses. The following four address formats are methods for accessing an address specified as an address register's contents or as the sum of an address register's contents and a displacement. •...
  • Page 240 Chapter 12 List of Machine Language Instructions Register relative indirect addressing Register relative indirect addressing determines the address to access using the following three combinations. 1. An address register, An, plus a sign-extended 8-bit or 16-bit displacement or the stack pointer register, SP, plus a zero-extended 8-bit or 16-bit displacement.
  • Page 241 3. The program counter, PC, plus a sign-extended 8-bit or 16-bit displacement or a 32-bit displace- ment. Absolute addressing Absolute addressing specifies the address to be accessed as a 16-bit or 32-bit displacement. Chapter 12 List of Machine Language Instructions sign-extended Address specification abs32/abs16...
  • Page 242 Chapter 12 List of Machine Language Instructions Index addressing Index addressing adds the contents of an address register, An, and a data register, Dn, to yield a displacement. 230 Addressing Modes Address specification...
  • Page 243: List Of Machine Language Instructions

    12.3 List of Machine Language Instructions Symbol An, Am Dn, Dm imm8 imm16 imm32 abs16 abs32 regs Chapter 12 List of Machine Language Instructions Description Address register (n, m=3 to 0) Data register (n, m = 3 to 0) Index, a data register (i=0,1,2,3) Stack pointer register Immediate data 8-bit immediate data specified with an instruction...
  • Page 244: Data Move Instructions

    Chapter 12 List of Machine Language Instructions 12.3.1 Data Move Instructions MOVE source to destination Mnemonic MOV Dm, Dn MOV Dm, An MOV Am, Dn MOV Am, An MOV SP, An Register Direct MOV Am, SP MOV PSW, Dn MOV Dm, PSW MOV MDR, Dn MOV Dm, MDR MOV imm, Dn...
  • Page 245 Mnemonic MOV (d, Am), An MOV (d, SP), An MOV (d8, Am), SP MOV Dm, (d, An) MOV Dm, (d, SP) MOV Am, (d, An) MOV Am, (d, SP) MOV SP, (d8, An) Register Relative Indirect MOVBU (d, Am), Dn MOVBU (d, SP), Dn MOVBU Dm, (d, An) MOVBU Dm, (d, SP)
  • Page 246 Chapter 12 List of Machine Language Instructions Mnemonic MOVHU (d, Am), Dn MOVHU (d, SP), Dn MOVHU Dm, (d, An) MOVHU Dm, (d, SP) Register Relative Indirect MOVH (d, Am), Dn MOVH (d, SP), Dn MOVH Dm, (d, An) MOVH Dm, (d, SP) MOV (Di, Am), Dn MOV (Di, Am), An MOV Dm, (Di, An)
  • Page 247 Mnemonic MOV (abs32), Dn MOV (abs16), An MOV (abs32), An MOV Dm, (abs16) MOV Dm, (abs32) MOV Am, (abs16) MOV Am, (abs32) MOVBU (abs16), Dn MOVBU (abs32), Dn MOVBU Dm, (abs16) MOVBU Dm, (abs32) Absolute MOVB (abs16), Dn MOVB (abs32), Dn MOVB Dm, (abs16) MOVB Dm, (abs32) MOVHU (abs16), Dn...
  • Page 248 Chapter 12 List of Machine Language Instructions EXTEND Sign Mnemonic EXT Dn Extend Dn to 64 bits and store the highest 32 bits in MDR. EXTB Dn Sign-extend the lowest 8 bits of Dn to fill Dn. EXTBU Dn Zero-extend the lowest 8 bits of Dn to fill Dn. EXTH Dn Sign-extend the lowest 16 bits of Dn to fill Dn.
  • Page 249: Arithmetic Instructions

    12.3.2 Arithmetic Instructions Mnemonic ADD Dm, Dn Add the contents of Dm and Dn and store the result in Dn. ADD Dm, An Add the contents of Dm and An and store the result in An. ADD Am, Dn Add the contents of Am and Dn and store the result in Dn. ADD Am, An Add the contents of Am and An and store the result in An.
  • Page 250 Chapter 12 List of Machine Language Instructions MULTIPLY Mnemonic Multiplies the 32-bit signed integer multiplicand in Dm by the 32-bit signed MUL Dm, Dn integer multiplier in Dn and store the upper 32 bits of the product in MDR and the lower 32 bits in Dn.
  • Page 251: Logical Instructions

    12.3.3 Logical Instructions AND source with destination Mnemonic AND Dm, Dn AND Dm with Dn and store the result in Dn. AND the zero-extended imm8, zero-extended imm16, or imm32 with Dn and AND imm, Dn store the result in Dn. AND imm16, PSW AND imm16 with PSW and store the result in PSW.
  • Page 252 Chapter 12 List of Machine Language Instructions ARITHMETIC SHIFT RIGHT Mnemonic Arithmetically shift the contents of Dn right the number of bits specified in ASR Dm, Dn Dm and store the result in Dn. Arithmetically shift the contents of Dn right the number of bits specified by ASR imm8, Dn imm8 and store the result in Dn.
  • Page 253: Bit Manipulation Instructions

    12.3.4 Bit Manipulation Instructions Bit operations Mnemonic AND the zero-extended imm8, zero-extended imm16, or imm32 with the contents BTST imm, Dn of Dn and set the flags according to the result. AND the zero-extended imm8 with the zero-extended 8-bit contents of the memory BTST imm8, (d8,An) location specified by d8 and An and set the flags according to the result.
  • Page 254 Chapter 12 List of Machine Language Instructions Mnemonic This instruction proceeds through the following three stages: 1.Transfer, with zero-extension, the 8-bit contents of the memory location specified with abs32 to a 32-bit internal temporary register. BCLR imm8,(abs32) 2.AND the temporary register with zero-extended imm8 and set the flags according to the result.
  • Page 255: Branching Instructions

    12.3.5 Branching Instructions CALL Subroutine Mnemonic label is either (d16,PC) or (d32,PC). Push the program counter containing the address of the next instruction and necessary registers onto the stack, secure the necessary stack area, and branch to the specified address. CALL label This instruction is used paired with either a RET or RETF instruction.
  • Page 256 Chapter 12 List of Machine Language Instructions Unconditional BRANCH Mnemonic JMP (An) Store the contents of An in the program counter. If label is (d16,PC), the 16-bit displacement is sign-extended and added to the program counter. The result is stored in the program counter. Any overflow during the addition is ignored.
  • Page 257 Conditional BRANCH Mnemonic Meaning BEQ label ZF=1 BNE label ZF=0 BGT label < (signed) BGE label < (signed) BLE label > (signed) BLT label > (signed) BHI label < (unsigned) BCC label < (unsigned) CF=0 BLS label > (unsigned) BCS label <...
  • Page 258 Chapter 12 List of Machine Language Instructions Conditional BRANCH for LOOP Mnemonic Meaning ZF=1 ZF=0 < (signed) < (signed) > (signed) > (signed) < (unsigned) < (unsigned) CF=0 > (unsigned) < (unsigned) CF=1 Mnemonic SETLB 246 List of Machine Language Instructions Description of operation If ZF = 1, branch to the top of the loop as specified with SETLB.
  • Page 259: User-Defined Instructions

    12.3.6 User-Defined Instructions User Defined FUNCTION Mnemonic If nn is between 00 and 15, compute with the contents of Dm and Dn and store the result in Dn. The nature of the calculation and the UDFnn Dm, Dn effects on the flags are user defined. If nn is between 20 and 35, compute with the contents of Dm and Dn.
  • Page 260: Other Instructions

    Chapter 12 List of Machine Language Instructions 12.3.7 Other Instructions NO OPERATION Mnemonic Description of operation Do nothing. 248 List of Machine Language Instructions...
  • Page 261: Chapter 13 Error Messages

    Chapter 13 Error Messages...
  • Page 262: Purpose Of This Chapter

    Chapter 13 Error Messages 13.1 Purpose of This Chapter Error messages are divided into three categories depending on the severity of the error. • Warnings • Errors • Fatal errors These messages are displayed during assembler and linker operations. A warning message warns the user of some state and consists of the marker "Warning," the warning number, and the text of the message.
  • Page 263: Assembler Errors

    Chapter 13 Error Messages 13.2 Assembler Errors The assembler displays three types of messages: warning messages, error messages, and fatal error mes- sages. Assembler Errors 251...
  • Page 264: Warning Messages

    The usage of a series of instructions may be restricted in MN1030/ 103S series The usage of a series of instructions may be restricted in MN1030 series. Careful operation is needed as some operations are not guaranteed. Refer to the notes, attentions or warnings written in MN1030/MN103S Series Instruction Manual for 32-bit and ensure that the expected operation is guaranteed.
  • Page 265 2011 Not guaranteed operand by the instruction allocation. The usage of a series of instructions may be restricted in the microcomputer. Careful operation is needed as some operations are not guaranteed. Refer to the notes, attentions or warnings written in the Instruction Manual for 32-bit and ensure that the expected operation is guaranteed.
  • Page 266: Error Messages

    Chapter 13 Error Messages 13.2.2 Error Messages 2301 Syntax error. The current line contains a syntax error. Consult this Manual and the MN1030/MN103S Series Instruction Manual. 2302 Illegal character. A string contains an illegal character. Use only legal characters 2303 Illegal string.
  • Page 267 2314 Illegal section name. There is an error in a section name. Check the spelling of the section name. 2315 Operand error. An operand of the wrong type is used. Check the number and types of operands. 2316 Illegal operand expression. An operand expression does not evaluate to a value within the specified range.
  • Page 268 Chapter 13 Error Messages 2328 Too many arguments. A macro invocation has too many arguments. Check the macro definition. 2329 Can’t find FUNCINFO directive. There is a ret or retf machine instruction before the corresponding funcinfo directive. Declare funcinfo directive before the ret or retf machine instruction. 2330 Line too long.
  • Page 269: Fatal Error Messages

    13.2.3 Fatal Error Messages 2501 Illegal option (string). There is an unrecognized option on the command line. Check the command line options. 2502 Too many input files (filename). There is more than one input file name on the command line. Limit the command line to a single input file.
  • Page 270: Linker Errors

    Chapter 13 Error Messages 13.3 Linker Errors The linker displays three types of messages: warning messages, error messages, and fatal error messag- 258 Linker Errors...
  • Page 271: Warning Messages

    13.3.1 Warning Messages 3000 filename: Section not found. This file ignored. The input file does not contain section information. Check the contents of the specified input file. 3001 filename: Illegal section[name] attribute or align value. Different files have sections with the same name, but different attributes or alignment values. Make sure that the attributes and alignment value for all sections with the same name agree across files.
  • Page 272: Error Messages

    Chapter 13 Error Messages 13.3.2 Error Messages 3300 Bad option switch.(string) There is an error in the option specifications. Check the option specifications 3301 No parameter for (option) option. There is no parameter for the specified option. Check the command line options. 3302 Illegal parameter with (option) option.
  • Page 273 Chapter 13 Error Messages 3313 Extra symbol[name] used as normal symbol. The extra symbol, which is reserved for instruction RAM use, is used in a context other than a - PUT option. Modify the program to use a different symbol in that context. Linker Errors 261...
  • Page 274: Fatal Error Messages

    There is no object file (with extension .rf) specified as an input file. Make sure that the object file is properly specified. 3505 filename: This file is not a object file for MN1030 The input file is not a relocatable object file. Check the file name specification for errors.
  • Page 275 3512 filename: Illegal relocation information.(line lineno) The relocation information in the specified input file is invalid. Check the specified line in the source file. If there are no problems there, reassemble the corresponding source file and check the disk for hardware errors. 3513 filename: Illegal optimize information.(line lineno) The optimization information in the specified input file is invalid.
  • Page 276 Chapter 13 Error Messages 264 Linker Errors...
  • Page 277: Chapter 14 Readinig List Files

    Chapter 14 Readinig List Files...
  • Page 278: Purpose Of This Chapter

    Chapter 14 Reading List Files 14.1 Purpose of This Chapter This chapter explains how to read the list files output during assembly. There are two types of information output in a list file. • Machine language code • Symbol table This chapter also explains how to read the information added by individual options and the meanings of special symbols.
  • Page 279: Reading List Files

    Chapter 14 Reading List Files 14.2 Reading List Files Adding the l (letter) option, when the assembler is invoked, will generate the list file in the current directory. List file contents are entirely in text format, so those can be viewed by using an editor. Reading List Files 267...
  • Page 280: Output Format Of Machine Language Code

    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 Machine Language Code Object Each of these fields is described below. Location (Loc) The location field shows the location counter values during assembly. For section address format programs, the location field shows the relative value from the start of the section.
  • Page 281: Supplemental Information

    Supplemental information A line number can provide additional information in the form of preceding periods and the suffixes X or +. “.” Line numbers preceding 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, “.”...
  • Page 282 The source statements of the source file are output as is. If the Lm option is added when the assembler is invoked, output of source statements resulting from macro expansion will be suppressed. Below are example of source statement. *** PanaX Series MN1030 Cross Assembler *** Object 00000000 00000000...
  • Page 283: Symbol Table

    14.2.2 Symbol Table If only the l (letter) option is specified, and not the c or s options, when the assembler is invoked, the assembler will output a symbol table to the list file after the machine language code section. If the c option is specified, a cross-reference table will be output instead of the symbol table.
  • Page 284 Chapter 14 Reading List Files Symbol Name Symbol names are shown up to 255 characters. An output example of a symbol table is shown below. Symbol Table 12345678 00000000 272 Reading List Files listspl.lst data move main Page 2...
  • Page 285: Chapter 15 Using Library Manager

    Chapter 15 Using Library Manager...
  • Page 286: Purpose Of This Chapter

    Chapter 15 Using Library Manager 15.1 Purpose of This Chapter A library file is a collection of relocatable object files which you can pull out as needed. Library files are convenient for placing frequently used modules. When a module is called from within a program, the linker searches the library file, extracts only the required relocatable object file, and loads it in the executable format file.
  • Page 287: Starting 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. slib103 library_file_name[options](relocatable_object_file_name) ...
  • Page 288: Command Options

    Chapter 15 Using Library Manager 15.3 Command Options This section describes the options using the following categories. 15.3.1 Error Message Options Output error and warning messages in Japanese Functional description This option causes an error and warning messages and help screens sent to the console to appear in Japanese.
  • Page 289 Output error and warning messages in Japanese using EUC encoding Functional description This option causes all error and warning messages and help screens sent to the console to appear in Jap- anese using EUC coding. Rules of use To specify the option, enter the hyphen (-) followed by the upper case letter “J” and the lower case letter “e”.
  • Page 290 Chapter 15 Using Library Manager Output error and warning messages in Japanese using Shift JIS encoding Functional description This option causes all error and warning messages and help screens sent to the console to appear in Japanese using Shift JIS coding. Rules of use To specify the option, enter the hyphen(-) followed by the upper case letter ’J’...
  • Page 291 Output error and warning messages in Japanese using JIS encoding Functional description This option causes all error and warning messages and help screens sent to the console to appear in Japanese using JIS coding. Rules os use To specify the option, enter the hyphen (-) followed by the upper case letter “J” and the lower case letter “j”.
  • Page 292 Chapter 15 Using Library Manager Output error and warning messages in English Functional description This option causes all error and warning messages and help screens sent to the console to appear in English. Rules of use To specify the option, enter the hyphen (-) followed by the lower case letter”e”. slib103 test.lib Default specification...
  • Page 293 W number Do not output warning messages of the specific number Functional description This option suppresses output of warning messages generated during library manager operation. For a list of warning messages and numbers, see Chapter 15 “Using the Library Manager” Section 15.4 “Error Messages”...
  • Page 294: Program Generation Options

    Chapter 15 Using Library Manager 15.3.2 Program Generation Options Create a new library file Functional description If a file with same name of the specified library file already exists, the library manager will inquire if the file should be modified. Based on the response, the library manager with determine whether or not to create the library file.
  • Page 295 Force creation of a library file Functional description This option forces creation of the library file. If a file with the same name as the specified library file already exist, the library manager will overwrite it. Rules of use To specify the option, enter the hyphen (-) followed by the lower case letter “r”. slib103 test.lib Operation example...
  • Page 296: Functional Options

    Chapter 15 Using Library Manager 15.3.3 Functional Options Add the specified relocatable object file to the library file Functional description This option is used to add relocatable object files to the library file. Rules of use To specify the option, enter the hyphen (-) followed by the lower case letter “a”. slib103 test.lib Operation example...
  • Page 297 Delete the specified relocatable object file from the library file Functional description This option is used to delete relocatable object files from the library file. If a specified file does not exist in the library file, the library manager will output a warning message and continue processing.
  • Page 298 Chapter 15 Using Library Manager Output information about externally defined symbols in the library file Functional description This option is used when you want know the externally defined symbol names that exist in the library file. When a relocatable object file name is specified following the -p option, and a file with the same name exists in the library file, the externally defined symbol names in that relocatable object file will be output.
  • Page 299 Replace the specified relocatable object file in the library file Functional description This option is used to replace relocatable object files in the library file. If a specified file does not exist in the library file, the library manager will output a message add the relocatable object file.
  • Page 300 Chapter 15 Using Library Manager Output a list of the relocatable object files that make up the library file. Functional description This option is used when you want to know the names of the relocatable object files that exist in the library file.
  • Page 301 Extract the specified relocatable object file from the library file Functional description This option is used when you want to extract relocatable object files that exist in the library file. When a relocatable object file name is specified following the -x option, and a file with the same name exists in the library file, that relocatable object file will be extracted into the specified file name.
  • Page 302: Other Options

    Chapter 15 Using Library Manager 15.3.4 Other Options @filename Specify a parameter file. Functional description The options you will use with slib103 can be written to a file, so instead of specifying all those options for execution, you can specify just that file name. Every option other than the @ option can be written in a parameter file.
  • Page 303 Display a listing at available library manager’s options on the console Functional description This option displays the library manager’s version number, command line options and a brief description on the console. The -j, -Je, -Js, -Jj and -e options, if they appear, control the language and the coding scheme used to display this information.
  • Page 304: Error Messages

    Chapter 15 Using Library Manager 15.4 Error Messages The library manager displays three types of messages: warning message, error messages, and fatal error messages. These messages are display during library manager operation. A warning message warns the user of some state and consists of the marker “warning”, the warning number, and the text of the message.
  • Page 305: Warning Messages

    15.4.1 Warning Messages 4001 Filename not found The specified file is not in the library. Check the list of files in the library file. 4002 This file has no public symbol information.(filename) There is no public symbol information for the file filename. Check whether the file is actually needed.
  • Page 306: Error Messages

    Check the file system’s capacity. 4305 This file is not object file for MN1030. (filename) The specified object file is not an object file. Check the object file specifications. If they are correct, the file is most likely corrupted, so re-create 4306 This file is not library file for MN1030.
  • Page 307 4313 Parameter-file already specified. (filename) The same parameter file is specified more than once. Eliminate the duplicate specifications. 4314 Cannot read parameter-file. (filename) The library manager cannot read the parameter file--because it contains illegal characters, for example. Check the parameter file for control characters and kanji codes outside comments. If the parameter file passes this test, the problem could be insufficient memory, so check the memory capacity.
  • Page 308: Fatal Error Messages

    Chapter 15 Using Library Manager 15.4.3 Fatal Error Messages 4501 Illegal option. (string) The library manager does not support the specified option. Check the command line option specifications. 4502 Library file name not found. Either the command line contains no library file specification or the specification is in the wrong place.
  • Page 309: Chapter 16 Notes On Operating Environment

    Chapter 16 Notes on Operating Environment...
  • Page 310: Purpose Of This Chapter

    Chapter 16 Notes on the Operating Environment 16.1 Purpose of This Chapter This chapter contains descriptions left out of other chapters. 298 Purpose of This Chapter...
  • Page 311: Personal Computer Versions

    Chapter 16 Notes on the Operating Environment 16.2 Personal Computer Versions This section contains notes on using the personal computer versions of the software in this package. Personal Computer Versions 299...
  • Page 312: Operating Environment

    Chapter 16 Notes on the Operating Environment 16.2.1 Operating Environment This system runs on the following personal computers and compatibles. Host Machine Operating System PC/AT Windows DOS/V Windows 300 Personal Computer Versions Version of OS 98/2000/Me/XP 98/2000/Me/XP...
  • Page 313: Files

    Chapter 16 Notes on the Operating Environment 16.2.2 Files The installation media for this system contains the following files. AS103.EXE (Assembler) AS103.EXE is the assembler. For a description, see the chapter 5 “Using the Assembler.” LD103.EXE (linker) LD103.EXE is the linker. For a description, see the chapter 6 “Using the Linker.” SLIB103.EXE (library manager) SLIB103.EXE is the library manager;...
  • Page 314: Installation

    Chapter 16 Notes on the Operating Environment 16.2.3 Installation For the installation media, installation procedures, and notes on installation, see the MN1030 Series Installation Manual. 302 Personal Computer Versions...
  • Page 315: Environment Settings

    16.2.4 Environment Settings Before using this series Cross-Assembler, verify or change the following two files. CONFIG.SIS If FILES and BUFFER specifications do not already exist in CONFIG.SYS, you must add them. If they do already exist, check their settings and change them if necessary. FILES=20 BUFFERS=20 NOTE:...
  • Page 316 Chapter 16 Notes on the Operating Environment NOTE: Once you have edited AUTOEXEC.BAT, reset the computer and restart. The new setting will then automatically take effect. Terminology: AUTOEXEC.BAT AUTOEXEC.BAT is a batch file that MS-DOS automatically runs when it loads. SET is the command for setting MS-DOS environment variables. Application programs have free access to these variables.
  • Page 317: Differences From Workstation Versions

    16.2.5 Differences From Workstation Versions The personal computer versions of the assembler, linker function and the library manager are exactly the same as their workstation counterparts. Command line differences • When specifying the command name, omit the file extension .EXE. •...
  • Page 318: Error Correction Using Tag Jumps

    Chapter 16 Notes on the Operating Environment 16.2.6 Error Correction Using Tag Jumps This section describes a convenient way to fix errors. When code mistakes, syntax errors, or other errors and warnings occur in a source file, further development cannot proceed unless they are fixed. In long source files, it can be a lot of work to find the source statements in which errors and warnings were detected.
  • Page 319 MAIN.ASM(5):Error 2304: Instruction not found. MAIN.ASM(7):Error 2306: Multiple define symbol. The following explanation is for the programmer’s editor MIFES. Start up MIFES and open two files. MI MAIN.ASM ERROR The contents of the file ERROR will be displayed on the screen. MAIN.ASM(5):Error 2304: Instruction not found.
  • Page 320 Chapter 16 Notes on the Operating Environment Return to error file To return to the error file, press the HOME CLR key (above and to the left of the period key). When the screen switches to the error file, the cursor will move to the next error line. MAIN.ASM(7): Error 2306: Multiple define symbol.
  • Page 321: Chapter 17 Appendix

    Chapter 17 Appendix...
  • Page 322: Numeric Restrictions

    Chapter 17 Appendix 17.1 Numeric Restrictions This section shows the numeric restrictions on this series cross-assembler. Be sure not to exceed these values when writing programs. Assembler restrictions Item Characters per symbol Characters per line Lines per file Linker restrictions Item Number of OVL options Directive restrictions...
  • Page 323: List Of Command Options

    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 specification_example Chapter 17 Appendix List of Command Options 311...
  • Page 324: List Of Assembler Command Options

    Chapter 17 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. as103 [options] Contents of brackets [ ] may be omitted. Output file options Specify the relocatable object file name to be output.
  • Page 325 Error message options Output error and warning messages in Japanese as103 -j sample.asm Output error and warning messages in Japanese using EUC encoding. as103 -Je sample.asm Output error and warning messages in Japanese using Shift JIS encoding. as103 -Js sample.asm Output error and warning messages in Japanese using JIS encoding.
  • Page 326 Chapter 17 Appendix Others Display a listing of available assembler options on the console. as103 -h Display the assembler’s version number on the console. as103 -v 314 List of Command Options...
  • Page 327: List Of Linker Command Options

    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. ld103 [options] Contents of brackets [ ] may be omitted. Ellipses (...) indicates item may be repeated. Output file options Specify the path name and file name of the executable format file to be output.
  • Page 328 Chapter 17 Appendix Program generation options Output debug information to the executable format file. ld103 -g main.rf sub.rf Specify a section start address. T section-address ld103 -T_TEXT@CODE=80000000 -T@DATA=0 main.rf sub.rf Output an executable format file even if errors are detected. ld103 -r main.rf Do not output symbol table within the executable format file.
  • Page 329 Others Specify a parameter file. ld103 @ pfile Display help information on the console. ld103 -h Display the linker’s version number on the console. ld103 -v Chapter 17 Appendix List of Command Options 317...
  • Page 330: List Of Assembler Directives

    Chapter 17 Appendix 17.3 List of Assembler Directives This section provides a list of assembler directives. Directives for program control Syntax symbol instruction operand align expression expression name section [definition1 [,definition2[,expression]]] on | off Directives for symbols Syntax symbol instruction operand name value name...
  • Page 331 Directives for data area allocation Syntax symbol instruction operand definition | expression(,definition | expression)... expression(,expression)... expression(,expression)... expression1 [,expression2[. expression3]] Directives for list control Syntax symbol instruction operand [“string”] listoff liston xlistoff xliston page lines[, columns] Chapter 17 Appendix Function & Notes Allocates 8-bit data areas.
  • Page 332 Chapter 17 Appendix Other directives Syntax symbol instruction operand notation format radix expression name funcinfo label,expression,register list 320 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 Specifies the radix to be used by default.
  • Page 333: List Of Assembler Control Statements

    17.4 List of Assembler Control Statements This section provides a list of assembler control statements. Syntax #include “file_name #define identifier[replacement_string] #undef identifier #ifdef identifier block1 [#else block2] #endif #ifndef identifier block1 [#else block2] #endif expression block1 [#else block2] #endif #ifn expression block1 [#else...
  • Page 334 Chapter 17 Appendix Syntax #iflt expression block1 [#else block2] #endif #ifle expression block1 [#else block2] #endif #ifgt expression block1 [#else block2] #endif #ifge expression block1 [#else block2] #endif #ifb dummy_ parameter block1 [#else block2] #endif #ifnb dummy_ parameter block1 [#else block2] #endif 322 List of Assembler Control Statements...
  • Page 335 I n d e x Symbols #define ...187 #else ...191 #endif ...189 #if ...193 #ifb ...202 #ifdef ...191 #ifeq ...195 #ifge ...200 #ifgt ...200 #ifle ...198 #iflt ...198 #ifn ...193 #ifnb ...202 #ifndef ...191 #ifneq ...195 #include ...184 #undef ...188 &...
  • Page 336 j ... 91, 111 l library_filename ... 103 L path_name ... 104 Label Field ... 148 LD103.EXE ... 300 LD103.RC ... 302 Library File Options ... 103 Library Manager ... 275 Line ... 268 Line number ... 268 Linker options ... 87 listoff ...
  • Page 337 Unary minus ...138 Unary negation ...139 Unary plus ...138 Unconditional Branch Instructions ...46 UND ...142 Undefined ...142 undefined ...173 W number ...96 Wall ...96 Warning Messages ...313 x ...289 xlistoff ...176 xliston ...176 < Index 3 >...
  • Page 338 < 4 Index >...
  • Page 339 MN1030 Series Cross Assembler User’s Manual June, 2004 12th Edition Issued by Matsushita Electric Industrial Co., Ltd.  Matsushita Electric Industrial Co., Ltd.
  • Page 340 [PANABRAS] — Shum Yip Centre Office: 25F, Shum Yip Centre, #5045, East Shennan Road, Shenzhen, China Tel:86-755-8211-0888 Panasonic Shun Hing Industrial Sales (Hong Kong) Co., Ltd. [PSI(HK)] 11th Floor, Great Eagle Center 23 Harbour Road, Wanchai, Hong Kong [PIE] Tel:852-2529-7322 ˜...