ө Hitachi SH Series Cross Assembler User's Manual PN: HOO9-A February 18, 1994 SH Series Cross Assembler User's Manual -HSO700ASCUISE Preface This manual describes the SH Series Cross Assembler. This manual is organized as follows: Overview: Gives an overview of the functions of the assembler. Programmer's Guide: Describes the assembler language syntax and programming techniques. User's Guide: Describes the use (invocation) of the assembler program itself. Appendix: Describes assembler limitations and error messages. The related manuals are listed below. For information concerning the SH microprocessor hardware: *SH7000 Series Hardware Manual" For information concerning the SH microprocessor executable instructions: “SH Series Programming Manual" | For information concerning software development support tools: “SH Series C Compiler User’s Manual” “H Series Linkage Editor User's Manual” “H Series Librarian User’s Manual” “SH Series Simulator/Debugger User’s Manual” Notes: • Тһе following symbols have special meanings in this manual. «item»: «specification item» A Blank space(s) or tab(s) >: The OS prompt (indicates the input waiting state) (КЕТ): Press the Return (Enter) key. КАН The preceding item can Бе repeated. [I The enclosed item is optional (і.е., can be omitted.) • Numbers are written as follows in this manual. Binary: A prefix of " B'" is used. Octal: A prefix of "Q'" is used. Decimal: А prefix of "D'" is used. Hexadecimal: A prefix of " H'" is used. However, when there is no specification, the number without a prefix is decimal. UNIX is an operating system administrated by the UNIX System Laboratories (United States). MS-DOS is an operating system administrated by the Microsoft Corporation (United States). Contents Overview Section 1 (УН ы.а... 3 Section 2 Relationships between the Software Development Support TOOLS — ——————— .ӘЖӘлл(:Т -5 Programmer's Guide Section 1 Program Elements e ———— 11 11 1.2 13 1.4 Section2 Basic Programming Knowledge 2.1 2.3 Source Statements .................,з.4аҮ1 171 .ə əл лл ыла ын. өлен өн кеннен лене т п 1.1.1 Source Statement Structure ................ ааа tese esas sn enue 11 1.12 Coding of Source Statements 13 1.1.3 Coding of Source Statements across Multiple Lines ...................... 15 Reserved Word ....c.c.cossscssssccssecccsccsseccsecacsocessrsenanssesesestssescsosssssesssassecssssesessssssesessscsssesee 16 Symbols ARR —— 16 1.3.1 Functions of Symbols ————— 16 1.32 Coding of Symbols ; 18 [eese CREARE 19 1.4.1 Integer Constants ..............ә..............2.2..2 2. ........ 19 1.4.2 Character Constants ....... ал азама. 20 Location Counter .........ӛ.Ӛ.0.. нн ннен нее кенен е мекен лен кен кел кене етек мн өле ке. Expressions ...... : 1.6.1 Elements of Expression ..............................2...........2.....1.1....... ..,,. 23 1.6.2 Operation Priority ...........ә.........а.....2.............. 25 1.63 Notes on Expressions ................................................... .. 1.2.01. 28 Character Strings .........22.2............аал..11.2......л.... НИНИН 29 Sections .....sccsccccccsceesscccecsocnsscsocecsecssereessesssessesesecssnssccsensssassnactacsecaneecennessnnssnesensconrssecrones 2.1.1 Section Types by Usage ........................ аннин ненненинне вене нена ——— € 2.1.2 Absolute Address Sections and Relative Address Sections Absolute and Relative Values ................ал.. ала 221 Absolute Values .................. e eere esee entm eterne 222 Relative Values ә.з 38 Symbol Definition and Reference 23.1 Symbol Definition... ...sscssscsessnessneseserecsneseanessneessns КОННИ 2.3.2 Symbol Reference M — —ÓÓ—— нене НнННее 2.4 Separate Assembly ............ m——— ÓOA E —— ——M 43 2.4.1 Separate Assembly алмалы. 43 2.4.2 Declaration of Export Symbols and Import Symbols .................... esse 44 Section 3 Executable Instructions .. енна 47 3.1 Overview of Executable Instructions ....ӛ. оо... 47 3.2 Notes on Executable Instructions. ................1.1.1. л аə алы — 52 3.2.1 Notes on the Operation 5іге.......ӛӛӚ.. 2 е. мамы. 52 3.22 Notes on Delayed Branch Instructions ....................2...2.2........ 58 3.23 Notes on Address Calculations .....әа... ЛД. 59 Section 4 Assembler Directives .-----------------ееееее езе ее кенə іі eee rese testen snos ннн seems нынын. 63 4.1 Overview of the Assembler Directives ..........-cscccscssscosseacccssaseorsscssssccensseccsceseecsacsaraseres 63 4.2 Assembler Directive Reference ..........---scscssscssssverscecsscecssersvorssnesessensesesscceecscnssnssesneseees 65 4.2.1 Section and Location Counter Assembler Directives ...................................... 65 .SECTION Section Declaration .......csssecsssssssseorssecsscnsstecceeseceesecrseee: 6 ORG ————— — Location-Counter- Value Setting ....................................... 71 ALIGN ————— Location-Counter- Value Correction ................................. 73 4.22 Symbol Handling Assembler Directives ................ шшс. 75 EQU — Symbol Value Setting (resetting not allowed) .................. 76 -ASSIGN Symbol Value Setting (resetting allowed) ........................ 78 КЕС --------- Alias of a Register Name Definition 4.23 Data and Data Area Reservation Assembler Directives ............................... БАТА ——— Integer Data Reservation ....../мл2..222..22............ .DATAB ——— — Integer Data Block Reservation e 85 .SSDATA ——— — Character String Data Reservation ................................... 88 .SSDATAB ——— — Character String Data Blocks Reservation ....................... 90 -SDATAC Character String Data Reservation (with length) .............. 93 -SDATAZ Character String Data Reservation (with zero terminator) 222... Ды 95 RES -------- Data Area Reservauon ............................. е 97 .SRES -------- Character String Data Area Reservation ........................... 100 .5ВЕ5С ------- Character String Data Area Reservation (with length) ..... 102 .SSRESZ ——— — Character String Data Area Reservation (with zero terminator) ......ӛӚ20....2....2.2.22.......2.47.4. 4 ч.0Ү1.42.44ә7!.0)( 104 4.2.4 Export and Import Assembler Directives аа. .EXPORT Export Symbols Declaration ......................................... 107 IMPORT Import Symbols Declaration ....................—. eee 109 СОВА ——— Export and Import Symbois Declaration ........................... 111 4.25 Object Module Assembler Directives ...........4ы....22.м.22222.. 113 OUTPUT —— Object Module Output Control ................... ees 114 .DEBUG ———— Symbolic Debug information Output Control .................. 117 4.2.6 Assemble Listing Assembler Directives ......................22 1... 119 PRINT ———— — Assemble Listing Output Control .................................... 120 LIST --------- Source Program Listing Output Control ........................... 122 .FORM — — ——— Assemble Listing Line Count and Column Count 5ешіпг ..................................................................126 .HEADING Source Program Listing Header Setting ........................... 128 PAGE —— — —- Source Program Listing New Page Insertion .................... 130 .5РАСЕ -———— Source Program Listing Blank Line Output ..................... 132 427 Other Assembler Directives ............а. ыы 134 PROGRAM ——— Object Module Name Setting, ................—. sss. 135 RADIX —————— Default Integer Constant Radix Setting ............................ 137 END --------- Source Program End Declaration ..................................... 139 Section 5 File Inclusion Function .......- «лала ажа алама ааа 141 INCLUDE File Inclusion .....2...... Ды. 142 Section 6 Conditional Assembly Function ........——— mene 145 61 Overview of the Conditional Assembly Function .....Ӛ.0лмо.лм.....2.22.... а... 145 6.1.1 Preprocessor Variables ....../..............а.... ныны нөө 145 6.1.2 Conditional Assembly ........о...л......м ЛД 146 6.1.3 Iterated Expansion ............л............ ара Др 147 6.1.4 Conditional Iterated Expansion .........................4........ 148 6.2 . Conditional Assembly Directives ............Ӛ.... ..-................. 149 | .ASSIGNA ------------- Integer Preprocessor Variable Definition (redefinition is possible)............. 150 .ASSIGNC Character Preprocessor Variable Definition (redefinition is possible)............ 153 .AIF .AELSE .AENDI Conditional Assembly ............................... 155 .AREPEAT .AENDR —————— Iterated Expansion ...............!.................... 157 .AWHILE .AENDW ——— —— Conditional Iterated Expansion ................. 159 .EXITM Expansion Termination .............................. 161 Section 7 Macro Function .------ееееее еее еее ны енене ннен ененнен 163 7. Overview of the Macro Function .......c.ccsccscssscssossssessssesssersssscssssncserssstssnssecscesessnssesseessece 103 72 Macro Function Directives ........ə.о.о...о....ш.....222м ЛД 165 .MACRO .ENDM —— ——— — Macro Definition .................... sse 166 EXITM Expansion Termination ..........................-.-- 169 7.4 Macro Call ARR 175 7.5 Character String Manipulation Functions ....................2..........177 LEN Character String Length Count .................. 178 INSTR Character String Search ............................. 180 .SSUBSTR Character Substring Extraction .................. 182 Secüon 8 Automatic Literal Pool Generation Function ..............—..———.————— 185 8.1 Overview of Automatic Literal Pool Generation .................................................... 185 8.2 Extended Instructions Related to Automatic Literal Pool Generation ......................... 186 8.3 Literal Pool Output ........-..-..sccscrccssonsecversneseccsececcesensvsesensrosnsersovsenereasesesssteenenensasasaensses 186 8.3.1 Literal Pool Output after Unconditional Branch (BRA, JMP, RTS, RTE) ........ 187 8.3.2 Literal Pool Output to the POOL Location .................................................... 188 8.4 Literal Sharing ........c.-.-cccsersovessscssessensssnscrsssncusscrasescsessssccnassssecesecssesssesesecsssccerasersseserses 189 8.5 Literal Pool Output Suppression ....................................... 190 8.6 | Notes on Automatic Literal Pool Output лла. 191 User's Guide Section 1 Executing the Assembler ал... ЛД... 195 11 Command Line Format ..........s..sessssscseccosseresorveesssnecesorcnsestssssessecesersssavesenssersassessncosaceres 195 1.2 File Specification Format ............. ——— 196 Section 2 Command Line Options ........................ нне 197 2.1 Overview of the Command Line Options ...................... ананан ананна 197 22 Command Line Option Reference ............................2........ 198 22.1 Object Module Command Line Options....................... eese trennen 198 OBJECT NOOBJECT ————— Object Module Output Control .................. 199 DEBUG NODEBUG —————— Debug information Output Control ........... 201 222 Assemble Listing Command Line Орноп5....................................... 203 LIST NOLIST ----------- Assemble Listing Output Control .............. 204 SOURCE NOSOURCE Source Program Listing Output Control .... 2 CROSS, REFERENCE -I- Cross-Reference Listing Output Control ... 208 NOCROSS REFERENCE SECTION NOSECTION Section Information Listing Output Control „аеннан ыы 210 SHOW NOSHOW —-————— Source Program Listing Output Controi .... 212 LINES ------------- Sets the Number of Lines іп the Assemble Listing ............................... 214 COLUMNS —— —— — ———— Sets the Number of Columns in the Assemble Listing ................................. 215 Appendix Appendix A Limitations and Notes on Programming -4...ӛ...........42.1.... 219 Appendix B Sample Program енен нн ГГ... 220 Appendix С Assemble Listing Output Example ..........................). 223 C.1 Source Program Listing .........ə.əӚ.Ӛ9ə 2.7... ЛД... 224 C2 Cross-Reference Listing 2.2222 2. м.а... ы Дем. 225 СЗ Section Information Listing ........ шшш —— Ó —— 226 Appendix D Error Messages .-..--.------ -ф............ ...л.... 227 рл Еос Туреѕ ннн енн нанын ннн на анааран ынаан Аа RP (à D.2 Error Message Tables 2.2... Дам. 229 Appendix Е ASCII Code Table bee АКЫК Mah ааа ean a 241 Figures Overview Figure 1-1 Function of the Assembler — НаННа 3 Figure 2-1 Relationships between the Software Development Support Tools ....................... 6 Programmer’s Guide Figure 2-1 Memory Reservation of Common 5еспоп...........ам ыы 33 Figure 2-2 Data Structure Example Using Dummy Section....................... eere 35 Figure 2-3 Meaning of the Terms Forward and Backward................... esee eterne 41 Figure 2-4 Meaning of the Term Елхетгі...2.л......ы ааа. 41 Figure 2-5 Relationship between the Changed Range of the Program and the Range of the Program that must be Кеаз5етЫей......................................... 43 Figure 3-1 Address Calculation Example (normal case) ..................................................1.. 59 Figure 3-2 Address Calculation Exampie (when the value of PC differs due to a БгапсВ).............................................. 60 Figure 3-3 Address Calculation Example (when SH microprocessor corrects the value of PC) ................... esas 61 Figure 3-24 Address Calculation Example (when SH microprocessor does not correct the value Of РС)............................... 61 Appendix Figure C-1 Source Program Listing Output Example ............................................................ 22A Figure C-2 Cross-Reference Listing Output Example .................. eee eese 225 Figure C-3 Section Information Listing Output Ехатріе....................................................... 226 Tables Programmer's Guide . Table 1-1 Орегаюгв...ә..ә.əм2..а..ам ааа ЛЛ... 23 Table 1-2 Operator Priority and Association Rules ................................ 25 Table 3-1 Addressing Моев...... м... 88 Table 3-2 Allowed Displacement Values .........оәооомл............. 2. 50 Table 3-3 Allowed Immediate Values ..........-...ssosseecsesssssocecsenscsesecrsrseccesessusecssrcosnrserensessecees 51 Table 3-4 Executable Instruction and Operation Size Combinations................................... 52 Table 3-5 Relationship between Delayed Branch Instruction and Delay Slot Instructions .. 58 Table 41 Assembler Directives D 63 Table 8-1 Extended Instructions and Expanded Results .................................:................... 186 User's Guide . Table 2-1 — Command Line Орпопв...........а...а... 2... ЛДІ. 197 Appendix Table A-1 Limitations and Notes on Programming .................... eese eee не 219 Table D-1 Command Error Мевагев......................................аӘ а ааа мəр. .. 229 Table D-2 Source Program Error Messages ..................2...2........2...... 230 Table D-3 Fatal Error Мессадев...............2.....2.2......................... 240 Table E-1 ASCI Code Table ........ tte 241 Overview (This page intentionally left blank.) Section 1 Overview The “SH Series Cross Assembler" (referred to below as the (or this) assembler) converts source programs written in assembly-language into a format that can be handled by SH microprocessors, and outputs the result as an object module. Also, the resuits of the assembly processing are output as an assemble listing. This assembler provides the following functions to support efficient program development: * Assembler directives Give the assembler various instructions. • File inclusion function Includes files into a source file. • Conditional assembly function Selects source statements to be assembled or repeats assembly according to a specified condition. * Macro function Gives a ame to a sequence of statements and defines it as onc instrucuon. * Automatic literal pool generation funcuon Interpretes data transfer insurucüions MOV.W #imm, MOV.L #imm, and MOVA #imm that are no provided by the SH microprocessor as extended instructions and expands them into SH microprocessor executable instructions and constant data (literals). Figure 1-1 shows the function of the assembler. Assembly-language included file source program * Assembler directives * Conditional assembly * Macro + Automatic literal pool generation Object module Assemble listing Figure i-1 Function of the Assembler 3 (This page intentionaily left blank.) Section 2 Relationships between the Software Development Support Tools The following software development support tools are available for the SH microprocessors. • SH Series C Compiler (Referred to below as the C compiler.) * Н Ѕегіеѕ Linkage Editor (Referred to below as the linkage editor.) • Н Series Librarian (Referred to below as the librarian.) * Н Series Object Converter (Referred to below as the object converter.) ¢ SH Series Simulator/Debugger (Referred to below as the simulator/debugger.) Note: The linkage editor refers to version 5.0 or iater. These tools assist in the efficient development of application software. Figure 2-1 shows the relationships between the software development support tools. source program 25 Assembler - 25, ама mte information file Simulator/debugger S-type-format load module Figure 2-1 Relationships between the Software Development Support Tools Supplement: Use a general purpose editor (a text editor) to edit source programs. The C compiler converts programs written in Ше C-language into either object modules or assembly-language source programs. The librarian converts object modules and relocatable load modules into library files. We recommend handling processing that is common t0 multiple programs as a library file. (This has several advantages, including allowing modules to be easily managed.) The linkage editor links together object modules and library files to produce load modules. (Load modules are programs in a format that a computer can execute.) The object converter converts load modules into the S-type format. (The S-type format is a standard load module formar.) ^ The simulator/debugger assists debugging microprocessor software. Load modules created by this development support system can be input to several types of emulator. (Emulators are systems for debugging microprocessor system hardware and software.) Also, S-type-format load modules can be input into most EPROM writers. (This page intentionally left blank.) Programmer's Guide (This page intentionaily left blank.) Section 1 Program Elements If source programs are compared to natural language writing, a source statement will correspond io "a sentence." The "words" that make up a source statement are reserved words and symbols. This section describes these basic program elements. 1.1 Source Statements 1.1.1 Source Statement Structure The figure below shows the structure of a source statement. {<1аре1>] (А<орегасіоп>(А<орегапа(5)>11 [«comment») Example: ; This is an exampie of a source statement. Comment 11. (1) Label A symbol that is a tag attached to a source statement is written as a label. A symbol is a name defined by the programmer. (2) Operation The mnemonic of an executable instruction, an extended instruction, an assembler directive, or a directive statement is written as the operation. Executable instructions must be SH microprocessor instructions. Extended instructions are instructions that are expanded into executable instructions and constant data (literals). For details, refer to Programmers Guide, 8, "Automatic Literal Pool Generation Function". Assembler directives are instructions that give directions to the assembler. Directive statements are used for file inclusion, conditional assembly, and macro functions. For details on each of these functions, refer to Programmer's Guide, 5, "File Inclusion Function”, 6. "Conditional Assembly Function”, or 7, "Macro Function”. (3) Operand The object(s) of the operation’s execution are written as the operand. The number of operands and their types are determined by the operation. There are aiso operations which do not require any operands. (4) Comment Notes or explanations that make the program easier to understand are written as the comment. 12 1.1.2 Coding of Source Statements Source statements are written using ASCII characters. In principle, a single statement must be written on a single line. The maximum iength of a line is 255 bytes. (1) Coding of Label The label is written as follows: * Written starting in the first column, Or: * Writien with а colon (:) appended to the end of the label. Examples: ; This label is written starting in the first column. ; This label is terminated with a colon. ; This label is regarded as an error by the assembler, ; Since it is neither written starting in the first column ; norterminated with a colon. (2) Coding of Operation The operation is written as follows: • When there is no label: Written starting in the second or later column. “ When there is a label: Written after the label, separated by one or more spaces or tabs. Examples: ; An example with no label. ; An example with a label. 13 CAUTION! Since white spaces and tabs are ASCII characters, each space or tab requires a byte of storage. o (3) Coding of Operand The operand is written following the operation field, separated by one or more spaces or tabs. Examples: ; The ADD instruction takes 2 arguments. ADD t SHAL [В ; The SHAL instruction takes 1 argument. (4) Coding of Comment The comment is written following a semicolon (;). The assembler regards all characters from the semicolon to the end of the line as the comment. Exampies: 1.13 Coding of Source Statements across Multiple Lines We recommend writing a single source statement across several lines in the following situations: * When the source statement is too long as a single statement * When it is desirable to auach a comment to each operand. Write source statements across multiple lines using the following procedure. (a) Insert a new line writing a comma that separates operands as the point to break the line. (b) Insert a plus sign (+) in the first column of the next line. (c) Continue writing the source statement following the plus sign. Spaces and tabs can be inserted following the plus sign. Examples: .DATA.L . H'FFFFO000; ; inthis example, a single source statement is written across three lines. A comment can be attached at the end of each line. Examples: .DATA.L H'FFFF0000, s niia value 1. + H'FFOOFFOO, %7 Initial value 2. + H'FFFFFFFF x. Initial value 3. ; This is an example of attaching a comment to each operand. 15 1.2 Reserved Words Reserved words are names that the assembler reserves as symbols with special meanings. This assembler uses the following reserved words. “ Register names RO Rl R2 R3 R4 RS R6 R7 R8 R9 R10 R11 R12 RI3 КМ RIS SP* SR GBR VBR MACH МАС. PR PC Note: * R15 and SP indicate the same register. * Operators (STARTOF, SIZEOF) ¢ The location counter symbol, the doilar sign (a single character symbol) Reserved words cannot be used as user-defined symbols. Reference: Operators — Programmer's Guide, 1.6.1, "Expression Elements" Location counter —› Programrer's Guide, 1.5, "Location Counter” Symbols — Programmer’s Guide, 1.3, “Symbols” 1.3 Symbols 1.3.1 Functions of Symbols Symbols are names defined by the programmer, and perform the following functions. * Address symbols ................ Express data storage and destination addresses. _ e Constant symbols ............... Express constants. * Aliases of register name ..... Express general registers. • Section патесѕ..................... Express section names. * Note: * A section is a part of program, and the linkage editor regards it as a unit of processing. The following show examples of symbol usages. 16 Examples: ; BRA is a branch instruction. ; SUB1 is the address of the destination. 5: .EoU 100 .EQU is an assembler directive that sets a value to a symbol. Mov ¥HAK,RO MAX expresses the constant value 100. — oo ee a a D ES ань ано a a e МҰН: .REG (БО) ; .REG is an assembler directive that defines a register ; name. MOV #100, MIN’ : Here, MIN is a name for RO. . ` —— meum a еген EE UI I) әлекке de n pint ie M i i еее t i p tro I o «кек uo e ae a e m m e em a e e — - SECTION fCD, CODE, ALIGN=4 SECTION is an assembler directive that declares a section. CD is the name of the current section. А , , 17 1.3.2 Coding of Symbols (1) Available Characters The following members of the ASCII character can be used. • Upper-case and lower-case leners (А to Z, a to z) “ Numbers (0 to 9) “ The underscore character (_) • The dollar sign character ($) The assembler distinguishes upper-case and lower-case in symbols. (2) First Character in a Symbol The first character in a symbol must be one of the following. • Upper-case and lower-case letters (A to Z, a to 2) * The underscore character ( ) • The dollar sign character ($) (3) Maximum Length of a Symbol A symbol may contain up to 32 characters. The assembler ignores any characters after the first 32. (4) Names that Cannot Be Used as Symbois Reserved words cannot be used as symbols. The following names must not be used because they are used as internal symbols by the assembler. _$Sannnn (nis a number from 0 to 9.) Note: Internal symbols are necessary for assembler internal processing. Internal symbols are not output to assemble listings or object modules. CAUTION! The dollar sign character used alone is a reserved word that expresses the location counter. References: Reserved words — Programmer's Guide, 1.2, "Reserved Words" 18 1.4 Constants 1.4.1 Integer Constants Integer constants are expressed with a prefix that indicates the radix. The radix indicator prefix is a notation that indicates the base of the constant. © Binary numbers ........................ The radix indicator “В'” plus a binary constant. © Octal numbers .................... The radix indicator “Q'” plus an octal constant. © Decimal numbers ...................... The radix indicator “ D'” plus a decimal constant. * Hexadecimal numbers .............. The radix indicator “H” plus a hexadecimal constant. The assembler does not distinguish upper-case and lower-case letters in the radix indicator. The radix indicator and the constant value must be written with no intervening space. Exampies: | .DATA.B 810001000 .DATA.B р'136 ; numerical value. .DATA.B 'H'88 ; ; These source statements all the same The radix indicator can be omitted. Integer constants with no radix indicator are normally decimal constants, although the radix for such constants can be changed with the .RADIX assembler directive. References: Interpretation of integer constants without a radix specified — Programmer's Guide, 4.2.7, "Other Assembler Directives", RADIX Supplement: "Q" is used instead of “О” to avoid confusion with the digit О. 19 1.4.2 Character Constants Character constants are considered to be constants that represent ASCII codes. o Character constants are written by enclosing up to 4 ASCII characters in double quotation marks. The following ASCII characters can be used in character constants. ASCII codes Í H'09 (tab) 1720 (space) to H'7E (tilde) Examples: This is the same as .DATA.L H'00414243. ; This is the same as .DATA.W H'4142. This is the same as .DATA.B H'41. ; The ASCII code for A is: H'41 The ASCII code for B is: H'42 The ASCII code for C is: H'43 Use two double quotation marks in succession to indicate a single double quotation mark in a character constant. Example: .DATA.B "72" ; This is a character constant consisting of a single double quotation mark. 20 L5 Location Counter The location counter expresses the address (location) in memory where the corresponding object code (the result of converting executable instructions and data into codes the microprocessor can regard) is stored. The value of the location counter is automatically adjusted according to the object code output. The value of the location counter can be changed intentionally using assembler directives. Examples: H* 00001000 ; This assembler directive sets the location counter to ; H'00001000. .DATA.W H'FF ; The object code generated by this assembler directive has : alength of 2 bytes. ; The location counter changes to H'00001002. ; The object code generated by this assembler directive has ; a length of 2 bytes. ; The location counter changes to H'00001004. ; The object code generated by this assembler directive has : а length of 2 bytes. ; The location counter changes to Н"00001006. ACION 4 : The value of the location counter is corrected to be a multiple ; of 4. ; The location counter changes to H'00001008. .DATA.L H'FFFFEFFE The object code generated by this assembler directive has a length of 4 bytes. The location counter changes to Н"0000100С. чз ; ORG is an assembler directive that sets the value of the location counter. ; ALIGN is an assembler directive that adjusts the value of the location counter. ; .DATA is an assembler directive that reserves data in memory. ; Wis a specifier that indicates that data is handled іп word (2 byte) size. ; .L is a specifier that indicates that data is handled in long word (4 byte) size. 21 References: Setting the value of the location counter o — Programmer's Guide, 4.2.1, "Section and Location Counter Assembler Directives" .ORG Correcting the value of the location counter — Programmer’s Guide, 4.2.1, "Section and Location Counter Assembler Directives” ALIGN The location counter is referenced using the dollar sign symbol. Examples: ; This assembler directive sets the value of the ; location counter to the symbol LABEL 1. -EQU is an assembler directive that sets the value to a symbol. 22 1.6 Expressions Expressions are combinations of constants, symbols, and operators that derive a value, and are used as the operands of executable instructions and assembler direcuves. 1.6.1 Elements of Expression An expression consists of terms, operators, and parentheses. (1) Terms The terms are the followings: • Aconstant ¢ The location counter reference ($) • Asymbol (excluding aliases of the register name) • The result of a calculation specified by a combination of the above terms and an operator. An independent term is also a type of expression. (2) Operators Table 1-1 shows the operators supported by the assembler. Table 1-1 Operators Operator Type Operator Operation Coding Arithmetic + Unary plus + operations - Unary minus = «term» + Addition «termi» + - Subtraction «termi» — d Multiplication * / Division «termi» / Logic - Unary negation | ~ operations & Logical AND & | Logical OR «termi» | «term2» - Exclusive OR «termi» ~ Section set STARTOF Derives the starting address STARTOF
operations* of a section set. SIZEOF Derives the size in bytes SIZEOF «section name» of a section set. Note: * See the supplement on the following page. 23 А (3) Parentheses Parentheses modify the operation priority. o See the next section, section 1.6.2, "Operation Order", for a description of the use of parentheses. Supplement: In this assembly-language, programs are divided into units called section. Sections are the units in which linkage processing is performed. When there are multiple sections of the same type and same name within a given program, the linkage editor links them into a single "section set". STARTOF is an operator that determines the starting address of the section set. SIZEOF is an operator that determines the size of the section set in byte units. References: Sections > Programmer 's Guide, 2.1, "Sections" 24 1.6.2 Operation Priority When multiple operations appear in a single expression, the order in which the processing is performed is determined by the operator priority and by the use of parentheses. The assembler processes operations according to the following rules. ` «Rule 1> Processing starts from operations enclosed in parentheses. When there are multiple parentheses, processing starts with the operations surrounded by the innermost parentheses. | «Rule 2» | Processing starts with the operator with the highest priority. . Processing proceeds in the direction of the operator association rule when operators have the same priority. Table 1-2 shows the operator priority and the association rule. Tabie 1-2 Operator Priority and Association Rules Priority Operator Association Rule 1 (high) : 4-7 STARTOF SIZEOF* Operators are processed from right to left. 2 udi Operators are processed from teft to right. 3 +- Operators are processed {гот ieft to right. 4 & Operators are processed from left to right. 5 (low) |7 . Operators are processed from lett to right. Note: * Unary operators have the first priority. The figures below show examples of expressions. Example 1: 1%(2-(3%4(4-5))) (а) (b) (d) The assembler calculates this expression in the order (a) to (d). The result of (a) is -1 The result of (b) is 2 The result of (c) is 0 The result of (d) is 1 The final result of this caiculation is 1. Example 2: = H'FFFFFFF1 + Н"000000Ғ0 * Н'00000010 | Н"000000Ғ0 & H'OOOOFFFF The assembler calculates this expression in the order (a) to (e). The result of (a) is H'O000000F The result of (b) is Н"00000Ғ00 The resutt of (c) is Н"00000ҒОҒ The final result of this calculation is Н"ОООООҒҒҒ. The гезип of (d) is Н000000Ғ0 The result of (ә) is Н"00000ҒҒҒ 26 Example 3: - ~ - ~ R'0000000F (а) The assembler calculates this expression іп the order (a) to (d). The resuit of (a) is H'FFFFFFFO The resuit of (b) is H'O0000010 The result of (c) is НҒЕҒҒҒҒЕҒ The result of (d) is H'O0000011 The final resutt of this calculation is H'00000011. 27 1.6.3 Notes on Expressions (1) Internal Processing The assembler regards expression values as 32-bit signed values. Example: “H'FO The assembier regards H'FO as Н"000000Ғ0. Therefore, the value of -H'FO is H'FFFFFFOF. (Note that this is not H'O000000F.) (2) Arithmetic Operators The multiplication and division operators cannot take terms that contain relative values (values which are not determined until the end of the linkage process) as their operands. Also. a divisor of 0 cannot be used with the division operator. (3) Logic Operators The logic operators cannot take terms that contain relative values as their operands. References: Relative values — Programmer's Guide, 2.2, “Absolute and Relative Values". 28 1.7 Character Strings Character strings are sequences of character data. The following ASCII characters can be used in character strings. ASCII codes Н 09 (tab) Н "20 (space) to H'7E (tilde) A single character in a character string has as its value the ASCII code for that character and is represented as a byte sized data object. Character strings are written enclosed in double quotation marks. Use two double quotation marks in succession to indicate a single double quotation mark in a character string. Examples: .SDATA "Нео" ; This statement reserves the character string data ; Hello! .SDATA """Hello!*"" ; This statement reserves the character string data ; “нео! - .SDATA is an assembler directive that reserves character string data in memory. Supplement: The difference between character constants and character strings is as follows. Character constants are numeric values. They have a data size of either 1 byte, 2 bytes, or 4 bytes. Character strings cannot be handled as numeric values. A character string has a data size of between 1 byte and 255 bytes. 29 (This page intentionally left blank.) Section2 Basic Programming Knowledge This section presents the basic knowledge required for programming in assembly-language. 2.1 Sections If source programs are compared to natural language writing, a section will correspond to a “chapter.” The section is the processing unit used when the linkage editor links an object modulc. 2.1.1 Section Types by Usage Sections are classified by usage into the following types. * Code secuon * Data section • Common section • Stack section • Dummy section (1) Code Section The following can be wriucn in a code section: * Executable instrucuons * Extended instructions « Assembler directives that reserve initialized data. Examples: CD, CODE, ALIGNe4 ; This assembler directive deciares a 7 code section with the name CD. ; This is an executable instruction. ; This assembler directive reserves ; initialized data. 31 (2) Data Section The following can be written in a data section: * Assembler directives that reserve initialized data. * Assembler directives that reserve uninitialized data. Examples: DT1, DATA, ALIGNe4 H'FFOO .SECTION OT2,DATA,ALI 32 ; This assembler directive declares ; a data section with the name DT1. ; These assembler directives reserve ; initialized data. This assembler directive declares a data section with the name DT2. : These assembler directives reserve ; data areas that do not have initial ; values. (3) Common Section А соттоп section is used as a section to hold data that is shared between files when a source program consists of multiple source files. The following can be written in a common section: * Assembler directives that reserve initialized data. * Assembler directives that reserve uninitialized data. Supplement: The linkage editor reserves common sections with the same name to the same area in memory. In the example shown in figure 2-1, the common section CM declared in file A and the common secuon CM declared in file B are reserved to the same area in memory. Figure 2-1 Memory Reservation of Common Section (4) Stack Section The section that SH microprocessors use as a stack area (an area for temporary data storage) is called the stack section. The following can be written in the stack section: e Assembler directives that reserve uninitialized data. Examples: .SECTION ST, STACK, ALIGNe4 ; This assembler directive declares a stack ; section with the name ST. .RES.B 1024 This assembler directive reserves a stack ; area of 1024 bytes. (5 Dummy Section A dummy section is a hypothetical section for representing data structures. The assembler does not output dummy secuons to the object module. The following can be written in a dummy section: * Assembler directives that reserve uninitialized data. Examples: -SECTION DM, DOM” ; This assembler directive declares ; adummy section with the name DM. 1 ; The assembler does not output the H ; section DM to the object module. 2 Specific methods for specifying data structures are described in the supplement on the next page. Suppiement: ' As shown in figure 2-2, it is possible to access areas in memory by using address symbols from а dummy section. Figure 2-2 Data Structure Example Using Dummy Section Coding Example: in the example above, assume that R1 holds the starting address of area 1 and R2 holds the starting address of area 2. @(B,R1),RO : Moves the contents of item B in area 1 to RO. RO, 8 (B, R2) ; Moves the contents of RO to item B in area 2. CAUTION: 1. The following cannot be used in stack and dummy sections: * Executable instructions • Extended instructions * Assembler directives that reserve initialized data (.DATA, .DATAB, .SDATA, .SDATAB, .SDATAC, and .SDATAZ) 2. When using a data or common secuon, be sure to keep in mind whether that section is reserved to ROM or RAM. 2.1.2. Absolute Address Sections and Relative Address Sections A section can be classified as either an absolute address section or as a relative address section depending on whether absolute start addresses are given to the sections at assembly. (1) Absolute Address Sections The memory location of absolute address sections is specified in the source program, and cannot be changed by the linkage editor. In this assembly language, locations in an absolute address section are expressed as absolute addresses, which are addresses that express the position in memory itself. Examples: .SECTION ABS, DATA, IOCATE-H:O000F 000; .DATA.W Н'1111 .DATA.W H'2222 36 ; ABS is an absolute-address section. ; The starting address of section ABS is ; the absolute address Н"0000Ғ000. The constant H'1111 is reserved at ; the absolute address Н'0000Ғ000. ; The constant H'2222 is reserved at ; the absolute address H'O000FO002. (2) Relative Address Section The location in memory of relative sections is not specified in the source program, but rather is determined when the sections are linked by the linkage editor. In this assembiy-language, locations in a relative address section are expressed as relative addresses, which are addresses that express the position relative to the start of the section itself. Examples: REL, DATA, ALIGN]4: ; REL is a relative address section. ; The starting address of section REL is ; determined after linkage. : The constant H'1111 is reserved at the ; relative address Н"00000000. ; The constant H'2222 is reserved at the ; relative address Н"00000002. Supplement: | - Dummy sections correspond neither to relative nor to absolute sections. 37 2.2 Absolute and Relative Values Absolute values are determined when assembly completes. Relauve values are not determined o until the linkage editor completes. 2.2.1 Absolute Values The following are the absolute values handled by the assembler. (1) Constants * Integer constants * Character constants • Symbols that have a value that is one of the above (referred to below as constant symbols). (2) Absolute Address Values • The location counter referenced in an absolute address section • The location counter referenced in a dummy section • Symbols that have a value that is опе of the above (referred to below as absolute address symbols). (3) Other Absolute Values Expressions whose value is determined when assembly completes. 2.2.2 Relative Values The following are the relative values handled by the assembler. (1) Relative Address Values • The location counter referenced in a relative address segment • Symbols that have the above as a value. (Such symbols are referred to as relative address symbols.) (2) External Reference Values Symbols that reference another file (referred to below as import symbols). (3) Other Relative Values Expressions whose value is not determined until the linkage editor completes. 38 2.3 Symbol Definition and Reference 2.1 Symbol Definition (1) Normal Definition The normal method for defining a symbol consists of writing that symbol in the label field of a Source statement. The value of that symbol will then be the value of the location counter at that point in the program. Examples: . SECTION DT1,DATA, LOCATE-H' 0000Ғ000 ; This statement deciares an ; absolute address section. .DATA.W H'1111 ; The value of X1 becomes H'0000F000. .DATA.W H'2222 ; The value of X2 becomes Н"0000Ғ002. -SECTION DT2,DATA, ALIGNe4 `; This statement declares a relative address ; section. ; The value of Y1 is determined when the ; linkage editor completes, and its value is ; the start address of the section. H'2222 ; The value of Y2 is determined when the ; linkage editor completes, and its value is the start address of the section pius 2. bee еее ее о ------------ —— == ------------------..-..-.................. 4 e 1 П 4 1 1 t ! % ( П ' 4 1 4 4 ' Li і * 1 т 1 r ' 1 LI LI ! ! LI LI ' 4 Ц 4 [] ! 1 t 1 4 1 ! ! ! ' 39 (2) Definition by Assembler Directive Symbols can be defined by using assembler directives to set an arbitrary value or a special meaning. Examples: .SECTION DEI, DATA, ALIGN=4 DT1 is the section name. ; А section name is also a type of symbol, ; a symbol that expresses the start ; address о! a section. ; However, the syntactic handling of address symbols and section names is different. ; The value of X is 100. X cannot be redefined. The value of Y is 10. Y can be redefined. ; Z becomes an alias of the general ; register R1. ; Z cannot be redefined. 2.32 Symboi Reference There are three forms of symbol reference as follows: ¢ Forward reference * Backward reference * Extemai reference Supplement: Figure 2-3 shows the meaning of the terms forward and backward as used in this manual. Backward Program start ‘Reference position Program end Figure 2-3 Meaning of the Terms Forward and Backward Figure 2-4 shows the meaning of the term external as used in this manual. [Heference position External Figure 2-4 Meaning of the Term External 41 (1) Forward Reference Forward reference means referencing a symbol that is defined forward from the point of reference. o i.e., is defined later in the program. Examples: BRA FORWARD ; BRA isa branch instruction. ; This is a forward reference to the symbol FORWARD. (2) Backward Reference Backward reference means referring to a symbol that is defined backward from the point of reference, і.е., is defined earlier in the program. Exampies: ; BRA isa branch instruction. : This is a backward reference to the symbol! BACK. (3) External Reference When a source program consists of multiple source files, a reference to a symbol defined in another file is called an external reference. External reference is described in the next section, 2.4, "Separate Assembly". 42 2.4 Separate Assembly 2.4.1 Separate Assembly Separate assembly refers to the technique of creating a source program in multiple separate source files, and finally creating a single load module by linking together those source files’ object modules using the linkage editor. The process of developing software often consists of repeatedly correcting and reassembling the program. In such cases, if the source program is partitioned, it will be only necessary to reassemble the source file that was changed. As a result, the time required to construct the compiete program will be significantly reduced. ifa source program is collected If a source program is partitioned together in a singie file... into several files... ile Processing 1 File | Processing 2 | ile Processing 4 File | Processing 6 | : Part of the source program that requires changes. t: Range of the program that must be reassembied. Figure 2-5 Relationship between the Changed Range of the Program and the Range of the Program that must be Reassembled 43 The procedure involved in separate assembly consists of steps (a) to (d). (a) Investigate methods for partitioning the program. Normally, programs are partitioned by function. Note that the memory reservation of the section must aiso be considered at this point. (b) Divide the source program into separate files and edit those files accordingly. (c) Assemble the individual files. (d) Link the individual object modules into a singie load module. 2.42 Declaration of Export Symbols and Import Symbols When a source program consists of multiple files, referencing a symbol defined in one file from another file is called “external reference" or "import." When referencing a symbol externally (this declaration is called “external definition" or “ехрог”), it is necessary to declare to the assembler that “this symbol is shared between multiple files." (1) Export Symbol Declaration This declaration is used to declare that the definition of the symbol is valid in other files. . EXPORT or .GLOBAL assembler directive is used to make this declaration. (2) Import Symbol Deciaration This declaration is used to declare that a symbol is defined in another file. . IMPORT ог. GLOBAL assembler directive is used to make this declaration. Examples: In this example the symbol MAX is defined in file А and referenced in file B. File A: ; Declares MAX to be an export symbol. ; Defines MAX. ; Declares MAX to be an import symbol. : References МАХ. References: Symbol Export and Import — Programmer's Guide, 4.2.4, "Export and Import Assembler Directives”, EXPORT, IMPORT, .GLOBAL (This page intentionally left blank.) Section 3 Executable Instructions This section describes the points that must be kept in mind when using executable instructions in this assembler. 3.1 Overview of Executable Instructions The executable instructions are the instructions of SH microprocessor. SH microprocessor interprets and executes the executable instructions in the object code stored in memory. An executable instruction source statement has the following basic form. {:] Saunnemonic>|[. і, <асагеззіпа model] [;«comment»] L—— LÁ А лон Qperason Operano Coroners This section describes the mnemonic, operation size, and addressing mode. The other elements are described in detail in section 1, "Program Elements", in the Programmer's Guide. (1) Mnemonic The mnemonic expresses the type of executable instruction. Abbreviations that indicate the type of processing are provided as mnemonics for SH microprocessor instructions. The assembler does not distinguish upper-case and lower-case letters in mnemonics. (2) Operation Size The operation size is the unit for processing data. The operation sizes vary with the executable instruction. The assembler does not distinguish upper-case and lower-case letters in the operation size. Specifier Data Size B | Byte ұу Word (2 bytes) L І Long word (4 bytes) 47 (3) Addressing Mode g addressing mode specifies the data area accessed, and the destination address. The addressing modes vary with the executable instruction. Table 3-1 shows the addressing mode. Table 3-1 Addressing Modes Addressing Mode Name Description rere acd E RR Rn Register direct The contents of the general register Rn. SR SR direct The contents of the status register (SR). GBR GBR direct The contents of the global base register (GBR). VBR VBR direct The contents of the vector base register (VBR). MACH MACH direct The contents of the accumulator register (MACH). MACL MACL direct The contents of the accumulator register (MACL). PR PR direct The contents of the procedure register (PR). (Rn Register indirect A memory location. The value in Rn gives the start address of the memory accessed. @Rn+ Register indirect A memory location. The value in Rn (before being with post-increment incremented") gives the start address of the memory accessed. SH microprocessor first uses the value in Вп for the memory reference, and increments Rn afterwards. ©-Ап Register indirect A memory location. The valve in Rn (after being with pre-decrement decremented”) gives the start address of the memory accessed. ы SH microprocessor first decrements Вп, and then uses that value for the memory reference. @(disp,Rn) Register indirect А memory location. The start address of the with displacement"? memory access is given by: the value of Rn pius the displacement (disp). The value ої Rn is not changed. @(RO0,Rin) Register indirect A memory location. The start address of the with index memory access is given by: the value of RO plus the value of Rn. The values of RO and Rn are not changed. @(disp,GBR) GBR indirect with А memory location. The start address of the displacement memory access is given by: the value of GBR plus the displacement (disp). The value of GBR is not changed. Notes 1 t0 3: See next page. Table 3-1 Addressing Modes (cont) Addressing Mode Name Description Q(RO.GBR) GBR indirect A memory location. The start address of the with index memory access is given by: the value of GBR plus 1he value of RO. The values of GBR and RO are not changed. @(disp,PC) PC relative with A memory location. The start address of the displacement memory access is given by: the value of the PC plus the displacement (disp). symbol PC relative specitied [When used as the operand of a branch with symbol instruction) . The symbol directiy indicates the destination address. The assembler derives a displacement (disp) from 2 the symbol and the value of the PC, using the formuia: disp = symbol - PC. [When used as the operand of a data move instruction) M A memory location. The symbol expresses the — starting address of the memory accessed. The assembier derives a displacement (disp) fram the symbol and the value of the PC, using the formula: disp « symbol - PC. #imm immediate Expresses a constant. L emeena eeaeee ee Note: Вп................................. А general register (RO to R1574 т^ SR ......................«-..--. Тһе Status register VBR...............— The vector base register РА........................-...... Тһе procedure register D M— The general register RO (when only RO can be specified) СВА ........................... The Global base register MACH, MACL ОА The accumulator register PC RR The program counter Notes: 1. Increment The amount of the increment is 1 when the operation size is a byte, 2 when the operation size is a word, and 4 when the operation size is a long word. 2. Decrement The amount of the decrement is 1 when the operation size is a byte, 2 when the operation size is a word, and 4 when the operation size is a long word. 3. Displacement A displacement is the distance between 2 points. in this assembly-language, the unit of displacement values is in bytes. 4. Concerning R15 R15 can also be specified by the symbol SP. SP is an abbreviation for stack pointer, a pointer to the stack area. 49 The values that can be used for the displacement vary with the addressing mode and the operation size. Table 3-2 Allowed Displacement Values Addressing Mode Dispiacement* @(disp,Rn) When the operation size is byte (B): H'00000000 to Н0000000Ғ (010 15) When the operation size is word (W): H'00000000 to Н0000001Ғ (01031) When the operation size is long word (L): Н 90000000010 H'0000003F (010 63) @(disp,GBR) When the operation size is byte (B): H'00000000 to H'O00000FF (010 255) When the operation size is word (W): H'00000000 to H'000001FF (010511) When the operation size is long word (L): H'O0000000 to H'O00003FF (0 to 1023) (Q (disp, PC) When the operation size is word (W): H'00000000 to H'000001FF (010511) When the operation size is long word (L): | H'O0000000 to H'O00003FF (Oto 1023) symbol [When used as a branch instruction operand] When used as an operand for a conditional branch instruction (BT or BF): H'00000000 to H'O00000FF (010 255) H'FFFFFFOO to H'FFFFFFFF (--256 to -1) When used as an operand for an unconditional branch instruction ' (BRA, BSR, JMP, JSR, or RTS) | H'00000000 to H'O00000FFF (010 4095) H'FFFFF000 to H'FFFFFFFF (-4096 to -1) [When used as the operand of a data move instruction] When the operation size is word (W): H'00000000 to H'000001FF (010511) When the operation size is long word (L): H'O0000000 to H'O00003FF (0 to 1023) Note: * Units are bytes, numbers in parentheses are decimal. 50 The values that can be used for immediate values vary with the executable instruction. Table 3-3 Allowed Immediate Values Executable Instruction Immediate Value TST, AND, OR, XOR H'00000000 to H'O00000FF (0 to 255) MOV H'00000000 to H'O00000FF (0 to 255) H'FFFFFF80 to H'FFFFFFFF (-128 to -1) * ADD, CMP/EQ H*'00000000 to H'O00000FF (0 to 255) H'FFFFFF80 to H'FFFFFFFF (128 to -1) * TRAPA Н"00000000 to H*000000FF (0 0 255) Note: * Values in the range H'FFFFFF80 to H'FFFFFFFF can be written as positive decimal values. CAUTION! The assembler corrects the value of displacements under certain conditions. Condition - Type of Correction The lower bit of the displacement is discarded, resulting in the value being a multiple of 2. The lower 2 bits of the displacement are discarded, resulting in the value being a multiple of 4. The lower bit of the displacement is When the operation size is a word and the displacement is not a multiple of 2 bid When the operation size is a long word and the displacement is nat a multiple of 4 bid When a displacement of the branch - instruction is not a multiple of 2 discarded, resulting in the value being a muttíple of 2. bad Be sure to take this correction into consideration when using operands of the mode @(disp.Rn), @(disp,GBR), and @(disp,PC). Example: MOV.L @(63,R0) _ The assembler corrects the 63 to be 60, and generates object code identical to that for the statement MOV.L @(60,R0), and warning number 870 occurs. 51 3.2 Notes on Executable Instructions 3.2.1 Notes on the Operation Size The operation sizes that can be specified vary with the mnemonic and the addressing mode combination. Table 3-4 shows the allowable executable instruction and operation size combinations, Table 3-4 Executable Instruction and Operation Size Combinations (part 1) 1. Data Move instructions —————— ow «> «в «ә «> «ә «в «е n an wee meee <> —— OD ч е яр «ә чь € == —€—— — — —— — ——— ——————— ————————————— OMe к өсе HK Oe «> «> е» өз че өк а» өк «ь в «> «> «> «ә «г «с Ар өз «> өк ез « «е Oe we «с «> “в өз «в © eee mew ewe meee eee чь өе жь чь же ee ы эз чы — + +» өзен «өз өз ee ә ез ез өз өз е ч» өз ш» а а» ею «в « «> «к «в ч» ч өз өз «- «в е ee wee жь «= “--е--------------------.---.-...-..... = + чь +» + =» ч» а а>» «в ч» а» <> «е «к чь «сөз eee өн <> е» «ә «зек «ее A DE D—————————————————————————Ó————————————— —————" uA 449 чь Ma «л» eo ap mmm «> е р «> е а е------....-»4.--..-..-.--......... O———————————————————————— «ғ =» «> е «г «е «г чь ар == mew ee wom че чы эь а а ар жь а ж eens «== ч «кеме» а» «к кез өз == «=» «в ез өш = жь өз өз ео ар «в р «> чә иһ өм ао «> «><» ез «> «> чь аъ «ы «в «в ш» «> «е чо ес «» =» « ч» «ә «в аһ ез «е « «> чь «> өз е «><» чь ав оь шь чь ты чь ч owe eros ече л» өз өз «к «в өп =» «һө «кез өз өз ч а» ч CBee нә = He өз «> <>. ч» чө «к жь «в өз «в ез «в «ғ «> «в «> «в «гө «> «> н « = - өк ч» we же чю == чө чь чь жы эв эз а ше эе а jD——————————————Ó—————————OO—— P жы чь жь эь чь ав э» ч чь аы з ————— ——— «> e «> —— е «5 н «в аш» аз «в «> «ғ ч» өз =» чь «е «е ч чю = == ез ‚р чь mmm mmm mm = =ч» == = оч OOO ч € 4pm mma Tm аю ар ч чь ак а чє аа = р == чь ч ч = э чә ж» э жь ж ш» э чө а» ә = = ж = p—"-————————————————————————————————————————————————————— аы ео ъ= ш -- «> «ә ез «> өз әз ар а» а» р <> ем е өз ез «к өз е ез ез «= «к «> «> ав аю «ы чы ч өк «көз ж ч» чь е то чш эъ ар эр ар ар а чь аә ж аш э чш же аш =» жь = чы ч ә єє ч = Notes: 1. In this case Rn must be one of R1 to R15. 2. in this case Rm must be one of R1 to R15. Addressing Mode ttimm,Rn Operation Sizes B w L О A А х о > х е! е! х х 2 о о O O o о O Ə О О x x x x e x x о 9) О х х x э Detault when Omitted a Table 3-4 Executable Instruction and Operation Size Combinations (part 1) (cont) Symbol meanings: Rn, Rm ................... A general register (RO to R15) SR ......................... The status register VBR ........................ The vector base register PR ...... 4. 4 .. .. Тһе procedure register RO.......... The general register RO (when only RO can be specified) СВВ........................ The giobal base register MACH, MACL......... The accumulator register PC .......................- .. The program counter [uL ae An immediate value symbol .... A symbol disp....................—.—- A displacement value В............................ Byte | RR Long word (4 bytes) W ..........- НА Word (2 bytes) ` ) - Осн. Valid specification € — Invalid specification: = The assembier regards instructions with this combination as the specification being omitted. Г. — — The assembler regards them as extended instructions. References: 7 Extended Instructions — Programmer's Guide, 8.2, “Extended Instructions Related to Automatic Literal Pool Generation” Table 3-4 Executable Instruction and Operation Size Combinations (part 2) 2. Arithmetic Operation instructions Operation Sizes Default when Mnemonic Addressing Mode B w L Omitted ADD An, Rm x x o L ADD o o #imm An о о; x x oO Li арс — | АА x x o L о ADDV | ёт ооо; x x O о СМРЕО imm, RO; x x O Li LC СМРЕО | Вт ооо о,» x x o ti - CMPHS | нағя x x Oo Li — CMPGE || RaRm x x o> Li ^. CMPH | RaRm x x зо о ооо CMPGT | тииди. x x узу о ооо CMPPZ | в 3 x x о Li ' CMPPL | Rn 3 x x > Li . CMPSTR | RaRa x x O L -— Ovi — 1 ТЕ x x 29 Li — DOS ғап) 7” x x o Li DNOU — (по operands) x x x — exis Anam о oo x w | Exu Anam —— 1 o O x w —. MAC | QReGRm« SSCS x O x wo o MUS à | RnRm 20-777 x x oO LL | MUU — Anam ооо оо; x x o Li NEG | наиб x x э Li — NEGC | RaRm 00-077 x x Oo Li SUB — ! наға,” x x э Li — sues RnRm О; x x Oo Lo. SUBV — | RaRm Т, x x Oo Li ^ Table 3-4 Executable Instruction and Operation Size Combinations (part 3) 3. Logic Operation instructions Operation Sizes Default when Mnemonic Addressing Mode B үу L Omitted AND Ra,Rm x x o L AND — 1 kimm Ro —» x x о tb AND — 1 WimmQ(ROGBR) |. O x x B -—- NOT 1 Raam ооо ооо хх O Li . OR ! Наяғб 3 x x O Li —. OR | 4тпті0000,- x x O L1 . OR | i #imm.@(ROGBR) |: ох x B o YS — тт O хв зт oo СҮТ: ооо x x .O i -. ЕСІ o | gimmRO > x x д Li — TST o 1 WimmQ(ROGBR) —— « O x x B —. XOR — | Aa Rm 0-77, x x o b -— ха” KmmRO — —. » x x Oo Li — XOR — i #imm,@(ROGBR) — € O x x B Table 3-4 Executable Instruction and Operation Size Combinations (part 4) 4. Shift Instructions Operation Sizes Defauit when Mnemonic Addressing Mode B үу L Omitted ROTL Rn x x о L вот — |! Rn) x x O i ROTCL | ба 3 x x о Lb. ROTCR å I В x x оо — SHAL — 1! Rn O 3 x x Oo ш SHAR 1 Rn °° ©. 3 x x о i SHL |! a. > x x O Li -. SHR ! Rn ооо; x x о о i . SHu2 ! воо оо x x 2 Li . SHLR2 — Aaa 77777777 x x э Li 4. нив Rn ооо, tt ә x x о SHLRB — Aa 3 x x Oo Li -—- SHiüii6 — | Rn. 3 x x O i . SHLRI6 —— 1 в ооох э x о Li — Table 3-4 Executable Instruction and Operation Size Combinations (part 5) §. Branch instructions Operation Sizes Defauit when Mnemonic Addressing Mode в. W L Omitted BF symbol x x x — зз, symbol ооо» x o x x -- ТТ BRA —— symbol — 3 X Xx x -— BSR — : sym! 5 хх М2. өң хох о хоо ш ISA тт x хх -= RTS ——— | (nooperand) x x x — 56 Table 3-4 Executable Instruction and Operation Size Combinations (part 6) 6. System Control instructions Operation Sizes Defauit when Mnemonic Addressing Mode B М L Omitted CLRT (no operands) x x x — CUIRMAC 7 (по operands) x x x "OPENS Dc ! ғ, И ЭЙЕ КЕЛ 061 RnGBR 5 x x Oo L o 0с 87, x x о be шс @Rm, н O x x O L . De QRwGBR ——» хх о ооо we} е азу, e HE NAE Он ГИЛ? шш Ra MACH » хх о э ооо 1051 Ra MACL 2-77 x x 3 to iS o ! а, хх о о 777177 US QR»-MACH — » хх ошм 9 —. 1005 QR»eMACL җ 5 ee ee Еу is å o @RmPR 7, x x o Li - NOP "(mooperands) Хх x x P MCA MEA RE ""(mopeands) х x x "x POM SEIT ep QUA (по operands) x x x = 00 SUEEP — ^ no operands) x x x — 2 ГНИ SARn о; x x о L o se GBA.Rn U3 x x o bE te stc 7-те x x o м о СИГ: е x хо ste TT ӨЛСЕ — о; хох o VE uos. SIC. оо VBR(-Rn 0-2, хох о Lh. SiS м, хох о м Um 5751 МАССА о оо о» хх o м и SiS Рав о > x x O ü 9 81801 MACH-Rn 2, хх о м 22 27. sts o MACLO-Rn 2-2 хх о м er Су ШШ рада 202-795 хох о ы о TRAPA — — атт хох ә ш ооо 3.2.2 Notes on Delayed Branch Instructions The unconditional branch instructions (BRA, BSR, JMP, JSR, RTS, and RTE) are delayed branch instructions. SH microprocessors execute the delay slot instruction (the instruction directly following a branch instruction in memory) before executing the delayed branch instruction. If an instruction inappropriate for a delay slot is specificd, the assembler issues error number 150. Table 3-5 shows the relationship between the delayed branch instruction and the delay siot instructions. Table 3-5 Relationship between Delayed Branch Instruction and Delay Slot Instructions Detayed Branch Detay Siot BRA BSR JMP JSR RTS RTE BF x x x x x x BT x x x x x x BRA x x x x x x BSR x x x x x x JMP x x x x x x JSR x x x x x x RTS x x x x x x RTE x x x x x x TRAPA x x x x x x MOV @(disp,PC),Rn ^ 4 4 5 А А symbol.Rn 4 А х х х х МОУА @(disp,PC),RO ^ 4 4 4 A 4 symbol.RO А 4 x x x Extended MOV.L #imm.Rn x x x x x x instructions MOV.W #imm. Rn x x x x x x MOVA #imm,RO x x x x x x Any other instruction O О е! е! Symbol meanings: 9 ... Normal, i.e., the assembler generates the specified object code. ... Warning 871 Note on the value of PC: PC = «destination address for the delayed branch instruction» + 2 The assembler generates the specified object code. X ..... Error 150 or 151 The instruction specified is inappropriate as a delay slot instruction. The assembler generates object code with a NOP instruction (Н"0009) in the object code. > 58 CAUTION! If the delayed branch instrucuon and the following instruction are coded in different sections, the assembier does not check the delay slot instruction. References: Extended Instructions — Programmer's Guide, 8.2, "Extended Instructions Related to Automatic Literal Pool Generation" 3.2.3 Notes on Address Calculations When the operand addressing mode is PC relative with displacement, i.e., @(disp,PC), the value of PC must be taken into account in coding. The vaiue of PC can vary depending on certain conditions. = (1) Normai Case The value of PC is the first address in the currently executing instruction plus 4 bytes. Examples: (Consider the state when a MOV instruction is being executed at absolute address H'00001000.) Absolute addresses H'00001000 MOV.L @(8,PC),RO H'00001004 -disp = 8 bytes H'0000100C Area being accessed Figure 3-1 Address Calculation Example (normal case) 59 (2) During the Delay Slot Instruction The value of PC is destination address for the delayed branch instruction plus 2 bytes. Examples: (Consider the state when a MOV instructon is being executed at absolute address H'00001000.) Absolute addresses H'00001000 MOV.L @(8,PC),RO L1 = Ho0001006 H'00001008 po disp = 8 bytes H'00001010 Area being accessed Figure 3-2 Address Calculation Example (when the vaiue of PC differs due to a branch) Supplement: When the operand is the PC relative specified with the symbol, the assembler derives the displacement taking account of the value of PC when generating the object code. 60 (3) During the Execution of Either а MOV.L (à (disp.PC),Rn or a MOVA (Q(disp.PC).RO When the value of PC is not a multiple of 4 SH microprocessors correct the value by discarding the lower 2 bits when calculating addresses. Examples 1. When SH microprocessor corrects the value of PC. (Consider the state when a MOV insuucuüon is being executed at absolute address H'00001002.) disp = 8 bytes The value of the PC is corrected to be a multiple of 4. ————V—————— 2 bytes Figure 3-3 Address Caiculation Example (when SH microprocessor corrects the value of PC) 2. When SH microprocessor does not correct the valuc of PC. (Consider the state when a MOV instrucuon is being executed at absolute address H'00001000.) H'00001000 MOV.L @(8,PC).RO DESSEN еы PC [H00001004 puo езі poem [dC disp = 8 bytes The value of the PC Pe eee л. ьш is not changed. H'0000100C Area being accessed Figure 3-4 Address Calculation Example (when SH microprocessor does not correct the value of PC) 61 Supplement: When the operand is the PC relative specified with the symbol, the assembler derives the displacement taking account of the value of PC when generating the object code. 62 Section 4 Assembler Directives 4.1 Overview of the Assembler Directives The assembler directives are instructions that the assembler interprets and executes. Table 4-1 lists the assembler directives provided by this assembler. Table 4-1 Assembler Directives Type Mnemonic Function Section and the location SECTION Declares a section. counter ORG Sets the vaiue of the location counter. -ALIGN Corrects the vaiue of the location counter. Symbols .EQU Sets a symbol value (reset not allowed). .ASSIGN Sets a symbol value (reset allowed). .REG . Defines the alias of a register name. Data and data area .DATA Reserves integer data. reservation .DATAB Reserves integer data blocks. .SDATA Reserves character string data. .5ОАТАВ Reserves character string data blocks. .5ОАТАС Reserves character string data (with length). .-SDATAZ Reserves character string data (with zero terminator). .RES Reserves data area. SRES Reserves character string data area. .SRESC Reserves character string data area (with length). .SRESZ Reserves character string data area (with zero terminator). Export and import symbol .ЕХРОНТ Declares export symbois. | .IMPORT Declares import symbols. GLOBAL Declares export and import symbols. Object modules .OUTPUT Controls object module output. .DEBUG . Controis the output of symbolic debug information. Table 4-1 Assembler Directives (cont) Type Mnemonic Assemble listing .PRINT LIST .FORM .HEADING .PAGE .SPACE Other directives .PROGRAM .RADIX .END Function Controis assembie listing output. Controis the output of the source program listing. Sets the number of lines and columns in the assemble listing. Sets the header for the source program listing. Inserts a new page in the source program listing. Outputs blank lines to the source program listing. Sets the name of the object module. Sets the radix in which integer constants with no radix specifier are interpreted. Declares the end of the source program. 4.2 Assembler Directive Reference 4.2.1 Section and Location Counter Assembler Directives This assembler provides the following assembler directives concerned with sections and the location counter. Declares a section. Sets the value of the location counter. Adjusts the value of the location counter to a multipie of the boundary alignment value. 65 Section Declaration Syntax .SECTIONA
[,
,ALIGN=}]] Statement Elements l. Label The label field is not used. 2. Operation Enter the . SECTION mnemonic in the operation field. 3. Operands a. First operand: the secuon name The rules for section names are the same as the rules for symbols. References: Naming sections | — Programmer's Guide, 1.3.2, “Coding of Symbols" Second operand: the section attribute Attribute Section Type DATA Data section STACK Stack section COMMON Common section DUMMY Dummy section The shaded section indicates the default value when the specifier is omitted. The section usage type is determined by the attribute specification. When the specification is omitted, the section will be a code section. 66 c. Third operand: start address or boundary alignment value Specification Section Type LOCATE = «start address» Absolute address section ALIGN e «boundary alignment value» Relative address section The specification determines whether the section type wiil be an absolute address section or а relative address section. When the specification is omitted, the section will be a relative address section with boundary alignment value of 4. Description l. SECTION is the section declaration assembler directive. A section is a part of a program, and the linkage editor regards it as a unit of processing. The following describes section declaration using the simple examples shown below. Source program "CODE, ALIGN=4 This statement declares the start of г--------------------....-........1..... section CD. This part of the source program belongs to section CD. This statement declares the start of section DT. This part of the source program belongs to section DT. This statement declares the start of section DM. This part of the source program belongs to section DM. This statement declares the end of the source program. Note: * This example assumes that the SECTION assembler directive does not appear in any of the source statement sets 1 to 3. „Ж 67 2. Itis possible to redeclare (and thus restart, i.e., re-enter) a section that was previously declared in the same file. The following is a simple example of section restart. Source program .SECTION CD, CODE, ALIGNe4 This statement declares the start of section CD. This part of the source program belongs to section CD. eere a e эш эъ == э ш = err err rra USECTION ТЕЕ This statement declares the restart ы, m————————————————— of section CD. This part of the source program aiso belongs to section CD. (This part of the program is a continuation of source statement set 1.) Note: * This example assumes that the . SECTION assembler directive does not appear in any of the source statement sets 1 to 3. CAUTION! When using the .SECTION assembler directive to restart a section, the second and third operands must be omitted. (The original specifications when first declaring the section remain valid.) 3. Use LOCATE = cstart address» as the third operand when starting an absolute address section. The start address is the absolute address of the start of that section. The start address must be specified as follows: • The specification must be an absolute value, and, • Forward reference symbols must not appear in the specification. 68 The values allowed for the start address are from H'00000000 to H'FFFFFFFF. (From —2,147,483,648 to 4,294,967 295 in decimal.) Use ALIGN = «boundary alignment value» to start a relative address section. The linkage editor will adjust the start address of the section to be a multiple of the boundary alignment value. The boundary alignment value must be specified as follows: ¢ The specification must be an absolute value, . and, * Forward reference symbols must not appear in the specification. The values allowed for the boundary alignment value are powers of 2, e.g. 2°, 2', 22, ..., 231. For code sections, the values must be 4 or larger powers of 2, e.g. 22, 23, 24, ..., 21, The assembler provides a default section for the following cases. 2. The use of executable instructions when no section has been declared. < The use of data reservation assembler directives when no section has been declared. • The use of the ALIGN assembler directive when no section has been declared. “ The use of the .ORG assembler directive when no section has been declared. • Reference to the location counter when no section has been declared. “ Тһе use of statements consisting of only the label field when no secuon has been declared. The default section is the following section. • Section пате: P e Section type: Code secuon . Relative address section (with a boundary alignment value of 4) 69 Coding Example Сс-------------------------------- «ALIGN 4 .DATA.L H'illillll i чы ч т» а» «э ео оаа е ----------- a ЕЖЕТТОНсо,сорЕ, ALIGN=4 ефе ое е ее ео ео а ео чоь ео ео ео ар ар чо ео чь р а а ар аа б ISECTIOR: DT, DATA, LOCATE*H*00001000 gemmis e — M ыды € m mm 1: .DATA.L | H'22222222 .DATA.L H' 33333333 ' L 1 ' 4 a 4 r] — ! 1% == == == = ее ете еее еее е ео а а ай .END This secton of the program belongs to the default secpon P. Тһе беѓаш: secuon P is а code section, and is a reianve address secoon with a boundary alignment үзіне of 4. This section of the program belongs to the secton CD. The secton CD is a code secton. and 15 a relabve accress secuon with a boundary alignment value of 4. This secnon of the program belongs to the secton DT. Тһе secton DT із а data secnon, and 15 an absolute address secton with a start address of H'00001000. Note: This example assumes the .SECTION assembler directive does not appear in the parts indicated by "~". 70 Location-Counter- Value Setting Syntax .ORGAX1location-counter-value» Statement Elements l. Label The label field is not used. 2. Operation Enter the .ORG mnemonic in the operation field. 3. Operands Enter the new vaiue for the location counter in the operand field. Description 1. .ORG is an assembler directive that sets the value of the location counter. The .ORG assembler directive is used to place executable instructions or data at a specific address. 2. Theiocation-counter-value must be specified as follows: . The specification must be an absolute value or an address within the section, and, « Forward reference symbols must not appear in the specificauon. The values allowed for the location-counter-value are from H'00000000 to H'FFFFFFFF. (From -2,147,483,648 to 4,294,967,295 in decimal.) When the location-counter-value is specified with an absolute value, the following condition must hold: «location-counter-value» > «section start address» (when compared as unsigned values) 71 3. The assembler handles the value of the location counter as follows. • The value is regarded as an absolute address value within an absolute address section. • The value is regarded as a relative address value within a relative address section. Coding Example Г""-----------------%-%-------------------.4 DT, DATA, LOCATE-H'FFEFOOO00 . H'11111111 Н"ҒЕҒЕ0010 : This statement sets the value of the location counter. H'22222222 The integer data H'22222222 is stored at absolute address H'FFFFO010. Explanatory Figure for the Coding Exampie Absolute address H'FFFFOO00 Locations from H'FFFFOOO4 to H'FFFFOOOF are not changed due to the use of Absolute address the .ORG assembler directive. H'FFFFO010 72 Location-Counter-Value Correction Syntax Statement Elements 1. Label The label field is not used. 2. Operation Enter the -ALIGN mnemonic in the operation ficld. 3. Operands Enter the boundary alignment value (the basis for adjusting the location-counter-value) in the operand field. Description 1. .ALIGN is an assembler directive that corrects the location-counter-value to be a multiple of the boundary alignment value. Executable instructions and data can be allocated on specific boundary values (address multiples) by using the .ALIGN assembler directive. 2. The boundary alignment value must be specified as follows: * The specification must be an absolute value, and, ¢ Forward reference symbols must not appear in the specification. Thé values allowed for the boundary alignment value are powers of 2, e.g. 20, 2!, 22, ..., 231. The boundary alignment value specified by ALIGN directive must be less than or equal to the boundary alignment value specified by SECTION directive. 3. When .ALIGN is used in a code section, data section, or dummy section, the assembler inserts NOP instructions in the object code* to adjust the value of the location counter. Odd byte size areas are filled with Н 09. When .ALIGN is used in a dummy or stack section, the assembler oniy adjusts the value of the location counter, and does not fill in any object code in memory. Note: * This object code is not displayed in the assemble listing. Coding Example ; This statement adjusts the value of the location counter to be a multiple of 2. ; This statement adjusts the value of the location ; Counter to be a multipie of 4. This example assumes that the byte sized integer data H'11 is originally located at the 4-byte boundary address. The assembler will insert the filler data as shown in the figure below. f H'1* H22 НЗЗ ' H'O9 H'4444 : ~ H'0009 ____Н'55555555 ___ | : Codes filled in by the assembler. 74 4.22 Symbol Handling Assembler Directives This assembler provides the following assembler directives concerned with symbols. Sets a symbol value. Sets and resets a symbol value. Defines the alias of a register name. 75 .EQU Symbol Value Setting (resetting not allowed) Syntax [:J]A.EQUA) Statement Elements l. Label Enter the symbol to be defined as the alias of a register name in the label field. 2. Operation Enter the -REG mnemonic in the operation field. 3. Operands Enter the register name for which the alias of a register name is being defined in the operand field. Description 1. .КЕС is the assembler directive that defines the alias of a register name. The alias of a register name defined with .REG can be used in exactly the same manner as the original register name. The alias of a register name defined with .REG cannot be redefined. 2. The alias of a register name can only be defined for the general registers (RO to R15, and SP). 3. Definitions with the .REG directive are valid from the point of the definition forward in the program. 4. Symbols defined with ВЕС have the following limitauons: * They cannot be used as export or import symbols. * They cannot be referenced from the simulator/debugger. Coding Example (R10) (R11) #0, MIN 499, MAX MIN, R1 LABEL R1, MAX ; This is the same as MOV #0,R10. ; This is the same as MOV #99,R11. 81 4.3 Data and Data Area Reservation Assembler Directives This assembler provides the following assembler directives that are concerned with data and data area reservation. b 2 2 .SDATAB Reserves integer data. Reserves integer data blocks. Reserves character string data. Reserves character string data blocks. Reserves character string data (with length). Reserves character string data (with zero terminator). Reserves data area. Reserves character string data area. Reserves character suing data area (with length). Reserves character string data area (with zero terminator). 82 Integer Data Reservation Syntax {{:]]4.DATA[.jA(,..., Statement Elements 1. Label Enter a reference symbol in the label field if required. 2. Operation а. Mnemonic Enter .DATA mnemonic in the operauon field. b. Operation size Specifier Data Size 8 Byte Ww Word (2 bytes) DX Long word (4 bytes) The shaded section indicates the defautt value when the specifier is omitted. The specifier determines the size of the reserved data. The long word size is used when the specifier is omitted. 3. Operands Enter the values to be reserved as data in the operand field. Description 1. .DATA is the assembler directive that reserves integer data in memory. 2. Arbitrary values, including relative values and forward reference symbols, can be used to . specify the integer data. а a —— 83 The range of values that can be specified as integer data varies with the operation size. Operation Size Integer Data Range* B H'00000000 to H'O00000FF (0 to 255) H'FFFFFF80 to HFFFFFFFF (—128 to -1) уу Н 00000000 to H'O000FFFF (0 to 65,535) H'FFFF8000 to H'FFFFFFFF — (-32,768 to -1) H'00000000 to H'7FFFFFFF (0 to 4,294,967,295) H'80000000 to H'FFFFFFFF — (-2,147,483,64B to -1) Note: * Numbers in parentheses are decimal. r Coding Exampie ; (This statement adjusts the value of the location counter.) H'11111111 ; H'2222,H' 3333 : These statements reserve integer data. H'44,H'55 ; Note: The data in this figure is hexadecimal. 84 Integer Data Block Reservation Statement Elements 1. Label Enter a reference symbol in the label field if required. ю а. Орегапоп Mnemonic Enter .DATAB mnemonic in the operation field. Operation size Specifler Data Size ne 8 Byte w Word (2 bytes) —— ——— ——— — М—_——_—___ L-spresmereress [опо word (4 bytes) A—— ———M— — ———Á—M—————— * The shaded section indicates the default value when the specifier is omitted. The specifier determines the size of the reserved data. The long word size is used when the specifier is omitted. 3. Operands a. First operand: block count Enter the number of times the data value is repeated as the first operand. Second operand: integer data Enter the value to be reserved as the second operand. Description 1. .DATAB is the assembler directive that reserves the specified number of integer data consecutively in memory. The block count must be specified as follows: The specification must be an absolute value, and, Forward reference symbols must not appear in the specification. Arbitrary values, including relative values and forward reference symbols, can be used to specify the integer data. The range of values that can be specified as the block size and as the integer data varies with the operation size. Operation Size Block Size Range* B H'00000001 to H'FFFFFFFF (1 to 4,294,967,295) үу Н "00000001 to H7FFFFFFF (1 to 2,147,483,647) L H'00000001 to H'3FFFFFFF (1 to 1.073.741.823) Operation Size Integer Data Range* 8 H'00000000 to H'O00000FF (0 to 255) H'FFFFFF80 to H'FFFFFFFF — (-128to -1) үү Н'ОООООООО to H'O000FFFF (0 to 65,535) HFFFF8000 to HFFFFFFFF (--22,768 to -1) L H'00000000 to H'7FFFFFFF (0 to 4,294,967,295) H'80000000 to H'FFFFFFFF (-2,147,483,648 to -1) Noto: * Numbers in parentheses are decimal. 86 Coding Example ; (This statement adjusts the value of the ; location counter.) 1,8'11111111 2,H'2222 ; This statement reserves two blocks of integer 3,H'33 Explanatory Figure for the Coding Example Memory Address symbol X Note: The data in this figure is hexadecimal. r П [] t t LI 4 4 0 4 ' 4 1 % ! 1 ! 1 1 ' 1 ' 4 % 4 t ' L] 4 1 1 , ..------------------------------ 87 . SDATA Character String Data Reservation Statement Elements 1. Label Enter a reference symbol in the label field if required. 2. Operation Enter the .SDATA mnemonic in the operation field. 3. Operands Enter the character string(s) to be reserved in the operand field. Description l. .SDATA is the assembler directive that reserves character string data in memory. References: Character swings — Programmer's Guide, 1.7, "Character Strings” 2. Acontrol character can be appended to a character string. The syntax for this notation is as follows. “”<> The ASCII code for a contro! character must be specified as follows. • Тһе specification must be an absolute value, and, * Forward reference symbols must not appear in the specification. кыөыш—————ү———————————————————— Coding Exampie ; (This statement adjusts the value of ; the location counter.) "AAAAA" ; This statement reserves character string data. """BBg""" ; The character string in this example includes ; double quotation marks. "ABAB"«H'07» ; The character string in this example has ; а сомго! character appended. Explanatory Figure for the Coding Exampie Memory Address symbol X Notes: 1. The data in this figure is hexadecimal. 2. The ASCII code for "A" is: H'41. The ASCII code for "B" is: H'42. The ASCI! code for **" is: H'22. е 1 1 1 M ' L] LI 1 t V ! M t LI ! M t ! 1 ' 1 ! M ‘ ! LI M 1 1 LI 1 П ' 1 ..---.----.-.-.-.----..-....--------....- 89 Character String Data Blocks Reservation Syntax [«*symbol»[:]]A.SDATABA«block count>,”> The ASCII code for a control character must be specified as follows. * Тһе specification must be an absolute vaiue, and, • Forward reference symbols must not appear in the specification. 91 .SDATAB Coding Example r [ ! t ! Li t 1 LI t t t ' 1 4 L] a 4 3 t 1 1 4 t 1 4 L| t і 1 t 4 , 11 ' 4 1 % 1 1 1 4 4 (This statement adjusts the vaiue of the ` location counter.) 2, “AAAAA” ; This statement reserves two character string ; data blocks. 2,"""BBB""" ; The character string in this example includes ; double quotation marks. 2, "ABAB" ; The character string in this exampie has : а сого! character appended. Explanatory Figure for the Coding Example Address X Notes: 1. The data in this figure is hexadecimal. 2. The ASCII code for "A" is: H'41. The ASCII code for "B" is: H'42. The ASCII code for "^" is: H'22. 92 Character String Data Reservation (with length) Syntax [«symbol»[:]]A.SDATACA"«character string»"[,"«character string»"...] Statement Elements l. Label Enter a reference symbol in the label field if required. Operation | Enter the .SDATAC mnemonic in the operation field. Operands | Enter the character suing(s) to be reserved in the operand field. Description l. .SDATAC is the assembler directive that reserves character string data (with length) in memory. A character string with length is a character string with an inserted leading byte that indicates the length of the string. The length indicates the size of the character string (not including the length) in bytes. References: Character strings — Programmer's Guide, 1.7, “Character Strings” . A control character can be appended to a character string. The syntax for this notation is as follows. “<сһагассег string>”<> The ASCII code for a control character must be specified as follows. ———— AMO UOQAMMLA'"""-Ip n —— Á— ———— M 93 • The specification must be an absolute value, and, * Forward reference symbols must not appear in the specification. Coding Example . ALIGN 4 (ODAAT || “AAAAA" "АВАВ"<Н"07> Address symbol ; (This statement adjusts the value oí the ; location counter.) : This statement reserves character string data ; (with length). ; The character string in this example inciudes double quotation marks. ; The character string in this example has ; acontrol character appended. hexadecimal. 2. The ASCII code for "A" is: H'41. The ASCII code for "B" is: H'42. The ASCII code for °°” is: H'22. Character String Data Reservation (with zero terminator) Syntax . [(:]]4.SDATAZA””<> The ASCII code for a control character must be specified as follows. 95 Coding Example е t t % LI L| 1 ' L ' 1 [] 1 LI LI 1 L| % t Li t 1 1 1 ! LI Li ' 4% t L] 4 LI 1 4 1 t * The specification must be an absolute value, and, ¢ Forward reference symbols must not appear in the specificauon. "ААААА" """HEREBe"e “ABAB"(:]]4.RES[.(,——_— Coding Exampie ; (This statement adjusts the vaiue of the location ; counter.) : This statement reserves а 7-byte area. ; This statement reserves a 6-byte area. ә---е-е------------------е----------------------------.--.--.-.....-..------- 4 Explanatory Figure for the Coding Example Memory Address symbol X 2-11. A ЖЖЖ ZA | —————————————————————— c (--.----------------“---------.......-.- 101 Character String Data Area Reservation (with length) Syntax («symbol»(:]]A.SRESCA«character string area size>(,...; Statement Elements 1. Label Enter a reference symbol in the label field if required. Operation Enter the SRESC mnemonic in the operation field. Operands Enter the sizes of the areas (not including the length) to be reserved in the operand field. Description 1. .SRESC is the assembler directive that reserves character string data areas (with length) in memory. A character string with length is a character siring with an inserted leading byte that indicates the length of the string. The length indicates the size of the character string (not including the length) in bytes. References: Character strings — Programmer’s Guide, 1.7, “Character Strings" The character string area size must be specified as follows: • The specification must be an absolute value, and, e Forward reference symbols must not appear in the specification. The values that are allowed for the character string area size are from Н'00000000 to H'O00000FF (in decimal, from 0 to 255). 102 3. Тһе size of the area reserved in memory is the size of the character string area itself plus 1 byte for the count Coding Example (This statement adjusts the value of the location ? counter.) ; This statement reserves 7 bytes plus 1 byte for ; the count. ; This statement reserves 6 bytes plus 1 byte for ; the count. Explanatory Figure for the Coding Example Address symbol ZZZZZZN г 4 ! 1 ! % 1 % 4 4 ' 4% 4 4 ! Б t 4 4 0 1 4 LI L| 1 4 1 ' ! ' LI ' ' 1 + t 1% 103 Character String Data Area Reservation (with zero terminator) Syntax [*symbol»(:]]A.SRESZA«character string area size»(,«character string area size»...j| Statement Elements 1. Label Enter a reference symbol in the label field if required. 2. Operation Enter the .SRESZ mnemonic in the operation field. 3. Operands Enter the sizes of the areas (not including the terminating zero) to be reserved in the operand field. Description 1. .SRESZ is the assembler directive that allocates character string data areas (with zero termination). A character string with length is a character string with an appended tailing byte (with the value H'OO) that indicates the end of the string. References: Character strings — Programmer’s Guide, 1.7, "Character Strings" 2. The character string area size must be specified as follows: “ Тһе specification must be an absolute value, and, * Forward reference symbols must not appear in the specification. The values that are allowed for the character suring area size are from H'00000000 to H'O00000FF (in decimal, from О to 255). 3. The size of the area reserved in memory is the size of the character string area itseif plus 1 byte for the terminating zero. Coding Exampie ; (This statement adjusts the value of the location counter.) ; This statement reserves 7 bytes plus 1 byte for ; the terminating byte. : This statement reserves 6 bytes plus 1 byte for ; theterminating byte. Explanatory Figure for the Coding Example Memory Address symbol X rA г 1 1 t Ц 1 LI L| ! LI t 4 4 % LI Li L| t 4 1 * Li . 4 1 L] a 0 e ' t 1 1 zi ‘ 4 % 4 .........-...............-.--..-..-.......-.-- 105 4.24 Export and Import Assembler Directives This assembler provides the following assembler directives concerned with export and import. .EXPORT Declares export symbols. This declaration allows symbols defined in the current file to be referenced in other files. .IMPORT Declares import symbois. This declaration allows symbols defined in other files to be referenced in the current file. . GLOBAL Declares export and impor symbols. o This declaration allows symbols defined in the current file to be referenced in other files, and allows symbols defined in other files to be referenced in the current file. 106 .EXPORT Export Symbols Declaration Syntax .EXPORTA«symbo1»[,«symbol»...] | Statement Elements 1. Label The label field is not used. Operation Enter the .EXPORT mnemonic in the operation field. 3. Operands Enter the symbols to be declared as export symbols in the operand field. Description 1. .EXPORT is the assembler directive that declares export symbols. An export symbol declaration is required to reference symbols defined in the current file from other files. The following can be declared to be export symbols. “ Constant symbols (other than those defined with the .ASSIGN assembler directive) * Absolute address symbols (other than address symbols іп a dummy section) e Relative address symbols 3. To reference a symbol as an import symbol, it is necessary to declare it to be an export symbol. and also to declare it to be an import symbol. Import symbols are declared in the file in which they are referenced using either the . IMPORT or the .GLOBAL assembler directive. 107 .EXPORT Coding Exampie (In this example, a symbol defined in file A is referenced from file B.) ; This statement declares X to be an export : symbol. H'10000000 ; This statement defines X. : This statement declares X to be an import ; symbol. ; This statement references X. 108 . IMPORT Import Symbols Declaration Syntax .IMPORTA«symbol»[,«symbol»...] Statement Elements 1. Label The labei field is not used. 2. Operation Enter the . IMPORT mnemonic in the operation field. 3. Operands | Enter the symbols to be declared as import symbols in the operand field. Description 1. .IMPORT is the assembler directive that declares import symbols. An import symbol declaration is required to reference symbols defined in another file. 2. Symbols defined in the current file cannot be declared to be import symbois. bel To reference a symbol as an import symbol, it is necessary to declare it to be an export symbol, and also to declare it to be an import symbol. Export symbols are declared in the file in which they are defined using either the EXPORT ` or the .GLOBAL assembler directive. . IMPORT Coding Exampie (In this example, a symbol defined in file A is referenced from fiie B.) H'10000000 This statement declares X to be an export symbol. ; This statement defines X. This statement declares X to be an import symbol. This statement references X. 110 . GLOBAL Export and Import Symbols Declaration Syntax .GLOBALA«symbol»[,«symbol»...] Statement Elements 1. Label The label field is not used. 2. Operation Enter the .GLOBAL mnemonic in the operauon field. Operands Enter the symbols to be declared as export symbols or as import symbols in the operand field. Description l. GLOBAL is the assembler directive that declares symbols to be either export symbols or import symbols. An export symbol declaration is required to reference symbols defined in the current file from other files. An import symbol declaration is required to reference symbols defined in another file. | A symbol defined within the current file is declared to be an export symbol by a GLOBAL declaration. A symbol that is not defined within the current file is declared to be an import symbol by а. GLOBAL declaration. The following can be declared to be export symbols. e Constant symbols (other than those defined with the .ASSIGN assembler directive) 111 * Absolute address symbols (other than address symbols іп a dummy section) * Relative address symbolis 4. То reference a symbol as an import symbol, it is necessary to declare it to be an export symbol, and also to declare it to be an import symbol. Export symbols are declared in the file in which they are defined using either the .EXPORT or the .GLOBAL assembler directive. Import symbols are declared in the file in which they are referenced using either the . IMPORT or the .GLOBAL assembler directive. Coding Example (In this example, a symbol defined in file A is referenced from file B.) ; This statement declares X to be an export : symbol. H'10000000 ; This statement defines X. : This statement declares X to be an import symbol. This statement references X. 112 4.2.5 Object Module Assembler Directives This assembler provides the following assembler directives concerned with object modules. .OUTPUT Controls object module and debug information output. .DEBUG Controls the output of symbolic debug information. 113 . OUTPUT Object Module Output Control Statement Elements 1. Label The labe! field is not used. 2. Operauon Enter the .OUTPUT mnemonic in the operation field. 3. Operands: «output specifier» Output Specifier Output Control OBI SSA's Ап object module is output. NOOBJ No object module is output. ова Debug information is output in the object module. ODBG. «aig Мо debug information is output in the object module. 77 The shaded section indicates the default value when the specifier is omitted. The output specifiers control object module and debug information output. Description 1. .OUTPUT is the assembler directive that controls object module and debug information output. 2. Ifthe .OUTPUT directive is used two or more times in a program with inconsistent output specifiers, an error occurs. 114 3. Specifications conceming debug information output are only valid when an object moduie is output. ' 4. The assembler gives priority to command line option specifications concerning object module and debug information output. References: Object module output —. User's Guide, 2.2.1, “Object Module Command Line Options" OBJECT NOOBJECT Debug information output — User's Guide, 2.2.1, "Object Module Command Line Options” DEBUG NODEBUG Coding Exampie Note: This example and its description assume that no command line options concerning object module or debug information output were specified. ; Anobject module is output. ; No debug information is output. ; Both an object module and debug information ; An object module is output. ; No debug information is output. 115 Supplement: Debug information is required when debugging a program using the simulator/debugger, and is part of the object module. Debug information includes information about source statements and information about symbols. 116 Statement Elements 1. Label The label field is not used. 2. Operation Enter the .DEBUG mnemonic in the operation field. Operands: output specifier Output Control Symbolic debug information is output starting with the next source statement. Output Specifier Она Ж ELTE, OFF Symbolic debug information is not output starting with the next source statement. The shaded section indicates the default value when the specifier is omitted. The output specifier controls symbolic debug information output. Description 1. .DEBUG is the assembler directive that controls the output of symbolic debug information. This directive allows assembly time to be reduced by restricting the output of symbolic debug information to only those symbols required in debugging. The specification of the .DEBUG directive is only valid when both an object module and debug information are output. 117 .DEBUG References: Object module output — Programmer’s Guide, 4.2.5, “Object Module Assembler Directives", .OUTPUT — User's Guide, 2.2.1 "Object Module Command Line Options" OBJECT NOOBJECT Debug information output — Programmer's Guide 4.2.5, “Object Module Assembler Directives", .OUTPUT — User's Guide, 2.2.1, “Object Module Command Line Options" DEBUG NODEBUG Coding Exampie Starting with the next statement, the assembler does not output symbolic debug information. Starting with the next statement, the assembler outputs symbolic debug information. Supplement: The term "symbolic debug information” refers to the parts of debug information concerned with symbols. 118 4.2.6 Assemble Listing Assembler Directives This assembler provides the following assembler directives for controlling the assemble listing. Controls assembie lisung output. Controls the output of the source program listing. Sets the number of lines and columns in the assemble listing. Sets the header for the source program listing. PAGE Inserts a new page in the source program lisung. Outputs blank lines to the source program listing. Supplement: The assemble listing is a listing to which the results of the assembly are output, and includes a source program listing, a cross-reference listing, and a section informauon listing. References: For a detailed description of the assemble listing. see appendix C, "Assemble Lisung Output Exampie". 119 Assemble Listing Output Control Statement Elements 1. Label The label field is not used. 2. Operation Enter the PRINT mnemonic in the operation field. 3. Operands: output specifier Output Specifier Assembler Action LIST An assemble listing is output. МОТ; 9 Мо assemble listing is output. SRCZEÉJWEET;-::4 А source program listing is output in the assemble listing. NOSRC . No source program listing is output in the assemble listing. CREF ахы oi __ A cross-reference listing is output in the assemble listing. NOCREF No cross-reference listing is output in the assemble listing — SCIT Ser ow А section information listing is output in the assemble listing. NOSCT No section information listing is output in the assemble listing. The shaded sections indicate the default settings when the specifier is omitted. The output specifier controls assemble listing output. 120 Description 1. .PRINT is the assembler directive that controls assemble listing output. 2. If the PRINT directive is used two or more times in a program with inconsistent output specifiers, an error occurs. ~ -PRINT LIST .PRINT NOLIST |e Error 3. The output specifiers concerned with the source program listing, the cross-reference listing, and the section information listing are only valid when an assemble listing is output. 4. The assembler gives priority to command line option specifications concerning assemble listing output. References: Assemble listing output -» User's Guide, 2.2.2, “Assemble Listing Command Line Options" LIST NOLIST SOURCE NOSOURCE CROSS REFERENCE МОСКО55 КЕҒЕКЕМСЕ SECTION NOSECTION Coding Example Note: This example and its descnption assume that no command line options concerning assemble listing output are specified. ; Alltypes of assemble listing are output. tt € a ia ае AM € € e ч à € € I € M ж — M" À — À шеш. LIST, NOSRC, NOCREF ; Only a section information listing is output. 121 .LIST Source Program Listing Output Control pa————————ÓÀÓ—ÀÓM— A —ÓÀÓÓ—ÓÁ————————— ал» Syntax .LISTAXoutput specifier>{,...] Output type: {ON/OFF | СОМЮ | NOCOND | DEF | NODEF | CALL | NOCALL i EXP | NOEXP | CODEI NOCODE! Statement Elements 1. Label The label field is not used. 2. Operation Enter the .LIST mnemonic in the operation field. 3. Operands Enter the output specifiers in the operand filed. Description 1. .LIST is the assembler directive that controls output of the source program listing in the following three ways: І Selects whether or not to output source statements. I] Selects whether or not to output source statements related to the condiuonal assembly and macro functions. TII Selects whether or not to output object code lines. .LIST 2. Output is controlled by output specifiers as follows: Output Specifier Type Output Notoutput Object | (ОМЖ OFF fl Failed condition NODEF Definition 0 CALL; NOCALL сш o ш ERA NOCODE Object code lines Description Source statements The source statements following this directive Condition-faiied .AIF directive statements Macro definition statements .AREPEAT and .AWHILE definition statements INCLUDE directive statements .ASSIGNA and .ASSSIGNC directive statements Macro са!! statements, . AIF and .AENDI directive statements Macro expansion statements .AREPEAT and .AWHILE expansion statements The object code lines exceeding the source statement lines The shaded sections indicate the default settings when the specifier is omitted. — Programmer's Guide, 4.2.6, “Assemble Listing Assembler Directives", 3. The specification of the .LIST directive is only valid when an assemble lisung is output. References: Source program listing output .PRINT | — User's Guide, 2.2.2, “Assemble Listing Command Line Options”. LIST NOLIST SOURCE NOSOURCE 3. program listing output. The assembler gives priority to command line option specifications concerning source References: Output on the source program listing — User's Guide, 2.2.2, “Assemble Listing Command Line Options" SHOW NOSHOW 4. LIST directive statements themselves are not output on the source program listing. Coding Exampie This statement controls source program listing output. .AIF \GSHIFT СЕ 16 SHLR16 \Rd -ASSIGNA N&SHIFT-16 -AENDI -AIF Х55НІҒТ GE 8 SHLRB \Rd -ASSIGNA \&SHIFT-8 .AENDI „AIF N&SHIFT GE 4. These statements define a generai- SHLR2 \Rd purpose muttipte-bit shift proedure as а SHLR2 \Rd macro instruction. .ASSIGNA N&SHIFT-4 .AENDI «АТҒ \&5НТЕТ GE 2 SHLR2 \Rd -ASSIGNA \éSHIFT~2 -AENDI AIF \GSHIFT GE 1 SHLR -AENDI -------- Macro са! Note: This exampie and its description assume that no command line options concerning source program listing output are specified. 124 .LIST Source Listing Output of Coding Exampie The LIST assembler directive suppresses the output of the macro definition, .ASSIGNA directive statement, and .AIF condition-failed statements. *** SH SERIES ASSEMBLER Ver. 1.2 *** 07/09/93 16:33:49 PAGE 1 PROGRAM NAME = 31 32 SHLRN 23,RO0 33 35 36 . 37 00000000 39 40 41 45 46 47 00000002 48 00000004 50 51 52 53 00000006 55 56 57 .AIF 23 GE 16 SHLR16 RO .AENDI .AIF 7 GE 8 -AIF 7 GE 4 SHLR2 RO SHLR2 RO .AENDI .AIF 3 GE 2 SHLR2 RO .AENDI .AIF 1 GE 1 58 00000008 SHIR RO 59 .AENDI 60 .END *****TOTAL ERRORS *****TOTAL WARNINGS zZXOXEGEGEOOCEK XGXE OO OOGROXG Goo oOX oux x т. 125 Assemble Listing Line Count and Column Count Setting Statement Elements 1. № bed Label The label field is not used. Operation Enter the FORM mnemonic in the operation field. Operands: size specifier Size Specifier Listing Size LINe«ine count» The specified value is set to the number of lines per page. COLe«column count» The specified value is set to the number of columns per line. These specifications determine the number of lines and columns in the assemble listing. Description — . ы bed -FORM is the assembler directive that sets the number of lines per page and columns per line in the assemble listing. The line count and column count must be specified as follows: * Тһе specifications must be absolute values, and, * Forward reference symbols must not appear in the specifications. The values allowed for the line count are from 20 to 255. The values allowed for the column count are from 79 to 255. The FORM directive can be used any number of times in a given source program. 126 4. The assembler gives priority to command line option specifications concerning the number of lines and columns in the assemble listing. References: Setting the line count in assemble listing — User's Guide, 2.22, “Assemble Listing Command Line Options" LINES Setting the column count in assemble lisung — User's Guide, 2.22, “Assemble Listing Command Line Options" COLUMNS . 5. When there is no specification of command line opuon or .FORM assembler direcuve specification for the line count or the column count, the following values are used: • Linecount.............. 60 lines e Column count......... 132 columns Coding Exampie Note: This example and its description assume that no command line options concerning the assemble listing line count and/or column count are specified. [FORM ІІМе60, СОІ/е200 ; Starting with this page, the number of lines ; per page in the assembie listing is 60 lines. ; Also, starting with this line, the number of ; columns per line in the assembie listing ts ; 200 columns. —— tron LINe55, COLe150 : Starting with this page, the number of lines ; per page in the assemble listing is 55 lines. ; Also, starting with this line, the number of ; columns per line in the assemble listing is ; 150 columns. 127 . HEADING Source Program Listing Header Setting Syntax . HEADINGA”] ` Statement Elements 1. Label The label field is not used. Operation Enter the SPACE mnemonic in the operation field. ы 3. Operands: line count Enter the number of blank lines in the operand fieid. ‚ A single blank line is output if this operand is omitted. Description 1. .SPACE is the assembler directive that outputs the specified number of blank lines to the source program listing. Nothing is output for the lines output by the .SPACE directive; in particular line numbers are not output for these lines. м The line count must be specified as follows: * Тһе specification must be an absolute vaiue, and, * Forward reference symbols must not appear in the specification. Values from 1 to 50 can be specified as the line count. 9% + When a new page occurs as the result of blank lines output by the .SPACE directive, any remaining blank lines are not output on the new page. | > -SPACE directive statements themselves are not output to the source program listing. 132 .SPACE Coding Example DT1,DATA, ALIGNe4 .DATA.L H'121111111 .DATA.L H'22222222 -DATA.L Н" 33333333 .DATA.L H'44444444 ; Inserts five blank lines at the point ESPACE’ 5 ; where the section changes. DT2, DATA, ALIGNe4 Explanatory Figure for the Coding Example Source program listing *** SH SERIES ASSEMBLER Ver. 1.2 *** 10/10/93 12:23:50 PROGRAM МАМЕ > 00000000 . SECTION DT1, DATA, ALIGN-4 00000000 11111111 -OATA.L 4a*lllilli: 00000004 22222222 .2АТА.. 8%22222222 00000008 33333333 .2АТА... 8'33333353 0000000 44444444 САТА... 4*44444444 00000000 .SECTICN DT2,DATA, ALIGNe4 — Note: See appendix C, "Assemobie Listing Output Example", for an explanation of the contents of the source program listing. ———————À————À ———————————————————-—-4 <................-..-...-.-...-....-...-.-.-.-.-.-....-.--.-.. r 1 1 4 1 ' ' t t t ' t t [] ! ' ' t t t ' ! 4 t t t П 1 ' ' [| [ t 4 LI ' ! і ! ! [| [| L| 1 [| i 1 t 1 L t i 4 i V 4 i LI Ц 4 [| [| [| [| І t ! + [| 1 [| t ' ' 133 4.2.7 Other Assembler Directives This assembler provides the following additional assembler directives. Sets the name of the object module. Sets the radix in which integer constants with no radix specifier are interpreted. Declares the end of the source program. 134 Object Module Name Setting Syntax .PROGRAMA«object module name» | Statement Elements l. Label The label field is not used. 2. Орегацоп Enter the PROGRAM mnemonic in the operation field. 3. Operands: «object module name> Enter a name that identifies the object module in the operand field. Description 1. .PROGRAM is the assembler directive that sets the object module name. The object module name is a name that is required by the H Series Linkage Editor or the H Series Librarian to identify the object module. 2. Object module naming conventions are the same as symbol naming conventions. The assembler distinguishes upper-case and lower-case letter in object module names. References: Coding of symbols -» Programmer's Guide, 1.3.2, “Coding of Symbols" 3. Setting the object module name with the PROGRAM directive is valid only once in a given program. (The assembler ignores the second and later specifications of the PROGRAM directive.) . 135 4. If there is no PROGRAM specification of the object module name, the assembler will set a default (implicit) object module name. The default object module name is the file name of the object file (the object module output destination). | Example: Object file name ----------- ' PROG | з ғ OBI i 1 li File name File format 4 Object module name ----- PROG References: User's Guide, 1.2, "File Specification Format” 5. The object module name can be the same as a symbol used in the program. Coding Example EPROGRAM! PROGI ; This statement sets the object module name to be ; PROGI. eed 136 Statement Elements l. Label The label field is not used. 2. Орегацоп Enter the RADIX mnemonic in the operation field. 3. Operands: radix specifier Radix Specifier Radix of Integer Constants with No Radix Specification 8 Binary Q Octat 2: fau SM — Decimal H Hexadecimal The shaded section indicates the default setting when the specifier is omitted. This specifier sets the radix (base) for integer constants with no radix specification. ^ Description 1. RADIX is the assembler directive that sets the radix (base) for integer constants with no radix specification. 2. When there is no radix specification with the RADIX directive in a program, integer constants with no radix specification are interpreted as decimal numbers. 3. If hexadecimal (radix specifier Н) is specified as the radix for integer constants with no radix specification, integer constants whose first digit is A through F must be prefixed with a0 (zero). (The assembler interprets expressions that begin with A through F to be symbols.) ФЕЬ 137 4. Specifications with the RADIX directive are valid from the point of specification forward in the program. Coding Example ғ. .EQU ; This 100 is decimal. ; This 64 is hexadecimal. /; Azerois pretixed to this constant “ОР” since it would ; Бе interpreted as a symbol if it were written as simply F, 138 Source Program End Declaration Syntax .END(A«start address>] Statement Elements l. Label The label field is not used. 2. Operation Enter the .END mnemonic in the operation field. 3. Operands: start address Enter the start address for simulation in the operand field if required. Description 1. ЕМО is the assembler directive that declares the end of the source program. Assembly processing terminates at the point that the .END directive appears. 2. Ifa start address is specified with the END directive in the operand field, the simulator/debugger starts simulation from that address. 3. The start address must be specified with either an absolute value or an address value. 4. The value of the start address must be an address in a code section. 139 Coding Example .SECTION | CD,CODE, ALIGNe4 — ; symbol START. , , This statement declares the end of the source program. ; The simulator/debugger starts simulation from the address indicated by the value of the: 140 Section 5 File Inclusion Function The file inclusion function allows source files to be inserted into other source files at assembly time. The file inserted into another file is called an included file. This assembler provides the .INCLUDE directive to perform file inclusion. The file specified with the .INCLUDE directive is inserted at the location of the [INCLUDE directive. a: “INCLUDE "FILE.H" Included file FILE.H .SECTION CD1,CODE, ALIGN=4 | -MOV #ON, КО ' INCLUDE "FILE.H" "EQU 1 .EQU 0 .SECTION CD1,CODE,ALIGN-4 MOV £ON,RO 141 . INCLUDE File Inclusion Ln — ——Ó ——————————————————Ó————ÓÓÁÓÁIMBÓUOESODMDAMX———————SS SÉ» »]Á à í,',/£—————— AN Syntax Statement Elements 1. Label The label field is not used. 2. Operation Enter the INCLUDE mnemonic in the operation field. 3. Operands | Enter the file to be included. Description 1. .INCLUDE is the file inclusion assembler directive. № If no file format is specified, only the file пате is used as specified (the assembler does not assume any default file format). Reference: User's Guide, 1.2, "File Specification Format" w The file name can inciude the directory. The directory can be specified either by the absolute path (path from the route directory) or by the relative path (path from the current directory). Note: The current directory for the INCLUDE directive in a source file is the directory where the assembler is initiated. The current directory for the INCLUDE directive in an included file is the directory where the inciuded file exits. 4. Included files can include other files. The nesting depth for file inclusion is limited to eight levels (multiplex state). Coding Example This example assumes the following directory configuration and operations: Starts the assembler from the route directory (/) á Inputs source file /dirl/filel.src Inserts file2.h in filel.src Inserts file3.h in file2.h The start command is as follows: /asmsh /dirl/filel.src (RET) filel.src must have the following inclusion directive: .INCLUDE "dir2/file2.h" ; Jis the current directory (relative path specification). or : .INCLUDE "/dir2/file2.h" ; Absolute path specification file2.h must have the following inclusion direcuve: .INCLUDE "file3.h" ; /dir2 is the current directory (relative path specification). or .INCLUDE "/dir2/file3.h" ; Absolute path specification CAUTION! When using MS-DOS, change the slash in the above example to a backslash (\). (This page intentionally left blank.) Section 6 Conditional Assembly Function 6.1 Overview of the Conditional Assembly Function The conditional assembly function provides the following assembly operations: Selects whether or not to assemble a specified part of a source program according to the specified condition. | Iteratively assembles a specified part of a source program. 6.1.1 Preprocessor variables Preprocessor variables are used to write assembly conditions. Preprocessor variables are of either integer or character type. . 1. Integer preprocessor variables Integer preprocessor variables are defined by the .ASSIGNA directive (these variables can be redefined). When referencing integer preprocessor variables, insert a backslash (9 and ап ampersand (&) in front of them. Example: ETATEM C id LELAG: ASSIGNA 1 .AIF A&ELAG EQ 1 ; MOV RORI is assembled MOV RO,R1 ; when FLAG is 1. .AENDI . Character preprocessor variables Character preprocessor variables are defined by the .ASSIGNC directive (these variables can be redefined). When referencing character preprocessor variables, insert a backslash (\) and an ampersand (&) in front of them. TAG: -TASSIGNC "ON" .AIF БҮ ҒАС" EQ "ON" ; МОУ RORI is assembled MOV RO,R1 : when FLAG is "ON". .AENDI 6.1.2 Conditional Assembly The conditional assembly function determines whether or not to assemble a specified part of a source program according to the specified condition. A coding example is shown below. ~ .AIF «condition» «Statements to be assembled when the condition is satisfied» This part can be omitted from the coding. — .AIF "M&FLAG" EQ "ON" - MOV RO,R10 ; These statements MOV R1,R11 ; wili be assembled MOV R2,R12 ; when FLAG is "ON". .AELSE “MOV R10,R0 : These statements MOV R11,R1 : willbe assembled MOV R12,R2 ; when FLAG is not "ON". “ЛЕМІ 146 6.1.3 Iterated Expansion А part of a source program can be iteratively assembled the specified number of times. A coding example is shown below. — .AREPEAT «count» «Statements to be iterated» .AENDR — This exampie is a division of 64-bit data by 32-bit data. R1:R2 (64 bits) + RO (32 bits) = R2 (32 bits): Unsigned TST RO, RO : Zero divisor check BT zero div CMP/HS RO,R1 ; Overflow check BT over div | DIVOU ; Flaginitialization EXREPER 32 ROTCL R2 ; These statements are DIVI RO,R1 | iterated 32 times. (кен ROTCL R2 ; R2 = quotient 147 6.1.4 Conditional Iterated Expansion A part of a source program can be iteratively assembled while the specified condition is satisfied. A coding example is shown below. we AWHILE «condition» «Statements to be íterated» . AENDW ; This example is a multiply and accumulate : operation. TblSiz: .ASSIGNA 50 ; TbiSiz: Datatable size MOV А Tbll,R1 ; R1: Start address of data table 1 MOV A Tb12,R2 ; R2: Start address of data table 2 CLRMAC ; MAC register initialization PAWHILE \єть15іғе GT 0 ; While ТЫбіг is larger than 0, MAC .W GRO*,GR1-* ; this statement is iteratively assembled. TblSiz: .ASSIGNA \&ТЬ15$12-1 ; 1 is subtracted from Tb!Siz. TS S MACL, RO : The result is obtained in RO. 148 6.2 Conditional Assembly Directives This assembler provides the following conditional assembly directives. Defines an integer preprocessor variable. The defined variable can be redefined. Defines a character preprocessor variable. The defined variable can be redefined. Determines whether or not to assemble a part of a source S program according to the specified condition. When the condition is satisfied, the statements after the .AIF are assembled. When not satisfied, the statements after the .AELSE are assembied. Repeats assembly of a part of a source program (between .AREPEAT and .AENDR) the specified number of times. LE Assembles a part of a source program (between .AWHILE and .AENDW) iteratively while the specified condition is satisfied. Terminates .AREPEAT or AWHILE iterated expansion. 149 Integer Preprocessor Variable Definition (redefinition is possible) Syntax [:] .ASSIGNAA Statement Elements 1. Label Enter the name of the preprocessor variable. 2. Operation Enter the .ASSIGNA mnemonic in the operation field. 3. Operands Enter the value to be assigned to the preprocessor variable. Description 1. .ASSIGNA is the assembler directive that defines a value for an integer preprocessor variable. The syntax of integer preprocessor variables is the same as that for symbols. The assembier distinguishes uppercase and lowercase letters. 2. The preprocessor variables defined with the .ASSIGNA directive can be redefined with the .ASSIGNA directive. ы The values for the preprocessor variables must be the following: * Constant (integer constant and character constant) ғ Defined preprocessor variable * Expression using the above as terms 4. Defined preprocessor variables are valid from the point of specification forward in the source program. 5. Defined preprocessor variables can be referenced in the following locations: 150 • .ASSIGNA directive e .ASSIGNC direcuve • AIF directive » .AREPEAT directive е AWHILE directive * Macro body (source statements between .MACRO and .ENDM) When referencing integer preprocessor variables, insert a backslash (\) and an ampersand (&) in front of them. \&<ргергосеззог variable»í('] To clearly distinguish the preprocessor variable name from the rest of the source statement, an apostrophe (7) can be added. 151 Coding Exampie The expanded results are as follows: ; When the condition is satisfied, Rn is shifted to the right by 16 bits. ; When the condition is satisfied, Rn is shifted to the nght by 8 bits. ; When the condition is satisfied, Rn is shifted to the right by 2 bits. When the condition is satisfied. Rn is shifted to the right by 1 bit. SHLR16 R1 R1 This example generates a general-purpose muitiple-bit shift instruction which shifts bits to the right by the number of SHIFT. ; ROis setto Rn. ; 27 is set 0 SHIFT ; Condition: SHIFT 2 16 : When the condition is satisfied. Rn is shifted to the right by 16 bits. ; 16 is subtracted from SHIFT. ; Condition: SHIFT 2 8 ; When the condition is satisfied, Rin is shifted to the right by 8 bits. ; Bis subtracted from SHIFT. Condition: SHIFT 2 4 When the condition is satisfied, Rn is shifted to the right by 4 bits. ; 4is subtracted from SHIFT. Condition: SHIFT 2 2 ; When the condition is satisfied, Rn is shifted to the right by 2 bits. ; 2 is subtracted from SHIFT. ; Condition: SHIFT = 1 When the condition is satisfied. Rin is shifted to the right by 1 bit. і 152 Character Preprocessor Variable Definition (redefiniuon is possible) Syntax «preprocessor variable>(:] .ASSIGNCA"" Statement Elements 1. Label Enter the name of the preprocessor variable. 2. Operation Enter the .ASSIGNC mnemonic in the operation field. 3. Operands Enter the character string enclosed with double-quotation marks ("). Description 1. .ASSIGNC is the assembler directive that defines a character string for an character preprocessor variable. The syntax of character preprocessor variables is the same as that for symbols. The assembler distinguishes uppercase and lowercase letters. 2. The preprocessor variables defined with the .ASSIGNC directive can be redefined with the -ASSIGNC directive. 3. Character strings are specified by characters or preprocessor variables enclosed by double quotation marks (^). 4. Defined preprocessor variables are valid from the point of specification forward in the source program. | 5. Defined preprocessor variables сал be referenced in the following locations: * .ASSIGNA directive • .ASSIGNC directive • AIF directive кз———————————ү——— 153 * AAREPEAT directive * AWHILE directive * Macro body (source statements between .MACRO and ENDM) When referencing character preprocessor variables, insert a backslash (\) and an ampersand (&) in front of them. \&éAA .AELSE «Source statements assembled if the condition is not satisfied .AENDI Statement Elements 1. Label The label field is not used. 2. Operation Enter the . AIF, .AELSE (can be omitted), or AENDI mnemonic in the operation field. 3. Operands .AIF: Enter the condition. Refer to the description below. .AELSE: The operand field is not used. .AENDI: The operand field is not used. Description 1. .AIF,.AELSE, and .AENDI are the assembier directives that select whether or not to assembie source statements according to the condition specified. The .AELSE direcuve can be отшей. 2. Thecondition must be specified as follows: .AIFA«terml»A«relational operator»á«term2» C am — ams [эш Terms are specified with numeric values or character suings. However, when a numeric value and a character string are compared, the condition always fails. Numeric values are specified by constants or preprocessor variables. Character strings are specified by characters or preprocessor variables enclosed by double quotation marks ("). To specify a double quotation mark in a character string, enter two double quotation marks (" ") in succession. Бы The following relational operators can be used: EQ: termi = term2 NE: term] # term2 GT: termi > term2 LT: termi < term2 GE: term] 2 term2 LE: termi S term2 Note: Numeric values are handled as 32-bit signed integers. For character strings, only EQ and NE conditions can be used. Coding Exampie — PAIR. "\cFLAG" EQ "ON" ; These statements ; are assembled ; when FLAG is "ON". ; These statements ; are assembled ; when FLAG is not "ON". 156 .AREPEAT Iterated Expansion Syntax .AREPEAT «count» A Terms are specified with numeric values or character strings. However, when a numeric value and a character string are compared, the condition always fails. Le 159 ausos n————————————— Ó' ! "—"——— ÀÓ' "A AÓAAÓODDUOMOEMEMLLLLLLVLLLILLADLAPEGIILLHLGSDo QA Numeric values are specified by constants or preprocessor variables. Character strings are specified by characters or preprocessor variables enclosed by double quotation marks (7). To specify a double quotation mark in a character string, enter two double quotation marks (" ") in succession. Conditional iterated expansion terminates when the condition finally fails. An infinite loop occurs if a condition which never fails is specified. Accordingly, the condition for this directive must be carefully specified. | > The following relational operators can be used: EQ: termi = term2 NE: term] + term2 GT: term! > term2 LT: termi < term2 GE: termi 2 term2 LE: term! < term2 Note: Numeric values are handied as 32-bit signed integers. For character strings, only EQ and NE conditions can be used. Coding Exampie : This example is a multiply and accumulate ; operation. TblSiz: .ASSIGNA 50 ; ТЫЅіг: Data table size MOV А Tb1l,Rl ; Rt: Start address of data table 1 MOV А Tbl2,R2 ; R2: Stan address of data table 2 CLRMAC : MAC register initialization РЕТТЕ? \cTblsize GT O ; While TolSiz is larger than 0, MAC.W @RO+, @R1+ : this statement is iteratively assembled. TblSiz: .ASSIGNA \&ТЬ1512-1 : 115 subtracted from ТЫбіг. : The result is obtained in RO. 160 .EXITM Expansion Termination Syntax Statement Elements 1. Label The label field is not used. 2. Орегацоп Enter the .EXITM mnemonic in the operation field. 3. Operands The operand field is not used. Description 1. .EXITM is the assembler directive that terminates an iterated expansion (.AREPEAT to . .AENDR) or a conditional iterated expansion (.AWHILE to .AENDW). 2. Either expansion is terminated when this directive appears. 3. This directive is aiso used to exit from macro expansions. The location of this directive must be specified carefully when macro instructions and iterated expansion are combined. Reference: Macro expansion — Programmer's Guide, 7.2, "Macro Function Directives" 161 p— — PáPáBÀESHLIIÁ.ZCLLA]LLAVEULUI)Á,LELLUÁESEHEEILÁUÁXZELLLUILILILLIULÁLELIUIEL.LALLOLEGAGLULOLLLIILILO,ALAULUL"!XKZAILIACA. GqpApALLAIYUHGGAÁAD wILSx[ Coding Example —— COUNT .ASSIGNA 0 ; Oissetto COUNT. -AWHILE 1 EQ 1 ; An infinite loop (condition is always satisfied) is ; specified. ADD RO,Rl ADD R2,R3 COUNT .ASSIGNA \&COUNT+1 ; 1is added to COUNT. .AIF \GCOUNT EQ 2 ; Condition: COUNT = 2 EXIIM .AENDI -AENDW — When COUNT is updated and satisfies the condition specified with the .AIF directive, .EXITM is assembled. When .EXITM is assembled. .AWHILE expansion is terminated. The expansion results are as follows: RO,R1 ; When COUNT is 0 R2, R3 RO,R1 ; When COUNT is 1 R2, R3 After this, COUNT becomes 2 and expansion is terminated. 162 Section 7 Macro Function 7.1 Overview of the Macro Function The macro function allows commonly used sequences of instructions to be named and defined as one macro instruction. This is called a macro definition. Macro instructions are defined as follows: ~— .MACRO «macro name> «macro body» .ENDM —— A macro name is the name assigned to a macro instruction, and a macro body is the statements to be executed as the macro instruction. Using a defined macro instruction by specifying the name is called a macro call. Macro instructions are called as follows: — «defined macro name» т. An exampie of macro definition and macro call is shown below. Example: ҰМАСЕО; SUM . Processing to obtain the sum of RO. R1. R2. MOV R0,R10 . and R3 is defined as macro instruction SUM. ADD R1,R10 ADD R2,R10 ADD R3,R10 : This statement calls macro instruction SUM. ; Macro body MOV RO.R10 ADD R1,R10 ADD R2,R10 ADD R3,R10 ; is expanded from the macro instruction. 163 Parts of the macro body can be replaced when expanded by the following procedure: 1. Macro definition a. Declare formal parameters in the MACRO directive. b. Use the formal parameters in the macro body. Formal parameters must be identified in the macro body by placing a backslash (Y in front of them. 2. Macro cali Specify macro parameters in the macro call. When the macro instruction is expanded, the formal parameters are replaced with their corresponding macro parameters. Example: LMACRO 17504 ARGI: ; Formal parameter ARG1 is defined. MOV RO, NARGI ; ARG1 is referenced in the macro body. ADD Ri, \ARGi} ADD n2 ARS ADD R3, NARGI M — ESUM R10; ; This statement calls macro instruction SUM : specifying macro parameter R10. ; The formai parameter in the macro body is ; replaced with the macro parameter, and MOV RO,R10 ADD R1,R10 ADO R2.R10 ADO R3,R10 is expanded. 164 7.2 Macro Function Directives This assembler provides the following macro function directives. Defines a macro instruction. Terminates macro instruction expansion. 165 [macro | кш] Macro Definition Syntax .MACROA«macro name>[A(=] {,...]]} Statement Elements 1. Label The label field is not used. 2. Орегацоп Enter the . MACRO or ENDM mnemonic in the operation field. 3. Operands .MACRO: Enter the name and formal parameters for the macro instruction to be defined. When formal parameters are defined, their defaults can be defined (defaults can be omitted). .ENDM: The operand filed is not used. Description 1. -MACRO and .ENDM are the assembler directives that define a macro instruction (a sequence of source statements that arc collectively named and handled together). Macro definition Naming as a macro instruction the source statements (macro body) between . MACRO and -ENDM directives is called a macro definition. Macro name Macro names are the names assigned to macro instructions. Formal parameters Formal parameters are specified so that parts of the macro body can be replaced by specific 166 parameters at expansion time. Formal parameters аге replaced with the character strings (macro parameters) specified at macro expansion (macro call). a. Formal parameter syntax The syntax for formal parameters is the same as that for symbols. The assembler distinguishes uppercase and lowercase letters. b. Formal parameter reference Formal parameters are used (referenced) at the part to be replaced іп the the macro body. The syntax of formai parameter reference in macro bodies is as follows: \['] To clearly distinguish the preprocessor variable name from the rest of the source statement, an apostrophe (7 can be added. . Formal parameter defaults Defaults for forma! parameters can be specified in macro definitions. The default specifies the character string to replace the formal parameter when the corresponding macro parameter is omitted in a macro call. The default must be enclosed by double quotation marks (") or angle brackets (<>) if any of the following characters are included in the default. « Space • Тар “ Comma (.) • Semicolon (;) * Double quotation marks (7) * Angle brackets (< >) The assembler inserts defaults at macro expansion by removing the double quotation marks or angle brackets that enclose the character strings. 167 [aco | кюн 6. Restrictions on macro definitions a. Macros cannot be defined in the following locations: * Macro bodies (between . MACRO and .ENDM directives) * Between .AREPEAT and .AENDR directives • Between .AWHILE and .AENDW directives b. The ENDM directive cannot be used within a macro body. c. No symbol can be inserted in the label field of the .ENDM directive. The .ENDM directive is ignored if its label field is not blank, but no error is generated in this case. Coding Example [АСС sun MOV RO,R10 ADD R1,R10 ADD R2,R10 ADD R3,R10 РЕР; еты» ; Processing to obtain the sum of RO, R1, R2, ; and R3 is defined as macro instruction SUM. ; This statement calls macro instruction SUM ; Macro body MOV RO.R10 ; ADD R1.R10 ADD R2.R10 ADD R3.R10 is expanded. 168 Expansion Termination Syntax Statement Elements 1. Label The label field is not used. 2. Operauon Enter the .EXITM mnemonic in the operation field. 3. Operands The operand field is not used. Description l. .EXITM is the assembler directive that terminates a macro expansion. This directive can be specified within the macro body (between .MACRO and .ENDM directives). 2. Expansion is terminated when this directive appears. 3. This directive is also used to exit from iterated expansions specified with the .АКЕРЕАТ or .AWHILE directive. The location of this directive must be specified carefully when macro instructions and iterated expansion are combined. 169 Coding Exampie .ЕХПМ is expanded at (2) and macro expansion is terminated. Only the statements indicated by (1) are expanded. 170 7.3 Macro Body The source statements between the . MACRO and .ENDM directives are called a macro body. The macro body is expanded and assembled by a macro call. 1. Formal parameter reference Formal parameters are used to specify the parts to be replaced with macro parameters at macro expansion. The syntax of formal parameter reference in macro bodies is as follows: \] «macro name»[«macro parameter» [, «macro parameter» ...]] Statement Elements l. Label Enter a reference symbol in the label field if required. 2. Operauon Enter the macro name to be expanded in the operation field. The macro name must have been already defined before a macro сай, | 3. Operands Enter character sings as macro parameters to replace formal parameters at macro expansion. The formal parameters must have been declared in the macro definiuon with MACRO. Description 1. Macro parameter specification Macro parameters can be specified by either positional specification or keyword specification. a. Positional specification The macro parameters are specified in the same order as that of the formal parameters declared in the macro definition. b. Keyword specification Each macro parameter is specified following its corresponding formal parameter, separated by an equal sign (=). 175 2. Macro parameter syntax Macro parameters must be enclosed by double quotation marks (^) or angle brackets (<>) if any of the following characters are included in the macro parameters: . Space * Tab e Comma() “ Semicolon (;) ¢ Double quotation marks (") e Angle brackets (< >) Macro parameters are inserted by removing the double quotation marks or angle brackets that enclose character strings at macro expansion. Coding Example .MACRO SUM FROM=0, ТО=9 ; Macro instruction SUM and formal ; parameters FROM and TO are defined. MOV R\FROM, R10 .А55ІСМА \FROM+1 .AWHILE \&COUNT LE АТО Macro body is coded MOV R\&COUNT, R10 using formal parameters. .ASSIGNA \SCOUNT+1 . AENDW | . ENDM SUM 0,5 ] Both will be expanded SUM TO=5 into the same statements. Expanded results are as follows (thé formai parameters in the macro body are replaced with macro parameters): MOV RO, R10 MOV R1, R10 MOV R2, R10 MOV R3, R10 MOV R4, R10 MOV R5, R10 176 7.5 Character String Manipulation Functions This assembler provides the following character string manipulation functions. Counts the length of a character string. Searches for a character string. .SUBSTR Extracts a character string. Character String Length Count i LTTE NT LEONE ADS ELE ITT TATE TE CMM Dr m M Syntax -LEN[A] ("") Description 1. ГЕМ counts the number of characters іп a character string and replaces itself with the number of characters in decimal with no radix. 2. Character strings are specified by enclosing the desired characters in double quotation marks ("). To specify a double quotation mark in a character string, enter two double quotation marks in succession. 3. Macro formal parameters and preprocessor variables can be specified in the character string as shown below. ~LEN("\") .LEN("M&«preprocessor variable>") 4. This function can only be used within a macro body (between MACRO and .ENDM directives). - 178 EE —O E —————————————— Coding Example: .MACRO RESERVE LENGTH P1 .ALIGN 4 .SRES .ENDM — RESERVE LENGTH ABCDEF RESERVE LENGTH ABC Expanded results are as follows: .ALIGN .SRES : "ABCDEF" has six characters. .ALIGN .SRES : "ABC" has three characters. 179 Character String Search Syntax .ІМЅТЕ [4] ("","" {, parameters, this function is replaced with a blank space (" "). 5. Macro formal parameters and preprocessor variables can be specified in the character string, | and as the start position and extraction length parameters as shown below. .SUBSTR("\ ч» чь аю жь е чь ш эз рө ------- Extended instruction 1 | | | 1 i і Н RTS i Н КОР | ISNOPOOL ------- No literal pool is output here + CASE2: ' | MOV.L &H'FFFFOO00,RO ------- Extended instruction 2 RIS | Н NOP К ------ Literal pool is output here | Pee T—-———————————————————— P P 4444414 Automatic literal pool generation result (source list) Н а ! — 20 0000F000 20 CASEL: ! 21 0000Ғ000 5001 21 MOV.L #H'FFFF0000, RO ! 22 0000F002 000В 22 RTS ' ! 23 0000F004 0009 | 23 МОР ' ! 24 24 . NOPOOL ! — 25 0000Ғ006 25 CASE2: ! 26 0000Ғ006 5001 26 MOV.L #H'FFFF0000, RO |! 27 0000Ғ008 000В 27 RTS A * 28 0000ЕООА 0009 28 NOP ' ! 29 **** BEGIN-POOL **** ' ' 30 0000F00B 0000 — — — . . ALIGNMENT CODE ' ! .31 0000Ғ00С ҒҒҒҒ0000 DATA FOR SOURCE-LINE 21,26 ' ' 032 **** END-POOL **** + 1 190 8.6 Notes on Automatic Literal Pool Output 1. If an error occurs when an extended instruction is wnuen — Extended instructions must not be specified in delay siots (error 151). — Extended instructions must not be specified in relative sections having a boundary alignment value of less than 2 (error 152). — MOVL #imm, Rn or MOVA #imm, RO must not be specified in relative sections having a boundary alignment value of less than 4 (error 152). . Ifan error occurs when a POOL directive is written .POOL directives must not be written after unconditional branches (error 522). If an error occurs when a .NOPOOL directive is written .NOPOOL directives are valid only when written after delay slot instructions. If written at Other locations, the .NOPOOL directive causes error 521. . If the displacement of an executable instruction exceeds the valid range when an extended instruction is expanded The assembier generates a literal pool and outputs error message 402 for the instruction having a displacement outside the valid range. Solution: Move the literal pool output location by the .NOPOOL directive, or change the location or addressing mode of the instrucuon causing the error. If the literal pool output location cannot be found If the assembler cannot find a literal pool output location satisfying the following conditions in respect to the extended instruction, ` — Same file — Same section — Forward direction the assembler outputs, at the end of the section which includes the extended instrucuon, the literal pool and a BRA instruction with a NOP instruction in the delay slot to jump around the literal pool, and outputs warning message 876. If the displacement from the extended instruction exceeds the valid range If the displacement of the literal pool from the extended instruction exceeds the valid range, error 402 is generated. Solution: Output the literal poo! within the valid range using the POOL directive. 191 (This page intentionally left blank.) 192 User's Guide (This page intentionally left blank.) Section 1 Executing the Assembler 1.1 Command Line Format To start the assembler, enter a command line with the following format when the host computer operating system is in the input wait state. » imo ET Eu source 2182] l. } ERGDBJECT The abbreviated forms are indicated by shading. Description 1. The OBJECT option specifies output of an object module. The NOOBJECT option specifies no output of an object module. 2. The object output file specifies the output destination for the object module. 3. When the object output file parameter is omitted. the assembler takes the following actions: • If the file format is omitted: The file format obj is supplied. • If the specification is completely omitted: The file format obj is appended to the name of the input source file (the first specified source file). 4. Donotspecify the same file for the input source file and the output object file. 199 TT Relationship with Assembler Directives The assembler gives priority to specifications made with command line options. Command Line Option Assembler Directive Result OBJECT (regardless of any specification) An object module is output. NOOBJECT (regardless of any specification) An object module is not output. (no specification) .OUTPUT OBJ An object module is output. OUTPUT NOOBS An object module is not output. (no specification) An object module is output. 200 DEBUG | NODEBUG Debug Information Output Controi Syntax ЁбЕвос ЕНАДЕВОС The abbreviated forms аге indicated by shading. Description 1. The DEBUG option specifies output of debug information. The NODEBUG option specifies no output of debug information. 2. The DEBUG and NODEBUG opuons are only valid in cases where an object module is being output. References: Object module output — Programmer’s Guide, 4.2.5, “Object Module Assembler Directives”, .OUTPUT — User's Guide, 2.2.1, "Object Module Command Line Options", OBJECT NOOBJECT Relationship with Assembler Directives The assembler gives priority to specifications made with command line opuons. p""""""""—!"—- L— —————!Ón€———————— M Command Line Option Assembler Directive Resuit DEBUG (regardless of any specification) Debug information is output. NODEBUG (regardless of any specification) Debug information is not | output. (no specification) OUTPUT DBG Debug information is output. .OUTPUT NODBG Debug information is not output. (no specification) Debug information is not output. 201 ШТІ Supplement: Debug information is information required when debugging a program using the simulator/debugger or the emulator, and is part of the object module. Debug information includes information about source statement lines and information about symbols. 202 o 2.22 Assemble Listing Command Line Options This assembler provides the following command line options concerned with the assemble listing. These command line options control output of an assemble listing. These command line options control output of a source program listing. CROSS REFERENCE | |NOCROSS REFERENCE These command line options control output of a cross-reference listing. These command line options control output of a section information listing. These command line options control output of the source program listing. This command line option sets the number of lines in the assemble listing. This command line option sets the number of columns in the assemble listing. 203 Assemble Listing Output Control Syntax EIST ( =[,(,(, Example: 10 NO INPUT FILE SPECIFIED (2) Source Program Errors These are syntax errors in the source program. The assembler outputs the error message to standard output (usually the display) or the source program listing. (If a source program listing is output during assembly, these messages are not _ output to standard output.) The format of these messages is as follows: "