Home

MN10300 Series Cross-Assembler User`s Manual

image

Contents

1. Source Instruction First Candidate Second Candidate Third Candidate UDF00 imm Dn UDF00 imm8 Dn UDFO00 imm16 Dn UDF00 imm32 Dn UDFO1 imm Dn UDFO1 imm8 Dn UDFO01 imm16 Dn UDFO1 imm32 Dn UDF02 imm Dn UDF02 imm8 Dn UDF02 imm16 Dn UDF02 imm32 Dn UDF03 imm Dn UDF03 imm8 Dn UDF03 imm16 Dn UDF03 imm32 Dn UDF04 imm Dn UDF04 imm8 Dn UDF04 imm16 Dn UDF04 imm32 Dn UDFOS imm Dn UDFOS imm8 Dn UDFOS imm16 Dn UDFOS imm32 Dn UDFO06 imm Dn UDFO06 imm8 Dn UDF06 imm16 Dn UDF06 imm32 Dn UDF07 imm Dn UDFO7 imm8 Dn UDF07 imm16 Dn UDF07 imm32 Dn UDF08 imm Dn UDFO0S8 imm8 Dn UDFO08 imm16 Dn UDF08 imm32 Dn UDF09 imm Dn UDFO09 imm8 Dn UDF09 imm16 Dn UDF09 imm32 Dn UDF10 imm Dn UDF10 imm8 Dn UDF10 imm16 Dn UDF10 imm32 Dn UDF11 mmm Dn UDF11 imm8 Dn UDFI11 imm16 Dn UDF11 imm32 Dn UDF12 imm Dn UDFI2 imm8 Dn UDF12 imm16 Dn UDF12 imm32 Dn UDF13 imm Dn UDF13 imm8 Dn UDF13 imm16 Dn UDF13 imm32 Dn UDF14 imm Dn UDF14 imm8 Dn UDFI4 imm16 Dn UDF14 imm32 Dn UDFI5 imm Dn UDF15 imm8 Dn UDFI5 imm16 Dn UDF15 imm32 Dn UDFUO0 imm Dn UDFUOO imm8 Dn UDFUO00 imm16 Dn UDFU00 imm32 Dn UDFUO imm Dn UDFUOI imm8 Dn UDFUO1 imm16 Dn UDFUOI imm32 Dn UDFUO2 imm Dn UDFUO2 imm8 Dn UDFUO2 imm16 Dn UDFU02 imm32 Dn UDFU03 imm Dn UDFUO3 imm8 Dn UDFUO03 imm16 Dn UDFUO03 imm32 Dn UDFUO4 imm Dn UDFU04 imm8 Dn UDFU04 imm16 Dn UDFU04 imm32 Dn UDFUOS imm Dn UDFUOS imm8 Dn UDFUOS imm16 Dn UDFUOS imm32 Dn UDFU06 imm Dn UDFU06 imm8 Dn UDFU06 imm16 Dn UDFU06
2. Mnemonic Description of operation MOV Dm Dn Transfers the contents of Dm to Dn MOV Dm An Transfers the contents of Dm to An MOV Am Dn Transfers the contents of Am to Dn MOV Am An Transfers the contents of Am to An a MOV SP An Transfers the contents of SP to An Register Direct MOV Am SP Transfers the contents of Am to SP MOV PSW Dn Transfers the contents of PSW to Dn MOV Dm PSW Transfers the contents of Dm to PSW MOV MDR Dn Transfers the contents of MDR to Dn MOV Dm MDR Transfers the contents of Dm to MDR MOV imm Dn Transfers the sign extended imm8 sign extended imm16 Tusedise or imm32 to Dn Value MOV imm An Transfers the zero extended imm8 zero extended imm16 or imm32 to An MOV Am Dn Transfers the contents of the memory location specified by Am to Dn MOV Am An Transfers the contents of the memory location specified by Am to An MOV Dn An Transfers the contents of Dm to the memory location specified by An Register MOV An An Transfers the contents of Am to the memory location Indirect specified by An MOVBU Am Dn Transfers with zero extension the 8 bit contents of the memory location specified by Am to Dn MOVBU Dm An Transfers the lowest 8 bits of Dm to the memory location specified by An MOVB Am Dn Transfers with sign extension the 8 bit contents of the memory location specified by Am to Dn MOVB Dn A
3. 73 83 error message options library manager 299 301 error message options Omker cece eee 103 108 error messages Ossembler see 277 error messages library manager 320 error messages linker eese 283 ET EE 12 excv103 file conversion utility esee 4 EXCV103 EXE file conversion utility 326 exclusive E 157 executable format file ces 27 expression attributes CXPTESSION SyBLAX vaa egen teen XMS SIONS coiere radi un eres nen eer Pe PERENNE LUE etes drea extended C language format sse 149 external definitions 5 tesine cansino ento ann apnd external label cin external references AE EE E f library manager esee enn niente ntn tih fatal error messages assembler sss 281 fatal error messages library manager 322 fatal error messages linker file CONVETSION utility ui le Extension nada file layout A A eet e RR 4 file organization personal computer version 326 files used by the assembler and linker 27 final list file fixed programi portion eren iret 128 forced termination of macro expansion PUTTING scott ste ct Ede rente vase E apes functional options library manager G Assembler Option corro eren 92 amp linke
4. Do not output any warning messages Program generation options g Output debug information to the executable format file Tsection address Specify a section start address r Output an executable format file even if errors are detected Do not output symbol table within the executable format file Ed Enable output of DATA sections to the executable file Library file options l library filename Specify a library file L path name Specify a path name for library files Instruction RAM options OVL ID number section address Specify starting address for section in instruction RAM PUT extra_symbol address Specify address for extra symbol 104 Starting The Linker filename Specify a parameter file h Display help information on the console V Display the linker s version number on the console Chapter 6 Using The Linker 6 3 Command Options L 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 has been specified during the assembly phase the linker optimizes unconditional branches and all instructions subject to optimization to use machine instructions that are not necessarily the
5. 1d103 1 usr local lib sample lib main rf sub rf L path name Specify a pathname for library files 1d103 L usr lib L usr local lib lsample lib main rf sub rf B Instruction OVL ID number section address RAM options Specify starting address for section in instruction RAM 1d103 T CODE 80000000 main rf sub rf OVL 1 TEXT 40000000 segl rf OVL 2 TEXT CONST 40000000 seg2 rf PUT extra symbol address Specify address for extra symbol 1d103 T CODE 80000000 main rf sub rf OVL 1 TEXT 40000000 segl rf OVL 2 TEXT 40000000 seg2 rf PUT overlay table a0000000 PUT iram manage 30000000 List Of Command Options 343 Chapter 17 Appendix Bi Others filename Specify a parameter file 1d103 pflie Display help information on the console 1d103 h Display the linker s version number on the console ld103 v 344 List Of Command Options Chapter 17 Appendix 1 7 3 List Of Assembler Directives E This section provides a list of assembler directives E Directives for program control Syntax Function amp Notes symbol instruction operand align expression Adjusts the location counter to be a multiple of the value indicated by expression The expression must be a power of 2 in the range 1 to 215 name end Indicates the end of the program o
6. 9 4 1 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements section E Syntax label operation operand section name section definition1 definition2 expression definitionl Section attribute CODE or DATA definition2 2 Linking type PUBLIC Note that the words PRIVATE and COMMON are reserved for use in expansion expression Alignment factor for the location counter 2 to the specified power E Default settings If the section name appears for the first time in the file the following defaults are used definition CODE definition2 PUBLIC expresson 1 For subsequent appearances of the section name the section inherits the values from previous appearances E Functional description The section directive specifies a section name as well as its attribute link type and location boundary During linking the linker gathers sections with the same name and links them together by attribute The order of linking is determined by the link type and the order in which the linker encounters the sections E Section linking rules 1 Link sections in order of appearance 2 Link by attribute 3 Link by link type PUBLIC Link across all linked files Writing Directive Statements 1 73 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements iil Operand coding rules Only specific strings can be defined for definitionl and definition2 If so
7. RX ss Address specification 250 Addressing Modes Chapter 12 List Of Machine Language Instructions 1 2 3 List Of Machine Language Instructions L Symbol Description An Am Address register n m 3 to 0 Dn Dm Data register n m 3 to 0 Di Index a data register i 0 1 2 3 SP Stack pointer register imm Immediate data imm8 8 bit immediate data specified with an instruction imml6 16 bit immediate data specified with an instruction imm32 32 bit immediate data specified with an instruction abs16 A 16 bit absolute address specified by the instruction abs32 A 32 bit absolute address specified by the instruction d Displacement data d8 8 bit offset data specified with an instruction dl6 16 bit offset data specified with an instruction d32 32 bit offset data specified with an instruction MDR Multiply divide register LIR Loop instruction register LAW Instruction fetch address register PSW Program status word CF Carry flag ZF Zero flag NF Negative flag VF Overflow flag PC Program counter regs Specification of multiple registers Indicates an indirect address List Of Machine Language Instructions 251 Chapter 12 List Of Machine Language Instructions 12 3 1 Data Move Instructions AAA X RU X c U HJ n M E MOVE source to destination
8. eese 233 11 6 Forced Termination Of Macro Expansion exitm eese 235 11 7 Purging Macro Definitions purge sss 237 I 238 i Le EE 240 VETO TPC sait sectio bee dite edidere A ad do ln rS 242 Chapter 11 Writing Macro Control Statements 1 1 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 When a macro with parameters is called part of the text to be substituted will be modified by the strings specified as the parameters This chapter explains how define and call macros It also describes the directives used for macros m Common coding rules The characters that can be used for macro names dummy parameters parameters and identifiers are upper and lower case letters digits and underscores _ The first character must not be a digit Symbols used in expressions must have been previously defined The following directives cannot be coded within macro blocks include directive macro definitions Refer to section 11 2 Macro Definitions regarding macro definitions and blocks The rept and irp directives and macro calls can be coded within macro blocks Up to 20 nesting levels are allowed A dummy parameter appearing in a string or character constant ins
9. By using names that represent their processing actions macro names can make listings easier to read In such cases listings without expanded mnemonics will be easier to look at This is why the Lm option is provided If the 1 option is not specified then the Lm option will be ignored even if specified Source files with no macro expansion will be assembled normally even if assembled with the Lm option Bi Rules of use The Lm option is specified with the hyphen option specification character followed by the upper case letter L and lower case letter m The pair of characters of Lm are handled as a single option as103 Lm 1 sample asm a The Lm option is used in conjunction with the option lower case l list output H E Default specification Source statements expanded from macros will be output to the list file E Operation example The following command line assembles the source file sampl asm and creates a listing file samp1 lst that suppresses all text generated by the expansion of macros as103 1 Im sampl asm Command Options 79 Chapter 5 Using The Assembler 80 Command Options Do not output source statements that were not assembled due to unfulfilled conditions of conditional assembly to the list file E Functional description The Lc option suppresses output of blocks of unsatisfied conditions with conditional assembly to the list file It also suppresses source statements o
10. keyword Description Ed OPTION This entry controls the output of DATA sections to the executable file Following the keyword Ed OPTION and separated from it with white space is one of the parameters ON or OFF These parameters have the following meanings Ed OPTION ON Enable output of DATA sections to the executable file Ed OPTION OFF Disable output of DATA sections to the executable file The default setting is to disable output of DATA sections to the executable file m OPTION This entry controls the output of the map file Following the keyword m OPTION and separated from it with white space is one of the parameters ON or OFF These parameters have the following meanings m OPTION ON Enable output of the map file m OPTION OFF Disable output of the map file The default setting is to disable output of the map file r OPTION This entry controls the output of the executable file when there are assembler errors Following the keyword r OPTION and separated from it with white space is one of the parameters ON or OFF These parameters have the following meanings r OPTION ON Enable output of the executable file when there are assembler errors r OPTION OFF Disable output of the executable file when there are assembler errors The default setting is to disable output of the executable file when there are assembler errors Setup 11 Chapter 1 Getting Started 12 File Conversion Utility
11. As a result the programmer must be aware that the generated code will differ from the source statements coded in the list file Refer to chapter 4 Optimization for details Programming With The Assembler 21 Chapter 2 Program Development Flow il Conditional assembly If a program for product A is to be created by partially modifying a program for product B then both can be combined into a single program by using conditional assembler control instructions Conditional assembly is done by defining a single symbol at the start of the program using a define control directive Here is an example defin TYPE A Using TYPE and conditional assembler control directives to process different parts of the program the programmer writes code in the format below TYPI Program of product A Program of product B TYPE has been defined with define so in this case the program for product A will be assembled If the statement define TYPE A is omitted then the program for product B will be assembled By using conditional assembler control directives in this manner different versions of programs can be managed in a single source file Refer to chapter 10 Writing Assembler Control Statements for details 22 Programming With The Assembler Chapter 2 Program Development Flow B Macros Macros are an important function of the assembler A macro assigns a name to a proce
12. E Default specification The entire symbol table will be output It is also possible to disable symbol table output by default with an entry in the linker s start up file See Chapter 1 Getting Started Section 1 5 Setup Chapter 6 Using The Linker Ed Output DATA sections to the executable E Functional description This options causes the linker to write sections with the DATA attribute to the executable E Rules of use The Ed option is specified with the hyphen option specification character followed by the upper case letter E and the lower case letter d The two letters together function as a single option ld103 Ed main rf sub rf E Default specification The default is not to output DATA sections to the executable It is also possible to enable DATA section output by default with an entry in the linker s start up file See Chapter 1 Getting Started Section 1 5 Setup Command Options 121 Chapter 6 Using The Linker 6 3 4 Library File Options library filename Specify a library file E Functional description The 1 options specifies a library file E Rules of use The 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 1d103 1 usr lib sample lib main rf sub rf E Default specification No library files will be rea
13. For the installation media installation procedures and notes on installation see the MN10300 Series PanaX Series Installation Manual Personal Coomputer Versions 327 Chapter 16 Notes On The Operating Environment 16 2 5 Environment Settings Before using the MN10300 Series Cross Assembler verify or change the following two files If FILES and BUFFER 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 error message bad tmpbss w will be output and processing will stop This a Be sure to make these settings If the assembler is started without them then the means that the number of files that can be opened simultaneously is insufficient Terminology U CONFIG SYS This is the file that sets the MS DOS operating environment FILES specifies the number of files that can be read and written simultaneously BUFFERS specifies the size of memory used for reading writing disks il AUTOEXEC BAT To be able to run the software simply by typing in its name include its directory in the path search list given by the environment variable PATH Under MS DOS adding the directory in which the software is installed to the PATH variable and activating the new value for PATH allows you to run the programs in this system simply by entering their names SET PATH A usr local bin 328 Personal C
14. Start with 0 zero and letter B or b followed by binary digits Start with 0 zero followed by octal digits Code decimal number as is Start with 0 and letter X or x followed by hexadecimal digits Bi Intel format Current default radix Radix Binary Octal Decimal Hexadecimal 101B 101B 101B 101B Binary 101 5670 5670 5670 5670 Octal 567Q 567Q 567Q 567Q 567 789D 789D 789D 789D Decimal 789 OdefH OdefH OdefH OdefH Hexadecimal Odef Coding rules Binary Octal Decimal Hexadecimal Follow binary digits with letter B or b When the default is binary the suffix B may be omitted Follow octal digits with letter O or o or Q or q When the default is octal the suffix O or Q may be omitted Follow decimal digits with letter D or d When the default is decimal the suffix D may be omitted Follow hexadecimal digits with letter H or h If the digits begin with a letter A F then they must be prefixed with the digit 0 zero When the default is hexadecimal the suffix H may be omitted Numbers 1 49 Chapter 8 Writing Source Statements 150 Numbers Ml Matsushita format Current default radix Radix Binary Octal Decimal Hexadecimal B 101 B 101 B 101 B 101 Binary 101 0 567 0 567 0 567 0 567 Octal 567 F 789 F 789 F 789 F 789 Decimal 789 X def X def X def X def Hexadecimal
15. Usage Example 65 Chapter 4 Optimization E Example unconditional branch instruction converted to relative branch This example shows the branch destination of a JMP LABEL unconditional branch instruction within the permitted range 128 to 127 of PC for relative branching The source list is as follows opt on _ TEXT section CODE PUBLIC 1 sub_func addr_set jmp func_end org addr_set 127 func_end rus end The final list file after assembly is shown next The branch destination of the JMP LABEL instruction on line number 4 is in the permitted range for relative branching so it has been converted to BRA LABEL Note that the mnemonics and object code are different opt3 lst Page 1 NUS PanaX Series MN103000 Cross Assembler TOME Loc Object Line Source 1 opt on 2 _TEXT section CODE PUBLIC 1 40000000 3 sub func 40000000 CAT7F 4 addr_set jmp func_end 5 6 org addr_set 127 4000007 7 func_end 4000007 FOFC 8 rts 9 end opt3 lst Page 2 Symbol Table 40000000 T sub_func 40000000 T addr_set 4000007 T func end 66 Usage Example E Example subroutine call converted to a relative branch This section gives an example of a CALLS LABEL instruction with a target address Chapter 4 Optimization within the range of a relative jump that is between 32 768 and 32 767 from the current program counter The source list is as follows TEXT sub_func addr_set func_end opt secti
16. File Conversion Utility This file conversion utility converts an executable produced by the linker into a file in Intel HEX format or Motorola S format E 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 E Options Option Function j Display errors and warning messages in Japanese 1 e Display errors and warning messages in English 2 h Display help information regarding file conversion utility options W Perform conversion using a work file during execution This enables a large amount of data to be converted even if the personal computer has little memory However the conversion is performed at slower speed a Output the execution file in Intel HEX format S3 Output the execution file in Motorola S3 format S2 Output the execution file in Motorola S2 format S1 Output the execution file in Motorola S1 format ofile Specify the file name to be output p No padding P Padding R start address last address If omitting the end address a conversion is performed until the last address of the execution module A start address Convert the start address of the EX file to the specified address Option for UNIX version 2 Option for DOS V and PC9800 version Chapter 1 Getting Started E Defau
17. m Usage example A source file that uses ifeq and ifneq is shown below The macro named compare uses two dummy parameters datal data2 Within the macro it compares the strings of those dummy parameters If they match then an instruction that sets the A register to 1 will be assembled If they do not match then an instruction that sets the A register to 0 will be assembled The macro is called by specifying strings to be passed to the dummy parameters compare macro datal data2 ifeq datal data2 mov 0x01 D0 ls mov 0x02 D0 ndif enam TEXT section CODE PUBLIC 1 compare abc abc compare abc acb 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 ifeq lst Page 1 eee PanaX Series MN103000 Cross Assembler yen Loc Object Line Source M1 compare macro datal data2 2 ifeg datal data2 3 mov 0x01 D0 4 felse 5 mov 0x02 D0 6 fendif 7 endm 8 9 _TEXT section CODE PUBLIC 1 M 10 compare abc abc 0 ifeg abc abc 00000000 8001 10 mov 0x01 D0 O felse OX mov 0x02 D0 0 fendif M 11 compare abc acb 1 tifeg abc ach 1X mov 0x01 D0 1 else 00000002 8002 11 mov 0x02 D0 1 endif 216 Conditional Assembly 10 5 4 Hiflt ifle Chapter 10 Writing Assembler Control Statements B Syntax Syntax for iflt iflt expression block1 is block2 nd
18. New Jersey Office 2 Panasonic Way Secaucus New Jersey 07094 Tel 201 392 6173 Fax 201 392 4652 Milpitas Office 1600 McCandless Drive Milpitas California 95035 Tel 408 945 5630 Fax 408 946 9063 O Chicago Office 1707 N Randall Road Elgin Illinois 60123 7847 Tel 847 468 5829 Fax 847 468 5725 O Atlanta Office 1225 Northbrook Parkway Suite 1 151 Suwanee Georgia 30174 Tel 770 338 6940 Fax 770 338 6849 San Diego Office 9444 Balboa Avenue Suite 185 San Diego California 92123 Tel 619 503 2940 Fax 619 715 5545 E CANADA SALES OFFICE Panasonic Canada Inc PCI 5700 Ambler Drive Mississauga Ontario LAW 2T3 Tel 905 624 5010 Fax 905 624 9880 E GERMANY SALES OFFICE Panasonic Industrial Europe G m b H PIEG Munich Office Hans Pinsel Strasse 2 85540 Haar Tel 89 46159 156 Fax 89 46159 195 E U K SALES OFFICE Panasonic Industrial Europe Ltd PIEL Electric component Group Willoughby Road Bracknell Berkshire RG12 8FP Tel 1344 85 3773 Fax 1344 85 3853 E FRANCE SALES OFFICE Panasonic Industrial Europe G m b H PIEG Paris Office 270 Avenue de President Wilson 93218 La Plaine Saint Denis Cedex Tel 14946 4413 Fax 14946 0007 B ITALY SALES OFFICE Panasonic Industrial Europe G m b H PIEG Milano Office Via Lucini N19 20125 Milano Tel 2678 8266 Fax 2668 8207 E HONG KONG SALES OFFICE Panasonic Shun Hing Industrial Sales Hong Kong Co Ltd PSI HK 11 F Great Eagle
19. Numbers The MN10300 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 ntel format Matsushita format One of these formats is selected by using the notation directive The default is extended C language format Four radices can be used Radix 2 binary Radix 8 octal Radix 10 decimal Radix 16 hexadecimal Any radix can be selected by using the radix directive but only decimal is allowed in extended C language format The default is decimal regardless of coding format To code numbers with a radix other than the default a fixed suffix indicating the radix is appended to the digits E Radices and allowed digits Radix 2 binary Radix 8 octal Radix 10 decimal Radix 16 hexadecimal Pop am a a Ol DO On 7 789 789 ABCD E F or 456789abcdef A B C D E F are hexadecimal digits that correspond to decimal 10 ooooo o oa a to Pp NNN ND w www 11 12 13 14 15 Lower case letters can also be used The next page shows how the various radices and formats are coded Chapter 8 Writing Source Statements E Extended C language format Current default radix Radix Binary Octal Decimal Hexadecimal Binary _ OB101 SS Octal _ 0765 e Decimal x z 789 B Hexadecimal _ _ OXDEF Coding rules Binary Octal Decimal Hexadecimal
20. Repeated input of lines like this is tedious and prone to errors For this reason the very convenient option is provided with the linker With an editor create a file pfile the name can be freely chosen with the following contents The contents of pfile are as follows m g T CODE 00 80000000 T CODE 01 80005000 program3 rf program4 rf T This file is called a parameter file If the option is specified when linking then the linker will read a parameter file and will interpret its contents as command options for execution The two specifications below will be equivalent 1d103 pfile 1d103 m g T CODE 00 80000000 T_CODE_01 80005000 program3 rf program4 rf Assembling And Linking Multiple Sections 41 Chapter 3 Introduction To Operation Bl Generate final list files Let us use the map file m103 map to generate the final listing file and see what happens to the plus signs as103 1 a m103 map program3 asm as103 1 a m103 map program4 asm l option Option to output a list file a option Option to use a map file Specify the map file name after the a option followed by the source file name Based on the link information written in the map file the assembler will reassemble the source file and generate a final list file Let s look at the final list files with all addresses resolved The contents of the final list file program3 Ist are as follows Note that the symbol table is not di
21. The a option is used to generate a final list file with resolved addresses First you must have generated a map file map by specifying the m option with the linker Then using this map file reassemble with the a option to generate the final list file Specifying the wrong map file or specifying the different option from the one assembled at first results in an error E Rules of use The a option is specified with the hyphen option specification character followed by the lower case letter a then followed by the map file name as103 a sample map 1 sample asm When specifying the a option always specify the option to output a list file No Y list file will be generated if only the a option is specified Specify a option and 1 H option adding to the first assembled option for the final list file E Default specification The assembler will not generate a final list file with addresses resolved by a map file 82 Command Options Chapter 5 Using The Assembler 5 3 2 Error Message Options Output error and warning messages in Japanese E 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 Sparc EUC HP9000 Shift JIS PC 9801 Shift JIS DOS V Shift JIS PC AT not supported ii Rules of use To spe
22. and the linker will replace it with the option specifications All options other than the option can be written in a parameter file If a parameter file that does not exist is specified then the linker will display an error message E Rules of use The option does not use the hyphen option specification character It specified alone followed by the parameter file name 1d103 pfile Comments may be inserted into parameter files by starting them with a sharp Y The linker then ignores everything from the sharp to the end of the line E E Default specification None Chapter 6 Using The Linker E Operation example Assume the following contents for pfile o main ex gm T CODE 80000000 progl rf TGDATA f0000000 prog2 rf Then specifying the following two commands is equivalent 1d103 pfile 1d103 o main ex gm T CODE 80000000 progl rf T DATA f 0000000 prog2 rf Command Options 125 Chapter 6 Using The Linker 126 Command Options Display help information on the console E Functional description The h option displays linker command options and their descriptions on the console E Rules of use The h option is specified with the hyphen option specification character followed by the lower case letter h 1d103 h a Even if the h option is not specified input of Id103 alone will also display the help Screen E Default specificatio
23. ls block2 ndif m Coding rules ifgt Syntax for ifge ifge expression block1 felse block2 fendif If the value of expression is positive then block will be assembled If it is not positive and an else directive has been coded then block2 will be assembled ifge If the value of expression is O or positive then block will be assembled If it is negative and an else directive has been coded then block will be assembled Note that 0 is not included in positive numbers m Usage example A source file that uses ifgt is shown below DEVICE TEXT ifgt else endif ifge else endif equ section DEVIC mov mov DEVICE mov mov E 1 CODE 0x01 0x02 0x03 0x04 PUBLIC 1 DO DO D1 D1 Conditional Assembly 219 Chapter 10 Writing Assembler Control Statements The assembled list file is shown below You can see that the value of expression ifgt is 0 so block 2 was assembled for ifgt and block 1 was assembled for ifge ifgt lst Page 1 wx PanaX Series MN103000 Cross Assembler woke Loc Object Line Source 1 DEVICE equ 1 2 i 3 _TEXT section CODE PUBLIC 1 4 ifgt DEVICE 1 5X mov 0x01 D0 6 felse 00000000 8002 7 mov 0x02 D0 8 fendif 9 tifge DEVICE 1 00000002 8503 10 mov 0x03 D1 11 felse 12X mov 0x04 D1 13 fendif 220 Conditional Assembly 1 0 5 6 ifb ifnb B
24. 1 Chapter 17 Appendix List Of Assembler Command Options E Assembler command general format Below is the general format of the command to use when starting the assembler as103 options source filename Contents of brackets may be omitted E Output file options o file name Specify the relocatable object file name to be output as103 o usr obj test rf sample asm 1 Output a list file as103 1 sample asm Li Do not output files included by include to the list file as103 Li 1 sample asm Lm Do not output assembler source created by macro expansion using macro or irp to the list file as103 Lm 1 sample asm Ls Do not output a symbol table to the list file as103 Ls 1 sample asm Lc Do not output source statements that were not assembled due to unfulfilled conditions of conditional assembly to the list file as103 Lc 1 sample asm a map file name Read the map file to output a list file with resolved addresses as103 1 a m103 map sample asm List Of Command Options 339 Chapter 17 Appendix E Error message options Output error and warning messages in Japanese as103 j sample asm Je Output error and warning messages in Japanese using EUC encoding as103 Je sample asm JS Output error and warning messages in Japanese using Shift JIS encoding as103 Js sample asm Jj Output error and warning messages in Japanese using JIS encoding as1
25. 13 2 3 Chapter 13 Error Messages 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 file filename There is more than one input file name on the command line Limit the command line to a single input file 2503 Input file not found There is no input file specification Specify an input file 2504 Output file name not found There is no output file specification Specify an output file 2505 Can t open filename file There is an error in the input output file specifications Alternatively the disk is full or defective In the former case check the file name specifications in the latter check the disk 2506 Memory allocation error The assembler was unable to allocate memory Check the amount of memory available 2507 Data write error The assembler was unable to write data to the output file Check the file system capacity 2508 File is used recursively filename The specified file is used recursively Check the file specifications 2509 Illegal map file information The map file information is incorrect Check the map file information Assembler Errors 281 Chapter 13 Error Messages 1 3 3 Linker Errors The linker displays three types
26. 2 7 Error Correction Using Tag Jumps eene 331 Chapter 16 Notes On The Operating Environment 1 6 1 Purpose Of This Chapter mH This Chapter contains descriptions left out of other Chapters 324 Purpose Of This Chapter Chapter 16 Notes On The Operating Environment 1 5 2 Personal Computer Versions L 16 2 1 Purpose Of This Section This Section contains notes on using the personal computer versions of the software in this package 16 2 2 Operating Environment This system runs on the following personal computers and compatibles Host Machine Operating System PC 9801 MS DOS PC AT MS DOS MS DOS V Personal Coomputer Versions 325 Chapter 16 Notes On The Operating Environment 16 2 3 The installation media for this system contain the following files AS103 EXE assembler AS103 EXE is the assembler For a description see Chapter 5 Using the Assembler LD103 EXE linker LD103 EXE is the linker For a description see Chapter 6 Using the Linker SLIB103 EXE library manager SLIB103 EXE is the library manager a utility for creating library files For a description see Chapter 15 Using the Library Manager EXCV103 EXE file conversion utility This utility converts an executable produced by the linker into a file in Motorola S format Intel HEX format or Matsushita format 326 Personal Computer Versions Chapter 16 Notes On The Operating Environment 1 6 2 4 Installation
27. 3 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 These defaults have been chosen to reflect the most frequently used settings As long as the default settings are acceptable it is possible to omit most options For the details of the interpretation when an option is omitted see the description below for that option Command Options 75 Chapter 5 Using The Assembler 76 9 3 1 Command Options Output File Options o file_name Specify the relocatable object file name to be output E Functional description The o option specifies the relocatable object file name to be output by the assembler If the specified file already exists then its previous contents will be erased If a path name that does not exist is specified then the assembler will display an error message and suspend processing Because the symbol is used as the character for specifying parameter files it cannot be used as the first character of file names E Rules of use The o option is specified with the hyphen option specification character followed by the lower case letter o then either immediately followed by the file name or a space and the file name If the file is to be o
28. 6 Using The Linker The starting address in instruction RAM is given in hexadecimal 1d103 T CODE 80000000 main rf sub rf OVL 1 CODE 40000000 segl rf OVL 2 CODE 40000000 seg2 rf 1d103 T CODE 80000000 main rf sub rf OVL 1 TEXT CONST 40000000 segl rf OVL 2 TEXT CONST 40000000 seg2 rf 1d103 T CODE 80000000 main rf sub rf OVL 1 segl rf OVL 2 TEXTG CODE 40000000 seg2 rf XT CODE 40000000 H E Default specification If there are no OVL options the instruction RAM function is not used and linking proceeds in the normal fashion 132 Instruction RAM Support Chapter 6 Using The Linker PUT symbol address Specify address for extra symbol E Functional description This option is used to specify addresses for the extra symbols used by the instruction RAM function 1 A PUT option is only valid when there are one or more OVL options n B Rules of use The PUT 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 There are two extra symbols overlay table and iram manage The address is in hexadecimal 1d103 T CODE 80000000 main rf sub rf OVL 1 _TEXT 40000000 segl rf PUT __overlay_table a0000000 PUT __iram_manage 30000000 Bi Default specification The default
29. An and displacement d 8 and 16 bit displacements are sign extended MOVHU Dn d SP Transfers the lowest 16 bits of Dm to the memory location specified by SP and displacement d 8 and 16 bit displacements are zero extended 254 List Of Machine Language Instructions Chapter 12 List Of Machine Language Instructions Mnemonic Description of operation Register relative indirect MOVH d Am Dn Transfers with sign extension the 16 bit contents of the memory location specified by Am and displacement d to Dn 8 and 16 bit displacements are sign extended MOVH d SP Dn Transfers with sign extension the 16 bit contents of the memory location specified by SP and displacement d to Dn 8 and 16 bit displacements are zero extended MOVH Dm d An Transfers the lowest 16 bits of Dm to the memory location specified by An and displacement d 8 and 16 bit displacements are sign extended MOVH Dm d SP Transfers the lowest 16 bits of Dm to the memory location specified by SP and displacement d 8 and 16 bit displacements are zero extended Index MOV Di Am Dn Transfers the 32 bit contents of the memory location specified by Di and Am to Dn MOV Di Am An Transfers the 32 bit contents of the memory location specified by Di and Am to An MOV Dnm Di An Transfers the contents of Dm to the memory location specified by Di and An MO
30. CODE same atu ere DM B _CONST CODE section with the highest address TEXT CODE _TEXT CODE LA sees with the same attribute Seet _TEXT CODE _GCONST CODE ROM CODE Remaining sections are merged after the section with the highest address DATA DATA _GCONSTECODE _ROMECODE DATAQDATA OxFFFFFFFF Figure 6 2 Memory Space Layout Command Options 117 Chapter 6 Using The Linker 118 Command Options E Operation example The following are examples of section layout for two files main rf and sub rf in the current directory Both files contain multiple CODE and DATA sections ld103 main rf sub rf The linker merges the CODE sections in the order that they appear in the input files starting at address 0 It then merges the DATA sections in the order in which they appear 1d103 T CODE 80000000 T DATA 0 main rf sub rf The linker merges the DATA sections in the order that they appear in the input files starting at address 0 It then merges the CODE sections in the order in which they appear starting at address 80000000 hex 1d103 T CODE 80000000 main Cf T DATA 0 sub rf 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 sections from main rf do not have an address specification so are merged following the DATA sections from sub rf Chapter 6 Using The Linker r
31. Centre 23 Harbour Road Wanchai Hong Kong Tel 2529 7322 Fax 2865 3697 Matsushita Electronics Corporation 2000 E TAIWAN SALES OFFICE Panasonic Industrial Sales Taiwan Co Ltd PIST Head Office 6th Floor Tai Ping amp First Building No 550 Sec 4 Chung Hsiao E Rd Taipei 10516 Tel 2 2757 1900 Fax 2 2757 1906 Kaohsiung Office 6th Floor Hsien 1st Road Kaohsiung Tel 7 223 5815 Fax 7 224 8362 E SINGAPORE SALES OFFICE Panasonic Semiconductor of South Asia PSSA 300 Beach Road 16 01 The Concourse Singapore 199555 Tel 390 3688 Fax 390 3689 E MALAYSIA SALES OFFICE Panasonic Industrial Company Malaysia Sdn Bhd Head Office PICM Tingkat 16B Menara PKNS PJ No 17 Jalan Yong Shook Lin 46050 Petaling Jaya Selangor Darul Ehsan Malaysia Tel 03 7516606 Fax 03 7516666 Penang Office Suite 20 17 MWE PLAZA No 8 Lebuh Farquhar 10200 Penang Malaysia Tel 04 2625550 Fax 04 2619989 Johore Sales Office 39 01 Jaran Sri Perkasa 2 1 Taman Tampoi Utama Tampoi 81200 Johor Bahru Johor Malaysia Tel 07 241 3822 Fax 07 241 3996 E CHINA SALES OFFICE Panasonic SH Industrial Sales Shenzhen Co Ltd PSI SZ 74 107 International Business amp Exhibition Centre Futian Free Trade Zone Shenzhen 518048 Tel 755 359 8500 Fax 755 359 8516 Panasonic Industrial Shanghai Co Ltd PICS 1F Block A Development Mansion 51 Ri Jing Street Wai Gao Qiao Free Trade Zone Shanghai 200137 T
32. Chapter 10 Writing Assembler Control Statements Conditional Assembly The MN10300 Series 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 The actual program structure of conditional assembly is shown below fif expression identifier parameter etc block 1 to be assembled if condition is true else block 2 to be assembled if condition is false fendif a The contents of brackets from else on can be omitted LI The basic function of conditional assembly is for the assembler to evaluate the condition specified by if and then to select the block to assemble based on the result Conditional assembly is used for the following purposes Different object code for different versions can be output with a single source program Machine language instructions differ depending on the device type Conditional assembly can be included in programs being debugged Conditional Assembly 209 Chapter 10 Writing Assembler Control Statements 210 Conditional Assembly The table below lists the directives used for conditional assembly Directive Condit
33. Directive Statements E Machine language instruction statements Machine language instructions are instructions that the microcontroller directly executes on its own hardware Each machine language code has a corresponding mnemonic Machine language statements are statements written using these mnemonics The assembler converts them into machine language also called object code MN10300 Series instructions have the following features Memory oriented instruction set all calculations performed throughout memory e Single and double operand instructions Minimized instruction set and instruction codes Six addressing formats The example below shows machine language instruction statements Oxff DO datal A0 DO A0 1 D0 E Directive statements Directive statements are not converted to machine language code Within programs they specify assembler attributes to modify program structure and addresses select radices define constants and control list file style The example below shows directive statements global save equ 0x12 section CODE PUBLIC 1 org 100 dc ES end Machine Language Instruction Statements And Directive Statements 141 Chapter 7 Types Of Source Statements 7 4 Assembler Control Statements L Assembler control statements are source statements that control how the assembler processes The assembler provides include directives that include files and conditional asse
34. Dm to the memory location specified by abs16 abs16 is zero extended 256 List Of Machine Language Instructions MOVB Dm abs32 Transfer the lowest 8 bits of Dm to the memory location specified by abs32 Chapter 12 List Of Machine Language Instructions Mnemonic MOVHU abs16 Dn Description of operation Transfer with zero extension the 16 bit contents of the memory location specified by abs16 to Dn abs16 is zero extended MOVHU abs32 Dn Transfer with zero extension the 16 bit contents of the memory location specified by abs32 to Dn MOVHU Dm abs16 Transfer the lowest 16 bits of Dm to the memory location specified by abs16 abs16 is zero extended MOVHU Dm abs32 Absolute Transfer the lowest 16 bits of Dm to the memory location specified by abs32 MOVH abs16 Dn Transfer with sign extension the 16 bit contents of the memory location specified by abs16 to Dn abs16 is zero extended MOVH abs32 Dn Transfer with sign extension the 16 bit contents of the memory location specified by abs32 to Dn MOVH Dm abs16 Transfer the lowest 16 bits of Dm to the memory location specified by abs16 abs 16 is zero extended MOVH Dm abs32 Transfer the lowest 16 bits of Dm to the memory location specified by abs32 E EXTEND sign Mnemonic Description of operation EXT Dn Extend Dn to 64 bits and store
35. E For gt unary operators Attribute Of Operand Attribute Of Result UND UND ABS ABS REL REL EXT EXT Expressions 161 Chapter 8 Writing Source Statements 162 Expressions E For addition operator operandl operand2 addition Operand 2 UND ABS RE EXT UND UND UND UND UND ABS UND ABS RE EXT Operand 1 REL UND REL RE EX EXT UND EXT EXT EX E For subtraction operator operandl operand2 Operand 2 subtraction E UND ABS REL EXT UND UND UND UND UND ABS UND ABS REL EX Operand 1 l REL UND REL REL EX EXT UND EXT EXT EXT MFor lt lt gt gt amp operators operand operator operand2 L lt lt gt gt amp Operand 2 ei UND ABS REL EXT UND UND UND UND UND ABS UND ABS REL EXT Operand 1 i i REL UND REL REL EX EXT UND EXT EXT EX The expressions written in pseud instruction and assembler control instruction Y must be absolute attributes ABS 8 8 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 Reserved words can be in either upper or lower case They m
36. JS Jj SUN Sparc O O O O HP9000 O O O O PC 9800 O X O X DOS V O X O X PC AT X X X X 300 Starting The Library Manager Chapter 15 Using The Library Manager 1 5 3 Command Options 15 3 1 This section describes the options using the following categories Error Message Options j Output error and warning messages in Japanese E Functional description This option causes all error and warning messages and help screens sent to the console to appear in Japanese The character coding depends on the host machine and the operating system Host machine Character coding Sun Sparc EUC HP9000 Shift JIS PC 9801 Shift JIS DOS V Shift JIS PC AT not supported E Rules of use To specify the option enter the hyphen followed by the lower case letter j Slib103 test lib f j testl rf test2 rf test3 rf a This option is not available on PC AT machines n E Default specification The default language used depends on the host machine and the operating system Host machine Message language Sun Sparc English HP9000 English PC 9801 Japanese in Shift JIS DOS V Japanese in Shift JIS PC AT English Command Options 301 Chapter 15 Using The Library Manager 302 Command Options Je Output error and warning messages in Japanese using EUC encoding E Functional description This option causes all error and warning messages and help screens sent to the console to appear in Japanese using
37. Li assembler Option iii ici 78 library file options linker ess 103 122 library tiles aste mis eim eee etes 20 27 298 MA co sett id eges 297 Ibn 292 MA A 293 AA tare ene d uite enis 282 Tinker options oo nro tetat lis 103 list E listoff LOG E EEEee Inc local symbol declaration eee 233 local Symbols init iere EERS 233 location CoUnter nin aoreet erc ses 154 logical AND cuina co easet 157 logicalanstructions eren cinc 00 og oegmomesea 262 logical E 157 logical operators emisario tiara 157 logical OR 5e tarii eso een 157 logical Tisht Shift erat 157 Ls ass mbler Optom joco rte rhet hereto 81 M iri linker Opin On ET 106 ERR LEE 11 IET q ETE 107 LUSIT 107 Machine language code iiiter tse 292 machine language code supplemental information 292 machine language instruction statements 141 171 MACHO eC 227 MACOS A n 23 Triactoc DOG aa rt exe Pda macro Call usina rtt rte dus macro control statements macro definitions i avos ec eri a ee X Ee rina vs Macro xpansiOn EE Macro ANG antenas as macro operators MAKE Zenger e el EE EE EDI ens 19 Vp FAG Sonar Pan 27 Matsushita format file conversion utility 12 Matsushita format numbers I SSA OC EE uer modulo Operator eerte ri
38. Manual and the MN10300 Series Instruction Manual 2302 Illegal string A string contains an illegal character Use only legal characters 2303 Instruction not found A string contains an error Correct the string 2304 Instruction not found The specified instruction does not exist Consult this Manual and the MN10300 Series Instruction Manual 2305 Code size overflow A section contains too much code Divide the section into smaller parts 2306 Multiple define symbol A symbol is defined more than once Use different symbol names 2307 Illegal symbol name There is an error in a symbol name Change the symbol name 2308 Label symbol is reserved word A reserved word is used as a label Change the label name 2309 Label not permitted A label specification is not permitted here Eliminate the label specification Assembler Errors 277 Chapter 13 Error Messages 278 Assembler Errors 2310 Label nothing The label specification is missing Specify a label 2311 Illegal operand size An operand is of the wrong size Check the size specification 2312 2313 Out of section error A specification is not inside a section Move the specification inside a section Section name count over max 255 There are more than 255 s
39. OPERATION Mnemonic Description of operation NOP Do nothing List Of Machine Language Instructions 271 Chapter 12 List Of Machine Language Instructions 272 Chapter 13 Iu M NE 1 Error Messages 13 1 Purpose Of This Chapter pere ee phe adie Ea IER Te ERI SEND 274 13 2 Assembler D i nest nao ett as 275 1322 1 Warning Menage seid deene sees E Ub etait a etre ee go 2775 13 2 2 ls AAA eed etre Pe E een tert E 277 13 2 3 Fatal Error Messages iii ERREUR UMEN 281 13 3 Linker EE 282 13 3 Warririg Messages ipe pe ide 282 13 3 2 Error Message Sis ee eee ed eee tei ee teet retains 283 13 3 3 Fatal Error Mes ages iii t e e ee aet e reped tene ees 285 Chapter 13 Error Messages 1 3 1 Purpose Of This Chapter n Errors messages are divided into three categories depending on the severity of the error Warning messages Error messages Fatal error messages These messages are displayed during assembler and linker 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 After displaying the warning message the assembler or linker continues processing An error message notifies the user of an error and consists of the marker Error the error number and the text of the message A fatal error message notifies the user of a system error and consists of the mark
40. Optimized Conditional Branch Instructions Instruction Branch Range BLT LABEL Relative branch i Branch within 128 to 127 bytes of the PC instruction Unconditional branches and subroutine calls subject to optimization Instruction Type Branch Range BRA label Relative branch instruction Branch within 128 to 127 bytes of the PC CALL label CALLS label JMP label JSR label Absolute branch instruction Branch within the 4 giga byte memory space 54 Usage Example Chapter 4 Optimization Data transfer instructions subject to optimization Instruction Type Branch Range MOV abs An MOV abs Dn MOV An abs MOV Dn abs MOVBU abs Dn MOVBU Dn abs MOVB abs Dn MOVB Dn abs MOVHU abs Dn MOVHU Dn abs MOVH abs Dn MOVH Dn abs Absolute addressing Branches possible to anywhere in the 4 gigabyte memory space MOV d An An MOV d An Dn MOV d SP An MOV d SP Dn MOV An d An MOV An d SP MOV Dn d An MOV Dn d SP MOVBU d An Dn MOVBU d SP Dn MOVBU Dn d An MOVBU Dn d SP MOVB d An Dn MOVB d SP Dn MOVB Dn d An MOVB Dn d SP MOVHU d An Dn MOVHU d SP Dn MOVHU Dn d An MOVHU Dn d SP MOVH d An Dn MOVH d SP Dn MOVH Dn d An MOVH Dn d SP Register relat
41. PC AT and compatibles because of such differences as the ability to display Japanese this Manual indicates a machine running the English only MS DOS operating system as a PC AT and one running MS DOS V as a DOS V machine Installing this system requires approximately 700 kilobytes of free disk space Note that this is just the space required for the files in the system distribution Additional space is required for development Operating Environment 3 Chapter 1 Getting Started 4 1 3 File Organization 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 the Assembler 1d103 linker 1d103 is the linker For a description see Chapter 6 Using the Linker slib103 library manager slib103 is the library manager a utility for creating library files For a description see Chapter 15 Using the Library Manager excv103 file conversion utility This utility converts an executable produced by the linker into a file in Motorola S format Intel HEX format or Matsushita format In addition to the above files the installation media may contain a README or README DCC file containing late breaking news missing from this Manual Please read this file carefully before proceeding Chapter 1 Getting Started 1 4 Installation For the installation media installation procedures and notes on instal
42. The following explanation illustrates a simple example of only one section In this example you will assemble and link two source files program1 asm and program2 asm These two files have related external references and external definitions where the subroutine of program2 asm is called from programl asm Therefore the final list files cannot be created just by assembling programl asm In this example you will generate with the linker a map file and then generate the final list files Ml Create source files First create the source files Using an editor create the two programs shown below program1 asm and program2 asm The contents of program1 asm are as follows global data set CODE section CODE PUBLIC 1 main mov 0 A0 mov Oxff DO mov 0x80 D1 jsr data set bra main DATA section DATA PUBLIC 4 datal ds 4 end programl asm consists of a section called CODE attribute CODE link type PUBLIC and a section called DATA attribute DATA link type PUBLIC Basic Operation Of Assembler And Linker 29 Chapter 3 Introduction To Operation The contents of program2 asm are as follows global CODE section data set mov data set loop cmp bcc mov add add bra data set end rts end data set CODE PUBLIC 1 0 D2 D1 D2 data set end DO A0 1 D2 2 A0 data set loop program2 asm also consists of a section called CODE attribute CODE link type PUBLIC
43. a program Choose a common format for coding comment statements 20 Programming With The Assembler Chapter 2 Program Development Flow E Optimization This Series optimizations apply to unconditional branches data transfer instructions arithmetic instructions logical instructions bit manipulation instructions and user defined instructions Unconditional branches that undergo optimization Data transfer arithmetic logical bit manipulation and user defined instructions that undergo optimization Coding is not a simple task if the programmer must always select the optimal instruction from the above instructions In particular it is nearly impossible to select the optimal instructions when coding a program divided between files in section format The optimization functions provide a solution to these problems The assembler and linker use them to produce the optimal code no matter what the source code The assembler evaluates the source statement notation It evaluates the immediate data memory specifications and displacement data appearing as operands to a data transfer arithmetic logical bit manipulation and user defined instructions and selects the shortest version of the instruction The assembler also examines unconditional branches choosing the shortest versions for the CALL CALLS JMP and JSR instructions The linker evaluates instructions that were the object of optimization and selects the optimal codes
44. adds a line number to each source statement E Line number supplemental information A line number can provide additional information in the form of preceding periods and the suffixes X or Line numbers preceded by a period indicate that the line was included by an include directive The number of periods indicate the nesting levels of include directives For example means the line was included by an include directive that itself was within an include file 10 include 10 include include 10 include include include If the Li option is added when the assembler is invoked then output of lines included by include directives will be suppressed The X suffix on the line number indicates a line that the assembler ignores and does not process During conditional assembly this is used for lines in the block of the unfulfilled condition If the Lc option is added when the assembler is invoked then output of blocks of unfulfilled conditions will be suppressed Line numbers followed by a plus sign indicate the line was a result of macro expansion In addition to macro expansions defined by macro directives a plus sign is added to expansions by irp and rept directives Reading List Files 293 Chapter 14 Reading List Files E Source statement The source statements of the source file are output as is If the Lm option is added when the assembler is invoked then output of source statem
45. and error messages Bl How to read Heading Chapter 16 Notes On The Operating Environment 16 2 5 Environment Settings Before using the MN10300 Series Cross Assembler verify or change the following two files If FILES and BUFFER 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 Program example FILES 20 BUFFERS 20 Usage note Be sure to make these settings If the assembler is started without them then the lt error message bad tmpbss w will be output and processing will stop This means that the number of files that can be opened simultaneously is insufficient Supplementary explanation Terminology CONFIG SYS e This is the file that sets the MS DOS operating environment FILES specifies the number of files that can be read and written simultaneously BUFFERS specifies the size of memory used for reading writing disks E AUTOEXEC BAT To be able to run the software simply by typing in its name include its directory in the path search list given by the environment variable PATH Under MS DOS adding the directory in which the software is installed to the PATH variable and activating the new value for PATH allows you to run the programs in this system simply by entering their names SET PATH A usr local bin 328 Personal C
46. and warning messages in Japanese using Shift JIS encoding Jj Output error and warning messages in Japanese using JIS encoding Output error and warning messages in English W number Do not output warning messages of the specified number Wall Do not output any warning messages Program c Create a new library file If a file with the same name already s exists the library manager displays an update confirmation options P prompt f Force creation of a library file Starting The Library Manager 299 Chapter 15 Using The Library Manager Option type Symbol Description Functional a Add the specified relocatable object file to the library file options d Delete the specified relocatable object file from the library file p Output information about externally defined symbols in the library file r Replace the specified relocatable object file in the library file t Output a list of the relocatable object files that make up the library file D Extract the specified relocatable object file from the library file Other Gfilename Specify a parameter file options h Display a listing of available library manager s options on the console V Display the library manager s version number on the console E Note The Japanese language display options vary with the host machine and operating system under which the library manager runs Host machine j Je
47. be the value of the expression coded in the operand When that name is coded in the operand of machine language instructions the assembler will reference the name s value System constants often used in programs memory size clock frequency etc can be assigned to names that describe those values MEMORY equ 0x20 MOTOR equ 10 STOP equ 0500001000 BASE equ 0x1000 This allows numbers used in programs to be coded as descriptive names instead making programs easier to read Furthermore values can be changed just by modifying the equ directive which in turn changes the data wherever it is used This makes programs easier to maintain E Operand coding rules Names defined in other programs cannot be specified within expression Names defined once with the equ directive cannot be defined again No memory area is reserved when an equ directive statement is executed 194 Writing Directive Statements Chapter 9 Writing Machine Language Instruction Statements And Directive Statements Symbols with unresolved values cannot be coded in the operand In the following example the value of ram1 is not resolved at the point where the value of ram2 is to be resolved so the assembler will generate an error Error example ram2 equ ram1 0x1 rami equ 0x10 By changing the order such that the value of ram1 is resolved first no error will occur No error example rami equ 0x10 ram2 equ ram1 0x1 E Usage example Below is a
48. coded in the operand must result in the attribute abs absolute For a discussion of attributes of expressions see Chapter 8 Writing Source Statements Section 8 7 Expressions Section 8 7 4 Expression Attributes The calculated result of the expression coded in the operand must be either 2 8 10 or 16 The radix of the expression in the operand is always 10 decimal regardless of the current default radix If the expression results in a number that does not specify a radix then the assembler will generate an error and ignore this directive 186 Writing Directive Statements ill Usage example Below is an example use of the radix directive Chapter 9 Writing Machine Language Instruction Statements And Directive Statements radix radix 16 BINARY Writing Directive Statements 187 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements 9 4 10 dc E Syntax label operation operand name dc constant expression constant expression E Functional description The dc directive is used to define constants in a memory area The 8 bit constant specified by the operand will be stored at the location of the statement specifying this directive When a name is coded for the label the assembler will assign the current location counter value to that name E Operand coding rules The expression coded in the operand must result in the attribute abs absolute For a di
49. counter E Conditional BRANCH Description of operation If ZF 1 execute a relative branch to the address specified by label Range 128 to 127 If ZF 0 execute next instruction If ZF 0 execute a relative branch to the address specified by label Range 128 to 127 If ZF 1 execute next instruction If ZF 0 and NF VF execute a relative branch to the address specified by label Range 128 to 127 If ZF 1 or NF VF execute next instruction If NF VF execute a relative branch to the address specified by label Range 128 to 127 If NF VF execute next instruction Mnemonic Meaning BEQ label ZF 1 BNE label ZF 0 BGT label lt signed BGE label lt signed BLE label 2 signed If CF 1 or ZF 1 execute a relative branch to the address specified by label Range 128 to 127 If CF 0 and ZF 0 execute next instruction 268 List Of Machine Language Instructions Chapter 12 List Of Machine Language Instructions Mnemonic Meaning Description of operation BLT label signed If NF 1 and VF 1 or NF 0 and VF 0 execute a relative branch to the address specified by label Range 128 to 127 If NF 1 and VF 0 or NF 0 and VF 1 execute next instruction BHI label unsigned If CF 0 and ZF 0 execute a relative branch to the address specified by label Range 128 to 127 If CF 1 or Z
50. 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 It generates an executable format file and depending on option specifications a map file Library files are collections of relocatable object files of frequently used programs and hardware interface programs Only needed modules are specified to have the linker extract the appropriate relocatable object files from library files and load them into the executable format file Several library files are provided but you can maintain them or newly create them yourself Refer to chapter 15 Using The Library Manager for details You cannot force different extensions for map files and list files You can only specify whether or not to output these files However the extensions of relocatable object files and the executable format file can be changed with assembler and linker option specifications In this case the file specification must include the extension 28 Files Used By Assembler And Linker 3 3 Chapter 3 Introduction To Operation Basic Operation Of The Assembler And Linker The MN10300 Series 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
51. file management table created by linker External memory Extra symbol iram manage EE I RF file specified H CG by T option O Transfer g rogram g d 5 H Assigned at the highest octo adeps arci 9 address of CODE attribute o S t RF file specified Sc Instruction RAM I i eferring instruction nstruction i by OVL option RAM addresses i Lune E NENG S m Pi t ferred 1 m o rograms are transterre i RF file specified Program 1 to instruction RAM in by OVL option z accordance with the ES E instruction RAM program r A Tomata management table generated table El information _____ 2 P go bo rogram kn g i Program 1 management information Program 2 management Extra symbol overlay table Y information Instruction RAM program management table portion Figure 6 3 Layout Image for Instruction RAM and External Memory When the instruction RAM function is in use the linker reserves the extra symbol Y names overlay table and iram manage for its own use so do not use z these names for ordinary symbols Instruction RAM Support 129 Chapter 6 Using The Linker 130 B File layout and transfer operations for an instruction RAM executable file Instruction RAM Support 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 foll
52. 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 If the file does not exist then the library manager will output a warning message and continue processing When no relocatable object file name is specified all relocatable object files that exist in the library file will be extracted E Rules of use To specify the option enter the hyphen followed by the lower case letter x Slib103 test lib x testl rf E Operation example Slib103 test lib x testl rf Slib103 test lib x The first example checks whether or not the file testl rf exists in test lib and if it does extracts testl rf The second example extracts all relocatable object files in test lib When slib103 is used to group relocatable object files into libraries it will store a them with debug information in the relocatable object files deleted if such debug n information exists Therefore when an ordinary relocatable object file is placed in a library it will be the same as that file when extracted from the library However if there will be differences if the relocatable file was generated with the g option Also be aware that when an object file is extracted it will overwrite any file of the same name existing in the current directory 15 3
53. for the extra symbol iram manage is the address 0 that for overlay table the address following the last section in the external memory Instruction RAM Support 133 Chapter 6 Using The 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 progl rf prog2 rf and prog3 rf in the current directory All files contain multiple CODE and DATA sections E Assigning to different addresses in instruction RAM 1d103 T CODE 80000000 T DATA 1000 main rf sub rf OVL 1 TEXT 40001000 progl rf OVL 2 TEXT 40002000 prog2 rf OVL 3 TEXT 40003000 prog3 rf Ka The linker first places all sections with the CODE attribute from main rf and sub rf in the order that they appear in the input files beginning at the address 80000000 hex It then places all sections with the DATA attribute from all input files beginning at the address 1000 hex The linker places all sections other than those named TEXT after the same sections in main rf and sub rf according to the T option placement rules See Section 6 3 3 The linker resolves all internal references within the TEXT sections of progl rf prog2 rf and prog3 rf so that the sections are ready to run in the specified instruction RAM addresses above 40000000 hex but places the sections in the order that they appear in the input files beginning at t
54. in Japanese using EUC coding E Rules of use The Je option is specified with the hyphen option specification character followed by the upper case letter J and the lower case letter e The two letters together function as a single option 1d103 Je sample rf a This option is not available on PC 9801 DOS V or PC AT machines n E Default specification The default language used depends on the host machine and the operating system Host machine Character coding Sun Sparc English HP9000 English PC 9801 Japanese in Shift JIS DOS V Japanese in Shift JIS PC AT English It is also possible to change the default message specification with an entry in the linker s start up file See Chapter 1 Getting Started Section 1 5 Setup Command Options 109 Chapter 6 Using The Linker 110 Command Options Js Output error and warning messages in Japanese using Shift JIS coding E 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 E Rules of use The Js option is specified with the hyphen option specification character followed by the upper case letter J and the lower case letter s The two letters together function as a single option 1d103 Js sample rf a This option is not available on PC AT machines H E Default specification The default language used depends o
55. linker bit manipulation instructions s s s eese blank Statements 1 rte SEENEN branching instructions C c library MANAGE E 307 Character constants necesse ree dsd 151 CLANC 179 command options library manager 301 comment Telde comment statements Compiler nana ee E conditional assembly conditional assembly and linking sss 45 conditional branch instructions ooooccocccnocnninnncnonos 268 269 CONFIG SYS siii mt tcu t dais 328 CUEN MIRE CIOLY onere eiae ete er oS D Pate terra 3l D D identifier assembler option 91 d library manager acte ia 310 data move instructions c cooonncnncnncnnonocnconcnncnncnnnoncnnconannconos 252 dao dn genes 188 n 193 default interpretations cin acierta nieto 71 default valles ui isla ds T3 HdE NNE edo fr rri eee pee en t AE differences from the workstation versions GIPECUIV E VISIO esca err erret or iere ee rer er er gerendo E e assembler Option rentre ener rennes 87 library MANAGET AAA ren apreis deaceiss 305 linker optiOti eerie erectos tarte A 112 Ed linker option 5 eerte tette rnnt nennen 121 Ed OPTION E 11 O 19 Er I k t OoptOD oi dt 120 EWOP MON 2 Rn Sohn abi en RN 10 error InfOrmatiORk 1 oso neret SEN renean one aeg TI error message options assembler
56. of messages warning messages error messages and fatal error 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 values for all sections with the same name agree across files 3002 Extra symbol name address aligned address The linker s alignment processing has changed the address assigned to the specified extra symbol Generate a map file and check the value for the extra symbol 3003 Address overlay with IRAM manager A section address overlaps the area assigned to the instruction RAM status management table Generate a map file check the addresses and change the command line options to eliminate the overlap 282 Linker Errors 13 3 2 Error Messages Chapter 13 Error Messages 3300 Bad option switch op There is an error in the option specifications Check the option specifications 3301 No parameter for op option There is no parameter for the specified option Check the command line options 3302 Illegal parameter wi
57. option enter the hyphen followed by the lower case letter h slib103 h E Default specification The default is not to display this help information on the console If the h option is not used then input of slib103 will also display help information Chapter 15 Using The Library Manager V Display the library manager s version number on the console E Functional description This option displays the library manager s version number on the console E Rules of use To specify the option enter the hyphen followed by the lower case letter v slib103 v E Default specification The default is to not display the version number Command Options 317 Chapter 15 Using The Library Manager 15 4 318 Error Messages Error Messages The library manager displays three types of messages warning messages error messages and fatal error messages These messages are displayed 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 After displaying the warning message the library manager continues processing An error message notifies the user of an error and consists of the marker error the error number and the text of the message A fatal error message notifies the user of a system error and consists of the marker Fatal error the error number and the text of the message The l
58. processing They specify include files 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 They are read in during assembly Conditional assembly allows the assembler to evaluate conditions and then to select a block of statements to assemble depending on whether the conditions are fulfilled or not This chapter describes these functions and how to code them and provides examples of actual use Many directives used in conditional assembly are used only within macro definitions Refer to chapter 11 Writing Macro Statements as needed E Common coding rules Here are some rules common to coding of all assembly control statements The assembler directive should be coded from the first column of its statement Both upper and lower case letters can be used The characters that can be used as identifiers are upper and lower case letter digits and underscores However the first character must not be a digit Further conditional assembly directives can be used within a block of conditional assembly directives Up to 255 nesting levels are allowed The else directive and the second block can be omitted Refer to section 10 5 Conditional Assembly for details about the second block An expression combines symbols self reference address symbols and constants with operators into an equation that
59. the file name specification Check the file name specification 2324 2325 Too many else There are too many else Check the else specifications Too many fif or tfendif The if and endif are not balanced Check the if and endif 2326 Missing endm A macro statement is missing its closing endm Check all macro and endm statements 2327 Macro symbol is used recursively A macro is defined recursively Check the macro definitions 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 Assembler Errors 2 9 Chapter 13 Error Messages 280 Assembler Errors 2330 Line too long A source statement exceeds the length limit Edit the source statement so that its length is within the limit 2331 No optimizing information The map file does not contain optimization information Check the map file 2332 Error in configure file There is an error in the start up file Correct the start up file 2333 Illegal map file value The map file and the assembly result disagree Check the value in the map file
60. 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 EXTHU Dn Zero extend the lowest 16 bits of Dn to fill Dn List Of Machine Language Instructions 257 Chapter 12 List Of Machine Language Instructions E MOVM Mnemonic Description of operation MOVM SP regs Load the specified registers from a block in memory MOVM regs SP Save the specified registers to a block in memory B CLR Mnemonic Description of operation CLR Dn Clear Dn to zero 258 List Of Machine Language Instructions Chapter 12 List Of Machine Language Instructions 12 3 2 Arithmetic Instructions a LI E B ADD Mnemonic Description of operation 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 ADD imm Dn Add the sign extended imm8 sign extended imm16 or imm32 to the contents of Dn and store the result in Dn ADD imm An Add the sign extended imm8 sign extended imm16 or imm32 to the contents of An and store the result in An ADD imm SP Add the sign extended imm8 sign extended imm16 or imm32 to the co
61. used within macro definitions 348 List Of Assembler Control Statements Chapter 17 Appendix Syntax Function amp Notes ifneq parameterl parameter2 Assembles block1 if parameter and block parameter2 are not equal Assembles block else if they are equal nothing will be assembled if block2 there is no else At least one or the other of Hendif parameterl and parameter2 must be a dummy parameter within a macro definition ifeq can only be used within macro definitions iflt expression Assembles block if the expression is block negative Assembles block2 if it is not Zelse negative nothing will be assembled if there block2 is no else endif ifle expression Assembles block if the expression is zero or block negative Assembles block2 if it is positive Helse nothing will be assembled if there is no block2 else endif ifgt expression Assembles block1 if the expression is block1 positive Assembles block2 if it is not else positive nothing will be assembled if there is block2 no Zelse endif ifge expression Assembles block if the expression is zero or block1 positive Assembles block2 if it is negative else nothing will be assembled if there is no block2 else endif ifb dummy_parameter Assembles block if the dummy parameter block is a null character Assembles block2 if it is else not nothing will be assembled if there is no block2 else ifb can only be used wit
62. uses an example to show how to run the assembler and linker Next it explains assembler and linker use when assembler control statements and macro instructions are included for high level operations After reading this chapter once through and trying actual operation you will have mastered basic assembler and linker operation 26 Purpose Of This Chapter Chapter 3 Introduction To Operation 3 2 Files Used By The Assembler And Linker n Figure 3 1 shows the inter relationships of the files used by the assembler and linker Map file sample map Library file sample lib Source file sample asm e Assembler Include file sample h Map file m103 map Q List file sample Ist Relocatable object files samplerf Executable file m103 ex Figure 3 1 Files Used The assembler inputs source files and include files and outputs relocatable object files Include files are not special files but are just files that comprise parts of the source file They are incorporated into assembly at the location of include directives defined within source statements Files Used By Assembler And Linker 27 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
63. 0 Conditional Assembly And Linking 45 Chapter 3 Introduction To Operation The operation of this program is meaningless The program will be used instead to explain program structure as it pertains to conditional assembly The define DEBUG on the first line selects DEBUG as a condition by defining the identifier DEBUG In the assembly control block starting with ifdef DEBUG on line 13 the instructions between ifdef to else will be assembled if DEBUG has been defined and the instructions between else to endif will be assembled if DEBUG is undefined In this example DEBUG was defined on line 1 so the instructions in the defined block will be assembled This program also uses a macro control directive Lines 4 to 8 are the macro definition The macro s name is dat set and it has two parameters adr dat E Assemble and link Assemble and link the program that you have created as103 program5 asm 1d103 m T CODE 40000000 program5 rf as103 1 a m103 map program5 asm The first assembly generates the relocatable object file program5 rf The second assembly generates the final list file program5 Ist Let s look at the contents of the list file that was generated 46 Conditional Assembly And Linking Chapter 3 Introduction To Operation The contents of the final list file program5 lst are as follows Note that the symbol table is not displayed program5 lst KRIK PanaX Series MN103000 Cross Assembler Loc 40
64. 000000 40000000 40000006 40000008 4000000C 40000010 Object FCDC0C000040 8011 60 00000000 00000000 Line z o A o oO 5 WN np 10 11 12 13 14 14 14 15 16X 17 18 19 20 21 22 kK Source define DEBUG dat_set macro mov mov mov endm _CODE section main ifdef DEBUG dat_set mov mov mov felse dat set fendif _DATA section datal dd data2 dd end Page 1 adr dat adr A0 dat DO DO A0 CODE PUBLIC 1 datal 0x11 datal A0 Ox11 D0 DO A0 datal 0x22 DATA PUBLIC 4 0 0 Line number 14 extends over four lines This indicates lines where macro expansion has been performed An M is added before the line number where the macro instruction statement is shown and a is added after the line numbers where the instruction statements from macro expansion are shown DEBUG has been defined so the block between ifdef to else was assembled Line number 16 has an X after the line number This indicates a statement that was not assembled because a condition was not fulfilled Conditional Assembly And Linking 47 Chapter 3 Introduction To Operation 48 lil Select false condition assemble and link Make the define source statement line into a comment line or just delete it Then assemble and link with the same procedure as before as103 14103 as103 The contents of the final list file program5 Ist are as follows Note that the symbol table is not displa
65. 0000016 T data set 40000000 T main 40000024 D datal 32 Basic Operation Of Assembler And Linker Chapter 3 Introduction To Operation The contents of the final list file program2 Ist are as follows KKK Loc 400000 400000 400000 400000 400000 400000 400000 400000 b c e 40000020 40000022 40000022 Symbol Table Object 8A00 A6 C60A 60 2A01 2002 CAF8 FOFC 40000016 40000018 40000022 program2 1st PanaX Series MN103000 Cross Assembler eee Line Source 1 global 2 3 _CODE section 4 data set 5 mov 6 7 data set loop 8 cmp 9 bcc 0 1 mov 2 add 3 add 4 bra 5 6 data set end q rts 8 end program2 1st data set data set loop data set end Page 1 data set CODE PUBLIC 1 0 D2 D1 D2 data set end DO A0 1 D2 2 A0 data_set_loop Page 2 Here is a simple explanation of how to read the list files A list file shows two items of information Source statements and machine language code e Symbol table Source statements and their corresponding machine language code are further divided into Loc Object Line and Source headings Basic Operation Of Assembler And Linker 33 Chapter 3 Introduction To Operation The Loc heading gives location counter values which show execution addresses in the final list files program1 Ist starts from location 40000000 hex and program2 1st starts from location 40000016 he
66. 004 DC00000000 11 jmp 200002 00000009 950 1 mov Al 0000000b 9000 1 2200002 mov 0 AO M 12 loc M 12 local labl lab2 0000000d 800 2 mov DO 0000000f A000 2 200003 cmp 0 DO 00000011 DC00000000 12 jmp 00004 00000016 950 2 mov Al 00000018 9000 2 27200004 mov 0 AO 234 Local Symbol Declaration local 11 6 Chapter 11 Writing Macro Control Statements Forced Termination Of Macro Expansion exitm E Syntax macro name macro parameter ifndef identifier exitm endif endm E 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 then expansion beyond endif will be performed The conditions are reversed when ifdef is used E Coding rules In addition to ifdef to endif all directives listed in chapter 10 Writing Assembler Control Statements section 10 5 Conditional Assembly can be used The exitm directive can be used at any location The assembler will terminate macro expansion after it appears The exitm directive can only be used within macro definitions E Usage example Usage example with ifb directive A source file is shown below The identifier TEST is used for the condition In main the first macro call is made with TEST undefined This causes exitm to be executed so jsr debug will no
67. 03 Jj sample asm Output error and warning messages in English as103 e sample asm W number Do not output warning messages of the specified number as103 W 2016 sample asm Wall Do not output any warning messages as103 Wall sample asm E Preprocessor options I path name Specify the path name of the directory that contains files specified by include as103 I usr defs sample asm D identifier Specify an identifier to be used by ifdef during conditional assembly as103 D VERSION sample asm 340 List Of Command Options Chapter 17 Appendix E Program generation options g Output debug information to the relocatable object file as103 g sample asm Od Turn off optimization as103 Od sample asm O Turn on optimization as103 O sample asm il Others h Display a listing of available assembler options on the console as103 h v Display the assembler s version number on the console as103 v List Of Command Options 341 Chapter 17 Appendix 17 2 2 List Of Linker Command Options E Linker command general format Below is the general format of the command to use when starting the linker 1d103 options filename Contents of brackets may be omitted Ellipses indicate item may be repeated E Output file options o filename Specify the path name and file name of the executable format file to b
68. 03 v E Default specification The default is to not display the version number 9 4 Chapter 5 Using The Assembler Operation example 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 With the assembler again use the map file to generate a final list file 1st with addresses resolved by the linker E Program assembly Generation of a list file with the option on the first assembly will not resolve addresses so you would not do so unless you have some special purpose For the same reason the Li Lm and Lc options are also not used as103 g sample asm The above command assembles the source file sample asm in the current directory and generates a relocatable object file sample rf with debug information in the current directory as103 g D VERSION o test rf user source main asm The above command assembles the source file main asm in the user source directory For conditional assembly of the source file assembly will proceed as though VERSION were defined The above command also generates a relocatable object file named test rf with debug information in the current directory as103 g o test rf I user lib sample asm The above example assembles the source file sample asm in the current directory Files s
69. 10 5 Conditional Assembly sss nennen nennen 209 ue te ER Ma oio eee enu Dem oen 211 10 5 2 ER O ei eet 213 10 5 9 File FING uie a e regelt 215 10 5 4 FIAT FAR inet me in dee 217 10 5 53fifgt Ife iui uicit e reet te cte tre dre 219 10 56 fb Hibisco da 221 11 Writing Macro Control Statements 11 1 Purpose Of This Chapter daniera aia 226 11 2 Macro Definition macro endm eme 227 11 3 Macro Calls And Expansion seseeeneeeennennen ene 229 11 4 Macro Opt neri e ORO eR PI NEEN 231 11 5 Local Symbol Declaration local 233 11 6 Forced Termination Of Macro Expansion exitm sess 235 11 7 Purging Macro Definitions purge coooocccnncccnnoncconaccnonanccnnnnrnn cnn cnc nara nnnnn rca 237 R M EE 238 Hire EP E 240 MN10300 Cross Assembler 12 List Of Machine Language Instructions 12 1 Purpose Of This Chapter nnne nennen 246 12 2 Addressing Modes EE 247 12 3 List Of Machine Language Instructions seeeeeen 251 12 3 1 Data Move Instruchons AA 252 12 9 2 Arithmetic Iristructions 3 trt dei 259 12 9 3 Logical Instructions ete 262 12 3 4 Bit Manipulation Instruction oooonnccnnnononnncccnnorncnnarnno narco raro ro nnnr nro 265 12 3 5 Branching Instructions A 267 12 3 6 User Defined Instructions AA 271 12 37 Other INStruCtionS 1 ica ia 271 13 Error Messages 13 1 Purpose Of This Chapter AA 274 13 2 Assem
70. 16 Notes On The Operating Environment zech ke Chapter 17 Appendix Index Table of Contents 1 Getting Started 1 1 Purpose Of This Chapter AA 2 1 2 Operating Environment nennen nennen 3 1 3 File Organization 14 M WMS tat OM P spero 6 1 6 File Conversion Utility AA 12 2 Program Development Flow 2 1 Purpose Of This Chiapter ii t is 16 2 2 Program Development Flow eese nnns 17 2 3 Programming With The Assembler s 19 3 Introduction To Operation 3 1 Purpose Of This Chapter sse 26 3 2 Files Used By Assembler And Linker AAA 27 3 3 Basic Operation Of Assembler and Linker ssseeeeene 29 3 4 Assembling And Linking Multiple Sections oonnociccnninnnccnncconncannccnnncnnnrcnnnncnnnos 35 3 5 Conditional Assembly And Linking 45 4 Optimization 4 1 Purpose Of This Chapter ied RR e ERES Re FRIES 52 4 2 Rules Of Usage eich ue e Moa Ld LE Ie Sede cie Pete Sdn EES 53 GMT Elle EE 54 5 Using The Assembler 5 1 Purpose Of This Chapter nennen rennen 70 5 2 Starting The Assembler iia cited ape minorities 71 segersmliuesBarii m 75 5 3 Output File OptIOrS coissins annienta n volet dude ato edes 76 5 3 2 Error Message Opttons nennen 83 5 3 3 Preprocessor OptiONS nnne neret 90 MN10300 Cross Assembler 5 3 4 Program Generation Optlons sese 92 5 3 5 OthierOptions n ctia A tn Ede gd 9
71. 2 An An MOV d An Dn MOV d8 An Dn MOV d16 An Dn MOV d32 An Dn MOV d SP An MOV d8 SP An MOV d16 SP An MOV d32 SP An MOV d SP Dn MOV d8 SP Dn MOV d16 SP Dn MOV d32 SP Dn MOV An abs MOV An abs 16 MOV An abs32 MOV An d An MOV An d8 An MOV An d16 An MOV An d32 An MOV An d SP MOV An d8 SP MOV An d16 SP MOV An d32 SP MOV Dn abs MOV Dn abs 16 MOV Dn abs32 MOV Dn d An MOV Dn d8 An MOV Dn d16 An MOV Dn d32 An MOV Dn d SP MOV Dn d8 SP MOV Dn d16 SP MOV Dn d32 SP MOV imm An MOV immg8 An MOV imm16 An MOV imm32 An MOV imm Dn MOV mm Dn MOV imm16 Dn MOV imm32 Dn Usage Example 61 Chapter 4 Optimization Source Instruction First Candidate Second Candidate Third Candidate MOVBU abs Dn MOVBU abs16 Dn MOVBU abs32 Dn MOVBU d An Dn MOVBU d8 An Dn MOVBU d16 An Dn MOVBU d32 An Dn MOVBU d SP Dn MOVBU d8 SP Dn MOVBU d16 SP Dn MOVBU d32 SP Dn MOVBU Dn abs MOVBU Dn abs16 MOVBU Dn abs32 MOVBU Dn d An MOVBU Dn d8 An MOVBU Dn d16 An MOVBU Dn d32 An MOVBU Dn d SP MOVBU Dn d8 SP MOVBU Dn d16 SP MOVBU Dn d32 SP MOVB abs Dn MOVB abs16 Dn MOVB abs32 Dn MOVB d An Dn MOVB d8 An Dn MOVB d16 An Dn MOVB d32 An Dn MOVB d SP Dn MOVB d8 SP Dn MOVB d16 SP Dn MOVB d32 SP Dn MOVB Dn a
72. 4 Chapter 15 Using The Library Manager Other Options filename Specify a parameter file E 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 If a parameter file that doesn t exist is specified then the library manager will display an error message E Rules of use This option uses neither a hyphen nor an option letter Enter a lone followed by the name of the parameter file E Default specification There is no default specification E Operation example Assume that the file pfile contains the following line test lib f testl rf test2 rf test3 rf a lib103 pfile lib103 test lib f testl rf test2 rf test3 rf 10 The above command line then produces the same results as the following one Command Options 315 Chapter 15 Using The Library Manager 316 Command Options h Display a listing of available library manager s options on the console E 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 E Rules of use To specify the
73. 5 5 4 Operation Example oia de 97 6 Using The Linker 6 1 Purpose Of This Chapter EE 100 6 2 Starting The BEE 101 6 3 Command Options is IE 104 6 3 1 Output File Options n me free tee 105 6 3 2 Error Message OptiONS nnns 108 6 3 3 Program Generation Options ceceeceeeceeeeeeseeeeeeeeeneeseaeeeeeesaeeeeeenaees 115 6 3 4 Library File Options AAA 122 6 3 5 Other Opt cistitis 124 6 4 Instruction RAM Gupport nennen nre 127 6 4 1 Structure Of IRAM Support Executable File ssessss 128 6 4 2 IRAM Support Options conc cnn cc nnncrnnccnncnnnno 131 6 4 3 Operation Exvamples ANA 134 7 Types Of Source Statements 7 1 Purpose Of This Chapter EE 138 Kee LE Lu Reie 139 7 3 Machine Language Instruction Statements And Directive Statements 141 7 4 Assembler Control Statements nenne 142 7 5 Macro Control Statements A 143 7 6 ComMent Statements vets ne rr otn Uefa I DEDERE AA 144 7 7 Blank Statements tic ate aee nhe ede dein 144 8 Writing Source Statements 8 1 Purpose Of This Chapters irinta m kf titt etd 146 8 2 Permitted Characters nnne nnne nennen nennen nni 147 8 9 nne 148 CR ele gn TEE 151 MN10300 Cross Assembler 8 5 Address Consta eio ner monete ee Pte ed 153 8 6 Location Counter Ld ee danda ete ebd 154 8 7 Exptessioris i oi eu e e I RR ER RR LEER EL ER enfe 155 8 7 1 Operators ied dfe dade ee hun 156 8 7 2 Expression Evaluation coito eis 1
74. 58 8 7 3 Expression SMA deco eem pne n HE DEM 160 8 7 4 Expression Attributes 161 8 8 Reserved Words eere etre dede dotted rane s 163 9 Writing Machine Language Instruction Statements And Directive Statements 9 1 Purpose Of This Chapter ANE 166 9 2 Instruction Statement Fields A 167 9 2 1 Writing The Label Field 168 9 2 2 Writing The Operation Pie 169 9 2 3 Writing The Operand Pied 169 9 2 4 Writing The Comment Field 170 9 3 Writing Machine Language Instruction Statements oooooccinococinoccccooocnnnnonnnonns 171 9 4 Writing Directive Giatememts A 172 A A ee es dg SED ERES ELE EUER e es 173 9 4 2align aie ttt e ete pe dier ae eme RE 175 9 4 9 6ndiL nuce ced ee EN RE UE A ud 177 9 4 4 listoff EE 178 9 4 5 motatlOn EE 179 9 4 6 0 Q O 181 JAT Opto io e eoa ER Ede eh Dc oe 183 9 4 8 pag8 i ie RORIS pieni ee 185 94 9 T8 0X neue erint e Rede eh a e ae eed ee o 186 GAO ddr tue 188 9 4 TT Sa acta 190 9 4 12 0Wc nii tete bait sq 192 E E EE 193 MN10300 Cross Assembler 9 4 14 QU in vn de EG A A eia 194 9 4 15 global iim E cee a A 196 9 416 EE 198 94 17 xlistotf XlIStOn atico iaa ee bao ber daret Pe PE ana 199 9 418 TUNING s s ea iet cte tmm tef eue bin ui fu eds 200 10 Writing Assembler Control Statements 10 1 Purpose Of This Chapter nennen nennen nen 204 10 2 sainclude ie oae attentus 205 10 9 2tdetine iodo d Ce eite er o E ERR 207 10 4 FUNCT iine o aor EG t ne hd odo b e ete Ec 208
75. 64 bit signed integer dividend with its upper 32 bits in MDR and its lower 32 bits in Dn by the 32 bit signed divisor in Dm and store the 32 bit remainder in MDR and the 32 bit quotient in Dn DIVU Dm Dn Divide the 64 bit unsigned integer dividend with its upper 32 bits in MDR and its lower 32 bits in Dn by the 32 bit unsigned divisor in Dm and store the 32 bit remainder in MDR and the 32 bit quotient in Dn B INC Mnemonic Description of operation INC Dn Add 1 to the contents of Dn and store the result in Dn INC An Add 1 to the contents of An and store the result in An INC4 An Add 4 to the contents of An and store the result in An 260 List Of Machine Language Instructions Chapter 12 List Of Machine Language Instructions E COMPARE source witth destination Mnemonic Description of operation CMP Dm Dn Subtract the contents of Dm from Dn and set the flags according to the result CMP Dm An Subtract the contents of Dm from An and set the flags according to the result CMP Am Dn Subtract the contents of Am from Dn and set the flags according to the result CMP Am An Subtract the contents of Am from An and set the flags according to the result CMP imm Dn Subtract the sign extended imm8 sign extended imm16 or imm32 from Dn and set the flags according to the result CMP imm An Subtract the zero extended imm8 zero extended imm16 or
76. 7 4 Expression Attributes Specify the number of lines in the range 10 to 255 Specify the number of columns in the range 60 to 255 If a value outside the allowable range is specified then the assembler will generate an error and ignore this directive ill Usage example Below is an example use of the page directive page 24 80 page LINE NO COLUMN NO Writing Directive Statements 1 85 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements 9 4 9 radix E Syntax label operation operand radix expression E Default settings Radix 10 decimal E Functional description The radix directive specifies the radix that will be used by default The MN10300 Series Cross Assembler provides three coding formats for numbers Extended C language format ntel format Matsushita format The format is selected with the notation directive Refer to the description of the notation directive The default is extended C language format The radix directive specifies the default radix for numbers in these coding formats by the expression in the operand Select one from radix 2 binary radix 8 octal radix 10 decimal and radix 16 hexadecimal directive The default is fixed as radix 10 decimal and it cannot be changed to In extended C language format the default radix cannot be specified by the radix a another radix E Operand coding rules The expression
77. 8 15 4 1 Warning Messages cion iii Het iia ie s 319 15 4 2 Error Messages rete eee tere eee 320 15 4 3 Fatal Error Messages iege rede eie B e e E 322 Chapter 15 Using The Library Manager 1 5 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 The library manager is a utility for managing library files It can create library files and add delete replace and search for relocatable object files This chapter explains how to use the library manager 298 Purpose Of This Chapter Chapter 15 Using The Library Manager 1 5 2 Starting The Library Manager The library manager is started like any other command by entering the command name plus options E 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 Contents of brackets may be omitted Table15 1 Library Manager Options Option type Symbol Description Error j Output error and warning messages in Japanese message options Je Output error and warning messages in Japanese using EUC encoding Js Output error
78. Aligns the location counter value to a multiple of an expression end Indicates the end of the program listoff Stops list output from the line following this directive liston Starts list output from this directive notation Selects the coding format for numbers org Changes the program address opt Enables disables optimization functions page Specifies the number of columns and rows on one page of the list file radix Selects the radix to be specified by default dc Stores an 8 bit constant in a memory area ds Reserves an 8 bit data area in a memory area dw Stores a 16 bit constant in a memory area dd Stores a 32 bit constant in a memory area equ Defines a name as the value of an operand expression global Declares external references with external declarations tit Specifies the header name of the list file xlistoff Stops list output including this directive xliston Starts list output from the line following this directive funcinfo Specifies additional information for a function il Document conventions Symbols used in this chapter have the following meanings Contents of brackets may be omitted C Contents of parentheses may be repeated Specify one or the other of the terms delimited by a vertical bar 172 Writing Directive Statements
79. C605 26 bcc 80000027 CA03 27 bra 28 8000002a 29 time_filler_end 8000002a FOFC 30 rts 31 end 32 Page 1 data set time filler CODE PUBLIC 1 0 D2 D1 D2 data set end DO A0 1 D2 2 A0 data set loop CODE PUBLIC 1 D1 D0 time_filler_end time_filler_loop Assembling And Linking Multiple Sections 43 Chapter 3 Introduction To Operation In this file the 4 on line numbers 14 and 27 have disappeared and the start address of the first section CODE 0I has been changed to address 80005000 hex as specified by the T option However the start address of section CODE 00 is address 80000022 hex This shows that it has been linked after the same section existing in program3 E Program locations after linking Program locations in the executable file after linking as above are shown below 0X0000 Ez Unused 0X80000000 main time filler Unused 0X80005000 data_set data1 Unused 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 Sections with the same section name and section attributes are merged in the order specified to the linker that is in the order in which they appear in the object file names following the linker options Rules for joining sections 1 Join in the order in which the sections appear during linking 2 Join sect
80. Cliapter ie eL Rp EN reti Se ud 52 4 2 Rules Of RE 53 43 Usage Bxatnple 24 cL IA 54 Chapter 4 Optimization 52 4 1 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 This chapter uses examples to explain what optimization is The assembler and linker make changes to object code not instruction mnemonics Pay close attention to this point when viewing list files When an is displayed before a line number in the list file it indicates that the statement has been optimized Purpose Of This Chapter Chapter 4 Optimization 4 2 Rules Of Usage n 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 a Optimization is off by default E Rules Of Usage 53 Chapter 4 Optimization 4 3 Usage Example n E Optimized 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
81. Dn UDFU09 imm Dn UDFU10 imm Dn UDFU11 imm Dn UDFU12 imm Dn UDFU13 imm Dn UDFU14 imm Dn UDFUIS imm Dn Usage Example 57 Chapter 4 Optimization 58 Usage Example E Optimization processing The assembler informs the linker about all instructions to be optimized Based on the information from the assembler the linker outputs instruction codes with the smallest code size E 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 If not in range then the linker will replace it with instructions for a wider branch range Take the BEQ instruction for example BEQ LABEL LABEL The destination label of the BEQ instructions must be in the range 128 to 127 However the assembler cannot make that determination so the following determinations are made during assembly and linking Assembler processing 1 The assembler outputs information about instructions to be optimized to the linker Linker processing 1 The linker inputs information from the assembler 2 The linker determines if the branch destinations of conditional branches are in range 3 If determined to be in range then the linker generates the normal code 4 If determin
82. EUC coding E Rules of use To specify the option enter the hyphen followed by the upper case letter J and the lower case letter e The two letters together function as a single option Slib103 test lib f Je testl rf test2 rf test3 rf a This option is not available on PC 9801 DOS V or PC AT machines E E Default specification The default language used depends on the host machine and the operating system Host machine Message language Sun Sparc English HP9000 English PC 9801 Japanese in Shift JIS DOS V Japanese in Shift JIS PC AT English Chapter 15 Using The Library Manager Js Output error and warning messages in Japanese using Shift JIS encoding E 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 E Rules of use To specify the option enter the hyphen followed by the upper case letter J and the lower case letter s The two letters together function as a single option slib103 test lib f Js testl rf test2 rf test3 rf a This option is not available on PC AT machines a E Default specification The default language used depends on the host machine and the operating system Host machine Message language Sun Sparc English HP9000 English PC 9801 Japanese in Shift JIS DOS V Japanese in Shift JIS PC AT English Command Options 303 Chapter 15 Using The Libra
83. F 1 execute next instruction BCC label unsigned CF 0 If CF 0 execute a relative branch to the address specified by label Range 128 to 127 If CF 1 execute next instruction BLS label 2 unsigned If CF 1 or ZF 1 execute a relative branch to the address specified by label Range 128 to 127 If CF 0 and ZF 0 execute next instruction BCS label lt unsigned CF 1 If CF 1 execute a relative branch to the address specified by label Range 128 to 127 If CF 0 execute next instruction BVC label VF 0 If VF 0 execute a relative branch to the address specified by label Range 128 to 127 If VF 1 execute next instruction BVS label VF 1 If VF 1 execute a relative branch to the address specified by label Range 128 to 127 If VF 0 execute next instruction BNC label NF 0 If NF 0 execute a relative branch to the address specified by label Range 128 to 127 If NF 1 execute next instruction BNS label NF 1 If NF 1 execute a relative branch to the address specified by label Range 128 to 127 If NF 0 execute next instruction BRA label Unconditionally execute a relative branch to the address specified by label Range 128 to 127 E Conditional BRANCH For LOOP Mnemonic Meaning Description of operation LEQ If ZF 1 branch to the top of the loop as specified with ZF 1
84. Instructions eese 271 123 7 Other Instr ctions i eite e etre teen ees 271 Chapter 12 List Of Machine Language Instructions 1 2 1 Purpose Of This Chapter The chapter lists machine language instructions of the MN10300 Series microcomputers This comprehensive list of addressing modes and mnemonics for every instruction can be quite useful when you are coding machine language instruction statements If you need to know about the detailed operation of individual instructions then refer to the MN10300 Series Instruction Manual 246 Purpose Of This Chapter 12 2 31 0 Chapter 12 List Of Machine Language Instructions Addressing Modes MN10300 Series microcomputers support 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 Register indirect addressing Register relative indirect addressing Absolute addressing Index addressing 1 Register indirect addressing Register indirect addressing is specifies the address to access with the address register An An RAM N wid Address specification Addressing Modes 247 Chapter 12 List Of Machine Language Instructions 2 Register relative indirect addressing Register relative indirect addressing determines the addres
85. OTATE LEFT Mnemonic Description of operation ROL Dn Rotate the contents of Dn plus the C flag left one bit and store the result in Dn 264 List Of Machine Language Instructions Chapter 12 List Of Machine Language Instructions 12 3 4 Bit Manipulation Instructions E Bit operations Mnemonic Description of operation BTST imm Dn AND the zero extended imm 8 zero extended imm16 or imm32 with the contents of Dn and set the flags according to the result BTST imm d8 An AND the zero extended imm8 with the zero extended 8 bit contents of the memory location specified by d8 and An and set the flags according to the result BTST imm8 abs32 AND the zero extended imm8 with the zero extended 8 bit contents of the memory location specified by abs32 and set the flags according to the result BSET Dm An This instruction proceeds through the following three stages 1 Transfer with zero extension the 8 bit contents of the memory location specified with An to a 32 bit internal temporary register 2 AND the temporary register with the contents of Dm and set the flags according to the result 3 OR the temporary register with the contents of Dm and store the lowest 8 bits of the result in the memory location specified with An BSET imm8 d8 An This instruction proceeds through the following three stages 1 Transfer with zero extension the 8 bit contents of the memory loc
86. Odef Coding rules Binary Octal Decimal Hexadecimal 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 Start with letter O or o and enclose octal digits in single quotation marks When the default is octal code the octal number as is Start with letter F or and enclose decimal digits in single quotation marks When the default is decimal code the decimal number as is Start with letter X or x and enclose hexadecimal digits in single quotation marks When the default is hexadecimal code the hexadecimal number as is When the number begins with a letter prefix it with 0 zero 8 4 Chapter 8 Writing Source Statements Character Constants Displayable ASCII characters can be coded as character constants or string constants The characters that can be used for constants are as follows Digits Letters upper or lower case String constants can use underscores and control characters other than carriage returns or line feeds E Character constants A character constant is stored as an ASCII code in the space of a single character The method for specifying character constants differs depending on the coding format The coding format is selected using the notation directive The default is extended C language format a The coding format also appli
87. Options for default interpretations Chapter 6 Using The Linker When specifying multiple files separate them with spaces Files without path specifications are assumed to be in the current directory The map file and executable file are always generated in the current directory regardless of any path specifications on the relocatable object files The default names for the executable file and the map file are m103 ex and m103 map respectively The o option is available for creating the executable file in a directory other than the current directory The map file is created in the same directory as the executable file Starting The Linker 103 Chapter 6 Using The Linker il Summary of Options Below is a list of options Option Type Table 6 1 Linker options Symbol Description Output file options o filename Specify the path name and file name of the executable format file to be output Output a map file Error message options Output error and warning messages in Japanese Output error and warning messages in Japanese using EUC encoding Output error and warning messages in Japanese using Shift JIS encoding Output error and warning messages in Japanese using JIS encoding Output error and warning messages in English Do not output warning messages of the specified number Refer to chapter 13 Error Messages for warning messages and their corresponding numbers
88. Output an executable format file even if errors are detected E Functional description The linker normally suppresses the creation of an executable file if it detects errors during linking The r option forces file creation even if there are errors An executable created with known linker errors will not execute properly The r a option is only a temporary measure Do not run the executable that results H E Rules of use The r option is specified with the hyphen option specification character followed by the lower case letter r 1d103 r progl rf E Default specification An executable format file will not be generated It is also possible to force creation of executable file by default with an entry in the linker s start up file See Chapter 1 Getting Started Section 1 5 Setup Command Options 119 Chapter 6 Using The Linker 120 Command Options Do not output symbol table within the executable format file E Functional description The En option suppresses output of a symbol table in the executable format file Only executable code will be output to the executable format file E Rules of use The En option is specified with the hyphen option specification character followed by the upper case letter E and lower case letter n The pair of characters of En are handled as a single option ld103 En main rf sub rf a The En option cannot be used in conjunction with the g option n
89. Pana Series The One toWatch for Constant Innovation Making the Future Come Alive MICROCOMPUTER MN10300 MN10300 Series Cross Assembler User s Manual Pub No 13110 051E Panasonic PanaXSeries is a trademark of Matsushita Electric Industrial Co Ltd Sun and Sun OS are trademarks of Sun Microsystems Inc HP and HP UX are trademarks of Hewlett Packard Corporation MS DOS is a registered trademark of Microsoft Corporation AT is a registered trademark of International Business Machine Corp UNIX is a registered trademark of X Open Co Ltd in U S and other countries MIFES s a trademark of Megasoft Inc The other corporation names logotype and product names written in this book are trademarks or registered trademarks of their corresponding corporations 1 2 3 4 Request for your special attention and precautions in using the technical information and semiconductors described in this book An export permit needs to be obtained from the competent authorities of the Japanese Government if any of the products or technologies described in this book and controlled under the Foreign Exchange and Foreign Trade Law is to be exported or taken out of Japan The contents of this book are subject to change without notice in matters of improved function When finalizing your design therefore ask for the most up to date version in advance in order to check for any changes We are not liable for any damage
90. SETLB If ZF 0 execute next instruction LNE If ZF 0 branch to the top of the loop as specified with ZF 0 SETLB If ZF 1 execute next instruction List Of Machine Language Instructions 269 Chapter 12 List Of Machine Language Instructions Description of operation If ZF 0 and NF VF branch to the top of the loop as specified with SETLB If ZF 1 or NF VF execute next instruction If NF VF branch to the top of the loop as specified with SETLB If NF VF execute next instruction If CF 1 or ZF 1 branch to the top of the loop as specified with SETLB If CF 0 and ZF 0 execute next instruction If NF 1 and VF 1 or NF 0 and VF 0 branch to the top of the loop as specified with SETLB If NF 1 and VF 0 or NF 0 and VF 1 execute next instruction If CF 0 and ZF 0 branch to the top of the loop as specified with SETLB If CF 1 or ZF 1 execute next instruction If CF 0 branch to the top of the loop as specified with SETLB If CF 1 execute next instruction If CF 1 or ZF 1 branch to the top of the loop as specified with SETLB If CF 0 and ZF 0 execute next instruction If CF 1 branch to the top of the loop as specified with SETLB If CF 0 execute next instruction Unconditionally branch to the top of the loop as specified with SETLB Description of operation Mnemonic Meaning LGT lt si
91. Statements 206 include E Usage example The following example illustrates the use of an include file The file inc h consists of the following statement data equ 0x12 The file to be assembled consists of the following statements include Mina bit TEX section CODE PUBLIC 1 main mov data AO mov 0x34 DO mov DO A0 end 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 10 3 Chapter 10 Writing Assembler Control Statements define E Syntax define identifier replacement_string comment E Functional description The define 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 E Coding rules Any string can be coded for the replacement string The string can include spaces and tabs If the replacement string is omitted then the identifier will be defined as a null character Everything after a semicolon is considered a comment Therefore semicolons cannot be included in the replacement string The same identifier cannot just be redefined with another define directive When used in conju
92. Syntax Syntax for ifb ifb dummy parameter block1 4else block2 tendif m Functional description ifb Chapter 10 Writing Assembler Control Statements Syntax for ifnb ifnb dummy_parameter block1 felse block 2 ndif If the dummy parameter is a null character then block1 will be assembled If itis not a null character and an else directive has been coded then block2 will be assembled ifnb If the value of expression is not a null character then block will be assembled If it is a null character and an else directive has been coded then block2 will be assembled m Coding rules These directives can only be used within macro definitions The parameter must be a dummy parameter Conditional Assembly 221 Chapter 10 Writing Assembler Control Statements 222 Conditional Assembly m Usage example A source file that uses ifb is shown below If the dummy parameter string to the macro debug is a null character then the program will execute proc If it is not a null character then the program will execute check and then execute proc In this example the identifier MODE is passed to the macro debug When a replacement string has been specified the call is without a null character debug ifb else dendif r TEXT define undef define global check proc macro string string jsr check jsr proc jsr proc endm section CODE PUBLIC 1 MODE debug_
93. The following descriptions assume that a map file has already been generated as103 1 a main map sub asm In the above example all files exist in or are output to the current directory The source file sub asm is assembled using a map file main map generating a list file sub Ist as103 1 Lc Lm a main map D MODE progl asm The above example assembles the source file progl asm in the current directory using a map file main map generating a list file prog 1st Assembly will be performed assuming that the identifier MODE has been defined for conditional assembly directives ifdef Source statements of unfulfilled conditions and macro expansion source will not be output Chapter 6 A E E SE Using The Linker 6 1 Purpose Of Thus Chapter 4e e oet eee Ode re Pe Ae aii 100 6 2 Starting The Linker is uice ine ob eine og ias 101 6 3 Command Options EE 104 6 3 1 Output File Options eese nennen nennen 105 6 3 2 Error Message OPtiONS tenente nennen nenne 108 6 3 3 Program Generation Option 115 6 3 4 Library File OPUS 122 6 35 Othe Options 2 a dep e os As 124 6 4 Instruction RAM Support 127 6 4 1 Structure Of IRAM Support Executable File eene 128 6 4 2 IRAM Support Options sess ER R AR Aa iati i 131 6 4 3 Operation ExampleS eese eene nennen nennen nennen 134 Chapter 6 Using The Linker 6 1 Purpose Of This Chapter L This chapter explains how to use a
94. The identifier VERSION is defined in line number 1 The replacement string is a null character Since VERSION has been defined the ifdef starting from line number 4 will assemble block 1 line number 5 here and will not assemble block 2 shown as line number X The ifndef directive inverts the condition so block 2 line number 12 will be assembled 10 5 2 Chapter 10 Writing Assembler Control Statements Hit ifn B Syntax Syntax for if ifn expression if expression ifn expression block1 block ls else block2 block2 Send endif m Functional description if If the value of expression is not 0 then block will be assembled If it is O and an else directive has been coded then block2 will be assembled ifn If the value of expression is 0 then block will be assembled If it is not O and an else directive has been coded then block2 will be assembled m Coding rules These directives can be used within macro definitions and wherever machine language instructions can be coded Conditional Assembly 213 Chapter 10 Writing Assembler Control Statements m Usage example A source file that uses if and ifn is shown below DEVICE equ 1 TEXT section CODE PUBLIC 1 i DEVICE 1 mov 0x01 D0 ls mov 0x02 D0 ndif ifn DEVICE 1 mov 0x03 D1 ls mov 0x04 D1 ndif The assembled lis
95. V Am Di An Transfers the contents of Am to the memory location specified by Di and An MOVBU Di Am Dn Transfers with zero extension the 8 bit contents of the memory location specified by Di and Am to Dn MOVBU Dnm Di An Transfers the lowest 8 bits of Dm to the memory location specified by Di and An MOVB Di Am Dn Transfers with sign extension the 8 bit contents of the memory location specified by Di and Am to Dn MOVB Dnm Di An Transfers the lowest 8 bits of Dm to the memory location specified by Di and An MOVHU Di Am Dn Transfers with zero extension the 16 bit contents of the memory location specified by Di and Am to Dn MOVHU Dnm Di An Transfers the lowest 16 bits of Dm to the memory location specified by Di and An MOVH Di Am Dn Transfers with sign extension the 16 bit contents of the memory location specified by Di and Am to Dn MOVH Dnm Di An Transfers the lowest 16 bits of Dm to the memory location specified by Di and An List Of Machine Language Instructions 255 Chapter 12 List Of Machine Language Instructions Mnemonic Description of operation MOV abs16 Dn Transfer the 32 bit contents of the memory location specified by abs16 to Dn abs16 is zero extended MOV abs32 Dn Transfer the 32 bit contents of the memory location specified by abs32 to Dn MOV abs16 An T
96. XT section 40000000 3 sub_func 40000000 8A00 4 mov 40000002 A6 5 cmp 40000003 C67F 6 addr_set bec 7 8 org 40000082 9 func end 40000082 FOFC 10 rts 11 end optl lst Symbol Table 40000000 T sub func 40000003 T addr set 40000082 T func end Page 1 on CODE PUBLIC 1 0 D2 D1 D2 func end addr_set 127 Page 2 64 Usage Example E Example Chapter 4 Optimization branch destination of conditional branch instruction out of range This example shows a branch outside the permitted range 128 to 127 of PC of a BCC LABEL conditional branch instruction The source list is as follows TEXT sub_func addr_set func_end opt section mov cmp bec org rts end on CODE PUBLIC 1 0 D2 D1 D2 func_end addr_set 128 The final list file after assembly is shown next LABEL exceeds the permitted branch range of BCC LABEL so the code has been converted to BCS 5 JMP LABEL Note that the mnemonics and object code are different opt2 1st mde PanaX Series MN103000 Cross Assembler KRR Loc Object Line Source 1 opt 2 TEXT section 40000000 3 sub func 40000000 8A00 4 mov 40000002 A6 5 cmp 40000003 C405CC0080 6 addr set bcc 7 8 org 40000083 9 func end 40000083 FOFC 10 rts 11 end 12 opt2 1st Symbol Table 40000000 sub func 40000003 addr set 40000083 func end Page 1 on CODE PUBLIC 1 0 D2 D1 D2 func end addr_set 128 Page 2
97. ame cannot be defined twice When the label is omitted it must be replaced with at least one space or tab Terminology U Column This is a column on the display or printer paper One character takes one column Columns are counted from the left as column 1 2 etc il Coding examples ABEL j ONGLABELLONGLABELLONGLABELLONGLAB main start cont The following examples are incorrect 1LABEL Starts with a digit STAR Uses a prohibited character START Does not start from the first column Instruction Statement Fields 9 2 2 9 2 3 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements Writing The Operation Field The operation field is written with a machine language instruction mnemonic or directive E Coding rules The operation field can be coded using upper case and lower case labels E Coding examples CONST1 equ 10 _CODE section CODE PUBLIC 2 start mov CONST1 D0 EES Writing The Operand Field The operand field coding is determined by the machine language instruction or directive in the operation field Refer to the MN10300 Series Instruction Manual for details on coding machine language instructions E Coding rules Operands are written with expressions and reserved words register names etc Operands cannot include spaces except for character constants and string constants When two o
98. and branch to the specified address JSR label label is either d16 PC or d32 PC Push the program counter containing the address of the next instruction onto the stack and branch to the specified address List Of Machine Language Instructions 267 Chapter 12 List Of Machine Language Instructions Mnemonic Description of operation RTS Branch to the return address saved on the stack RTS is used paired with JSR to maintain backward compatibility RTI Return from an interrupt service routine Restore the PSW stored on the stack and branch to the return address saved on the stack TRAP Push the program counter containing the address of the next instruction onto the stack and branch to the predefined address 0x40000010 This instruction is used for system calls to the operating system and libraries E Unconditional BRANCH Mnemonic Description of operation JMP An Store the contents of An in the program counter JMP label 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 The result is stored in the program counter If label is d32 PC the 32 bit displacement is added to the program counter The result is stored in the program counter Any overflow during the addition is ignored The result is stored in the program
99. and it makes an external declaration of data set E Assemble Assemble the two programs that you created to generate relocatable object files as103 programl asm as103 program2 asm This will generate two relocatable object files programl rf and program2 rf List files cannot be generated at this stage These files will be generated after linking when the relationships of external references and external definitions are resolved 3 Basic Operation Of Assembler And Linker Chapter 3 Introduction To Operation B Link Link the two relocatable object files to create an executable file At the same time generate a map file 1d103 m T CODE 40000000 programl rf program2 rf m option Option to output map file T option Option to specify section address 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 Supplemental Explanation The o option is also available for specifying a different output file name and directory for the executable file Omitting this option results in the use of the default name m103 and the extension ex There is no option for specifying the name of the map file It uses the same default name as the executable file m103 and the extension map The output directory is the same as that used for the executable file Bl Generate final list files After link processi
100. are as follows global main global data set time filler CODE 00 section CODE PUBLIC 1 main mov 0 A0 mov Oxff DO mov 0x80 D1 jsr data set jsr time filler bra main DATA section DATA PUBLIC 4 datal ds 4 end Assembling And Linking Multiple Sections 35 Chapter 3 Introduction To Operation The contents of program4 asm are as follows global data set time filler CODE 01 section CODE PUBLIC 1 data set mov 0 D2 data set loop cmp D1 D2 bcc data set end mov DO A0 add 1 D2 add 2 A0 bra data_set_loop data_set_end rts _CODE_00 section CODE PUBLIC 1 time filler mov 0 D2 time filler loop cmp D1 D0 bcc time filler end bra time filler loop time filler end rts end As can be seen from the above two files these programs are divided as follows main time filler CODE 00 e data set mm CODE 01 es daal aa DATA 36 Assembling And Linking Multiple Sections Chapter 3 Introduction To Operation E Assemble and generate list files Next assemble the two programs Assemble with the option for output of list files in order to see what the list file is like when final addresses are not resolved as103 1 g program3 asm as103 1 g program4 asm g option Option to output debug information in the relocatable object file l option Option to output list file not normally specified at this stage before linking but specify it here to see
101. arising out of the use of the contents of this book or for any infrigement of patents or any other rights owned by a third party No part of this book may be reprinted or reproduced by any means without written permission from our company If you have any inquiries or questions about this book or our semiconductors please contact one of our sales offices listed at the back of this book or Matsushita Electronics Corporation s Sales Department About This Manual This Manual describes the functions of and operating procedures for the cross assembler system for the MN10300 Series of 32 bit microcomputers E Features of This Manual t provides a chapter covering setup programming development flow and introductory operation so that beginners take only a short time to grasp the essentials and master operation t provides a separate chapter on the optimization functions that are such an important feature of this system It contains plentiful examples of assembler and linker operation and many programming examples t explains assembler directives assembler control statements and macro control instructions individually with usage specifications usage notes and examples t also describes the use of the library manager tool for managing libraries t provides personal computer users with coverage of the ways in which that version differs from the workstation version Appendices list machine instructions
102. as and spaces use the macro operator Chapter 11 Writing Macro Control Statements E Usage example In the following example the irp directive is in a macro definition that is used twice in the program init macro pl irp opr lt pl amp Ox0f gt mov opr DO endm endm TEXT section CODE PUBLIC 1 init 1 irp reg D2 D3 mov 0 reg endm The assembled list file is shown below irp lst Page 1 ARR PanaX Series MN103000 Cross Assembler AUN Loc Object Line Source M1 init macro pl 2 irp opr lt pl amp Ox0f gt 3 mov opr DO 4 endm 5 endm 6 A _TEXT section CODE PUBLIC 1 M 8 init 1 M 8 irp opr 1 amp Ox0f gt 8 mov opr DO 8 endm 00000000 8001 8 mov 1 amp OxOf DO M 9 irp reg D2 D3 10 mov 0 reg 11 endm 00000002 8A00 11 mov 0 D2 00000004 8F00 11 mov 0 D3 irp 241 Chapter 11 Writing Macro Control Statements 242 11 10 irpc irpc E Syntax irpe dummy parameter string block endm E 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 E Coding rules The string cannot include the characters amp V and Symbols cannot be used within a block If used then a double defi
103. atement then block will be assembled If it has not been defined and an else directive has been coded then block2 will be assembled Hifndef If the identifier has not been defined by a define directive before the ifndef statement then block will be assembled If it has been defined and an else directive has been coded then block2 will be assembled m Coding rules These directives can be used within macro definitions and wherever machine language instructions can be coded If an identifier is defined after ifdef or ifndef then it will be considered undefined Identifiers can be specified by the D option when the assembler is started even if they are not defined with define directives Conditional Assembly 211 Chapter 10 Writing Assembler Control Statements 212 Conditional Assembly m Usage example A source file that uses ifdef and ifndef is shown below define VERSION TEXT section CODE PUBLIC 1 ifdef VERSION mov 0x01 D0 felse mov 0x02 D0 fendif ifndef VERSION mov 0x03 D1 felse mov 0x04 D1 fendif The assembled list file is shown below ifdef lst Page 1 EN PanaX Series MN103000 Cross Assembler mw Loc Object Line Source all define VERSION 2 3 TEXT section CODE PUBLIC 1 4 ifdef VERSION 00000000 8001 5 mov 0x01 D0 6 else 7X mov 0x02 D0 8 endif 9 ifndef VERSION 10x mov 0x03 D1 11 else 00000002 8504 12 mov 0x04 D1 13 endif
104. ation specified with d8 and An to a 32 bit internal temporary register 2 AND the temporary register with zero extended imm8 and set the flags according to the result 3 OR the temporary register with zero extended imm8 and store the lowest 8 bits of the result in the memory location specified with d8 and An BSET imm8 abs32 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 2 AND the temporary register with zero extended imm8 and set the flags according to the result 3 OR the temporary register with zero extended imm8 and store the lowest 8 bits of the result in the memory location specified with abs32 List Of Machine Language Instructions 265 Chapter 12 List Of Machine Language Instructions Mnemonic Description of operation BCLR Dm An This instruction proceeds through the following three stages 1 Transfer with zero extension the 8 bit contents of the memory location specified with An to a 32 bit internal temporary register 2 AND the temporary register with the contents of Dm and set the flags according to the result 3 AND the temporary register with the ones complement of the contents of Dm and store the lowest 8 bits of the result in the memory location specified with An BCLR imm8 d8 An This instruction proceeds through
105. bits of Dm to the memory location specified by An and displacement d 8 and 16 bit displacements are sign extended MOVBU Dnm d SP Transfers the lowest 8 bits of Dm to the memory location specified by SP and displacement d 8 and 16 bit displacements are zero extended MOVB d Am Dn Transfers with sign extension the 8 bit contents of the memory location specified by Am and displacement d to Dn 8 and 16 bit displacements are sign extended MOVB d SP Dn Transfers with sign extension the 8 bit contents of the memory location specified by SP and displacement d to Dn 8 and 16 bit displacements are zero extended MOVB Dm d An Transfers the lowest 8 bits of Dm to the memory location specified by An and displacement d 8 and 16 bit displacements are sign extended MOVB Dm d SP Transfers the lowest 8 bits of Dm to the memory location specified by SP and displacement d 8 and 16 bit displacements are zero extended MOVHU d Am Dn Transfers with zero extension the 16 bit contents of the memory location specified by Am and displacement d to Dn 8 and 16 bit displacements are sign extended MOVHU d SP Dn Transfers with zero extension the 16 bit contents of the memory location specified by SP and displacement d to Dn 8 and 16 bit displacements are zero extended MOVHU Dnm d An Transfers the lowest 16 bits of Dm to the memory location specified by
106. bler Errors 2008 Macro name multiple defined Multiple macros share the same name Change the names of the extra macros 2009 The usage of a series of instructions may be restricted in MN10300 series The usage of a series of instructions may be restricted in MN10300 series Careful operation is needed as some operations are not guaranteed Refer to the notes attentions or warnings written in MN10300 Series Instruction Manual for 32 bit and ensure that the expected operation is guaranteed If it is not guaranteed modify the program See Chapter 3 How To Use Instructions in the Instruction Manual 3rd version or later or Chapter 5 section 2 Programming Notes in the former versions 2010 The usage of this instruction may be restricted in MN10300 series The usage of a series of instructions may be restricted in MN10300 series hardware Careful operation is needed as some operations are not guaranteed Refer to the notes attentions or warnings written in MN10300 Series Instruction Manual for 32 bit and ensure that the expected operation is guaranteed If it is not guaranteed modify the program See Chapter 3 How To Use Instructions in the Instruction Manual 3rd version or later or Chapter 5 section 2 Programming Notes in the former versions 13 2 2 Chapter 13 Error Messages Error Messages 2301 Syntax error The current line contains a syntax error Consult this
107. bler Errors tegt tet ete Te ee e pe deen eee adver 275 13 2 1 Warning Messages ccceesceecseeeeseneeeeeneeeeeeeeneseeeseneneeeseeseesensenenanes 275 19 2 2 Error Message S EE 277 13 2 3 Fatal Error Messages seen 281 49 3 Linker EITOrS 4 iro e t Ra a RARE bMS 282 13 3 1 Warning Messages A 282 13 3 2 Error Messages a ie det eee te ei rims 283 13 3 3 Fatal Error Messages AAA 285 14 Reading List Files 14 4 Purpose Of This Chapter ui 290 14 2 Reading List Files tene e tc eec 291 14 2 1 Output Format Of Machine Language Code ocococccoccciocccoccconnccancconnn ns 292 14 2 2 Symbol Tables uc de dece de 295 15 Using The Library Manager 15 1 Purpose Of This Chapter esses nnne 298 15 2 Starting The Library Manager 299 MN10300 Cross Assembler 15 3 Command Options t e E onte EORR RE PRU EUN 301 15 3 1 Error Message Opttons nennen 301 15 3 2 Program Generation Options sse 307 15 3 3 Functional Options eee D detener andes 309 15 3 4 Other Options reete e cd e tutt ae tet A 315 15 4 Error Messages int eee 318 15 4 1 Warning Messages ccessceeteceeseseneeseeneesesecensseesseneeeneneeeenseeeenenanes 319 15 4 2 Error Messages ec eee ee eroe odes 320 15 4 3 Fatal Error Messages AAA 322 16 Notes On The Operating Environment 16 1 Purpose Of This Chapter nennen 324 16 2 Personal Computer Versions essen 325 16 2 1 P
108. bs MOVB Dn abs16 MOVB Dn abs32 MOVB Dn d An MOVB Dn d8 An MOVB Dn d16 An MOVB Dn d32 An MOVB Dn d SP MOVB Dn d8 SP MOVB Dn d16 SP MOVB Dn d32 SP MOVHU abs Dn MOVHU abs16 Dn MOVHU abs32 Dn MOVHU d An Dn MOVHU d8 An Dn MOVHU d16 An Dn MOVHU d32 An Dn MOVHU d SP Dn MOVHU d8 SP Dn MOVHU d16 SP Dn MOVHU d32 SP Dn MOVHU Dn abs MOVHU Dn abs16 MOVHU Dn abs32 MOVHU Dn d An MOVHU Dn d8 An MOVHU Dn d16 An MOVHU Dn d32 An MOVHU Dn d SP MOVHU Dn d8 SP MOVHU Dn d16 SP MOVHU Dn d32 SP MOVH abs Dn MOVH abs16 Dn MOVH abs32 Dn MOVH d An Dn MOVH d8 An Dn MOVH d16 An Dn MOVH d32 An Dn MOVH d SP Dn MOVH d8 SP Dn MOVH d16 SP Dn MOVH d32 SP Dn MOVH Dn abs MOVH Dn abs 16 MOVH Dn abs32 MOVH Dn d An MOVH Dn d8 An MOVH Dn d16 An MOVH Dn d32 An MOVH Dn d SP MOVH Dn d8 SP MOVH Dn d16 SP MOVH Dn d32 SP ADD imm An ADD mm An ADD imm16 An ADD imm32 An ADD imm Dn ADD imm8 Dn ADD imm16 Dn ADD imm32 Dn ADD imm SP ADD imm8 SP ADD imm16 SP ADD imm32 SP AND imm Dn AND imm8 Dn AND imm16 Dn AND imm32 Dn CMP mmm An CMP mmm An CMP imm16 An CMP imm32 An CMP imm Dn CMP imm8 Dn CMP imm16 Dn CMP imm32 Dn OR imm Dn OR imm8 Dn OR imm16 Dn OR imm32 Dn XOR imm Dn XOR imm16 Dn XOR imm32 Dn BTST imm Dn BTST imm8 Dn BTST imm16 Dn BTST imm32 Dn 62 Usage Example Chapter 4 Optimization
109. ce 1 DATA section DATA PUBLIC 4 00000000 00 2 dsO ds 1 00000001 1122 8 ds 2 0x1122 00000003 3344556633445566 4 dsl ds 4 0x33445566 2 Writing Directive Statements 1 91 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements 9 4 12 22 E Syntax label operation operand name dw expression expression E Functional description The dw directive is used to define 16 bit constants in a memory area The 16 bit constant specified by the operand will be stored at the location of the statement specifying this directive When a name is coded for the label the assembler will assign the current location counter value to that name E Operand coding rules The operands are delimited with commas Any number of operands can be coded If data that exceeds 16 bits is specified then the lower 16 bits will be valid and the upper bits will be lost The assembler will output a warning message in such cases When the specified data has fewer than 16 bits those bits will fill the lower bits and the upper bits will be padded with zeroes E Usage example Below is an example use of the dw directive dw lst Page 1 EEK PanaX Series MN103000 Cross Assembler ARA Loc Object Line Source 1 _DATA section DATA PUBLIC 4 00000000 3930 2 dwO dw 12345 00000002 34127856 3 dwl dw 0x1234 0x5678 00000006 0000 4 dw2 dw 0 192 Writing Directive Statements 9 4 13 2 Chapter 9 Writing Machin
110. ce eee ee eeeeeeeeeeees 325 primitted Characters eec eerte tret retten einen 147 preprocessor options assembler 74 90 PLODE 18 program Ont nossas teineen 20 139 program generation options assembler 74 92 program generation options library manager 299 307 program generation options linker 103 115 program locations after linking sess 44 programming style programming with the assembler R t library manager o aecenas 312 f linker oppent eege retener ches 119 r OPTION 11 Eeer 186 redding list files inocencia iare 291 Se EE 331 LA EE relative relocatable object files ceret ritenere 27 TEMA ondo E PECORE ERE TEF R EESTE NOE RANNE 156 S SECO WE 173 SECO atinada 29 self reference address symbol sss 155 several points to be aware of when writing programs 140 Shift Operators DEC 157 slib103 library manager 4 SLIB103 EXE library manager 326 duc c 6 source code deDbupger o aerea 17 SUN Sparc stack frame Starting the assembler inician renes 71 starting the library Manager ee 299 SUTIN CONS E 152 subroutine Calls 1 m toronto eoe edes 54 SUDAC re 156 Symbol type eege 295 296 symbol table vi iia 295 T t library manager eerte ther teo 313 T sec
111. cify the option enter the hyphen followed by the lower case letter j as103 j sample asm a This option is not available on PC AT machines E E Default specification The default language used depends on the host machine and the operating system Host machine Message language Sun Sparc English HP9000 English PC 9801 Japanese in Shift JIS DOS V Japanese in Shift JIS PC AT English It is also possible to change the default message specification with an entry in the assembler s start up file See Chapter 1 Getting Started Section 1 5 Setup Command Options 83 Chapter 5 Using The Assembler Je Output error and warning messages in Japanese using EUC encoding E 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 E Rules of use To specify the option enter the hyphen followed by the upper case letter J and the lower case letter e The two letters together function as a single option as103 Je sample asm a This option is not available on PC 9801 DOS V or PC AT machines H E Default specification The default language used depends on the host machine and the operating system Host machine Message language Sun Sparc English HP9000 English PC 9801 Japanese in Shift JIS DOS V Japanese in Shift JIS PC AT English It is also possible to change the default messag
112. ctu te Motorola S format Motorola S1 format cocooccconccconancnnnncconanconanononacconacconanonnno 12 MS DOS cesta nba lali alicia viens 3 multiplication essere 156 N MOUAU OM Lara Ix e atre nea 179 Notation Pesar ais 9 MVM DOTS pil eI Ee numeric restrictions O O assembler Option iss cocinero retener 93 O OPTION o filename assembler option O filename linker option eene 105 gu atts 292 Od assembler option 94 Offset Values nos on pterea 154 operand EE 167 169 operation field 553 enema tee 167 169 Operator precedence territories 158 DEER ODE oceani mero EE Eege optimization optimization of function calls sese 59 OPtiON SPECIET er Er sre 71 OVS OOS output file options assembler output file options linker sess output map file cin idos OVL ID number section address linker option 131 P p library mianager ee ceci ctore oo tr trennt 311 Dr M 12 PAGS 8s ss H PAN Ain parameter file parameter file during linking sess 41 PATH urere ont Den ea dover teenies 6 path names personal COMPUTETS 0 ceecesseseoreessroessstersorsscesecensostenteness 3 personal computer versions 0 0 ce
113. d 122 Command Options Chapter 6 Using The Linker L path name Specify a directory containing library files E Functional description The L option specifies a directory that contains library files Library files following the L option specification will be searched for in the specified directory Searching will be performed first in the directories specified with L options and then in the current directory When the L option is defined multiple times the search will be performed in the order of definition Library files that have not been found in the specified directories will finally be searched for in the current directory If any library files still missing the linker outputs an error message to terminate operation E Rules of use The L option is specified with the hyphen option specification character followed by the lower case letter L then either immediately followed by the path name or a space and the path name 1d103 L usr lib lsample lib 1sample2 lib progl rf prog2 rf The files sample lib and sample2 lib will be searched for in the directory usr lib E Default specification Library files specified by the 1 option will be read Command Options 123 Chapter 6 Using The Linker 6 3 5 124 Command Options Other Options Specify a parameter file E Functional description By writing various option used by the linker in a file the option lets you specify just that file during execution
114. d Options 305 Chapter 15 Using The Library Manager 306 Command Options W number Do not output warning messages of the specified number E Functional description This option suppresses output of warning messages generated during library manager operation For a list of warning messages and their numbers see Chapter 15 Using the Library Manager Section 15 4 Error Messages Section 15 4 1 Warning Messages The library manager ignores specifications for warning numbers that do not have messages assigned to them E Rules of use To specify the option enter the hyphen followed by the upper case letter W and the number If another option follows separate it with a space Slib103 test lib W4001 c testl rf test2 rf test3 rf E Default specification The default is to display all warning messages Wall Do not output any warning messages E Functional description This option suppresses output of all warning messages generated during library manager operation E Rules of use To specify the option enter the hyphen followed by the letters Wall If another option follows separate it with a space Slib103 test lib Wall c testl rf test2 rf test3 rf E Default specification The default is to display all warning messages 15 3 2 Chapter 15 Using The Library Manager Program Generation Options C Create a new library file E Functional description If a file
115. d between the W and the warning number This option is provided for future expansion of functions 1d103 W3001 progl rf prog2 rf E Default specification Warning messages are output Command Options 113 Chapter 6 Using The Linker Do not output any warning messages E Functional description The Wall option suppresses output of all warnings detected during linking E Rules of use The Wall option is specified with the hyphen option specification character followed by the letters Wall When further options are specified they should be delimited by a space before the option specification character ld103 Wall main rf sub rf E Default specification Warning messages are output 114 Command Options 6 3 3 Chapter 6 Using The Linker Program Generation Options DENM Output debug information to the executable format file E 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 Names and addresses of variables Detailed information on variables Correspondences between line numbers and code addresses With this information debugging is much easier since the user can specify variables by name instead of by address The g option must also be specified when assembling lf the g option is not a specified for either the assembler or linker then debug informa
116. ding on the device being used This chapter uses the terminology of 1d103 as its general format E General format of commands Below is the general format of the command to use when starting the linker 1d103 options relocatable object filename Contents of brackets may be omitted Ellipses indicate item may be repeated Specifying options Except for the option an option starts with a hyphen as the options specifier followed by a character that indicate the particular option g The option is not preceded by a hyphen Option specifications are case sensitive so upper case and lower case letters must be specified correctly ID E B Single character options not accompanied by parameters can be specified as multiple characters following the hyphen option specifier The order is optional jmg If you want to separate multiple options delimit them with spaces jene Starting The Linker 101 Chapter 6 Using The Linker 102 Starting The Linker When an option is accompanied by a parameter and other options are to follow add a space after the parameter and then follow with the hyphen option specifier o main ex gm Parameters can be specified right after the option character or separated by one space TGCODE 80000000 or T CODE 80000000 Fl When options are omitted the linker operates in accordance with its built in default interpretations Refer to section 6 3 Command
117. e a AS108 l o USER TMP SAMPLE RF SAMPLE ASM E 330 Personal Computer Versions 16 2 7 Chapter 16 Notes On The Operating Environment 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 The error correction method described in this section uses the tag jump function of editors TM such as MIFES etc This assumes the necessity of an error file that incorporates tag jumps Assembler error messages implement the tag jump function When the assembler detects an error it outputs an error message to the display It will also output error messages to the list file if the l option was specified When the 1 option has not been specified and the assembler detects errors you can assemble again such that errors are not displayed to the screen but are redirected to an error file that the assembler generates The list file will include correct source statements in which errors were not detected while the file created by redirection will consist only of source statements in which errors were detected It is accordingly faster to access the file created by redirection when the source file is large Personal Coomputer Versions 331 Chapt
118. e output 1d103 o usr tmp test ex main rf sub rf Output a map file ld103 m main rf sub rf E Error message options Output error and warning messages in Japanese ld103 j main rf sub rf Je Output error and warning messages in Japanese using EUC encoding 1d103 Je main rf sub rf JS Output error and warning messages in Japanese using Shift JIS encoding 1d103 Js main rf sub rf Jj Output error and warning messages in Japanese using JIS encoding ld103 Jj main rf sub rf Output error and warning messages in English 1d103 e main rf sub rf W number Do not output warning messages of the specified number 1d103 W3001 main rf sub rf Wall Do not output any warning messages 1d103 Wall main rf sub rf 342 List Of Command Options Chapter 17 Appendix E Program generation options Output debug information to the executable format file ld103 g main rf sub rf T section address Specify a section start address 1d103 T_TEXT CODE 80000000 T DATA 0 main rf sub rf r Output an executable format file even if errors are detected ld103 r main rf En Do not output symbol table within the executable format file ld103 En main rf sub rf Ed Enable output of DATA sections to the executable file ld103 Ed main rf sub rf B Library file options llibrary filename Specify a library file
119. e Instruction Statements And Directive Statements 141 7 4 Assembler Control Statement 142 7 5 Macro Control St tem nts geed 143 7 6 Comment Statenients E 144 TE Blank Statements MEER 144 Chapter 7 Types Of Source Statements 7 1 Purpose Of This Chapter A Programs used by the MN10300 Series 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 Assembler control statements Macro control statements Comment statements Blank statements This chapter describes these five types of statements and at the same time explains their position and use when constructing a program 138 Purpose Of This Chapter 7 2 Program Format Chapter 7 Types Of Source Statements A program is text created to assemble as machine language instructions in order to operate a microcontroller 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 There are five types of source statements with the type determining how a source statement is written Basic program format is shown below A Comment statement finclude define definitions of constants macros globals section name section Program body Write comments as needed incl
120. e Language Instruction Statements And Directive Statements E Syntax label operation name dd E Functional description operand expression expression The dd directive is used to define 32 bit constants in a memory area The 32 bit constant specified by the operand will be stored at the location of the statement specifying this directive When a name is coded for the label the assembler will assign the current location counter value to that name E Operand coding rules The operands are delimited with commas Any number of operands can be coded Specifying an expression that evaluates to a value too large to fit within 32 bits produces an error When the specified data has fewer than 32 bits those bits will fill the lower bits and the upper bits will be padded with zeroes E Usage example Below is an example use of the dw directive Loc Object 00000000 78563412 00000004 00000000 00000008 00000000 Line Oo oO A W N FP RAK PanaX Series MN103000 Cross Assembler Source _DATA dado ddl dd lst KKK global section dd dd dd Page 1 dd0O ddl g_dd0 DATA PUBLIC 4 0x12345678 ado o ddO Writing Directive Statements 1 93 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements 9 4 14 equ E Syntax label operation operand name equ expression E Functional description The equ directive defines the name to
121. e assembler and linker but this one describes the many options available with the assembler and gives examples 70 Purpose Of This Chapter 9 2 Chapter 5 Using The Assembler Starting The 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 E General format of commands Below is the general format of the command to use when starting the assembler as 103 options source filename Contents of brackets may be omitted Specifying options An option starts with a hyphen as the options specifier followed by a character that indicate the particular option Option specifications are case sensitive so upper case and lower case letters must be specified correctly Lc Single character options not accompanied by parameters can be specified as multiple characters following the hyphen option specifier The order is optional When an option is accompanied by a parameter and other options are to follow add a space after the parameter and then follow with the hyphen option specifier I user source Li Lc Parameters can be specified right after the option character or separated by one space I user sourc Or I user source When options are omitted assembly will be perform in accordance with the default interpretations built in to t
122. e keyword message and separated from it with white space is one of the parameters ENGLISH EUC SJIS or JIS These parameters have the following meanings message ENGLISH Outputs messages in English message EUC Outputs messages in Japanese using EUC encoding message SJIS Outputs messages in Japanese using Shift JIS encoding message JIS Outputs messages in Japanese using JIS encoding The default setting depends on the host machine and operating system Sun Sparc ENGLISH HP9000 ENGLISH PC 9801 SJIS DOS V SJIS PC AT ENGLISH g OPTION This entry controls the output of debugging information Following the keyword g OPTION and separated from it with white space is one of the parameters ON or OFF These parameters have the following meanings g OPTION ON Enable output of debugging information g OPTION OFF Disable output of debugging information The default setting is to disable output of debugging information En OPTION This entry controls the output of the symbol table to the executable file Following the keyword En OPTION and separated from it with white space is one of the parameters ON or OFF These parameters have the following meanings En OPTION ON Disable output of the symbol table to the executable file En OPTION OFF Enable output of the symbol table to the executable file The default setting is to disable output of the symbol table to the executable file Chapter 1 Getting Started
123. e letter g as103 g sample asm E Default specification Debug information will not be output Chapter 5 Using The Assembler O Turn on optimization E Functional description This option enables optimization of instructions by the assembler and linker For the instructions subject to optimization see Chapter 4 Optimization Functions This option overrides any opt off directives included in the source files For further details on the opt off directive see Chapter 9 Writing Machine Language Instructions and Directives Section 9 4 Writing Directives Section 9 4 opt E Rules of use To specify the option enter the hyphen followed by the upper case letter O as103 O sample asm E Default specification The default is to suppress optimization It is also possible to change the optimization default with an entry in the assembler s start up file See Chapter 1 Getting Started Section 1 5 Setup Command Options 93 Chapter 5 Using The Assembler o Turn off optimization E Functional description This option disables optimization of instructions by the assembler and linker For the instructions subject to optimization see Chapter 4 Optimization Functions This option overrides any opt on directives included in the source files For further details on the opt on directive see Chapter 9 Writing Machine Language Instructions and Directives Section 9 4 Writing Directives Section 9 4 opt E R
124. e list file the line numbers of source statements with macro calls will be prefixed by the letter M The source statements resulting from macro expansion will have a appended to the line number ill Usage examplen 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 The macro is called with varl and var2 as parameters varl equ 0x10 var2 equ varl 2 add_adr macro adr add adr AU endm CODE section CODE PUBLIC 2 main add_adr varl add_adr var2 end Reference By adding the Lm option when the assembler is started you can suppress the output of mnemonics of macros expanded by the assembler 230 Macro Calls And Expansion Chapter 11 Writing Macro Control Statements 1 1 A Macro Operators Macro operators are used in macro bodies to operate on parameters of macro calls Macro operators are listed below Operator Description amp Concatenates strings Macro definition dummy parameters Macro call Macro expansion pl amp p2 amp p3 gt abc def ghi gt abcdefghi pl amp p2 amp p3 gt data 1 3 gt datal3 Escape characters for including normally unusable characters lt gt amp in parameters of macro calls Macro definition dummy parameters Mac
125. e parenthsis and distinguish them When the expressions starting with parenthsis are coded to the operands of a from others Example mov 10 5 dO move the value of address 15 to dO equal to mov 15 dO mov 0 10 5 dO move the value of constant 15 to dO mov 10 5 2 dO Error 10 5 is regarded as an address reference It causes syntax error 160 Expressions 8 7 4 Chapter 8 Writing Source Statements 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 Undefined undefined UND Absolute absolute ABS External external EXT Relative relocate REL Bi Attribute of the operation result The attributes of the label itself or the operation result for the labels are following four UND Undefined attributes Undefined at referring the labels ABS Absolute attributes Defined with equ pesude instruction and its value is not changed The constant value directly written will be regarded as an absolute attributes REL Relatvie attributes The labels defined in the same file at referring the labels forward referring labels EXT External Reference attributes The labels declared with global pseud instruction and defined with the other files The rules for connecting attributes are as follows
126. e specification with an entry in the assembler s start up file See Chapter 1 Getting Started Section 1 5 Setup 84 Command Options Chapter 5 Using The Assembler JS Output error and warning messages in Japanese using Shift JIS encoding E 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 E Rules of use To specify the option enter the hyphen followed by the upper case letter J and the lower case letter s The two letters together function as a single option as103 Js sample asm i This option is not available on PC AT machines E E Default specification The default language used depends on the host machine and the operating system Host machine Message language Sun Sparc English HP9000 English PC 9801 Japanese in Shift JIS DOS V Japanese in Shift JIS PC AT English It is also possible to change the default message specification with an entry in the assembler s start up file See Chapter 1 Getting Started Section 1 5 Setup Command Options 85 Chapter 5 Using The Assembler Jj Output error and warning messages in Japanese using JIS encoding E 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 E Rules of use To specify the option
127. ecified ID and the two programs cannot coexist in the IRAM area because their addresses overlap Either change the OVL options so that the two programs can coexist in the IRAM area or revise the entire program 3519 Internal Error string The linker has detected an internal fault Contact Matsushita Electronics Linker Errors 287 Chapter 13 Error Messages 288 Chapter 14 Reading List Files 14 1 Purpose Of This Chapter AAA 290 14 2 Reading List Elles itt eee e t ils a 291 14 2 1 Output Format Of Machine Language Code cooccccccccocccocccconccanccnnnncnno 292 14 2 2 Symbol Table 295 Chapter 14 Reading List Files 14 1 Purpose Of This Chapter E 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 290 Purpose Of This Chapter Chapter 14 Reading List Files 1 4 2 Reading List Files Adding the 1 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 the can be viewed by using an editor Reading List Files 291 Chapter 14 Reading List Files 14 2 1 Output Format Of Machine Language Code 292 Reading List Files The output format of the machi
128. ecified by OVL ID id Either the target files do not contain the specified section or there are no target files Check the section specification for the specified OVL option as well as the file names following it 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 Chapter 13 Error Messages 13 3 3 Fatal Error Messages 3500 No memory space There is insufficient memory Make sure that there is sufficient memory capacity available 3501 filename Cannot open file The specified input file does not exist Check the disk for the file 3502 filename Cannot read file There is an error with the input file Reassemble the corresponding source file and check the disk for hardware errors 3503 filename Cannot read parameter file There is an error in the parameter file Make sure that the parameter file exists and has the proper access permissions If it passes both tests check the file for illegal characters 3504 Object file not specified There is no object file with extension rf specified as an input file Make sure that the object file is properly specified 3505 filename no object file The input file is not a relacatable object file Check the
129. ecified file redefines a public symbol already in the library Check the object files making up the library 4311 Object file number over max 65535 The number of object files in the library exceeds the limit Reduce the number of object files to within the limit 4312 Symbol name length over max 66 symbol A symbol in an object file exceeds the length limit Re create the object file using a shorter name for the symbol 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 4315 Not warning message number There is no warning message for the number specified with the W option Check the number specification Error Messages 321 Chapter 15 Using The Library Manager 15 4 3 322 Error Messages Fatal Error Messages 4501 Illegal option string The library manager does not support the specified option Check the command line option speci
130. ecimal In T CODE abc ABC is a hexadecimal number 1d103 T CODE 80000000 TGDATA 0 progl rf prog2 rf 1d103 T TEXT CONST 80000000 main rf T TEXT CONST 80002000 sub rf 1d103 T TEXTGCODE 80000000 testl rf test2 rf Be careful with the specification order for files since that order is the order in which the linker merges sections E Section layout rules The sections are merged according to the following rules 1 Sections appearing with T option specifications are assigned to the specified addresses 2 The remaining sections with no such specifications are arranged with the CODE sections preceding the DATA sections using the following rules a Sections with the same name and same attribute are merged after the section with the highest address b Sections with the same attribute are merged after the section with the highest address c Remaining sections are merged after the section with the highest address Figure 6 2 illustrates the process E Default specification Chapter 6 Using The Linker When there are no address specifications whatsoever the first section in the first file is assigned to address 0 The remaining sections are assigned using the rules under rule 2 above Section layout with T option specification Fixed layout 0x00000000 Sections without T option will be TEXTOCODE arranged by default rules _TEXT CODE _CONST
131. ecked using a hardware environment similar to that used by the final product Nearly all MN10300 series microcomputers will ultimately be incorporated within end products Therefore program debugging must also be performed under the same conditions as the end product This is why a source code debugger and in circuit emulator are provided Program Development Flow 17 Chapter 2 Program Development Flow The probe of the in circuit emulator can operate in place of the microcomputer by connecting it through the microcomputer socket in the product The source code debugger is a program for controlling the in circuit emulator s hardware The debugger downloads the application developed on a workstation or personal computer to the emulator s memory to create an environment in which the application runs as if it were in the microcomputer s ROM It can start program execution as the address of any source statement and can temporarily stop execution Also when execution is stopped the source code debugger can display values of internal registers and memory and can be used to verify desired operation of programs by changing those values It also enables more detailed operation checks with step operation whereby execution proceeds one instruction at a time Using this development environment the developer can prove programs in the same state as when finally incorporated into the microprocessor 18 Program Development Flow Chapter 2 Program De
132. ection names Reduce the number of section names to within 255 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 Check the operand expression 2317 Too many operand An operand of the wrong type is used Check the number and types of operands 2318 2319 Illegal operand value An operand has a value that is not within the specified range Change the operand value to place it within the specified range Operand type should be absolute An operand does not have an absolute value Specify an absolute value for the operand 2320 Chapter 13 Error Messages Debug operand error The assembler and the C compiler have different version numbers Check that the assembler and C compiler are the most recent versions 2321 Illegal location counter The location counter value for an org directive has an illegal value Change the location counter value for the org directive 2322 Operand not need There is a superfluous operand Eliminate the superfluous operand 2323 Include file cannot read There is a mistake in
133. ective Statements 9 4 2 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements align E Syntax label operation operand align expression E Default settings The current location counter value will be inherited E 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 4 8 12 16 20 24 28 32 When the location counter value is 13 then the statement after align 4 will have its location counter changed to 16 When the location counter is 23 the statement will have its location counter changed to 24 When the location counter is 30 the statement counter will have its location counter changed to 32 Thus the align directive rounds up the current location counter value up to the next greater multiple of the expression value E Operand coding rules The attribute of the calculated result of the expression coded in the operand must be abs absolute For a discussion of expression attributes see Chapter 8 Writing Source Statements Section 8 7 Expressions Section 8 7 4 Expression Attributes The expression value must be a power of 2 in the range to 2 2 4 8 16 32 64 128 256 If the expression is not a power of two the assembler issues a warning message and rou
134. ed to be not in range then the linker will substitute code that can branch correctly The substitution for the above example would be as follows BNE AS JMP LABEL LABEL Chapter 4 Optimization E Optimization of function calls This section describes the optimization of function calls by the linker The MN10300 Series 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 _Ofunc TEXT section CODE PUBLIC 1 call _Ofunc 1 global func func TEXT section CODE PUBLIC 1 func movm D2 SP 2 add 4 SP Ofunc funcinfo func 8 D2 3 ret 1 gives the call to the function Ofunc 3 is the body of the function 2 the section between the labels func and _Ofunc saves a register and sets up the stack frame When this source file is assembled and linked the linker eliminates section 2 This section is preserved in the following cases 1 The symbol func is referenced 2 There is a directive modifying the location counter i e section align or org in the section For further details on machine instructions and directives see the MN10300 Series Instruction Manual and Section 9 4 Writing Directives This optimization of function calls is always carried out regardless of the state of Y the optimization option O It is s
135. el 21 5866 6114 Fax 21 5866 8000 E THAILAND SALES OFFICE Panasonic Industrial Thailand Ltd PICT 252 133 Muang Thai Phatra Complex Building 31st Fl Rachadaphisek Rd Huaykwang Bangkok 10320 Tel 02 6933407 Fax 02 6933423 B PHILIPPINES SALES OFFICE National Panasonic Sales Philippines NPP 102 Laguna Boulevard Laguna Technopark Sta Rosa Laguna 4026 Philippines Tel 02 520 3150 Fax 02 843 2778 181199 Printed in JAPAN
136. embler 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 The Li option specification will be ignored for source files that do not have any include statements E Rules of use The Li option is specified with the hyphen option specification character followed by the upper case letter L and lower case letter i The pair of characters of Li are handled as a single option as103 Li 1 sample asm a The Li option is used in conjunction with the option lower case l list output m E Default specification Source files included by include will be output to the list file E Operation example The following command line assembles the source file sampl asm and creates a listing file samp Jet that suppresses all text merged with the assembler directive include as103 1 Li sampl asm a Files included with include must not terminate with the end directive n Chapter 5 Using The Assembler L Do not output assembler source created by macro m expansion to the list file E Functional description The Lm 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 machine language code will be output
137. en it and the operation field When the label field is omitted replace 1t with at least one space or tab Both upper case and lower case letters may be used Insert at least one space or tab between the operation field and operand field When a relative address is specified in an operand and only labels with specific addresses are coded the assembler will calculate and set the relative values il Coding examples START mov DO AO src register dst register indirect mov 0x11 DO srccimmediate data dst register not DO negate rol DO rotate left ror DO rotate right and OxOf DO logical AND or 0x30 DO logical OR XOr DO D1 exclusive OR add D1 D0 add sub D1 D0 subtract mul D1 D0 multiply divu D1 D0 divide cmp 0x05 DO compare bra SUBR unconditional branch jmp A0 unconditional branch register indirect jsr SUBR subroutine call rts return from subroutine Writing Machine Language Instruction Statements 171 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements 9 4 Writing Directive Statements n 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 Bi List of directives Below is a list of directives Directive Function section Specifies a section align
138. enter the hyphen followed by the upper case letter J and the lower case letter j The two letters together function as a single option as103 Jj sample asm a This option is not available on PC 9800 DOS V or PC AT machines H E Default specification The default language used depends on the host machine and the operating system Host machine Message language Sun Sparc English HP9000 English PC 9801 Japanese in Shift JIS DOS V Japanese in Shift JIS PC AT English It is also possible to change the default message specification with an entry in the assembler s start up file See Chapter 1 Getting Started Section 1 5 Setup 86 Command Options Chapter 5 Using The Assembler e Output error and warning messages in English Bi 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 E Rules of use To specify the option enter the hyphen followed by the lower case letter e as103 e sample asm Bi Default specification The default language used depends on the host machine and the operating system Host machine Message language Sun Sparc English HP9000 English PC 9801 Japanese in Shift JIS DOS V Japanese in Shift JIS PC AT English It is also possible to change the default message specification with an entry in the assembler s start up file See Chapter 1 Getting Started Section 1 5 Setup C
139. ents resulting from macro expansion will be suppressed Below are example of source statement listspl lst Page 1 POR PanaX Series MN103000 Cross Assembler wee Loc Object Line Source 1 include outlist h E data equ 0x12345678 2 3 global move 4 M5 load macro 6 mov A0 DO 7 mov DO A1 8 add 4 A0 9 add 4 A1 0 endm 1 2 _TEXT section CODE PUBLIC 1 00000000 3 main 4 ifdef VERSION 5X mov data D0 6x mov DO A0 7 else M 18 load 00000000 70 8 mov A0 DO 00000001 6 8 mov DO A1 00000002 2004 8 add 4 A0 00000004 2104 8 add 4 Al 00000006 70 9 mov A0 DO 00000007 6 20 mov DO Al 00000008 2004 21 add 4 A0 0000000a 2104 22 add 4 Al 23 endif 0000000c FCFF00000000 24 calls move 25 end listspl lst Page 2 Symbol Table 12345678 A data U move 00000000 T main 294 Reading List Files 14 2 2 Chapter 14 Reading List Files Symbol Table If only the 1 letter option is specified and not the c or s options when the assembler is invoked then the assembler will output a symbol table to the list file after the machine language code section If the c option is specified then a cross reference table will be output instead of the symbol table The symbol table outputs the name value and type of every symbol in the source file It has the following format Symbol Value Mo Mc Symbol Type Symbol Name d A 00000000 T XXXXXX U D E Symbol Value The symbol s
140. ept pi add 1 DO enam enam TEXT section CODE PUBLIC 1 repeat rept add endm RUN 238 rept Chapter 11 Writing Macro Control Statements The assembled list file is shown below rept lst Page 1 KER PanaX Series MN103000 Cross Assembler RRR Loc Object Line Source M 1 repeat macro pi 2 rept pl 3 add 1 DO 4 endm 5 endm 6 7 _TEXT section CODE PUBLIC 1 M 8 repeat 2 M 8 rept 2 8 add 1 DO 8 endm 00000000 2801 8 add 1 DO 00000002 2801 8 add 1 DO M 9 rept 3 10 add lr DI 11 endm 00000004 2901 11 add Le DL 00000006 2901 11 add 1 Dl 00000008 2901 11 add 1 Dl rept 239 Chapter 11 Writing Macro Control Statements 240 irp 11 9 irp E Syntax irp dummy_parameter parameter parameter block enam a Up to 10 dummy parameters can be specified LU E Functional description The irp directive repeatedly expands the specified block the specified number of times The dummy parameter is used within the block The macro expansion replaces the dummy parameter with each parameter in turn repeated for the number of parameters E Coding rules Symbols cannot be used within a block If used then a double definition error will occur The local directive cannot be used either If a comma delimiters in a row are specified then the corresponding parameter will be processed as though a null character had been specified To specify strings that include comm
141. er Fatal error the error number and the text of the message The assembler or linker aborts after displaying the message 274 Purpose Of This Chapter Chapter 13 Error Messages 1 3 2 Assembler Errors ii The assembler displays three types of messages warning messages error messages and fatal error messages 1 3 2 1 Warning Messages 2001 Operand error An operand is of the wrong type Check the number and types of operands 2002 Illegal operand value An operand does not have an acceptable value Change the value of the operand 2003 Define symbol multiple defined The same symbol is defined twice Change the identifier after the define or use the undef control statement 2004 Define symbol not defined The identifier specified in an undef statement has not been defined Check the spelling of the identifier 2005 Ignore RADIX If an expression uses extended language syntax the assembler ignores the radix directive Delete the radix directive 2006 Change RADIX equal 10 An expression using extended language syntax does not use a radix of 10 Use the radix directive to change the radix to 10 2007 Line too long A source statement exceeds the length limit Edit the source statement so that its length is within the limit Assembler Errors 275 Chapter 13 Error Messages 276 Assem
142. er 16 Notes On The Operating Environment Bl Generate error file The example below shows the generation of an error file ERROR by redirection This example assembles MAIN ASM and outputs error messages to the file ERROR instead of the screen First assemble a file that actually includes errors and generate an error file The following source file MAIN ASM includes two errors CODE section CODE PUBLIC 1 data equ 1 main mov Ox11 DO move Ox11 DO mov DO data main end The assembler will detect the errors so it will generate an error file by redirection AS103 MAIN ASM gt ERROR The contents of the generated error file ERROR are as follows 5 move 0x11 DO MAIN ASM 5 Error 2304 Instruction not found 7 main MAIN ASM 7 Error 2306 Multiple define symbol Errors 2 Warnings 0 MAIN ASM 332 Personal Computer Versions Chapter 16 Notes On The Operating Environment 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 5 move Ox11 DO MAIN ASM 5 Error 2304 Instruction not found 7 main MAIN ASM 7 Error 2306 Multiple define symbol Errors 2 Warnings 0 MAIN ASM E Tag jumps The first error message matches this display on the screen MAIN ASM 5 Error 2304 Instruction not found This line work
143. es an executable file m103 ex and map file m103 map in the current directory Command Options 107 Chapter 6 Using The Linker 6 3 2 Error Message Options Output error and warning messages in Japanese E 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 Sparc EUC HP9000 Shift JIS PC 9801 Shift JIS DOS V Shift JIS PC AT not supported E Rules of use The j option is specified with the hyphen option specification character followed by the lower case letter j 1d103 j sample rf a This option is not available on PC AT machines H E Default specification The default language used depends on the host machine and the operating system Host machine Character coding Sun Sparc English HP9000 English PC 9801 Japanese in Shift JIS DOS V Japanese in Shift JIS PC AT English It is also possible to change the default message specification with an entry in the linker s start up file See Chapter 1 Getting Started Section 1 5 Setup 108 Command Options Chapter 6 Using The Linker Je Output error and warning messages in Japanese using EUC coding E Functional description This option causes all error and warning messages and help screens sent to the console or the listing file to appear
144. es to numbers Refer to section 8 3 Numbers for H details Coding rules In extended C format and Intel format character constants are specified just with the character enclosed in single quotation marks In Matsushita format the enclosed character is preceded by the letter C or c The character A ASCII code 042 is specified in each coding format as follows Coding Format Character Constant Extended C language format A Matsushita format C A or c A Intel format A Specifying more than one character such as CFEDCBA or FEDCBA will cause an error 1 To specify a single quotation mark for a character constant precede the mark by a backslash ev Specifies Character Constants 151 Chapter 8 Writing Source Statements 152 Character Constants E 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 Specifies the string ABCDEFG as ASCII code amp SS Specifies the string amp 5S as ASCII code a backslash 1 To specify a double quotation mark in a character constant precede the mark by a b Specifies in ASCII code The coding format has no effect even when a single characte
145. etup the commands and options of the C Compiler gt MN10300 Series C Compiler User s Manual Language Description lt Describes the syntax of the C Compiler gt O MN10300 Series C Compiler User s Manual Library Reference Describes the the standard library of the C Compiler O MN10300 Series C Source Code Debugger User s Manual Describes the use of the C source code debugger gt NOTE Not required for C Source Code Debugger for Windows users O MN10300 Series C Source Code Debugger for Windows User s Manual Describes the use of the C source code debugger for Windows O MN10300 Series Installation Manual lt Describes the installation of the C compiler cross assembler and C source code debugger and the procedure for bringing up the in circuit emulator gt Main Contents Table of Contents Table of Contents Chapter 1 Getting Started Chapter 2 Program Development Flow Chapter 3 Introduction To Operation Chapter 4 Optimization Chapter 5 Using The Assembler Chapter 6 Using The Linker Chapter 7 Types Of Source Statement Chapter 8 Writing Source Statements Writing Machine Language Instruction Chapter 9 Statements And Directive Statements Chapter 10 Writing Assembler Control Statements Chapter 11 Writing Macro Control Statements Chapter 12 List Of Machine Language Instructions Chapter 13 Error Messages Chapter 14 Reading List Files Chapter 15 Using The Library Manager Chapter
146. f conditional directives E Rules of use The Lc option is specified with the hyphen option specification character followed by the upper case letter L and lower case letter c The pair of characters of Lc are handled as a single option as103 Lc 1 sample asm a The Lc option is used in conjunction with the option lower case l list output n E Default specification Blocks of unsatisfied conditions will be output to the list file E Operation example The following command line assembles the source file sampl asm and creates a listing file sampl lst that suppresses all text from conditional assembly blocks for which the condition Is not satisfied as103 1 Le sampl asm Chapter 5 Using The Assembler Do not output a symbol table to the list file E Functional description The Ls directive suppresses output of a symbol table when the list file is output B Rules of use The Ls option is specified with the hyphen option specification character followed by the upper case letter L and lower case letter s The pair of characters of Ls are handled as a single option as103 Ls l sample asm a The Ls option is used in conjunction with the option lower case l list output n E Default specification A symbol table will be output Command Options 81 Chapter 5 Using The Assembler Read the map file to output a list file with resolved address E Functional description
147. ff 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 a The listoff and liston directives themselves are output a Only output to the list file will be suppressed Output of object code will not be suppressed at all E Operand coding rules These directives take no operands E Usage example Below is an example use of the listoff and liston directives The mov 0x22 D0 is a statement that should not be output to the list file CODE section CODE PUBLIC 2 main mov Ox11 DO listoff mov 0x22 DO liston mov 0x33 D0 end 178 Writing Directive Statements 9 4 5 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements notation il Syntax label operation operand notation CLANG INTEL PANA E Default settings CLANG will be selected E Functional description The notation directive selects the format of numbers and character constants single character The MN10300 Series Cross Assembler provides three numeric formats Extended C language format ntel format Matsushita format Each format gives a specific way to represent binary octal decimal and hexadecimal numbers as well as character constants The notation directive selects which format numbers and character constants will be coded with Th
148. fications 4502 Library file name not found Either the command line contains no library file specification or the specification is in the wrong place Check the library file specification 4503 Multiply specified library file name filename The command name contains multiple library file specifications Check the library file specification 4504 Memory allocation error The library manager was unable to allocate memory Check the amount of memory available 4505 Cannot open file filename The library manager was unable to open the specified file Make sure that the file filename exists and has the proper access permissions 4506 Cannot read file filename The library manager was unable to read the specified file Make sure that the file filename exists and has the proper access permissions 4507 Cannot write file filename The library manager was unable to write to the specified output file Check the file system capacity Chapter 16 usc censere MM ME IM MEDII Notes On The Operating Environment 16 1 P rpose Of This Chapter oreet tee e dieere 324 16 2 Personal Computer Versions esee 325 16 2 1 Purpose Of This Section eene etetn tnmen enano rre recaen 325 16 2 2 Operating Environment 325 e E 326 16 24 Install ation 2 hri td ti 327 16 2 5 Environinent SENS tii de e ea da eee eae 328 16 2 6 Differences From The Workstation Versions o ooonccnnncncnicncnnoconcananonnnananonnnnnn 330 16
149. fied file Since the file is most likely corrupted re create it 4303 Cannot make temporary file name The creation of the temporary file failed for some reason Check the memory capacity 4304 4305 Can not create library file filename The library manager could not create the library file Check the file system s capacity This file is not object file filename The specified object file is not an object file Check the object file specifications If they are correct then the file is most likely corrupted so re create it 4306 This file is not library file filename The specified library file is not a library file Check the library file specification If it is correct then the file is most likely corrupted so re create it 4307 Object file name not found An option calling for an object file name is missing an object file specification Check the option syntax 4308 Invalid file information type exist filename The specified file contains incorrect file information Since the object file is most likely corrupted re create it Chapter 15 Using The Library Manager 4309 Conflicting option specified option The command line contains options that cannot occur together c and f for example Check the command line options 4310 This file has redefined public symbol filename The sp
150. file name specification for errors 3506 filename No library file The input file is not a library file Check the file name specification for errors 3507 filename Invalid file information type type There is a problem with the specified file Reassemble the corresponding source file and check the disk for hardware errors 3508 filename Bad file search There is a problem with the specified file Reassemble the corresponding source file and check the disk for hardware errors Linker Errors 285 Chapter 13 Error Messages 286 Linker Errors 3509 filename Illegal section attribute A section attribute in the specified input file is invalid Reassemble the corresponding source file and check the disk for hardware errors 3510 filename Invalid symbol detail information type type The symbol detailed information in the specified input file is invalid Reassemble the corresponding source file and check the disk for hardware errors 3511 filename Cannot make output file There is a problem creating the output file Check the file system capacity and other factors affecting file creation 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 cor
151. gned LGE signed LLE 2 signed LET gt signed LHI lt unsigned LCC lt unsigned CF 0 LLS 2 unsigned LCS lt unsigned CF 1 LRA 1 Mnemonic SETLB Store the four bytes following the SETLB and the address of the fifth byte in the Loop Instruction Register LIR and the Instruction Fetch Address Register LSR respectively 270 List Of Machine Language Instructions Chapter 12 List Of Machine Language Instructions 12 3 6 User Defined Instructions D EE E User Defined FUNCTION Mnemonic Description of operation UDFnn Dm Dn 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 effects on the flags are user defined If nn is between 20 and 35 compute with the contents of Dm and Dn Do not store the result in Dn or modify the flags UDFnn imm Dn Compute with the contents of Dn and the sign extended imm8 sign extended imm16 or imm32 and store the result in Dn The nature of the calculation and the effects on the flags are user defined UDFUnn imm Dn If nn is between 00 and 15 compute with the contents of Dn and the zero extended imm8 zero extended imm16 or imm32 and store the result in Dn The nature of the calculation and the effects on the flags are user defined 12 3 1 Other Instructions D pra Wo A il NO
152. harp through to the end of the line Each specification must end with a carriage return In particular make sure that the last line ends with a carriage return Some editors allow users to end the last line with an end of file mark instead of a carriage return 1 There is no way to specify multiple parameters on the same line Setup 7 Chapter 1 Getting Started 8 Setup The start up file as103rc supports the following keywords keyword Description message This entry specifies the language and coding scheme for messages from the assembler Following the keyword message and separated from it with white space is one of the parameters ENGLISH EUC SJIS or JIS These parameters have the following meanings message ENGLISH Outputs messages in English message EUC Outputs messages in Japanese using EUC encoding message SJIS Outputs messages in Japanese using Shift JIS encoding message JIS Outputs messages in Japanese using JIS encoding The default setting depends on the host machine and operating system Sun Sparc ENGLISH HP9000 ENGLISH PC 9801 SJIS DOS V SJIS PC AT ENGLISH file This entry configures the assembler to accept source files containing Japanese text by specifying the coding scheme used Note Errors may result if the specification does not match the coding scheme used in the file Following the keyword file and separated from it with white space is one of
153. he address following the end of the sections with the CODE attribute as placed with the T option Finally at the address following the end of all segments in external memory with the CODE option the linker creates the instruction RAM program management table used by the routine for copying sections to instruction RAM 134 Instruction RAM Support Chapter 6 Using The Linker ll Assigning to the same address in instruction RAM 1d103 T CODE 80000000 T8DATA 1000 main rf sub rf OVL 1 TEXT 40000000 progl rf OVL 2 TEXT 40000000 prog2 rf OVL 3 TEXT 40000000 prog3 rf The linker first places all sections with the CODE attribute from main rf and sub rf in the order that they appear in the input files beginning at the address 80000000 hex It then places all sections with the DATA attribute from all input files beginning at the address 1000 hex The linker places all sections other than those named TEXT after the same sections in main rf and sub rf according to the T option placement rules See Section 6 3 3 The linker resolves all internal references within the TEXT sections of progl rf prog2 rf and prog3 rf so that the sections are ready to run at the instruction RAM address 40000000 hex but places the sections in the order that they appear in the input files beginning at the address following the end of the sections with the CODE attribute as placed with the T option Finally at the address f
154. he assembler Refer to section 5 3 Command Options for default interpretations Starting The Assembler 71 Chapter 5 Using The Assembler Specifying a path for the source file does not affect the listing file and relocatable object file They are always created in the current directory Note however that the o option is available for creating the relocatable object file in another a Omitting the path specifies that the source file is in the current directory a directory Ze Starting The Assembler Chapter 5 Using The Assembler E Summary of options The following Table lists the available command line options Table 5 1 Assembler Options Option Type Symbol Description Output file ofile name Specify the relocatable object file name to be output options Output a list file Do not output files included by include to the list file Do not output assembler source created by macro expansion using macro or irp to the list file Output only the machine language code Do not output a symbol table to the list file Do not output source statements that were not assembled due to unfulfilled conditions of conditional assembly to the list file a map file name Read the map file to output a list file with resolved addresses Error message j Output error and warning messages in Japanese Output will options be to the screen and when a list file is specified to the list file O
155. hey will be processed as instructions or symbols The purge directive cannot be used within macro definitions When multiple macro names are specified they are delimited by commas E Usage example The following example illustrates the use of the purge control statement The above example contains two definitions for the same macro name The first instance of macl expands to a mov instruction After the purge control statement the second definition for mac takes effect maci macro pl p2 mov pl p2 endm TEXT section CODE PUBLIC 1 macl 0 Al purge macl macl macro pl p2 add pl p2 endm macl 1 Al Purging Macro Definitions purge 237 Chapter 11 Writing Macro Control Statements 11 8 22 E Syntax rept expression block endm E 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 E Coding rules Symbols cannot be used within a block If used then a double definition error will occur The local directive cannot be used either Further rept and ipt directives and macro calls can be coded within a block Up to 20 nesting levels are allowed E Usage example In the following example the rept directive is in a macro definition that is used twice in the program main repeat macro pi r
156. hin macro endif definitions ifnb dummy_parameter Assembles block if the dummy parameter bock is not a null character Assembles block2 if it else is nothing will be assembled if there is no block2 endif else ifnb can only be used within macro definitions List Of Assembler Control Statements 349 Chapter 17 Appendix 350 Symbols FASO SIC secs M N 329 ENEE 6 Dni Scc 329 A eege 129 a OVER AY table 4 5 nerit rrt ets 128 GP M 231 pp HU 231 n 231 filename library manager mals filename linker option eee 124 A a library manager a map filename assembler option 82 absolute addressing PRIMI senescence ais address constants canaria addressing modes erret here Address Specifier ita ii iii eee arithmetic instructions arithmetic operators sairis aa a aar as 156 ASTOS RE re E A ASIO EXE assembleert enic mettere 326 IEN 329 assembler assembler control statements sssssss 142 204 assembler Customization ccce otc i ee roe 6 assembler Errors diras cdta posts os 275 assembler Options nitro 73 assembling and linking multiple sections 35 assembly language noie ina 17 AUTOEXEG BAT 5 3 tnc HEREDI HRE 328 B basic operation of the assembler and
157. ibrary manager aborts after displaying the message The following pages list the error messages that may appear during library manager operation The list uses the following format E How to read The meanings of each entry in the error message tables are as shown below error number displayed message cause solutions 15 4 1 Chapter 15 Using The Library Manager 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 informations filename There is no public symbol information for the file filename Check whether the file is actually needed 4003 filename not found In addition to library This message indicates that the file to be replaced does not exist in the library In this case slib103 adds the file to the library Check whether the object file to be replaced is in the library Error Messages 319 Chapter 15 Using The Library Manager 15 4 2 320 Error Messages Error Messages 4301 Multiply specified object file name filename Either the same object file is specified twice on the command line or an object file with the same name is in the library Check the file name specifications If necessary change the file names 4302 Premature EOF filename There is something wrong with the contents of the speci
158. ide the macro is not expanded m Document conventions Symbols used in this chapter have the following meanings Contents of brackets may be omitted ues Contents of parentheses may be repeated 226 Purpose Of This Chapter 11 2 Chapter 11 Writing Macro Control Statements Macro Definition macro endm m Syntax macro name macro dummy parameter dummy parameter macro body endm Y Up to 10 dummy parameters can be specified m Functional description A macro assigns a name to a single process that is used repeatedly in a program simplifying the coding of source statements Macros must be defined before they are called The macro body is coded with multiple machine language instructions directives macro control instructions and conditional assembly control instructions A macro definition is the assignment of a name to the single process in the macro body A macro is called by coding its name in the operation field of a source statement The assembler then inserts the text of the macro body at that position This is called macro expansion Macro definitions can have up to 10 dummy parameters Dummy parameters are used within the macro body to allow the caller to modify some of the expanded text Reference Subroutines have similar functions but macros and subroutines differ on the following points 1 Macro expansion actually writes the macro body s machine language code i
159. if m Functional description iflt Syntax for ifle ifle expression block1 else block2 fendif If the value of expression is negative then block1 will be assembled If it is not negative and an else directive has been coded then block2 will be assembled ifle If the value of expression is 0 or negative then block will be assembled If it is positive and an else directive has been coded then block2 will be assembled m Usage example Following is an example of iflt A source file is shown below The size 16 expression of the iflt is not negative so block 2 is assembled MNXXX equ 32 dsize macro size iflt size 32 mov 0x01 D0 felse mov 0x02 D0 fendif endm TEXT section dsize MNXXX CODE PUBLIC 1 Conditional Assembly 217 Chapter 10 Writing Assembler Control Statements The assembled list file is shown below iflt lst Page 1 KA PanaX Series MN103000 Cross Assembler EEE Loc Object Line Source 2 MNXXX equ 32 2 M 3 dsize macro size 4 iflt size 32 5 mov 0x01 D0 6 else 7 mov 0x02 D0 8 endif 9 endm 0 1 _TEXT section CODE PUBLIC 1 M 12 dsize MNXXX 2 iflt MNXXX 32 2X mov 0x01 D0 2 else 00000000 8002 2 mov 0x02 D0 2 endif 218 Conditional Assembly 1 0 5 5 ifgt ifge Chapter 10 Writing Assembler Control Statements B Syntax Syntax for ifgt ifgt expression block
160. imm32 Dn UDFU07 imm Dn UDFUO7 imm8 Dn UDFUO07 imm16 Dn UDFUO07 imm32 Dn UDFUO8 mmm Dn UDFUOS imm8 Dn UDFUOS imm16 Dn UDFU08 imm32 Dn UDFU09 imm Dn UDFU09 imm8 Dn UDFUO9 imm16 Dn UDFUO9 imm32 Dn UDFU10imm Dn UDFUIO imm8 Dn UDFUIO imm16 Dn UDFU10 imm32 Dn UDFUIIimm Dn UDFUII imm8 Dn UDFUII imm16 Dn UDFUI1 imm32 Dn UDFUI2 imm Dn UDFU12 imm8 Dn UDFUI2 imm16 Dn UDFUI2 imm32 Dn UDFUI3 imm Dn UDFUI3 imm8 Dn UDFUI3 imm16 Dn UDFUI3 imm32 Dn UDFUI4 imm Dn UDFUI4 imm8 Dn UDFUI4 imm16 Dn UDFUIA4 imm32 Dn UDFUI5 imm Dn UDFU15 imm8 Dn UDFU15 imm16 Dn UDFUIS5 imm32 Dn Usage Example 63 Chapter 4 Optimization E Example branch destination of conditional branch instruction within range This example shows a branch in the permitted range 128 to 127 of PC of a BCC LABEL conditional branch instruction The source list is as follows opt on _TEXT section CODE PUBLIC 1 sub_func mov 0 D2 cmp D1 D2 addr_set bec func end org addr_set 127 func_end EES end The final list file after assembly is shown next The start address during linking is assumed to be 40000000 hex The E mark on line number 6 indicates that the instruction was the object of optimization Since the target address is within the range of a relative jump the assembler generates a BCC LABEL instruction optl lst HER PanaX Series MN103000 Cross Assembler EER Loc Object Line Source RH opt 2 _TE
161. imm32 from An and set the flags according to the result List Of Machine Language Instructions 261 Chapter 12 List Of Machine Language Instructions 12 3 3 Logical Instructions D u _ KENT E AND source with destination Mnemonic Description of operation AND Dm Dn AND Dm with Dn and store the result in Dn AND imm Dn AND the zero extended imm8 zero extended imm16 or imm32 with Dn and store the result in Dn AND imm16 PSW AND imm16 with PSW and store the result in PSW E OR source with destination Mnemonic Description of operation OR Dm Dn OR Dm with Dn and store the result in Dn OR imm Dn OR the zero extended imm8 zero extended imm16 or imm32 with Dn and store the result in Dn OR imm16 PSW OR imm16 with PSW and store the result in PSW B EXCLUSIVE OR source with destination Mnemonic Description of operation XOR Dm Dn XOR Dm with Dn and store the result in Dn XOR imm Dn XOR the zero extended imm16 or imm32 with Dn and store the result in Dn E NOT destination Mnemonic Description of operation NOT Dn Reverse all bits in Dn and store the result in Dn 262 List Of Machine Language Instructions Chapter 12 List Of Machine Language Instructions E ARITHMETIC SHIFT RIGHT Mnemonic Description of operation ASR Dm Dn Arithmetically shift the contents of Dn right the number of bits specified in Dm and s
162. in the function s declaration section This special format takes the form of the funcinfo directive The linker then uses the specified stack size and register list to automatically set up the proper calling sequences for calls to the function E Operand coding rules The label name gives the branch target used by instructions other than the call instruction the calls instruction for example This label name is necessary even if no other instructions call it In that case assign a label to any empty statement immediately preceding the funcinfo directive and use the name of that label The label name must be defined prior to the funcinfo directive Otherwise an error results The expression gives the size of the stack frame used by the function It must evaluate to a value between 0 and 255 A value outside this range results in an error The register list gives a list of registers to be saved to the stack before entering the function proper Enclose the list in square brackets and separate the registers in the list with commas The registers that can appear in the list are D2 D3 A2 A3 and OTHER where OTHER indicates DO D1 AO A1 MDR LIR and LAR A register specification other than these five results in an error 200 Writing Directive Statements Chapter 9 Writing Machine Language Instruction Statements And Directive Statements Optimization can eliminate the instructions between label name and the function Y name For detai
163. intermediate values This will assemble the two source files program3 asm and program4 asm in the current directory It will add debug information g option to the relocatable object files program3 rf and program4 rf and generate list files program3 Ist and program4 1st respectively in the current directory 1 option Adding debug information g option enables symbols to be used during debugging Let s take a look at the list files that were created Assembling And Linking Multiple Sections 37 Chapter 3 Introduction To Operation 38 The contents of the list file program3 1st are as follows Note that the symbol table is not displayed Loc 00000000 00000000 00000002 00000005 00000008 00000010 00000014 0000001c 00000020 00000000 Object 9000 2CFF00 2D8000 F8FEFCFCFF000000 OOF8FE04 F8FEFCFCFF000000 OOF8FE04 CA00 00000000 Lin 0 0 ONY O 0d o PN BF PanaX Series MN103000 Cross Assembler e D w W Dw FP O o program3 1st Source CODE 00 main DATA datal KKK global global section mov mov mov jsr jsr bra Page 1 main data set time filler CODE PUBLIC 1 0 A0 Oxff DO 0x80 D1 data set time filler main section DATA PUBLIC 4 ds end 4 There is a plus sign before line numbers 9 and 10 This indicates that the object code does not have final values This is because the two functions data set and time fil
164. ion for selecting block 1 Condition for selecting block 2 ifdef Identifier has been defined by define Identifier has not been defined ifndef Identifier has not been defined by define Identifier has been defined if Expression value is not 0 Expression value is 0 ifn Expression value is 0 Expression value is not 0 ifeq see note Parameters and 2 are the same string Parameters 1 and 2 are not the same string ifneq e anota Parameters 1 and 2 are not the same string Parameters 1 and 2 are the same string iflt Expression value is negative Expression value is not negative ifle Expression value is 0 or negative Expression value is not 0 and not negative ifgt Expression value is positive Expression value is not positive ifge Expression value is 0 or positive Expression value is not 0 and not positive ifb see note Parameter is the null character Parameter is not the null character ifnb Parameter is not the null character Parameter is the null character see note Note These directives can be used only within macro definitions 10 5 1 Chapter 10 Writing Assembler Control Statements i tifdef stifndef B Syntax Syntax for ifdef Syntax for ifndef ifdef identifier ifndef identifier block block ls felse block2 block2 ndif endif m Functional description ifdef If the identifier has been defined by a define directive before the ifdef st
165. ion operand Org expression E Default settings The current location counter value will be inherited E Functional description The org directive sets the location counter to the address value specified by expression E Operand coding rules For the expression coded in the operand the attribute of the calculation result must be abs absolute For a discussion of attributes of expressions see Chapter 8 Writing Source Statements Section 8 7 Expressions Section 8 7 4 Expression Attributes If the expression value is less than the current location counter it causes an error Writing Directive Statements 1 81 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements E Usage example Below is an example use of the org directive CODE section CODE PUBLIC 2 sec adr Instructions org 0x20 sec fnc Instructions org 0x100 end 182 Writing Directive Statements Chapter 9 Writing Machine Language Instruction Statements And Directive Statements 9 4 7 opt E Syntax label operation operand opt on off E Default settings If omitted then opt off will be assumed E Functional description The opt directive enables and disables the optimization functions of the assembler and linker The optimization function examines source statements and chooses the instruction variants that yield the shortest code after linking While the linker is linking multiple files
166. ions for which both name and attribute match 3 Join sections for which either name or attribute match For further details see Chapter 6 Using the Linker Section 6 3 Command Options Section 6 3 3 Program Generation Options 44 Assembling And Linking Multiple Sections 3 5 Conditional Assembly And Linking Chapter 3 Introduction To Operation The MN10300 Series Cross Assembler provides many assembler directives Assembler directives are not converted directly to machine language but are used to control how the assembler processes For example during the development stage a programmer may want to include a special program only for debugging This program must be deleted when the product is complete That can be accomplished by editing the source file but if that editing is spread throughout the program then mistakes will be easy to make It is convenient to use assembler directives in such cases The conditions for assembly are defined at the start of the program and programs to be assembled when the conditions are satisfied or not satisfied are written in the source file E Create source file Using an editor create the program program5 asm shown below The contents of program5 asm are as follows dat_set CODI main fifdef else endif _DATA datal data2 section D EBUG dat set dat set section E PUBLIC 2 datal 0x11 datal 0x22 DATA PUBLIC 2 0
167. is directive can be coded any number of times in a program For a discussion of character constant formats see Chapter 8 Writing Source Statements Section 8 7 Expressions Section 8 7 4 Expression Attributes il Operand coding rules The strings that can be specified in the operand and the format that they select are listed below operand Format CLANG Extended C language format INTEL Intel format PANA Matsushita format If other strings are specified then the assembler will generate an error and ignore this directive Writing Directive Statements 1 79 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements E Usage example Below is an example use of the notation directive notaion lst EER PanaX Series MN103000 Cross Assembler EKE Loc Object Line Source 1 _DATA section 2 notation 00000000 FF 3 dc 00000001 FF 4 dc 00000002 FF 5 dc 00000003 FF 6 dc 00000004 FF 7 dc 8 notation 00000005 FF 9 dc 00000006 FF 10 dc 00000007 FF T1 dc 00000008 FF 12 dc 13 notation 00000009 FF 14 dc 0000000a FF 15 dc 0000000b FF 16 dc 0000000c FF 17 dc Page 1 DATA PUBLIC 4 INTEL 11111111b 3773 3770 255d Offh CLANG 10 a al 0377 255 Oxff PANA b irTI3T311 o 377 E299 xU PI 180 Writing Directive Statements 9 4 6 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements org E Syntax label operat
168. it outputs the instructions with the smallest possible code size for the instructions subject to optimization Refer to chapter 4 Optimization for details The Od assembler option disables the optimization function such that optimization a will not be enabled even if opt on is coded in the source file H E Operand coding rules The strings that can be coded for the operand and their meanings are as follows opt on Enables optimization opt off Disables optimization Writing Directive Statements 183 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements E Usage example Below is an example use of the opt directive opt opt on off 184 Writing Directive Statements Chapter 9 Writing Machine Language Instruction Statements And Directive Statements 9 4 8 page E Syntax label operation operand page lines expression columns expression E Default settings Number of lines 60 Number of columns 132 E Functional description The page 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 then apply the newly set values E Operand coding rules The expressions coded in the operand must result in the attribute abs absolute For a discussion of attributes of expressions see Chapter 8 Writing Source Statements Section 8 7 Expressions Section 8
169. itial value expression 3 Number of iterations E Default settings expression2 initial value If omitted the assembler will assume 0 expression3 iterations If omitted the assembler will assume 1 E Functional description The ds directive reserves a memory area of the number of bytes specified by expressionl of the operand When expression2 initial value is specified that memory area will be filled with the initial value When expression3 iterations is specified the same specification will be repeated for the number of iterations For example if the operand is 4 0 3 then a 4 byte area will be filled with 0 three times Thus a 12 byte area will be reserved When a name is coded for the label the assembler will assign the current location counter value to that name E Operand coding rules The expressionl bytes expression2 initial value and expression3 iterations coded in the operand must result in the attribute abs absolute For a discussion of expression attributes see Chapter 8 Writing Source Statements Section 8 7 Expressions Section 8 7 4 Expression Attributes a When expression2 is omitted expression3 cannot be specified 190 Writing Directive Statements Chapter 9 Writing Machine Language Instruction Statements And Directive Statements E Usage example Below is an example use of the ds directive ds lst Page 1 Ld PanaX Series MN103000 Cross Assembler EER Loc Object Line Sour
170. ive indirect addressing Branches possible to anywhere in the 4 gigabyte memory space MOV imm An MOV imm Dn Immediate addressing 32 bit immediate data Usage Example 55 Chapter 4 Optimization Arithmetic instructions subject to optimization Instruction Type Branch Range ADD imm An ADD imm Dn ADD imm SP AND imm Dn CMP imm An CMP imm Dn Immediate addressing 32 bit immediate data Logical instructions subject to optimization Instruction Type Branch Range OR imm Dn XOR imm Dn Immediate addressing 32 bit immediate data Bit manipulation instructions subject to optimization Instruction Type Branch Range BTST imm Dn Immediate addressing 32 bit immediate data 56 Usage Example Chapter 4 Optimization User defined instructions subject to optimization Instruction Type Branch Range UDFO00 imm Dn UDFO0I imm Dn UDFO02 imm Dn UDFO03 imm Dn UDFO04 imm Dn UDF05 imm Dn UDF06 imm Dn UDFO07 imm Dn UDFO08 imm Dn UDFO9 imm Dn UDFIO imm Dn UDFI1 imm Dn UDFI2 imm Dn UDF13 imm Dn UDF14 imm Dn UDFIS5 imm Dn UDFUOO imm Dn Immediate addressing 32 bit immediate data UDFUOI imm Dn UDFUO02 imm Dn UDFUO3 imm Dn UDFU04 imm Dn UDFUOS imm Dn UDFUO6 imm Dn UDFU07 imm Dn UDFUOS imm
171. lation see the MN10300 Series PanaX Series Installation Manual Installation 5 Chapter 1 Getting Started 6 Setup 1 5 Setup These procedures are for setting up this system when it has just been installed or for altering basic settings E Setting the 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 If this system has been installed in usr local bin for example adding the directory usr local bin to the PATH environment variable permits the use of the command name only for the commands in this system Under Unix most users initialize environment variables via a start up file named cshrc and located in the user s home directory If this is the case use an editor to modify the PATH variable setting in this start up file To put the changes into effect either log out and then log in again or use the source command to execute the contents of cshrc Bi Start up files The assembler and linker start by reading start up files which contain statements for initializing start up variables The assembler start up file as103rc contains statements specifying the following four items 1 The default language and character coding scheme for messages from the assembler 2 The character coding scheme for assembler source files 3 The radix notation u
172. ler do not exist in this program so the call addresses will not be resolved unless linked That further means that this list file is not the final list file Line number 11 also has a plus sign This indicator warns that the line contains a symbol that is not assigned a final value until linking Finally notice that the list begins from location 00000000 The start addresses of section format programs are specified with the linker Here the assembler uses relative values beginning from 00000000 as location counter values Assembling And Linking Multiple Sections The contents of the list file program4 Ist are as follows Note that the symbol table is not displayed Chapter 3 Introduction To Operation program4 lst KER PanaX Series MN103000 Cross Assembler e Loc Object Line Source 1 global 2 3 _CODE_01 section 00000000 4 data_set 00000000 8A00 5 mov 6 00000002 7 data set loop 00000002 A6 8 cmp 00000003 C600 9 bcc 10 00000005 60 11 mov 00000006 2A01 12 add 00000008 2002 3 add 0000000a CA00 14 bra L5 0000000c L6 data set end 0000000c FOFC L7 rts 18 19 CODE 00 section 20 00000000 21 time filler 00000000 8A00 22 mov 23 00000002 24 time filler loop 00000002 A4 25 cmp 00000003 C600 26 bcc 00000005 CAO00 27 bra 28 00000007 29 time_filler_end 00000007 FOFC 30 rts 31 end 32 Page 1 data_set time_filler CODE PUBLIC 1 0 D2 D1 D2 data_set_end DO A0 1 D2 2 A0 data_
173. les of use To specify the option enter the hyphen followed by the lower case letter p Slib103 test lib p E Operation example lib103 test lib p testl rf u lib103 test lib p u The first example checks whether or not the file testl rf exists in test lib and if it does outputs the externally defined symbols within it The second example outputs the externally defined symbols in all relocatable object files in test lib Command Options 311 Chapter 15 Using The Library Manager 312 Command Options r Replace the specified relocatable object file in the library file E Functional description The r option is used to replace relocatable object files in the library file If a specified file does not exist in the library file then the library manager will output a message add the relocatable object file E Rules of use To specify the option enter the hyphen followed by the lower case letter r Slib103 test lib r testl rf E Operation example Specify the following to replace the relocatable object file testl rf in the library file test lib Slib103 test lib r testl rf Multiple files can be replaced with one r option To delete testl rf test2 rf and test3 rf from test lib specify the following Slib103 test lib r testl rf test2 rf test3 rf This example replaces the relocatable object files test1 rf test2 rf and test3 rf in test lib If specifying a file name with path name fo
174. list of assembler control statements Syntax Function amp Notes include file name Reads in the source file specified by file name define identifier replacement_string Replaces the identifier with the replacement string undef identifier Purges the identifier previously defined by define Hifdef identifier Assembles block if the identifier was block defined before the ifdef statement else Assembles block2 if it was not defined block2 nothing will be assembled if there is no endif else ifndef identifier Assembles block if the identifier was block defined before the ifdef statement else Assembles block2 if it was not defined block2 nothing will be assembled if there is no endif else T f expression Assembles block1 if the identifier was not bock defined before the ifndef statement else Assembles block2 if it was defined nothing block2 will be assembled if there is no else endif ifn expression Assembles block1 if the expression is not 0 block Assembles block2 if it is 0 nothing will be else assembled if there is no else block2 endif ifeq parameterl parameter2 Assembles block1 if parameterl and block parameter2 are equal Assembles block2 if else they are not equal nothing will be assembled if block2 there is no else At least one or the other of endif parameter1 and parameter2 must be a dummy parameter within a macro definition ifeq can only be
175. ll 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 If optimization has been specified during the assembly phase the linker optimizes unconditional branches and all instructions subject to optimization For programs in section address format the start address of each section is specified when linking The linker links relocatable object files by section in the order specified by the link command and then outputs an executable format file Figure 6 1 Link Model Of Section Address Format Relocatable Object Files Executable Format File 0x00000000 sectionA Start Addresses sectionA 0x00000000 PROGRAM sectionB 0x40000000 i sectionC 0x80000000 P sectionA PROGRAMS 0x40000000 sectionB Linker PROGRAM1 sectionB PROGRAM 0x80000000 This Series includes members with instruction RAM Generating programs capable of using this support requires the use of special linker functions For a description of these functions see Section 6 4 Instruction RAM Support 100 Purpose Of This Chapter 6 2 Chapter 6 Using The Linker Starting The Linker The linker is started by entering a command name and parameters The parameters are linker options and names of files to be linked The command name differs depen
176. ls see Chapter 4 Optimization Functions Section 4 3 Usage Examples Optimization of function calls E Directive Specification Rules The funcinfo directive must always define a branch target label for use with the call instruction E Usage Example The following gives an example of funcinfo usage global _Ofunc _TEXT section CODE PUBLIC 1 call _Ofunc global _Ofunc func _TEXT section CODE PUBLIC 1 fune movm D2 SP add 4 SP _Ofunc funcinfo _func 8 D2 ret 1 The ret and retf instructions free the stack frame and restore registers from the stack The assembler bases this code on the information provided by the funcinfo directive For this reason the ret and retf instructions cannot precede the funcinfo directive Writing Directive Statements 201 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements 202 Chapter 10 Oo a NCC Writing Assembler Control Statements 10 T Purpose Of This Chapter 52 eon tents en ed o fee noie ee 204 10 2 3hncl de ite etcetera pei tddi 205 10 3 E 207 10 4 Hunde EE EE 208 10 5 Conditional Assembly uoi Ute e E 209 TOS Dita Hd EE 211 LONDRES a 213 LORO AMO A Aa 215 IA TE EE 217 LOS IR E 219 10 5 648fb te i e dedere ean tdg preme rellene 221 Chapter 10 Writing Assembler Control Statements 1 0 1 Purpose Of This Chapter Assembler control statements are statements that control assembler
177. lt settings In the absence of the i S3 S2 or S1 options the output format defaults to the Motorola S3 format In the absence of the o option the output file has the name of the executable file with the extension sf added and is located in the same directory as the executable file In the absence of the p or P options padding is not supressed in the output file E Ruels of output file name Based on input file name or the file name specified with o option change the extension It is an output file name The rules are diferent from each option specified option extension 1 hex S3 S2 SI ef default Sf File Conversion Utility 13 Chapter 1 Getting Started 14 File Conversion Utility Chapter 2 Program Development Flow 2 1 Purpose Of This Chat o ele eee ER e UN es 16 2 2 Program Development FlOW esee rene 17 2 3 Programming With The Assembler essere ener 19 Chapter 2 Program Development Flow 2 1 Purpose Of This Chapter mH 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 describes the procedures for developing in assembly language 16 Purpose Of This Chapter 2 2 Chapter 2 Program Development Flow Program Development Flow E Main development flow MN10300 series microcompute
178. mbly directives that specify conditions for changing which instructions are assembled The example below shows assembler control statements E1 ASM include a file define an identifier begin conditional assembly block to assemble if condition is fulfilled sblock to assemble if unfulfilled 142 Assembler Control Statements 7 5 Chapter 7 Types Of Source 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 The macro body uses multiple machine language instructions to construct a single program process A macro call is just a macro name coded as a source statement The assembler will replace it with all the machine language instructions coded in the macro body This process is called macro expansion The basic difference between a macro call and a subroutine call is that a macro call actually outputs machine language instructions as source statements with arguments used to output different machine language instructions for each call The example below shows macro control statements macro definition adr set macro data reg mov reg A0 mov data DU m
179. mbol endm a Up to 30 symbols can be specified E E Functional description The local directive declares local symbols used in a macro body When local symbols are expanded the are expanded in the form XXXXX where XXXXX is in the range starting 00001 to 99999 E Coding rules Symbols specified with the local directive should not be used outside the macro definition The local directive can be used only within macro definitions Local symbols should be used after they have been declared by the local directive If the local symbol XXXXX used by the local directive is not undefined then an error will occur Local Symbol Declaration local 233 Chapter 11 Writing Macro Control Statements E Usage example An example using the local directive is shown below loc macro pi local labl lab2 mov pl DO labl cmp 0 DO jmp lab2 mov 1 Al lab2 mov 0 AO endm r _TEXT section CODE PUBLIC 1 loc 0 loc 1 The assembled list file is shown next You can see that each time the local symbol is expanded it is changed to 2200001 2200002 local lst Page 1 Xm PanaX Series MN103000 Cross Assembler EEK Loc Object Line Source M 1 loc macro pl 2 local labl lab2 3 mov pl DO 4 labl cmp 0 DO 5 jmp lab2 6 mov 1 A1 7 lab2 mov 0 A0 8 endm 9 i 0 _TEXT section CODE PUBLIC 1 M 11 loc 0 M 11 local labl lab2 00000000 8000 1 mov 0 DO 00000002 A000 1 2200001 cmp Dije DO 00000
180. me other string is defined then the assembler will generate an error and ignore this directive The value of expression must be a power of 2 between 1 and 32768 If its value is outside this range then the assembler will assume the closest valid value instead The attribute link type and location boundary of sections with the same name must be either identical or omitted If a different attribute link type or location boundary is defined then actual value will be inherited from the setting of the very first section If there is the same section name in a file with a different attribute link type or location boundary then the linker will locate the section using the attribute link type and location boundary of the first occurrence that it encounters E Directive coding rules The section direction has no restrictions on where in the source file it can be defined E Usage example Below is an example use of the section directive CODE section CODE PUBLIC 2 main jsr INIT Assembler instructions and dc dw ds and dd directives must be coded after a section has been defined If used before a section has been defined then the assembler will generate an error and ignore that assembler instruction or directive The value of the section name will be the top address of the section after the link If separating the sections the top address of the lowest section will be m used 174 Writing Dir
181. ms for each section linked Even when the program is divided between multiple files or when a file is divided into multiple sections identical sections are linked together with the same attributes Therefore the programmer must create programs such that addresses do not overlap Refer to chapter 6 Using The Linker for details E 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 MN10300 Series Cross Assembler Header files Constants and variables used in all files and define identifiers used in common should be gathered into a single header file As a result changes can be made at just one location in the header file Library files Subroutine programs frequently used by different files should be gathered by function as library files to make programs easier to use Declaration position global directives Use one position for global directive declarations The global directive can be declared anywhere within a program but confusion will result if the declaration positions differ across source files Unify radix and notation directives Choose a common default radix for coding numbers constant values strings etc Comment statements Comments reveal program algorithms and processing details within
182. n Transfers the lowest 8 bits of Dm to the memory location specified by An 252 List Of Machine Language Instructions Chapter 12 List Of Machine Language Instructions Register Indirect Mnemonic MOVHU Am Dn Description of operation Transfers with zero extension the 16 bit contents of the memory location specified by Am to Dn MOVHU Dm An Transfers the lowest 16 bits of Dm to the memory location specified by An MOVH Am Dn Transfers with sign extension the 16 bit contents of the memory location specified by Am to Dn MOVH Dm An Transfers the lowest 16 bits of Dm to the memory location specified by An Register relative indirect MOV d Am Dn Transfers the contents of the memory location specified by Am and displacement d to Dn 8 and 16 bit displacements are sign extended MOV d SP Dn Transfers the contents of the memory location specified by SP and displacement d to Dn 8 and 16 bit displacements are zero extended MOV d Am An Transfers the contents of the memory location specified by Am and displacement d to An 8 and 16 bit displacements are sign extended MOV d SP An Transfers the contents of the memory location specified by SP and displacement d to An 8 and 16 bit displacements are zero extended MOV d8 Am SP Transfers the contents of the memory location specified by SP and displacement d
183. n Help information will not be displayed to the screen V Display the linker s version number on the console E Functional description This option displays the linker s version number on the console E Rules of use The v option is specified with the hyphen option specification character followed by the lower case letter v 1d103 v E Default specification The version number will not be displayed on the console 6 4 Chapter 6 Using The 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 Instruction RAM Support 127 Chapter 6 Using The Linker 6 4 1 Structure Of IRAM Support Executable File E 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 This is automatically assigned to the external memory immediately following the fixed program portion C Instruc
184. n BRA Similarly a CALL label CALLS label or JSR label instruction is replaced by the shorter version with a 16 bit displacement d16 PC instead of the one with the 32 bit displacement d32 PC The following table shows the possibilities for optimizing the unconditional branch instructions and the subroutine call instructions Source Instruction First Candidate Second Candidate Third Candidate BRA label BRA label JMP label JMP label JMP label BRA label JMP label JMP label CALL label CALL label CALL label CALLS label CALLS label CALLS label JSR label JSR label JSR label E 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 displacement data The user thus obtains optimal code size without having to worry about instruction variants The following table shows the possibilities for optimizing data transfer arithmetic logical bit manipulation and user defined instructions Source Instruction First Candidate Second Candidate Third Candidate MOV abs An MOV abs16 An MOV abs32 An MOV abs Dn MOV abs16 Dn MOV abs32 Dn MOV d An An MOV d8 An An MOV d16 An An MOV d3
185. n example use of the equ directive equ lst Page 1 EK PanaX Series MN103000 Cross Assembler KEK Loc Object Line Source 1 MEMORY equ 0x20 2 MOTOR equ 10 3 STOP equ 0500001000 4 BASE equ 0x1000 5 6 TEXT section CODE PUBLIC 1 00000000 8020 7 mov MEMORY DO 00000002 800A 8 mov MOTOR DO 00000004 8008 9 mov STOP DO 00000006 2C0010 10 mov BASE DO Writing Directive Statements 1 95 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements 9 4 15 global E Syntax label operation operand global name name E Default settings External reference when omitted undefined label error External declaration when omitted undefined label error during linking E Functional description The global directive declares external references and external declarations For external references the global directive declares that the names coded in the operand are from other files For external declarations the global directive declares that the names coded in the operand can be referenced externally The global directive can be coded anywhere in a source programs E Operand coding rules Write the name coded in the label field as an operand Generally this will be a program name The names are delimited with commas Any number of operands can be coded When a specified name has been coded in a label field within the program it will be considered an external declaration Whe
186. n it has been coded as operands it will be considered an external reference 196 Writing Directive Statements ill Usage example Below is an example use of the global directive Chapter 9 Writing Machine Language Instruction Statements And Directive Statements main SUB1 global SUB1 global READ WRITE jsr READ jsr WRITE mov Ox11 DO rts end external declaration external reference Writing Directive Statements 197 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements 9 4 16 E Syntax label operation operand t string E Functional description The tit 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 E Operand coding rules The operand is written with any string enclosed by double quotation marks A double quotation mark itself cannot be included in the string E Usage example Below is an example use of the tit directive TIT LST Page 1 TEST PROGRAM Loc Object Line Source 1 tit TEST PROGRAM 000000 54 2 dc 0x54 3 end 4 198 Writing Directive Statements Chapter 9 Writing Machine Language Instruction Statements And Directive Statements 9 4 17 istoff xliston E Syntax label operation operand xlistoff xlis
187. n the host machine and the operating system Host machine Character coding Sun Sparc English HP9000 English PC 9801 Japanese in Shift JIS DOS V Japanese in Shift JIS PC AT English It is also possible to change the default message specification with an entry in the linker s start up file See Chapter 1 Getting Started Section 1 5 Setup Chapter 6 Using The Linker Jj Output error and warning messages in Japanese using JIS coding E 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 E Rules of use The Jj option is specified with the hyphen option specification character followed by the upper case letter J and the lower case letter j The two letters together function as a single option a This option is not available on PC 9801 DOS V or PC AT machines n 1d103 Jj sample rf E Default specification The default language used depends on the host machine and the operating system Host machine Character coding Sun Sparc English HP9000 English PC 9801 Japanese in Shift JIS DOS V Japanese in Shift JIS PC AT English It is also possible to change the default message specification with an entry in the linker s start up file See Chapter 1 Getting Started Section 1 5 Setup Command Options 111 Chapter 6 Using The Linker 112 Command Options e Output error and
188. n the object file each time the macro is called at that call s position For subroutines the subroutine body exists at one location in the program 2 By using parameters macro expansion allows the programmer to change the expanded machine language instructions each time the macro is called For subroutines the process cannot be changed Macro Definition macro endm 227 Chapter 11 Writing Macro Control Statements m 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 Refer to section 11 5 Local Symbol Declaration local for details A macro can be redefined The new definition will be effective from the following line on The purge directive can purge a macro definition The macro will be recognized as an instruction or symbol from the following line on The macro name cannot be the same as a machine language mnemonic The assembler does not perform syntax checks when a macro is defined If there are errors or warnings then they will be output when the macro is expanded m Usage example An example macro definition is shown below xchg macro mov D2 D0 m
189. nction with the undef directive redefinition is possible Refer to section 10 4 undef for details If the replacement_string is omitted then the identifier will be defined as a null character E Usage example Source file contents are shown below The first line replaces data with the character 5 The next line is an example of changing a mnemonic so mov data DU can be coded as load defin data 5 defin load mov data DO CODE section CODE PUBLIC 2 main mov data DU load end define 207 Chapter 10 Writing Assembler Control Statements 10 4 208 tundef itundef E Syntax undef identifier E Functional description The undef 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 E Coding rules The identifier for an undef directive must be the same string as the identifier for the corresponding define directive The string is case sensitive E Usage example A source file that uses undef is shown below define datal 0x11 define data2 0x22 CODE section CODE PUBLIC 2 mov datal D0 mov data2 D1 fundef datal mov datal DO fundef data2 define datal 0x33 define data2 0x44 mov datal DO mov data2 D1 end 10 5
190. nds the value up to the next higher power of two When the expression value is between 5to 7 it can be round up to 8 Also When the expression value is between 17to 31 it can be round up to 32 Writing Directive Statements 175 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements ill Usage example Below is an example use of the align directive align lst Page 1 Wan PanaX Series MN103000 Cross Assembler ERE Loc Object Line Source 1 _DATA section DATA PUBLIC 4 00000000 2 TABLE 00000000 01 3 dc 0x01 00000001 02 4 dc 0x02 00000002 03 5 dc 0x03 6 align 6 align asm 6 Warning 2002 Illegal operand value 00000008 04 7 dc 0x04 00000009 05 8 dc 0x05 0000000a 06 9 dc 0x06 10 align 8 00000010 07 11 dc 0x07 00000011 08 12 dc 0x08 l3 align 16 00000020 09 14 dc 0x09 00000021 0A 15 dc 0x0a Errors 0 Warnings 1 align asm In the align 6 directive on line 6 the expression value 6 is not a power of 2 so the assembler will convert it to align 8 The series of multiples of 8 is shown below Numbers in parentheses are hexadecimal 8 8 16 10 24 18 32 20 40 28 48 30 56 38 64 40 The location counter value at the line of align 6 is 0003 hex which is between 0000 and 0008 hex Therefore the next line will start from location 0008 hex The same series applies to the align 8 on line 10 The location counter there is 000B hex which is between 0008 and 0010 hex Therefo
191. ne language code section is shown below Location Loc Machine Supplemental Line Numb Supplemental Source Language Code Information me Number Information Statement Object M Line Source Each of these fields is described below E 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 However if the assembly is to output the final list by incorporating the map file from linking then the location field will match the execution addresses E Machine language code Object This field shows machine language code The eight bits of one byte are shown as two hexadecimal digits There are 1 byte 2 byte 3 byte and 4 byte instructions E Machine language code supplemental information The characters M and may be added to the machine language code as supplemental information The meaning of each character is as follows qus This line includes an externally defined symbol whose value will be determined during linking The machine language code does not indicate the final values This line is a result of macro expansion This line includes an instruction whose value will be the object of optimization during linking The machine language code does not indicate the final values Chapter 14 Reading List Files B Line number Line The assembler
192. ng is complete generate the final list files using the map file m103 map as103 l a m103 map programl asm as103 1 a m103 map program2 asm l option Option to output a list file a option Option to read a map file Specify the map file name after it This operation will generate the final list files program Jet and program2 lst in the current directory With the above operations you can generate an executable format file and final list files in the current directory You must generate the final list files using the map file after linking This is because linking determines the start addresses of sections following the T option for files in section address format Also note that there are lines for which it is impossible to determine the address until after optimization See Chapter 4 Optimization Functions Basic Operation Of Assembler And Linker 31 Chapter 3 Introduction To Operation The contents of the final list file program1 Ist are as follows programl lst Page 1 ZER PanaX Series MN103000 Cross Assembler PEK Loc Object Line Source 1 global data sert 2 3 CODE section CODE PUBLIC 1 40000000 4 main 40000000 29000 5 mov 0 A0 40000002 2CFF00 6 mov Oxff DO 40000005 2D8000 7 mov 0x80 D1 40000008 F8FEFCFCFFOCOOOO 8 jsr data set 40000010 OOF8FE04 8 40000014 CAF2 9 bra main 10 Ek DATA section DATA PUBLIC 4 40000024 00000000 12 datal ds 4 13 end programl lst Page 2 Symbol Table 4
193. nition error will occur The local directive cannot be used either A dummy parameter appearing in a string or character constant inside the irpc block is not expanded E Usage example The following example uses the irpc directive Chapter 11 Writing Macro Control Statements _ DATA section DATA PUBLIC 1 irpc dummy 0123456789 dc dummy endm end The assembled list file is shown below KORR PanaX Series MN103000 Cross Assembler Loc Object Line Source 1 _DATA M2 3 4 00000000 00 4 00000001 01 4 00000002 02 4 00000003 03 4 00000004 04 4 00000005 05 4 00000006 06 4 00000007 07 4 00000008 08 4 00000009 09 4 irpe Let KKK section irpc dc endm Page 1 DATA PUBLIC 1 dummy 0123456789 dummy wo 0 3 On 0 B W N L O irpc 243 Chapter 11 Writing Macro Control Statements 244 Chapter 12 Pa I n N List Of Machine Language Instructions 12 1 Purpose Of This Chapter none Roper eet Eo ipe Pr e Ete Ee 246 12 2 Addressing Modes ista dete eed eerte ege 247 12 3 List Of Machine Language Instructions esee 251 12 3 1 Data Move Instructions 0 cc eesceseseesceseseesceecsceecseeeesecsesecsesaeeesseeesesseeeeaees 252 12 3 2 Arithmetic Instruectons esee 259 12 3 3 Eogical Instruction 262 12 3 4 Bit Manipulation Instruction eese eene 265 12 3 5 Branching Instructions ii 267 12 3 6 User Defined
194. ntents of SP and store the result in SP il ADD with CARRY Mnemonic Description of operation ADDC Dm Dn Add the contents of Dm and the carry flag to Dn and store the result in Dn E SUBTRACT Mnemonic Description of operation SUB Dm Dn Subtract the contents of Dm from Dn and store the result in Dn SUB Dm An Subtract the contents of Dm from An and store the result in An SUB Am Dn Subtract the contents of Am from Dn and store the result in Dn SUB Am An Subtract the contents of Am from An and store the result in An SUB imm32 Dn Subtract imm32 from Dn and store the result in Dn il SUBTRACT with BORROW Mnemonic Description of operation SUBC Dm Dn Subtract the contents of Dm and the carry flag from Dn and store the result in Dn List Of Machine Language Instructions 259 Chapter 12 List Of Machine Language Instructions B MULTIPLY Mnemonic Description of operation MUL Dm Dn Multiply the 32 bit signed integer multiplicand in Dm by the 32 bit signed integer multiplier in Dn and store the upper 32 bits of the product in MDR and the lower 32 bits in Dn MULU Dm Dn Multiply the 32 bit unsigned integer multiplicand in Dm by the 32 bit unsigned integer multiplier in Dn and store the upper 32 bits of the product in MDR and the lower 32 bits in Dn E DIVIDE Mnemonic Description of operation DIV Dm Dn Divide the
195. ollowing the end of all segments in external memory with the CODE option the linker creates the instruction RAM program management table used by the routine for copying sections to instruction RAM If multiple sections share the same or overlapping regions in instruction RAM a 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 The linker automatically detects such conflicts and suppresses executable file output E Specifying an address for the instruction RAM program management table 1d103 T CODE 80000000 T8DATA 1000 main rf sub rf OVL 1 TEXT 40000000 progl rf OVL 2 TEXT 40000000 prog2 rf OVL 3 TEXT 40000000 prog3 rf PUT overlay table a0000000 The section layout is the same as the previous example The only difference is that the linker moves the instruction RAM program management table to the address 40000000 hex The developer must be careful not assign this table to an address where it Y overlaps with actual code LI Instruction RAM Support 135 Chapter 6 Using The Linker 136 Chapter 7 CaD E Types Of Source Statements dl Purpose OF Nei EE eere dde tetas 138 7 2 Program AAA ertet oce tr amd 139 7 3 Machine Languag
196. ollows 1 Directory contains assembler source file 2 Directory specified with I option E Rules of use The I option is specified with the hyphen option specification character followed by the upper case letter T then either immediately followed by the path name or a space and the path name as103 I user defs main asm E Default specification If not specifying this option the assembler traces the directory 1 written above Chapter 5 Using The Assembler T Specify an identifier to be used by ifdef during D identifier conditional assembly E 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 Identifier specifications by define directives in source statements may be omitted The statements to be assembled can instead be selected by specifying identifiers with the D option as needed Thus the D option allows conditions to be set freely at the assembly stage without fixing the conditions with define directives in source statements There are two conditional assembly directives that can make use of the D option ifdef ifndef No error will occur if identifiers specified by the D option are not used in the source file Assembly will process as
197. ommand Options 87 Chapter 5 Using The Assembler 88 Command Options Do not output warning messages of the specified E 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 E Rules of use To specify the option enter the hyphen followed by the upper case letter W and the number as103 Ww 2001 sample asm E Default specification The default is to display all warning messages Chapter 5 Using The Assembler Wall Do not output any warning messages E Functional description This option suppresses output of all warning messages generated during assembler operation E Rules of use To specify the option enter the hyphen followed by the letters Wall as103 Wall sample asm E Default specification The default is to display all warning messages Command Options 89 Chapter 5 Using The Assembler 90 9 3 3 Command Options Preprocessor Options path name Specifyt the trace directory of the include file E Functional description Trace from the directory that specifies the include file in the assembler source file If the absolute path starting with is written this option is invalid Assembler traces the include file from the directry as f
198. omputer Versions e Heading Chapter titles are shown here on each page so the reader can get a quick idea of contents while flipping through the pages e Program example These are actual examples of command options and instructions used by the assembler First time users should refer to these examples when trying to use the assembler e Usage note These give important information Usage note provide cautions about usage so they should always be read e Supplementary explanation These are hints and terminology definitions that can help the reader use the assembler m Reference Techniques E Table Of Contents Lond Table Of Co W Chapter Contents 5 2 Starting The Assembler E A Chapter5 m BW index Index Main Contents This shows the main contents of this manual Use it to look up the start of each chapter Table Of Contents This shows the title of all sections of this manual Chapter Contents Located at the start of each chapter this shows the titles of all sections in that chapter Index Refer to the index at the back of this manual to look up technical terms E Related Documents The following related manuals are available Please contact your sales representative for more details MN103S00 Series Instruction Manual lt Describes the instruction set gt MN10300 Series C Compiler User s Manual Usage Guide lt Describes the s
199. omputer Versions Chapter 16 Notes On The Operating Environment Ending a directory specification in the PATH environment variable with a U backslash results in errors The following are examples of incorrect PATH settings Example SET PATH AA SET PATH A usr local bin Once you have edited AUTOEXEC BAT reset the computer and restart The new U setting will then automatically take effect Terminology Q 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 B Start up files The assembler and linker start by reading start up files that provide a means of changing initial settings For a detailed description see Chapter 1 Getting Started Section 1 5 Setup Paragraph Start Up Files and substitute the file names AS103 RC and LD103 RC for as103re and ld103rc respectively Personal Coomputer Versions 329 Chapter 16 Notes On The Operating Environment 1 6 2 6 Differences From The Workstation Versions The personal computer versions of the assembler linker function and the library manager are exactly the same as their workstation counterparts E Command line differences When specifying the command name omit the file extension EXE The personal computer versions use the foward slash and backslash as directory separators Exampl
200. on calls org rts end on CODE PUBLIC 1 func_end addr_set 128 The final list file after assembly is shown next Since the CALLS LABEL instruction in line four contains a target address that may be expressed with a 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 opt4 lst RN PanaX Series MN103000 Cross Assembler TUM Loc Object Line Source 1 opt 2 TEXT section 40000000 3 sub func 40000000 FAFF8000 4 addr set calls 5 6 org 40000080 7 func end 40000080 FOFC 8 rts 9 end opt4 lst Symbol Table 40000000 T sub_func 40000000 T addr_set 40000080 T func_end Page 1 on CODE PUBLIC 1 func end addr_set 128 Page 2 Usage Example 67 Chapter 4 Optimization 68 Chapter 5 A A A Using the Assembler 5T Purpose Of Thus Chapter ub meo eade ge eae di 70 5 2 Starting The Assembler AA 71 5 9 Command HESE OOo ape ge 75 5 3 Output File Options o eee ve eU e ERO 76 5 3 2 Error Message Options eov oret ence p de e eo coe 83 5 3 3 Preprocessor Options ient og eee ede eat Pee dice i pep 90 5 3 4 Program Generation Option 92 5 3 Other ROT 95 5 4 Operation E 97 Chapter 5 Using The Assembler 5 1 Purpose Of This Chapter n This Chapter describes assembler operating procedures Chapter 3 Introduction to Operation described the basic operation of th
201. on debug MODE MODE MODE debug MODE 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 RER PanaX Series MN103000 Cross Assembler Loc 00000000 00000008 0000000c 00000014 00000018 00000020 Object F8FEFCFCFF000000 OOF8FE04 F8FEFCFCFF000000 OOF8FE04 F8FEFCFCFF000000 00F8FE04 Line wo 0 JJ Dn oO FPF W MN Hn w NM P o 14 14X 14X 14 14 14 14 TU 174 INE 17 1 174 17X 17 Source debug ifb else endif TEXT define ifb else endif fundef define ifb else endif ifb lst Page 1 KKK global check proc macro string string jsr check sr proc jsr proc endm section CODE PUBLIC 1 MODE debug on debug MODE debug on jsr check jsr proc jsr proc ODE ODE debug MODE jsr check jsr proc jsr proc Conditional Assembly 223 Chapter 10 Writing Assembler Control Statements 224 Chapter 11 r M be Writing Macro Control Statements 1H 3 Purpose Of This Chapter rd 226 11 2 Macro Definition macro endm 227 11 3 Macro Calls And Expansion ient esent nte teen estan tanen ina 229 TDA Macro Operators s creer tenen en CI eu ee eR 231 11 5 Local Symbol Declaration local
202. operator precedence The order of precedence can be changed using parentheses Operators with the same precedence are evaluated in order from left to right Table 8 1 Operator Precedence Precedence Operator Description Highest acm Unary negation Unary plus Unary minus 1 Multiply divide remainder Add subtract lt lt gt gt Left shift right shift amp Logical AND e Exclusive OR Lowest Logical OR An example of operators is shown below Chapter 8 Writing Source Statements cl c2 CODE datal data2 data3 data4 data5 data6 data7 data8 data9 datal0 main equ equ section de de de de de de de de de de org mov end 10 0501101110 CODE PUBLIC 1 c1 3 344 c1 3 3 4 o a2 c2 gt gt 2 cl lt lt 2 main gt gt 2 c2 gt gt 2 0b00111100 c2 amp 0b00001111 gt gt 2 c2 0b00001111 0x100 c2 amp 0600001111 D0 An asterisk is used as both the self reference address symbol and the multiplication operator so take care in its use The expression will be division of the self reference address symbol by itself Expressions 159 Chapter 8 Writing Source Statements 8 7 3 Expression Syntax Below is an expression syntax diagram Fig 8 1 Expression Syntax Machine language instructions it will be regarded as an address reference To be proceeded as expressions put 0 before th
203. ov D1 D2 mov DO D1 endm 228 Macro Definition macro endm Chapter 11 Writing Macro Control Statements 1 1 3 Macro Calls And Expansion a B Syntax macro_name parameter parameter a Up to 10 dummy parameters can be specified m 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 When parameters are specified their values are passed in the same order as the dummy parameter when the macro was defined macl macro paral para2 para3 macro expansion endm main macl address data count macro call In this example paral para2 and para3 are dummy parameters The parameters of the macro call are passed to the dummy parameters as follows paral address para2 data para3 count Macro Calls And Expansion 229 Chapter 11 Writing Macro Control Statements E Coding rules Any string can be specified as a parameter To specify a string that includes commas or spaces use the macro operator Refer to section 11 4 Macro Operators for details If there are more parameters than there were dummy parameters in the macro definition then an error will occur If there are fewer parameters than there were dummy parameters in the macro definition then the assembler will process the remaining parameters as though null characters were specified In th
204. ov DO AQ endm macro calls adr set datal regl adr_set data2 reg2 Macro Control Statements 143 Chapter 7 Types Of Source Statements 7 6 Comment Statements DW The source statement lines of comment statements are processed entirely as comments No matter what a comment is it will not affect program operation or function Comments are used to explain data structures program algorithms etc 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 SEHR SR ek decke deese IC SECC HCCC HA SII HA e ek CHA e SEI IC RR ebe a a a D MN10300 Series Cross Assembler s Sample Program LELLLLLLLLLLELLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLII include ram A RAM definition file include macro h macro definition file define VERSION sconditional assembly definition Program Start 7 7 Blank Statements a A blank statement consists of a single carriage return Blank statements are used to make printed lists easier to read 144 Comment Statements Blank Statements Chapter 8 cs Writing Source Statements 8 1 Purpose Of This Ch pter sao eeu inte da 146 8 2 Permitted Characters diee pi rd p ge bae e beo tte 147 8 3 Numbers on ee o tt eU e d o ed ee ee ies 148 8 4 Character Constants EE 151 8 5 Addre
205. owing the former The linker automatically generates the instruction RAM program management table C at the address specified with the PUT option If there is no specification the table immediately follows the instruction RAM portion The linker resolves address references to other portions of the program assuming that the instruction RAM portions are running at the specified addresses in instruction RAM The linker creates an instruction RAM transfer unit for each OVL option making entry for each one in the instruction RAM program management table The transfer program D obtains its parameters from this table during actual transfers When the program runs the actual code for an instruction RAM portion referenced must be in the instruction RAM The software must call upon the transfer routine to copy the necessary code into the instruction RAM immediately before it is referenced The instruction RAM status management table is for use by the debugger in determining how the instruction RAM is currently being used 6 4 2 Chapter 6 Using The Linker IRAM Support Options Using the following options creates an executable file supporting instruction RAM operation OVL ID number sectionsaddress Specify an address in instruction RAM for a section E Functional description This option assigns an address in instruction RAM for the specified section The linker then resolves all addresses to as
206. pecified by include will be read from the user lib directory The above command also generates a relocatable object file named test rf with debug information in the current directory Operation Example 97 Chapter 5 Using The Assembler 98 Operation Example as103 I user defs o user src sample rf D TYPE file asm The above example assembles the source file file asm in the current directory For conditional assembly ifdef assembly will proceed as though TYPE were declared The assembler reads files specified with the include directive from the directory user defs The above example will store the relocatable object file with name sample rf in the user src directory E Generation of final list file with resolved program addresses The final list file is generated as follows 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 2 Next use the linker to generate an executable format file by specifying the start address of each section and linking multiple files Specify the linker s m option to generate the map file Refer to chapter 6 Using The Linker for details 3 Use the assembler once more to assemble the source file This time read the map file generated by the linker with the assembler s a option If the I or D options are specified then the parameters at this stage must be the same as those of the first assembly
207. perands are coded they must be delimited by a comma il Coding examples ROL DO One operand mov CONST 3 D0 Operands are a register and expression jsr PRINT Operand is an address Instruction Statement Fields 169 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements 9 2 4 Writing The 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 E Coding rules Comments being with a semicolon and end with a line feed LF Comment fields may be written with letters digits special characters and control characters other than carriage return and line feed il Coding examples mov Ox10 DO Set count value 170 Instruction Statement Fields 9 3 Chapter 9 Writing Machine Language Instruction Statements 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 MN10300 Series Instruction Manual for details of machine language instructions E Coding rules When coding a label insert at least one space or tab betwe
208. 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 E Rules of use The m option is specified with the hyphen option specification character followed by the lower case letter m The map file has the same name as the executable file except that its extension is changed to map The map file will be output to the same directory as the directory where the executable format file is generated ld103 m main rf sub rf E Default specification A map file will not be output It is also possible to change the default for map file generation with an entry in the linker s start up file See Chapter 1 Getting Started Section 1 5 Setup E Operation example 1d103 o user obj main ex m T CODE 80000000 progl rf prog2 rf The above command line links two relocatable object files progl rf and prog2 rf located in the current directory locates the resulting CODE section starting at the address 80000000 hex and generates an executable file main ex and map file main map in the directory user obj 1d103 m T TEXT 80000000 T CONST 80005000 progl rf prog2 rf The above command line links two relocatable object files progl rf and prog2 rf located in the current directory locates the resulting TEXT and CONST sections starting at the addresses 80000000 hex and 80005000 hex respectively and generat
209. r Option 5 eon aee en sidra dis 115 H h assembler Option erret erneuern eren 95 bh library manager eere terit 316 hy Hiner oponen nas 126 header files HPUX EE TAR OOOO me EERT IBM POLAT SEES mitin 3 I path_name assembler option eese 90 identifier Index addressing 45 eee tianemesmererera 250 installation ecce eec treibt deed 5 installation personal computer version 327 instruction RAM program eee 128 instruction RAM program management table 128 IRAM support executable file sess 128 IRAM support options territi 131 ij T 240 pM M 242 J j assembler option ae j library NEE E HEN Hut ege DE Je assemble r OptlOmnD corio coeno ttr Rene Je library manager eire tette Je iker Option dirias treten Jj assembler option reni riter Jj library m n ger ir rene Jj linker option moriria recette Js assembler Opt src sii 85 Js library manager oi 303 Js linker opto 110 K key WO E 7 L I assembler optiOn a inocente ene n TI library filename linker option 122 L path name linker option eene 123 label field assa see as 167 168 Lc assembler OptlOrl eec enint tnde teen tne 80 1d103 A EE 4 LD103 EXE linker iro 326 LEDIO E 329
210. r provides high speed saving and restoring of registers to and from the stack and the securing and release of the stack area CALLS An Push the program counter containing the address of the next instruction onto the stack and branch to the specified address This instruction is used paired with a RETS instruction for table jumps and other situations where the registers to be saved and the size of the stack area are not known and for situations requiring backward compatibility with JSR CALLS label label is either d16 PC or d32 PC Push the program counter onto the stack and branch to the specified address This instruction is used paired with a RETS instruction for table jumps and other situations where the registers to be saved and the size of the stack area are not known and for situations requiring backward compatibility with JSR RET Restore saved registers from the stack free the stack area and branch to the return address saved on the stack RET is used paired with CALL and the funcinfo directive RETF Restore saved registers from the stack free the stack area and branch to the return address stored in MDR RETF is used paired with CALL and the funcinfo directive RETS Branch to the return address saved on the stack RETS is used paired with CALLS It is also used to maintain backward compatibility with RTS JSR An Push the program counter containing the address of the next instruction onto the stack
211. r relocatable object file to be Y switched the file name without path name exists or will be traced in the library file Chapter 15 Using The Library Manager t Output a list of the relocatable object files that make up the library file E Functional description The t option is used when you want to know the names of the relocatable object files that exist in the library file When a relocatable object file name is specified following the t option and a file with the same name exists in the library file that file name will be output If the file does not exist then the library manager will output a warning message and continue processing When no relocatable object file name is specified the names of all relocatable object files that exist in the library file will be output ii Rules of use To specify the option enter the hyphen followed by the lower case letter t Slib103 test lib t testl rf E Operation example lib103 test lib t testl rf a lib103 test lib t 10 The first example checks whether or not the file testl rf exists in test lib The second example outputs the names of all relocatable object files in test lib Command Options 313 Chapter 15 Using The Library Manager 314 Command Options X Extract the specified relocatable object file from the library file E Functional description The x option is used when you want to extract relocatable object
212. r string constant is Note that string constants are specified the same regardless of coding format a specified 8 5 Chapter 8 Writing Source Statements Address Constants Address constants return 32 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 There are two address specifiers Aora Return the lower 32 bits of the expression value bits 0 to 31 Example PI Assume that the following address is assigned to the label with the name MESSAGI address 00000000001110010101011011101001 binary a MESSAGE represents 00000000001110010101011011101001 The values expressed by MESSAGE and a MESSAGE are the same In a context calling for the address value associated with a symbol it is more common to use the symbol itself alone instead of adding the address specifier Address Constants 153 Chapter 8 Writing Source Statements 8 6 154 Location Counter Location Counter The assembler contains an variable for counting addresses of instructions This variable is called the location counter Each time the assembler convert
213. ram5 rf as103 1 a m103 map D DEBUG program5 asm D option 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 program5 1st Page 1 RRR PanaX Series MN103000 Cross Assembler Bae Loc Object Line Source 1 define DEBUG 2 3 M 4 dat set macro adr dat 5 mov adr A0 6 mov dat DO 7 mov DO AQ 8 endm 9 10 11 _CODE section CODE PUBLIC 1 40000000 12 main 13 ifdef DEBUG M 14 dat set datal 0x11 40000000 FCDC0C000040 14 mov datal A0 40000006 8011 14 mov 0x11 D0 40000008 60 14 mov DO A0 15 felse 16X dat set datal 0x22 17 fendif 18 19 DATA section DATA PUBLIC 4 4000000c 00000000 20 datal dd 0 40000010 00000000 21 data2 dd 0 22 end Conditional Assembly And Linking 49 Chapter 3 Introduction To Operation Line number 14 was assembled Check for yourself that omitting D DEBUG will assemble line number 16 instead This technique enables the programmer to freely choose assembly conditions with command option specifications There is also an assembler option for suppressing the source code lines not selected during conditional assembly For further details see Chapter 5 Using the Assembler and Chapter 6 Using the Linker 50 Conditional Assembly And Linking Chapter 4 _ _ gt gt gt _________ Optimization 4 1 Purpose Of This
214. ransfer the 32 bit contents of the memory location specified by abs16 to An abs16 is zero extended MOV abs32 An Transfer the 32 bit contents of the memory location specified by abs32 to An MOV Dn abs 16 Transfer the contents of Dm to the memory location specified by abs16 abs16 is zero extended MOV Dm abs32 Transfer the contents of Dm to the memory location specified by abs32 MOV Am abs16 Transfer the contents of Am to the memory location specified by abs16 abs16 is zero extended MOV Am abs32 Transfer the contents of Am to the memory location specified by abs32 MOVBU abs16 Dn Transfer with zero extension the 8 bit contents of the memory location specified by abs16 to Dn abs16 is zero extended Absolute MOVBU abs32 Dn Transfer with zero extension the 8 bit contents of the memory location specified by abs32 to Dn MOVBU Dnm abs16 Transfer the lowest 8 bits of Dm to the memory location specified by abs16 abs16 is zero extended MOVBU Dm abs32 Transfer the lowest 8 bits of Dm to the memory location specified by abs32 MOVB abs16 Dn Transfer with sign extension the 8 bit contents of the memory location specified by abs16 to Dn abs16 is zero extended MOVB abs32 Dn Transfer with sign extension the 8 bit contents of the memory location specified by abs32 to Dn MOVB Dn abs16 Transfer the lowest 8 bits of
215. rary file E Functional description The d option is used to delete relocatable object files from the library file If a specified file does not exist in the library file then the library manager will output a warning message and continue processing ii Rules of use To specify the option enter the hyphen followed by the lower case letter d Slib103 test lib d testl rf E Operation example Slib103 test lib d testl rf This example deletes the relocatable file test gf from the library file test lib Multiple files can be deleted with one d option To delete testl rf test2 rf and test3 rf from test lib specify the following Slib103 test lib d testl rf test2 rf test3 rf Chapter 15 Using The Library Manager p Output information about externally defined symbols in the library file E Functional description The p 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 If the file does not exist then the library manager will output a warning message and continue processing When no relocatable object file name is specified the externally defined symbols in all relocatable object files that exist in the library file will be output E Ru
216. re the next line will start from location 0010 hex Similarly the align 16 on line 13 uses the series 16 10 32 20 48 30 The location counter there is 0012 hex which is between 0010 and 0020 hex Therefore the next line will start from location 0020 hex 176 Writing Directive Statements 9 4 3 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements end E Syntax label operation operand name end E Default settings If the end directive is omitted then the assembler file will assume that the end of the file is the end of the program E Functional description The end directive is coded once at the end of a program All text coded after the end directive will be ignored by the assembler When a name is coded in the label field the current location counter value will be assigned to it E Operand coding rules The end directive takes no operands If operands are coded they will cause an error E Usage example Below is an example use of the end directive CODE section CODE PUBLIC 2 main jsr data move mov 0 DO end Writing Directive Statements 1 T7 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements 9 4 4 listoff liston E Syntax label operation operand listoff liston E Functional description The listoff and liston directives are used in pairs Statements from the statement following the listo
217. responding 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 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 3514 filename Illegal relocation optimize data format line lineno The relocation optimization data in the specified input file is in the wrong format Check the specified line in the source file 3515 Section size overflow The section s layout overflows the upper bound of memory If a map file is available check that Re evaluate the options for specifying section layout or the program itself 3516 Section address overlay Sections have relocation addresses that overlap If a map file is available check that Re evaluate the options for specifying section layout or the program itself Chapter 13 Error Messages 3517 Not exist CODE section in external memory OVL options have relocated all CODE sections to instruction RAM Modify the program so that there is at least one CODE section in external memory 3518 filename Refering to symbol name defined in a program ID id which overlap at IRAM area The input file contains a program with a reference to a symbol in the program with the sp
218. returns a single value as its result The value must have the attribute abs absolute Refer to chapter 8 Writing Source Statements section 8 7 Expressions regarding attributes of expressions E Document conventions Symbols used in this chapter have the following meanings Contents of brackets may be omitted 204 Purpose Of This Chapter 10 2 Chapter 10 Writing Assembler Control Statements include E Syntax include filename E Functional description The include directive causes the assembler to read in the source file with the specified name at the location of the directive The included file will be assembled and output to the relocatable object file and list file In order for the list file to show that lines were included as part of an include file a period will be prefixed before the line number By specifying the assembler s Li option you can suppress output of include files to the list file E Coding rules The file is specified by the file name enclosed in double quotation marks If the file is in a different directory then the file name specification must include the path name By adding the option when starting the assembler you can specify a path name for include files However even in this case the option will be ignored if a specific path name with absolute path is coded within filename include 205 Chapter 10 Writing Assembler Control
219. rg expression Changes the program address to the value specified by expression expression label_name constant name section definition1 definition2 expression Sets the start of a section definitionl section attribute CODE DATA definition2 link type PUBLIC PRIVATE COMMON expression location counter boundary value power of 2 opt on off Enables disables optimization li Directives for symbols Syntax Function amp Notes symbol instruction operand name equ value Defines a name as the value of the expression coded in the operand global name name Declares global declarations and global references List Of Assembler Directives 345 Chapter 17 Appendix Ml Directives for data area allocation Syntax Function amp Notes symbol instruction operand name dc definition expression definition expression Allocates 8 bit data areas name dw expression expression Allocates 16 bit data areas name dd expression expression Allocates 32 bit data areas name ds expression expression2 expression3 Allocates the number of bytes specified by expression to a data area If expression2 initial value is specified then the data area will be filled with that initial value If expression3 repeat count is specified then this operation will be repeated for the specified number of times E Direc
220. ro call Macro expansion pl amp p2 amp gt gt amp p3 amp 0x0F gt var 3 2 var3 gt gt 2 amp 0x0f lt gt Passes the enclosed string as a single parameter of a macro call Macro parameters Macro call Macro expansion pl gt lt abc 1 gt abc l ill Usage example The following example uses the operators V and amp The amp characters in the body of macro mac are used with two different meanings The amp before the dummy parameters is a macro operator The amp before the hexadecimal OxOf indicates a logical AND mac mac2 mac mov end mac pi end SEC mac mac end ro pl p2 p3 pl p2 gt gt sp3 amp 0x0F DO m ro pl p2 p2 m TION CODE PUBLIC 1 1 ly 2 3 2 add 1 DO Macro Operators 231 Chapter 11 Writing Macro Control Statements The assembled list file is shown below macexp lst Page 1 b PanaX Series MN103000 Cross Assembler EEE Loc Object Line Source M 1 macl macro pl p2 p3 2 mov pl amp p2 gt gt sp3 amp 0x0F DO 3 endm 4 M5 mac2 macro pl p2 6 pl p2 7 endm 8 9 TEXT SECTION CODE PUBLIC 1 M 10 maci liek 3 00000000 8001 10 mov 12 gt gt 3 amp 0x0f D0 M 11 mac2 add 1 D0 00000002 2801 11 add 1 DO 12 end 232 Macro Operators 11 5 Chapter 11 Writing Macro Control Statements Local Symbol Declaration local E Syntax macro name macro parameter local symbol symbol sy
221. rs are used in such diverse applications as AV equipment household electronics information equipment automobiles robots portable phones computer peripherals etc Programs developed with the MN10300 Series 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 ll Assembler and compiler Both the assembler and C compiler can be used to develop programs for MN10300 series microcomputers Compared to assembly language C language is a more productive language Programs coded using a high level language also offer superior documentabirity On the other hand microcomputer operations can be directly coded by programming with assembly language Compared to high level languages programs can be created with more compact code size less redundancy and faster processing Given the features of both languages the main body of a program can be coded using C language while parts that require fast processing can be coded using assembly language When developing a program the programmer must first consider which language to use program structure processing speed required to meet the target performance of the end product ROM size of the device and several other related factors E Source code debugger The software developed on a workstation or personal computer must be ch
222. ry Manager 304 Command Options Jj Output error and warning messages in Japanese using JIS encoding E Functional description This option causes all error and warning messages and help screens sent to the console to appear in Japanese using JIS coding E Rules of use To specify the option enter the hyphen followed by the upper case letter J and the lower case letter j The two letters together function as a single option Slib103 test lib f Jj testl rf test2 rf test3 rf 1 This option is not available on PC 9801 DOS V or PC AT machines LI E Default specification The default language used depends on the host machine and the operating system Host machine Message language Sun Sparc English HP9000 English PC 9801 Japanese in Shift JIS DOS V Japanese in Shift JIS PC AT English Chapter 15 Using The Library Manager e Output error and warning messages in English E Functional description This option causes all error and warning messages and help screens sent to the console to appear in English E Rules of use To specify the option enter the hyphen followed by the lower case letter e slib103 test lib f e testl rf test2 rf test3 rf E Default specification The default language used depends on the host machine and the operating system Host machine Message language Sun Sparc English HP9000 English PC 9801 Japanese in Shift JIS DOS V Japanese in Shift JIS PC AT English Comman
223. s Shift operators Logical operators E Arithmetic operators Arithmetic operators perform the four standard arithmetic calculations Operator Meaning i Multiplication Division Modulo operator remainder Addition Subtraction Unary plus positive Unary minus negative Formats operand T operand2 123 LABEL operand1 operand2 123 4 350 operandl operand2 COUNT 4 operand operand2 SATRT 0x10 operand operand2 STACK 16 operand SIGN operand SIGN Chapter 8 Writing Source Statements B Shift operators The shift operators shift to the left or right in bit units Operator Meaning gt gt Logical right shift lt lt Logical left shift Formats operand gt gt count operand lt lt count ADDRESS gt gt 3 ADDRESS lt lt 4 3 bit right shift 4 bit left shift Binary O zero will be shifted in Shifted out bits will be lost E Logical operators Logical operators perform calculation in bit units Operator Meaning amp Logical AND Exclusive OR Logical OR Unary negation l s complement Formats operand 1 amp operand2 ADDRESS amp MASK operand operand2 CONST 000011110000 operand operand2 VECT 050011110000 operand MAIN Expressions 157 Chapter 8 Writing Source Statements 8 7 2 158 Expressions Expression Evaluation There are seven levels of
224. s 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 Location counter values during execution will be offset values from the start of each section The address of the current instruction can be coded as an asterisk This asterisk 1s called the self reference address symbol By using a self reference address symbol in the operand field of a source statement you can reference the address assigned to that statement during execution Chapter 8 Writing Source Statements Expressions 8 7 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 It will then be resolved by the linker Expressions 155 Chapter 8 Writing Source Statements 8 T 1 Operators 156 Expressions There are three types of operators Arithmetic operator
225. s to access using the following three combinations 1 An address register An plus a sign extended 8 or 16 bit displacement or the stack pointer register SP plus a zero extended 8 or 16 bit displacement 16 0 d16 d8 31 0 31 0 An SP sign extended 31 0 RAM RX sy Address specification 248 Addressing Modes Chapter 12 List Of Machine Language Instructions 2 An address register An or the stack pointer register SP plus a 32 bit displacement 31 0 3 0 An SP d32 31 0 RAM NSSNSNNNNN Address specification 3 The program counter PC plus a sign extended 8 or 16 bit displacement or a 32 bit displacement 31 16 0 a32 016 a8 31 0 3 0 PC sign extended 31 Y 0 RAM NAAN a Address specification Addressing Modes 249 Chapter 12 List Of Machine Language Instructions 3 Absolute addressing Absolute addressing uses a 16 or 32 bit displacement to determine the address to access 31 0 abs32 abs16 H RAM RX gy Address specification 4 Index addressing Index addressing adds the contents of an address register An and a data register Dn to yield a displacement 31 0 RAM
226. s with tag jumps regardless of the character positions on screen Look at the display of function key F10 on the CRT screen It should be Tag JP This key specifies a tag jump so try pressing F10 The screen will switch and the cursor will be placed at the source file statement in which the error was detected _CODE section CODE PUBLIC 1 data equ l main mov Ox11 DO move Ox11 DO mov DO data main end Personal Coomputer Versions 333 Chapter 16 Notes On The Operating Environment B Fix errors The cursor will be located on the fifth line Fix the error here Change move to mov That alone fixes the line Switch the screen again to the error file E 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 Press F10 for the source screen By repeating this procedure you can fix all the errors Supplemental Explanation You can use other editors that support tag jumps VZ Editor RED 334 Personal Computer Versions Chapter 17 Appendix 17 1 Numernc Retsch ee a ER Ud pei e Ede 336 17 2 List Of Command Options esee nennen nennen enne 338 17 2 1 List Of Assembler Command Options eee 339 17 2 2 List Of Linker Command Option 342 173 List Of As
227. same as those specified by the mnemonics in the source files Command Options 105 Chapter 6 Using The Linker 6 3 1 106 Command Options Output File Options D Specify the path name and file name of the a ald executable format file to be output Bi Functional description The o option specifies the directory and file name of the executable format file to be output by the linker If the directory is omitted then the file will be output to the current directory If a file name that already exists is specified then that file will be overwritten with new contents If just a path name is specified or if a directory that does not exist is specified then an error message will be displayed Because the symbol is used as the character for specifying parameter files it cannot be used as the first character of file names E Rules of use The o option is specified with the hyphen option specification character followed by the lower case letter o then either immediately followed by the file name or a space and the file name 1d103 o usr tmp test ex main rf sub rf E Default specification The executable format file named m103 ex will be output to the current directory Chapter 6 Using The Linker m Output a map file E 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
228. scussion of attributes of expressions see Chapter 8 Writing Source Statements Section 8 7 Expressions Section 8 7 4 Expression Attributes Specify one of the following constants for the operand character constant string constant The operands are delimited with commas Any number of operands can be coded If data that exceeds 8 bits is specified then the lower 8 bits will be valid and the upper bits will be lost The assembler will output a warning message in such cases When the specified data has fewer than 8 bits those bits will fill the lower bits and the upper bits will be padded with zeroes 188 Writing Directive Statements Chapter 9 Writing Machine Language Instruction Statements And Directive Statements il Usage example Below is an example use of the dc directive dc lst Page 1 ERK PanaX Series MN103000 Cross Assembler KEK Loc Object Line Source 1 _DATA section DATA PUBLIC 4 00000000 41 2 edd dc A 00000001 414243 8 cdi dc ABC 00000004 3F 4 cd2 dc 255 gt gt 2 00000005 OE 5 cd3 dc 12 3 2 2 00000006 FF 6 cd4 dc 0b11111111 00000007 FFFE 7 cd5 dc 0377 0376 00000009 FF 8 cd6 dc 255 Writing Directive Statements 189 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements 9 4 11 ds E Syntax label operation operand name ds expression expression2 expression3 expression 1 Number of bytes of memory to reserve expression 2 In
229. sed for numbers 4 The default toggle switch setting for optimization The linker start up file l1d103rc contains statements specifying the following six items 1 The language and character coding scheme for messages from the linker 2 A toggle controlling output of debugging information to the executable file 3 A toggle controlling output of the symbol table to the executable file 4 A toggle controlling output of DATA sections to the executable file 5 A toggle controlling output of a map file 6 A toggle controlling output of an executable file when there are errors Chapter 1 Getting Started The assembler and linker search directories for these start up files in the following order the current directory the user s home directory and the directory containing the executable If they find such a file they use the contents to initialize their starting parameters Otherwise they set the parameters to their default values These default values are given in the section Start up file format B Start up file format The start up files contain statements using the following format keyword parameter The first field is a keyword giving the name of the start up parameter The second field specifies the value to assign to that parameter The two fields must be separated by at least one tab or space A sharp may be used to incorporate comments into these start up files The assembler and linker then ignore all text from the s
230. sembler Directives oro E RO ER Yee rei 345 17 4 List Of Assembler Control Statements Chapter 17 Appendix 17 1 Numeric Restrictions Bi This section shows the numeric restrictions on the MN10300 cross assembler Be sure not to exceed these values when writing programs Bl Assembler restrictions Item Numeric Restriction Characters per line 255 characters Lines per file No restriction B Linker restrictions Item Numeric Restriction Number of OVL options 255 E Directive restrictions Item Numeric Restriction section directives Number of distinct section names 255 336 Numeric Restrictions Chapter 17 Appendix E Assembler control directive restrictions Item Numeric Restriction include nesting levels 3 levels ifXX nesting levels 255 levels Bi Macro directive restrictions Item Numeric Restriction Macro nesting levels 20 levels Macro local symbols 30 symbols within one macro definition Bl Parameter file restrictions Item String length 1024 characters Numeric Restriction Numeric Restrictions 337 Chapter 17 Appendix 1 7 2 List Of Command Options T E How to read The entries in the command option tables below and their meanings are as follows option_name functional description specification example 338 List Of Command Options 17 2
231. set_loop CODE PUBLIC 1 0 D2 D1 D0 time_filler_end time_filler_loop Assembling And Linking Multiple Sections 39 Chapter 3 Introduction To Operation This file is defined as two sections The addresses of the starting locations of both sections is assumed 00000000 The plus signs in lines 14 and 27 have the same meaning that they had in program3 1st namely that the line contains a symbol that is not assigned a final value until linking B 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 1d103 m g T CODE 00 80000000 T CODE 01280005000 program3 rf program4 rf m option Option to output map file g option Option to add debug information to the executable format file T option Option to specify section address The above command line links two relocatable object files program3 rf and program4 rf in the current directory assigning the starting address 80000000 hex to section CODE 900 and the starting address 80005000 hex to section CODE 01 and creates an executable file m103 ex including debugging information and a map file m103 map in the current directory 40 Assembling And Linking Multiple Sections Chapter 3 Introduction To Operation E Parameter file during linking The following command was input to link 1d103 m g T CODE 00 80000000 T CODE 01 80005000 program3 rf program4 rf
232. splayed program3 lst Page 1 KER PanaX Series MN103000 Cross Assembler EES Loc Object Line Source 1 global main 2 global data set time filler 3 4 CODE 00 section CODE PUBLIC 1 80000000 5 main 80000000 29000 6 mov 0 A0 80000002 2CFF00 T mov Oxff DO 80000005 2D8000 8 mov 0x80 D1 80000008 F8FEFCFCFFF44F00 9 jsr data set 80000010 OOF8FE04 9 80000014 F8FEFCFCFFOCOO00 10 jsr time filler 8000001c 00F8FE04 10 80000020 CAEO 11 bra main 12 13 _DATA section DATA PUBLIC 4 8000500e 00000000 14 datal ds 4 15 end Compare this listing file to the one with indeterminate addresses Note how the plus signs have disappeared from lines 9 11 and how the addresses start from 80000000 hex the number specified with the T option 42 Assembling And Linking Multiple Sections The contents of the final list file program4 Ist are as follows Note that the symbol table is not displayed Chapter 3 Introduction To Operation program4 lst ERE PanaX Series MN103000 Cross Assembler xw Loc Object Line Source 1 global 2 3 CODE 01 section 80005000 4 data set 80005000 8A00 5 mov 6 80005002 7 data set loop 80005002 A6 8 cmp 80005003 C60A 9 bcc 10 80005005 60 11 mov 80005006 2A01 12 add 80005008 2002 13 add 8000500a CAF8 14 bra 15 8000500c 16 data set end 8000500c FOFC 17 rts 18 19 CODE 00 section 20 80000022 21 time filler 80000022 8A00 22 mov 23 80000024 24 time filler loop 80000024 A4 25 cmp 80000025
233. ss thereby simplifying the coding of that process By assigning an appropriate macro name to a block of multiple machine language instructions the programmer can create custom instructions E Debugging When performing final program debugging the programmer must verify whether the intended operations are being performed or not A source code debugger is provided for this The programmer uses the debugger to download generated and linked object code and then verify operation The g option of the assembler and linker generates information that allows the debugger to work with symbols This allows symbols to be used for specifying debugger start addresses breakpoint settings memory references and changes etc Programming With The Assembler 23 Chapter 2 Program Development Flow 24 Chapter 3 Introduction To Operation 3 1 Purpose Of This Chapter une Eee ep dette etes 26 3 2 Files Used By Assembler And Lnker eene 27 3 3 Basic Operation Of Assembler and Linker sees 29 3 4 Assembling And Linking Multiple Sections eese 35 3 5 Conditional Assembly And Linking eese 45 Chapter 3 Introduction To Operation 3 1 Purpose Of This Chapter L Many options are provided with the MN10300 Series Cross Assembler but you can use the assembler and linker without knowing all of them This chapter explains how to use the most useful options while demonstrating actual operation This chapter first
234. ss CONS A ERROR oH 153 8 6 Location Counter ayia died ela eaten dane OO ERES 154 E E 155 8 7 EG Sr M 156 8 7 2 Expression Evaluation itte aene e baee tee 158 8 T S ExptessioniSyntaxo ied duced e ette 160 8 74 Expression Attribution re tque eni ess 161 8 S Reserved WO soe RU RU RR AU ERE Eod 163 Chapter 8 Writing Source Statements 6 1 146 Purpose Of This Chapter 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 8 2 Permitted Characters Chapter 8 Writing Source Statements There are four types of characters that can be coded in source statements for the MN10300 Series Cross Assembler Digits 0123 45 6 7 8 9 Letters Upper case ABCDEFGHIJKLMNOPQRSTUVWXYZ Lower case abcdefghijklmnopqrstuvwxyz Control characters space tab carriage return line feed o d S amp i e Se E A ze E ze _ underscore Can be used in names labels mnemonics operands and comments Permitted Characters 147 Chapter 8 Writing Source Statements 8 3 148 Numbers
235. ss enne ii saiaren 172 O EE S Ee depen 173 VE lignzizcas ace tices a ti 175 94 3 end cus O deemed 177 04 4 UTE SAS OM i ee ERR RO GERD UNE RSEN EQ ees 178 DAMOS tdi e fade ta e e te d 179 DAO OTs nose eeh eei sb de ea oie e dee 181 OA Opty ze n abe iR RE E V up nm 183 DIAS PABe K sxccccssccsveess 185 DANO AGIA R E 186 E LEE 188 DA dS tiie maschera e eR AIEO S obe be hae estas 190 AAA Wi EU USOS epu E EMG 192 9413 di 193 MEI M 194 94 15 global ayia eer A EE e E ERROR A 196 oTe AKA E std ais trt EE 198 0 417 xlistoff AA iaa 199 9 4 TSUNGIN O reao Ene EEA RAEE OAE E NEE TE 200 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements 9 1 Purpose Of This Chapter This chapter explains how to write machine language instructions and directives There are five source statement formats nstruction statements that code machine language instructions and directives Assembler control statements that code assembler control instructions Macro control statements that code macro control instructions Comment statements Blank statements Each is coded differently This chapter explains in detail the code syntax and usage examples of machine language instructions and directives Refer to chapter 8 Writing Source Statements regarding numeric constants expressions and the
236. sume that the relocatable object file following the option is running in instruction RAM Note that this processing applies only to those relocatable object files between the current OVL option to the next T or OVL option or end of line Sections without OVL specifications are processed in accordance with the T specifications The linker merges all sections matching the OVL specification and places the result in the external memory starting immediately after the highest section with the CODE attribute The linker produces an error message if the relevant object files do not contain the specified section Specifying an OVL option without a following file produces the same result E Rules of use The OVL option is specified with the hyphen option specification character followed by the upper case letters OVL the ID number a colon the section specification an equals sign and the address in instruction RAM A space between the OVL option letters and the ID number is optional The ID number identifies a set of sections extracted from the corresponding object files and is used to reference that set during program operation It can be any number between 1 and 255 Sections may be specified by section name section attribute or both To specify a section attribute precede the name of the attribute with the character Multiple sections may be specified together as a comma delimited list Instruction RAM Support 131 Chapter
237. syntax rules for numbers and characters Refer to the MN10300 Series Instruction Manual for detailed descriptions of machine language instructions 166 Purpose Of This Chapter Chapter 9 Writing Machine Language Instruction Statements And Directive Statements 9 2 Instruction Statement Fields Source statements that code machine language instructions and directives are built from four fields label operation operand operand comment Contents of brackets can be omitted E Coding rules Source statements may contain a label field only Depending on the operation source statements may contain no operands Fields are delimited by at least one space or tab Two operands are delimited by a comma Statements are terminated by the LF character line feed 2 0x0A A statement with an LF only omitting all fields is a blank statement The maximum number of characters on one line is 255 Instruction Statement Fields 167 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements 168 9 2 1 Writing The 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 E Coding rules Labels can use upper case and lower case letters digits and underscores _ Labels are coded in the first column The first character of a label must not be a digit Labels are case sensitive The same label n
238. t be expanded TEST is defined before the second macro call so here the statements after endif will be assembled Forced Termination Of Macro Expansion exitm 235 Chapter 11 Writing Macro Control Statements global debug DH extml macro mov 1 D0 ifndef TEST exitm endif jsr debug endm TEXT section CODE PUBLIC 1 extml fdefine TEST extml The list file is shown below The second macro call has been expanded after endif exitm lst Page 1 duck PanaX Series MN103000 Cross Assembler T Loc Object Line Source d global debug 2 M3 extml macro 4 mov 1 D0 5 ifndef TEST 6 exitm 7 tfendif 8 jsr debug 9 endm 0 11 _TEXT section CODE PUBLIC 1 M 12 extml 00000000 8001 12 mov 1 D0 12 ifndef TEST M 12 exitm 13 define TEST M 14 extml 00000002 8001 14 mov 1 D0 14 ifndef TEST 14X exitm 14 endif 00000004 F8FEFCFCFF000000 14 jsr debug 0000000c 00F8FE04 14 236 Forced Termination Of Macro Expansion exitm Chapter 11 Writing Macro Control Statements 1 1 7 Purging Macro Definitions purge A E Syntax macro name macro name purge E Functional description The purge directive purges the definitions of the specified macro names E 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 T
239. t 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 if lst Page 1 ERK PanaX Series MN103000 Cross Assembler KRK Loc Object Line Source I DEVICE equ 1 2 3 _TEXT section CODE PUBLIC 1 4 if DEVICE 1 5X mov 0x01 D0 6 felse 00000000 8002 7 mov 0x02 D0 8 endif 9 ifn DEVICE 1 00000002 8503 10 mov 0x03 D1 11 felse 12X mov 0x04 D1 13 fendif 214 Conditional Assembly Chapter 10 Writing Assembler Control Statements 1 0 5 3 ifeq ifneq B Syntax Syntax for ifeq Syntax for ifneq ifeq parameterl parameter2 ifneq parameterl parameter2 bock block else else block2 block2 endif ndif m Functional description ifeq If parameter and parameter2 are the same string then block will be assembled If they are different and an else directive has been coded then block2 will be assembled ifneq If parameter and parameter are different strings then block will be assembled If they are the same and an else directive has been coded then block2 will be assembled m Coding rules These directives can only be used within macro definitions Either or both of parameterl and parameter2 may be dummy parameters set up during macro definition Conditional Assembly 215 Chapter 10 Writing Assembler Control Statements
240. th op option The parameter for the specified option is in the wrong format Check the option specifications 3303 Illegal address with op option addr The specified address is invalid Check the specified address value 3304 Illegal value with op option value The specified value is invalid Check the specified value 3305 Conflicting option specified op Conflicting options have been specified Check the option specifications 3306 filename Parameter file already specified The parameter file includes another parameter file Edit the parameter file to eliminate the duplication 3307 Multiply defined symbol A symbol is defined more than once Check the symbol declarations 3308 Undefined symbol A symbol is undefined Check the symbol declarations Linker Errors 283 Chapter 13 Error Messages 284 Linker Errors 3309 filename Relocation address out of range line lineno The results of a relocatable address calculation are out of range Check the specified line in the source file 3310 filename Symbol s not defined with FUNCINFO line lineno The specified input file contains a CALL instruction to a label without a FUNCINFO directive Check the specified line in the source file 3311 Program ID multiplied Two or more OVL options share the same overlay ID number Edit the OVL options to use different numbers 3312 filename Section not found sp
241. the following three stages 1 Transfer with zero extension the 8 bit contents of the memory location specified with d8 and An to a 32 bit internal temporary register 2 AND the temporary register with zero extended imm8 and set the flags according to the result 3 AND the temporary register with the ones complement of zero extended imm8 and store the lowest 8 bits of the result in the memory location specified with d8 and An BCLR immg8 abs32 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 2 AND the temporary register with zero extended imm8 and set the flags according to the result 3 AND the temporary register with the ones complement of zero extended imm8 and store the lowest 8 bits of the result in the memory location specified with abs32 266 List Of Machine Language Instructions Chapter 12 List Of Machine Language Instructions 12 3 5 Branching Instructions m m NX uU Ru CC E E CALL Subroutine Mnemonic Description of operation CALL label 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 This instruction is used paired with either a RET or RETF instruction This pai
242. the parameters ASCII EUC SJIS or JIS These parameters have the following meanings file ASCII Process input as ASCII code file EUC Process input as EUC code file SJIS Process input as Shift JIS code file JIS Process input as JIS code The default setting depends on the host machine and operating system Sun Sparc EUC HP9000 SJIS PC 9800 SJIS DOS V SJIS PC AT ASCII Chapter 1 Getting Started keyword Description notation This entry specifies the notation used for numbers in assembly language programs Following the keyword notation and separated from it with white space is one of the parameters PANA CLANG or INTEL These parameters have the following meanings notation PANA Use Panasonic notation notation CLANG Use C language notation notation INTEL Use Intel notation The default setting is in extended C language format O OPTION This entry controls optimization Following the keyword O OPTION and separated from it with white space is one of the parameters ON or OFF These parameters have the following meanings O OPTION ON Enable optimization O OPTION OFF Disable optimization The default setting is to disable optimization Setup 9 Chapter 1 Getting Started 10 Setup The start up file 1d103rc supports the following keywords keyword Description message This entry specifies the language and coding scheme for messages from the linker Following th
243. though conditions are unfulfilled B Rules of use The D option is specified with the hyphen option specification character followed by the upper case letter D then followed by the identifier A space can be inserted between D and the identifier The identifier must exactly match the string specified by ifdef Characters are case sensitive as103 D VERSION sample asm E Default specification Unfulfilled conditions will be selected The else to endif blocks will be assembled Command Options 91 Chapter 5 Using The Assembler 9 3 4 92 Command Options Program Generation Options g Output debug information to the relocatable object file E 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 Names and addresses of variables Detailed information on variables Correspondences between line numbers and code addresses With this information debugging is much easier since the user can specify variables by name instead of by address The g option must also be specified when linking If the g option is not specified Y for either the assembler or linker then debug information will not be output to the executable format file EX E Rules of use The g option is specified with the hyphen option specification character followed by the lower cas
244. tion RAM program management table When the program contains instruction RAM portions the linker automatically generates this table in the executable file Each entry for the transfer units contains the following information ID number 2 bytes Program size 2 bytes External memory address 4 bytes Instruction RAM address 4 bytes The linker indicates the last entry in this table by setting the highest bit in the ID number field to 1 The linker creates a extra symbol __overlay_table indicating the location of this table D Transfer program This portion copies the instruction RAM program from the external memory to the instruction RAM It refers to the instruction RAM program management table in the process The developer must create this portion and add it to the fixed program portion 128 Instruction RAM Support Chapter 6 Using The Linker E Instruction RAM status management table During execution this table keeps track of which portions are currently in the instruction RAM Since this is for use by the debugger in identifying the portions currently in the instruction RAM it is not necessary for a program that merely runs in instruction RAM The contents and usage of this table is determined by the debugger The linker creates an extra symbol iram manage indicating the location of this table D Instruction RAM status Executable
245. tion address linker option ss 116 IPAE 331 tatget EE 17 pip M M H 198 transfer DrOPTAI secedere Doa edades 128 U UNA M NUS cesa 156 unaty HELAN sessi 157 A aar E E EEEE EN EENES 156 unconditional branch instructions 52 54 268 UND espinal bra eet erue 161 A 208 undefined ansiosa 161 undefined label nada 196 Un anna TOT 6 user defined instructions essere o7 V v assembler option 96 v library EE 317 y linker Option hire ier eie 126 W W number assembler option 88 W number library manager 306 W number linker option eee 113 Wall assembler option 199 Wall library manager Wall linker OptOB osa anios warning messages assembler sess warning messages library manager warning messages linker seen WOYKStAMONS cuina 3 X x library MANAGE EE 314 XUI StOBE E 199 xliston MN10300 Series Cross Assembler User s Manual March 2000 5th Edition 1st Printing Issued by Matsushita Electric Industrial Co Ltd Matsushita Electric Industrial Co Ltd Semiconductor Company Matsushita Electronics Corporation Nagaokakyo Kyoto 617 8520 Japan Tel 075 951 8151 http www mec panasonic co jp SALES OFFICES E U S A SALES OFFICE Panasonic Industrial Company PIC
246. tion will not be output to the executable format file LEX If files assembled with the g option and files not assembled with the g option are linked with the g option then debug information will be output only for the files assembled with the g option E Rules of use The g option is specified with the hyphen option specification character followed by the lower case letter g ld103 g main rf sub rf E Default specification Debug information will not be output It is also possible to change the default with an entry in the linker s start up file See Chapter 1 Getting Started Section 1 5 Setup Command Options 115 Chapter 6 Using The Linker 116 Command Options Tsection address Specify the starting address for a section E 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 E Rules of use This option is specified with the hyphen option specification character followed by the upper case letter TT Sections may be specified by section name section attribute or both To specify a section attribute precede the name of the attribute with the character Multiple sections may be specified together as a comma delimited list The starting address is given in hexad
247. tives for list control Syntax l Function amp Notes symbol instruction operand tit string Specifies the header for the list file listoff Suppresses list output from the next line after this directive liston Resumes list output from the line of this directive xlistoff Suppresses list output from the line of this directive xliston Resumes list output from the next line after this directive page lines columns 346 List Of Assembler Directives Specifies the number of lines and columns on a page of list file Bl Other directives Chapter 17 Appendix Syntax symbol instruction operand Function amp Notes notation format Selects the coding format of numbers format CLANG INTEL PANA CLANG Extended C language format default INTEL Intel format PANA Matsushita format radix expression Specifies the radix to be used by default The result of expression must be either 2 8 10 or 16 If the default is 10 and if extended C language format has been selected then the radix will always be 10 regardless of the specification name funcinfo label expression register list Specifies additional information for a function name that appears as an operand for the CALL machine language instruction List Of Assembler Directives 347 Chapter 17 Appendix 1 7 4 List Of Assembler Control Statements E This section provides a
248. tl rf test2 rf test3 rf and test4 rf 1 With slib103 files that mutually reference symbols cannot be placed in library files with the same name If specifying a file name with path name for a relocatable object file its file a name without path name will be registered in a library file LI 15 3 3 Chapter 15 Using The Library Manager Functional Options a Add the specified relocatable object file to the library file E Functional description The a option is used to add relocatable object files to the library file E Rules of use To specify the option enter the hyphen followed by the lower case letter ai slib103 test lib a testl rf E Operation example slib103 test lib a testl rf This example adds the relocatable file test1 rf to the library file test lib Multiple files can be added with one a option To add testl rf test2 rf and test3 rf to test lib specify the following slib103 test lib a testl rf test2 rf test3 rf If any of the relocatable object files to add already exists in the library file then a the library manage will output an error message and terminate without H performing any processing If specifying a file name with path name its file name without path name will be added in the library file Command Options 309 Chapter 15 Using The Library Manager 310 Command Options d Delete the specified relocatable object file from the lib
249. to An 8 and 16 bit displacements are sign extended MOV Dnm d An Transfers the contents of Dm to the memory location specified by An and displacement d 8 and 16 bit displacements are sign extended MOV Dnm d SP Transfers the contents of Dm to the memory location specified by SP and displacement d 8 and 16 bit displacements are zero extended MOV Am d An Transfers the contents of Am to the memory location specified by An and displacement d 8 and 16 bit displacements are sign extended MOV Am d SP Transfers the contents of Am to the memory location specified by SP and displacement d 8 and 16 bit displacements are zero extended MOV SP d8 An Transfers the contents of SP to the memory location specified by An and 8 bit displacement d8 8 bit displacements are sign extended List Of Machine Language Instructions 253 Chapter 12 List Of Machine Language Instructions Mnemonic Description of operation Register relative indirect MOVBU d Am Dn Transfers with zero extension the 8 bit contents of the memory location specified by Am and displacement d to Dn 8 and 16 bit displacements are sign extended MOVBU d SP Dn Transfers with zero extension the 8 bit contents of the memory location specified by SP and displacement d to Dn 8 and 16 bit displacements are zero extended MOVBU Dm d An Transfers the lowest 8
250. ton E 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 a The xlistoff and xliston directives themselves are not output n Only output to the list file will be suppressed Output of object code will not be suppressed at all E Operand coding rules These directives take no operands ill Usage example Below is an example use of the xlistoff and xliston directives The range from xlistoff to xliston will be suppressed CODE section CODE PUBLIC 2 main mov Ox11 DO xlistoff mov 0x22 DO xliston mov 0x33 D0 end Writing Directive Statements 199 Chapter 9 Writing Machine Language Instruction Statements And Directive Statements 9 4 1 8 funcinfo E Syntax label operation operand function name funcinfo label name expression register list where expression Stack frame size E Functional description The funcinfo 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 To use call instructions the program must define the stack frame size and the registers to be saved using a special format
251. tore the result in Dn ASR imm8 Dn Arithmetically shift the contents of Dn right the number of bits specified by imm8 and store the result in Dn ASR Dn Arithmetically shift the contents of Dn right one bit and store the result in Dn E LOGICAL SHIFT RIGHT Mnemonic Description of operation LSR Dm Dn Logically shift the contents of Dn right the number of bits specified in Dm and store the result in Dn LSR imm8 Dn Logically shift the contents of Dn right the number of bits specified by imm8 and store the result in Dn LSR Dn Logically shift the contents of Dn right one bit and store the result in Dn E ARITHMETIC SHIFT LEFT Mnemonic Description of operation ASL Dm Dn Arithmetically shift the contents of Dn left the number of bits specified in Dm and store the result in Dn Zeros enter from the least significant bit ASL imm8 Dn Arithmetically shift the contents of Dn left the number of bits specified by imm8 and store the result in Dn Zeros enter from the least significant bit ASL2 Dn Arithmetically shift the contents of Dn left two bits and store the result in Dn Zeros enter from the least significant bit List Of Machine Language Instructions 263 Chapter 12 List Of Machine Language Instructions il ROTATE RIGHT Mnemonic Description of operation ROR Dn Rotate the contents of Dn plus the C flag right one bit and store the result in Dn E R
252. ude specifications Define define identifiers Statements to define constants and macros and to declare and define globals Declare start of section Machine language instructions conditional assembly directives macro e End of program xpansions Program Format 139 Chapter 7 Types Of Source Statements 140 Program Format There are several points to be aware of when writing programs Always declare an attribute and link type for a section name the first time it appears in a file The same section name cannot be set to a different attribute or link type The effective scope of a section is until the line preceding the next section Assembler instructions and dc dew and ds directives cannot be coded before a section The end of a program is indicated by end Below is an example source file SAMPLE PROGRAM comment tinclude FILE1 H include a file define TYPE define identifier for conditional assembly KEYBORD equ 0x32 define a constant data set macro data define a macro mov data AO mov 0x12 DO mov DO A0 endm end of macro TEXT section E PUBLIC 1 blank statement main statement with label only mov machine language instruction statement Hifdef TYPE conditional assembly directive data_set EY expand macro else mov Hendif end end of program 7 3 Chapter 7 Types Of Source Statements Machine Language Instruction Statements And
253. ules of use To specify the option enter the hyphen followed by the upper case letter O and the lower case letter d The two letters together function as a single option as103 Od sample asm E Default specification The default is to suppress optimization It is also possible to change the optimization default with an entry in the assembler s start up file See Chapter 1 Getting Started Section 1 5 Setup 94 Command Options Chapter 5 Using The Assembler 5 3 5 Other Options Display listing of available assembler option on the console E Functional description The h 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 E Rules of use To specify the option enter the hyphen followed by the lower case letter h as103 h Even if the h option is not specified input of AS103 alone will also display the e help screen E Default specification Help information will not be displayed to the screen Command Options 95 Chapter 5 Using The Assembler 96 Command Options V Display the assembler s version number on the console E Functional description This option displays the assembler s version number on the console E Rules of use To specify the option enter the hyphen followed by the lower case letter v as1
254. uppressed throughout if even one of the source files to be linked contains a calls instruction with the operand An Usage Example 59 Chapter 4 Optimization 60 Usage Example Substituted Instructions For Out Of Range Conditional Branch Instructions Source Instruction First Candidate Second Candidate Third Candidate x x BLT LABEL BLT LABEL BGE H gt BGE 7 JMP LABEL JMP LABEL x x BGT LABEL BGT LABEL BLE 4S BLE 7 JMP LABEL JMP LABEL ok BGE LABEL BGE LABEL BEES BLIYE JMP LABEL JMP LABEL BLE LABEL BLE LABEL BOLES BGI ser JMP LABEL JMP LABEL x x BCS LABEL BCS LABEL BOC PS BCC E JMP LABEL JMP LABEL x x BHI LABEL BHI LABEL BLS TFS BESET JMP LABEL JMP LABEL x x BCC LABEL BCC LABEL BCS ro BOSE JMP LABEL JMP LABEL BLS LABEL BLS LABEL E BELE JMP LABEL JMP LABEL x BEQ LABEL BEQ LABEL BNE 9 BREST JMP LABEL JMP LABEL BNE LABEL BNE LABEL BEQ 5 PEO XE JMP LABEL JMP LABEL x x BVC LABEL BVC LABEL Be Bye ae JMP LABEL JMP LABEL E BVS LABEL BVS LABEL BVC 6 BVC tn JMP LABEL JMP LABEL x x BNC LABEL BNC LABEL BNS O BNS sae JMP LABEL JMP LABEL E E BNS LABEL BNS LABEL BNC 6 BAC TTS JMP LABEL JMP LABEL Chapter 4 Optimization E Optimization of branches For unconditional branch instructions a JMP label instruction is replaced by a BRA label instruction if the jump target is within the range available for the shorter relative branch instructio
255. urpose Of This Section sse 325 16 2 2 Operating Environment 325 HI E 326 16 2 4 InstallatlOn icio rp tr citt d re pce ec tends 327 16 2 5 Environment Settings AAA 328 16 2 6 Differences From The Workstation Versions esseere 330 16 2 7 Error Correction Using Tag Jumpe 331 17 Appendix 17 1 Numeric PIeSITICTOnS ei EE ere DE ete ree ros 336 17 2 List Of Command OPtiONS nennen 338 17 2 1 List Of Assembler Command Options esee 339 17 2 2 List Of Linker Command Options seen 342 17 3 List Of Assembler Direchhves nen 345 17 4 List Of Assembler Control Gtatements 348 Chapter 1 RCREPIO ACCU GG Getting Started 1 1 Purpose Ot This Chapter ende eee bb due teenie 2 LEN 1 2 Operating Environment 2 err too deerat e e ep ote e 3 T3 Fil Organization phe end e e e e eld e ed o bete ed 4 EE E ee ee e ene bere PE eden ane 5 LES Setups ernest Ede onn memi 6 1 0 Fil Conversion Ut ROO etie tees 12 Chapter 1 Getting Started 1 1 Purpose Of This Chapter L This Chapter describes the operating environment for this system and the usage of the file conversion tool 2 Purpose Of This Chapter Chapter 1 Getting Started Operating Environment 1 2 opening This system runs on the following workstations personal computers and compatibles Host machine Operating system Sun Sparc SunOS HP9000 HP UX PC 9801 MS DOS PC AT MS DOS MS DOS V For the
256. ust not however mix upper and lower case Machine language instruction mnemonics Port names Register names Address constants Directives Assembler control instructions Macro control instructions Except for machine language instruction mnemonics and port names the reserved words are listed below Register names dO dl d2 d3 a0 al a2 a3 psw mdr sp Address constants a Directives align dc ds dw end equ global listoff liston xlistoff xliston notation org opt page radix section tit funcinfo Assembler control define if ifb ifdef ifeq ifge ifgt instructions ifle iflt ifn ifnb ifndef ifneq include undef Macro control endm exitm irp irpc instructions local macro purg rept 163 Reserved Words Chapter 8 Writing Source Statements 164 Chapter 9 a JY l i Writing Machine Language Instruction Statements And Directive Statements 9 1 Purpose Of This Chapter opone eee ie HERR RR Rd 166 9 2 Instruction Statement Fields hte de deese ipee R iin 167 92 T Writing The Label Feld egen eet ett Rene tede end 168 9 2 2 Writing The Operation Field A 169 9 2 3 Writing The Operand Field eee 169 9 2 4 Writing The Comment Field 170 9 3 Writing Machine Language Instruction Statements eee 171 9 4 Writing Directive Statements se
257. utput error and warning messages in Japanese using EUC encoding to the console and if specified the listing file Output error and warning messages in Japanese using Shift JIS encoding to the console and if specified the listing file Output error and warning messages in Japanese using JIS encoding to the console and if specified the listing file Output error and warning messages in English Output will be to the screen and when a list file is specified to the list file W number Do not output warning messages of the specified number Output will not be performed to either the screen or list file Refer to chapter 13 Error Messages for warning messages and their corresponding numbers Do not output any warning messages Starting The Assembler 73 Chapter 5 Using The Assembler 74 Option Type Symbol Description Preprocessor options I path name Specify the path name of the directory that contains files specified by include D identifier Specify an identifier to be used by ifdef during conditional assembly Program generation options Output debug information to the relocatable object file Turn off optimization Turn on optimization Starting The Assembler Display a listing of available assembler options on the console Display the assembler s version number on the console Chapter 5 Using The Assembler 5
258. utput to the current directory then only the file name needs to be specified If the file is to be output to a different directory then both a path name and a file name must be specified as103 o user obj test rf main asm E Default specification The assembler creates a file with the same name as the input file but with the extension changed to rf in the current directory E Operation example The following command line assembles the source file sampl asm in the current directory and creates the relocatable object file user obj sampl rf It does not create a listing file as103 o user obj sampl rf sampl asm Chapter 5 Using The Assembler Output a list file Bi Functional description The option outputs a list file The file name of the list file will be the source file name with the extension Ist The list file will be generated in the same directory as the source file If any assembler errors are detected then error information will also be written to the list file B Rules of use The 1 option is specified with the hyphen option specification character followed by the lower case letter T as103 1 sample asm E Default specification No list file will be output Command Options T Chapter 5 Using The Assembler 78 Command Options Do not output files included by include to the list file E Functional description The Li option suppresses output of source file contents included by ass
259. value is shown as eight hexadecimal digits E Supplemental Information The symbol type may be preceded by a or Tus This indicates an externally defined symbol T This indicates an undefined symbol S This indicates an externally referenced symbol Reading List Files 295 Chapter 14 Reading List Files 296 Reading List Files E Symbol Type This indicates the type of symbol All symbols can be classified into four types A U T and D A This indicates that the symbol value is absolute je Indicates a symbol with the CODE attribute and an address as its symbol value Us Indicates that the symbol is not defined in the source file Das Indicates a symbol with the DATA attribute and an address as its symbol value E Symbol Name Symbol names are shown up to 32 characters An output example of a symbol table is shown below listspl lst Page 2 Symbol Table 12345678 A data U move 00000000 T main Chapter 15 ma uPRCECEER O DO tI1 Using The Library Manager 15 1 Purpose Of This Chapter ehe Rep ENEE Sec 298 15 2 Starting The Library Manager 299 15 3 Command Option Si oci o eee e e e Re eh e alte beet 301 15 3 1 Error Message Options trennen nennen rennen 301 15 3 2 Program Generation Options nennen 307 153 3 Functional Options 2 een DDR BER E 309 15334 Other Options eR ERES wand eee Ree 315 15 4 Error Messages eoe b vb ee wna eee ated 31
260. velopment Flow 2 3 Programming With The Assembler a Before creating programs using the assembler you must understand the following items E Required knowledge MN10300 series machine language instructions MN10300 series 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 Therefore you should as much as possible automate assembler and linker commands debugger calls and error correction B MAKE When a program is divided into multiple files for joint development efforts by several programmers a control system must be created for assembly and linking without error If this is not done then an old undebugged program could be linked within the iterative development process The solution lies with the following program which runs on the workstation or personal computer MAKE With MAKE the programmer defines the dependency relationships of the files needed to generate the final executable file and list files Afterwards MAKE will automatically assemble and link only those files that have been modified Programming With The Assembler 19 Chapter 2 Program Development Flow E Program format The MN10300 Series Cross Assembler utilizes a program format called section address format Section address format specifies the start addresses of progra
261. warning messages in English E 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 E Rules of use The e option is specified with the hyphen option specification character followed by the lower case letter e 1d103 e sample rf E Default specification The default language used depends on the host machine and the operating system Host machine Character coding Sun Sparc English HP9000 English PC 9801 Japanese in Shift JIS DOS V Japanese in Shift JIS PC AT English It is also possible to change the default message specification with an entry in the linker s start up file See Chapter 1 Getting Started Section 1 5 Setup Chapter 6 Using The Linker Do not output warning messages of the specified E Functional description The W 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 Specifying Wall will suppress output of all warnings Refer to chapter 13 Error Messages for warning numbers and their corresponding messages E Rules of use The W option is specified with the hyphen option specification character followed by the upper case letter W and then followed by the warning number specification A space may or may not be inserte
262. 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 will determine whether or not to create the library file E Rules of use To specify the option enter the hyphen followed by the lower case letter c slib103 test lib c testl rf E Operation example Slib103 test lib c testl rf test2 rf test3 rf test4 rf This example will create a library file called test lib from the four relocatable object files testl rf test2 rf test3 rf and test4 rf slib103 cannot create a library file from an relocatable object file with the same name If specifying a file name with path name for a relocatable object file its file a name without path name will be registered in a library file E Command Options 307 Chapter 15 Using The Library Manager 308 Command Options f Force creation of a library file E Functional description The f option forces creation of the library file If a file with the same name as the specified library file already exists then the library manager will overwrite it E Rules of use To specify the option enter the hyphen followed by the lower case letter f s1ib103 test lib f testl rf E Operation example Slib103 test lib f testl rf test2 rf test3 rf test4 rf This example will create a library file called test lib from the four relocatable object files tes
263. x The Object heading shows the codes of instructions converted to machine language by the assembler Instructions consist of one to seven bytes 1 byte 8 bits shown as two to eight hex digits After some machine language code the symbol M will be added The M indicates an instruction that was expanded from a macro instruction The Line heading shows line numbers added by the assembler The Source heading shows the source statements as coded 34 Basic Operation Of Assembler And Linker 3 4 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 The start addresses of a program in section format are set for each section during linking Therefore when a program divided into multiple files is developed work can proceed without the programmer staying aware of the code size of each file The programmer an also freely change the order in which files are linked The following explanation illustrates a simple example dividing two source files into sections for each routine allocated to two sections li Create source files Using an editor create the two programs shown below program3 asm and program4 asm The contents of program3 asm
264. yed Loc 40000000 40000000 40000006 40000008 4000000C 40000010 program5 asm m T CODE 40000000 program5 rf 1 a m103 map program5 asm Object FCDC0C000040 8022 60 00000000 00000000 KEE PanaX Series MN103000 Cross Assembler Line 00 0 1 HD oO VG W N F La M B C uo 6 6 6 20 21 22 program5 lst Source define dat_set CODE main ifdef else tendif _DATA datal data2 KKK DEBUG macro mov mov mov endm section DEBUG dat_set dat_set mov mov mov section dd dd end Page 1 adr dat adr A0 dat DO DO A0 CODE PUBLIC 1 datal 0x11 datal 0x22 datal A0 0x22 D0 DO A0 DATA PUBLIC 4 0 0 Note how line number 14 is not assembled because the condition fails and how line number 16 is assembled instead Conditional Assembly And Linking Chapter 3 Introduction To Operation E Specify assembly conditions in the command Until this point the condition has been specified by define in the source file but it has been bothersome to edit the source file each time The explanation below describes how to directly specify conditions with command options This operation is valid only with regards to ifdef In the previous file you either deleted the define line or made it into a comment so you can use it to once again select the true condition as103 D DEBUG program5 asm 1d103 m T CODE 40000000 prog

Download Pdf Manuals

image

Related Search

Related Contents

L 602 VR  Warnungen  VisiPC Configurator for Vis3  Wayne CDT33 Use and Care Manual  Gebrauchsanweisung AutoBlackBox - Klicke hier  MANUEL D`INSTRUCTIONS    New York Wire FCS9190-M Instructions / Assembly  はじめにお読みください  guide d`utilisation powerheart® g5 défibrillateur  

Copyright © All rights reserved.
Failed to retrieve file