Home

- Stealth 316

image

Contents

1. B 3 Bit Test and Branch B 4 Register Indirect iuniore prie pri edited B 4 Move Immediate se B 4 PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE APPENDIX B B 4 B 4 1 B 42 B 4 3 B 4 4 B 4 5 B 4 6 B 4 7 B 5 B 5 1 B 52 B 5 3 B 5 4 B 5 5 B 6 B 6 1 B 6 2 B 6 3 B 6 4 B 6 5 B 6 6 B 6 7 B 6 8 APPENDIX C APPENDIX D APPENDIX E E 1 E 2 E 3 E 4 TABLE OF CONTENTS cont d PAGE ADDRESSING MODES cont d M6805 68HC05 ADDRESSING MODES B 4 Inherent or Accumulator Addressing B 5 Immediate Addressing ses B 5 Relative Addressing esie icons eri tete rince nd etie e eps B 5 Indexed Addressing oes B 5 Direct and Extended Addressing B 5 Bit Set or Clear urne retiro rtt eod ma ea etd od B 6 Bit Test and Branch B 6 M6809 ADDRESSING MODES B 6 Inherent or Accumulator Addressing B 6 Immediate Addressing B 6 Relative Addressing B 8 Indexed Addressing s B 8 Direct and Extended Addressing B 10 M68HC11 AD
2. 4 2 FCB FORM CONSTANT BYTE 4 2 FCC FORM CONSTANT CHARACTER STRING 4 3 FDB FORM DOUBLE BYTE CONSTANT 4 3 FILL FILL MEMORY 4 3 OPT ASSEMBLER OUTPUT OPTIONS 4 4 ORG SET PROGRAM COUNTER TO ORIGIN 4 4 PAGE TOP OF PAGE iis dM DR qe 4 5 RMB RESERVE MEMORY BYTES 4 5 ZMB ZERO MEMORY BYTES 4 5 GHARACTER SET pulo nS A 1 ADDRESSING MODES INTRODUCTION OMEN EU B 1 M6800 6801 ADDRESSING MODES B 1 Inherent or Accumulator Addressing B 1 Immediate Addressing B 1 Relative Addressing ssseessssss B 1 Indexed Addressing eo correre B 2 Direct and Extended Addressing B 2 M6804 68HC04 ADDRESSING MODES B 2 Inherent or Accumulator Addressing B 3 Immediate Addressing B 3 Relative Addressing B 3 Direct and Extended Addressing B 3 Short Direct RES CI EA B 3 Bit Set or Clear
3. FDB Form constant double byte FILL Initialize a block of memory to a constant RMB Reserve memory single bytes ZMB Zero Memory Bytes same as BSZ Listing Control OPTc Enable cycle counting OPT cre Print cross reference table OPTI Print source listing from this point OPT nol Inhibit printing of source listing from this point OPT s Print symbol table PAGE Print subsequent statements on top of next page PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE C 1 APPENDIX D ASSEMBLER LISTING FORMAT The assembler listing has the following format LINE ADDR OBJECT CODE BYTES 4 CYCLES SOURCE LINE The LINE is a 4 digit decimal number printed as a reference used in the cross reference The ADDR is the hexadecimal value of the address for the first byte of the object code for this instruction The OBJECT CODE BYTES are the assembled object code of the source line in hexadecimal If a source line causes more than 6 bytes to be output a long FCC directive additional bytes up to 64 are listed on succeeding lines with no address preceding them The CYCLES will only appear in the listing if the c option is in effect It is enclosed in brackets which helps distinguish it from the source listing The SOURCE LINE is reprinted exactly from the source program including labels The symbol table will be printed when the listing control OPT s is selected The symbol table has the following format SYM
4. 7010100 70210101 PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE Reason Invalid missing percent too many digits invalid digit 2 8 An octal constant consists of a maximum of six numeric digits excluding the digits 8 and 9 preceded by a commercial at sign Octal constants must be in the ranges 0 to 0177777 The following example shows both valid and invalid octal constants Vali Invalid Reason Invalid 017634 02317234 too many digits 0377 0277272 out of range 0177600 023914 invalid character A single ASCII character can be used as a constant in expressions ASCII constants are preceded by a single quote Any character including the single quote can be used as a character constant The following example shows both valid and invalid character constants lt alid Invalid Reason Invalid VALID too long For the invalid case above the assembler will not indicate an error but will assemble the first character and ignore the remainder 2 2 4 Comment Field The last field of an assembler source statement is the comment field This field is optional and is only printed on the source listing for documentation purposes The comment field is separated from the operand field or from the operation field if no operand is required by at least one whitespace character The comment field can contain any printable ASCII characters PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREE
5. S MANUAL MOTOROLA FREEWARE 2 3 2 2 3 2 M6804 68HC04 Operand Syntax For M6804 68HC04 MCU family devices the following operand formats are used Operand Format no operand expression expression expression expression expression lt x gt or lt y gt lt expression gt lt expression gt Addressing Mode Accumulator and Inherent Direct Extended or Relative Immediate Bit Set or Clear Bit Test and Branch Register Indirect Move Indirect Details of the M6804 68HC04 addressing modes are in Appendix B 2 2 3 3 M6805 68HC05 Operand Syntax For M6805 68HC05 MCU family devices the following operand formats are used Operand Format no operand expression expression expression expression lt expression gt lt expression gt lt expression gt Addressing Mode Accumulator and Inherent Direct Extended or Relative Immediate Bit Set or Clear Bit Test and Branch Details of the M6805 68HC05 addressing modes are in Appendix PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE 2 4 2 2 3 4 Operand Format no operand expression expression lt expression gt X lt lt expression gt gt lt expression gt lt expression gt lt expression gt R lt lt expression gt R gt lt expression gt R lt expression gt R lt lt expression gt R gt lt expression gt R Q Q Q Q Q Q W1 W2 Wn M6809 Operand Synt
6. Test and Branch The bit test and branch addressing mode is a combination of direct and relative addressing The bit to be tested and its condition set or clear is included in the opcode The data space address of the byte to be tested is in the single byte immediately following the opcode byte and follows direct addressing rules The third byte is sign extended by the processor during execution to form the 12 bit relative address which is added to the program counter if the condition is true This allows branches based on any readable bit in the data space The branch span is 125 to 130 from the opcode address The branch target address is used by the programmer to signify the relative offset the assembler calculates the offset value Branches out of bounds are flagged as errors by the assembler B 3 8 Register Indirect In the register indirect mode the operand is at the address in data space pointed to by the contents of one of the indirect registers X or Y The particular indirect register is encoded in bit 4 of the opcode by the assembler The assembler operand syntax for register indirect is lt gt Or lt y gt B 3 9 Move Immediate The MVI move immediate instruction has its own format mvi expression 1 gt lt expression 2 where expression 1 gt is a direct address and expression 2 gt is the data value to be written B 4 M6805 68HC05 ADDRESSING MODES The M6805 68HC095 uses the following types of addressing m
7. The listing and or error messages may be saved to a file for later examination or printing by appending an i o redirection command to the command line On the PC i o redirection is indicated with the greater than gt symbol followed by any new or existing file name Command line examples The command line 5 myfile would run the M6805 68HC05 assembler on the source file myfile The object file would be written to myfile s19 and any errors would appear on the screen The command line as9 test asm nexttest s would run the M6809 assembler on the source files test asm and nexttest s The object file would be written to test s19 and any errors and the assembly listing would appear on the screen The command line as9 test asm nexttest s cre s gt test Ist would run the M6809 assembler on the source files test asm and nexttest s The object file would be written to test s19 A listing would be created followed by a cross reference and symbol table which would all be written to the file test Ist PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE 3 2 3 2 ERROR MESSAGES Error diagnostic messages are placed in the listing file just before the line containing the error The format of the error line is Line number Description of error Or Line number Warning Description of error Errors in pass one cause cancellation of pass two A warning error line message does not cause cancellation of pa
8. The valid forms for the automatic increment decrement mode are as follows for each row the three entries shown are equivalent R 0 R R 0 R R R 0 R R R 0 R R R 0 R 0 R In this form the only valid expression is 0 Like the accumulator offset mode this form generates a one byte operand postbyte only The valid forms for the expression offset mode are R lt expression gt R R LR lt expression gt R lt R lt R lt lt expression gt R lt R lt R lt lt expression gt R gt R gt R gt lt expression gt R gt R gt R gt lt expression gt R The lt and gt characters force an 8 or 16 bit offset respectively If no expression is specified or if an expression with a value of zero is specified only the postbyte of the operand is generated If an expression with a value in the range 16 to 15 is specified without indirection a one byte operand is generated which contains the expression s value as well as the index register indicator At execution time the expression s value is expanded to 16 bits with sign extension before being added to the index register All other forms will generate a postbyte as well as either a one or two byte offset which contains the value of the expression The size of the offset is determined by the type and size of the expression Expressions with values in the range 128 to 127 generate an 8 bit offset all oth
9. depending on the instruction All instructions referencing the accumulator A or B or the condition code register CC will generate a one byte immediate value Also immediate addressing used with the PSHS PULS PSHU and PULU instructions generates a one byte immediate value Immediate operands used in all other instructions generate a two byte value PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE B 6 The register list operand does not take the form expression but still generates one byte of immediate data The form of the operand is R1 R2 Rn where Ri i 1 to n is one of the symbols A B CC D DP PC S U X or Y The number and type of symbols vary depending on the specific instruction For the instructions PSHS PULS PSHU and PULU any of the above register names may be included in the register list The only restriction is that U cannot be specified with PSHU or PULU and S cannot be specified with PSHS or PULS The one byte immediate value assigned to the operand is calculated by the assembler and is determined by the registers specified Each register name causes the assembler to set a bit in the immediate byte as follows w Register PC U S Y X DP B D A D CC a MI For the instructions EXG and TFR exactly two of the above register names must be included in the register list The other restriction is the size of the registers specified For the EXG instruction the
10. lt gt comment The FDB directive may have one or more operands separated by commas The 16 bit value corresponding to each operand is stored into two consecutive bytes of the object program The storage begins at the current program counter and the label Is assigned to the first 16 bit value Multiple operands are stored in successive bytes The operand may be a numeric constant a character constant a symbol or an expression If multiple operands are present one or more of them can be null two adjacent commas in which case two bytes of zeros will be assigned for that operand 4 7 FILL FILL MEMORY lt label gt FILL lt expression gt lt expression gt The FILL directive causes the assembler to initialize an area of memory with a constant value The first expression signifies the one byte value to be placed in the memory and the second expression indicates the total number of successive bytes to be initialized The first expression must evaluate to the range 0 255 Expressions cannot contain forward references or undefined symbols PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE 4 3 4 8 OPT ASSEMBLER OUTPUT OPTIONS OPT lt option gt lt option gt lt option gt comment The OPT directive is used to control the format of the assembler output The options are specified in the operand field separated by commas All options have a default condition Some options can be initiali
11. register The address is calculated at the time of instruction execution by adding a zero one or two byte displacement to the current contents of the X register The displacement immediately follows the operation code in memory If the displacement is zero no offset is added to the index register In this case only the operation code resides in memory Since no sign extension is performed on a one byte displacement the offset cannot be negative Indexed addressing is indicated by the characters X following the expression in the operand field The special case of X without a preceding expression is treated as 0 X Some instructions do not allow a two byte displacement B 4 5 Direct and Extended Addressing Direct and extended addressing utilize one direct or two extended bytes to contain the address of the operand Direct addressing is limited to the first 256 bytes of memory Direct and extended addressing are indicated by having an expression only in the operand field Some instructions do not allow extended addressing Direct addressing will be used by the assembler whenever possible PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE B 5 B 4 6 Bit Set or Clear The addressing mode used for this type of instruction is direct although the format of the operand field is different from the direct addressing mode described previously The operand takes the form expression 1 gt expression 2 The bit to b
12. BOL ADDR The symbol is taken directly from the label field in the source program The ADDR is the hexadecimal address of the location referenced by the symbol The cross reference table will be printed when the listing control OPT cre is selected The cross reference table has the following format SYMBOL ADDR LOC1 LOC2LOC3 The SYMBOL and ADDR are the same as above The first location in the list is marked with an asterisk to indicate the line where the symbol was defined The LOCs are the decimal line numbers of the assembler listing where the label occurs PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE D 1 APPENDIX E S RECORD INFORMATION E 1 INTRODUCTION The S record output format encodes program and data object modules into a printable ASCII format This allows viewing of the object file with standard tools and allows display of the module while transferring from one computer to the next or during loads between a host and target The S record format also includes information for use in error checking to insure the integrity of data transfers E 2 S RECORD CONTENT S Records are character strings made of several fields which identify the record type record length memory address code data and checksum Each byte of binary data is encoded as a 2 character hexadecimal number with the first character representing the high order 4 bits of the byte and the second the low order 4 bits The 5 fie
13. DRESSING MODES B 10 Prebyle Jr ued 11 Inherent or Accumulator Addressing B 11 Immediate Addressing B 11 Relative Addressing ccce eerte teer ether B 11 Indexed Addressing 5 o certet B 11 Direct and Extended Addressing B 12 Bit s Set or Clear 3 eee B 12 Bit Test and Branch B 12 DIRECTIVE SUMMARY C 1 ASSEMBLER LISTING FORMAT ss D 1 S RECORD INFORMATION INTRODUCTION vsa cick cick Ux M nex ose UR a ep qn ac a E up Rue ks E 1 S RECORD CONTENT E 1 S RECORDTYPES 2i e e vetu E 2 SS RECORD EXAMPLE oia ect unie Ee Ie ub enin aed un E 2 PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE LIST OF TABLES TABLE A 1 ASCII Character Codes sees rennen PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE PAGE CHAPTER 1 GENERAL INFORMATION 1 1 INTRODUCTION This is a reference manual for hosted Motorola freeware 8 bit cross assemblers used with IBM PC computers Also it is an introduction for those unfamiliar with Motorola assembler syntax and format It details the features and capabilities of the cross assemblers assembler syntax and directives options and listings The fi
14. M68FCASS AD1 Motorola Freeware PC Compatible 8 Bit Cross Assemblers User s Manual M68FCASS AD1 March 1990 MOTOROLA FREEWARE PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL Motorola reserves the right to make changes without further notice to any products herein to improve reliability function or design Motorola does not assume any liability arising out of the application or use of any product or circuit described herein neither does it convey any license under its patent rights nor the rights of others Motorola products are not authorized for use as components in life support devices or systems intended for surgical implant into the body or intended to support or sustain life Buyer agrees to notify Motorola of any such intended end use whereupon Motorola shall determine availability and suitability of its product or products for the use intended IBM PC is a registered trademark of International Business Machines Corp First Edition Copyright 1990 by Motorola Inc TABLE OF CONTENTS PAGE CHAPTER 1 GENERAL INFORMATION 1 1 INTRODUCTION baina eec eta euet 1 1 1 2 ASSEMBLY LANGUAGE edem ioci edem dalar 1 1 1 3 ASSEMBLER PROCESSING 1 2 CHAPTER 2 ASSEMBLY LANGUAGE PROGRAMS 2 1 INTRODUCTION eret ectetuer sioe de 2 1 2 2 SOURCE STATEMENT FORMAT 2 1 2 2 1 Babel Field 1 eret recle ect cen ca entree 2 1 2 2 2 Operation F
15. MBLERS USER S MANUAL MOTOROLA FREEWARE B 1 B 2 4 Indexed Addressing Indexed addressing is relative to the index register The address is calculated at the time of instruction execution by adding a one byte displacement in the second byte of the instruction to the current contents of the X register Since no sign extension is performed on this one byte displacement the offset cannot be negative Indexed addressing is indicated by the characters X following the expression in the operand field The special case of X without a preceding expression is treated as 0 X B 2 5 Direct and Extended Addressing Direct and extended addressing utilize one direct or two extended bytes to contain the address of the operand Direct addressing is limited to the first 256 bytes of memory Direct and extended addressing are indicated by having an expression only in the operand field Direct addressing will be used by the assembler whenever possible B 3 M6804 68HC04 ADDRESSING MODES The M6804 68HC04 uses the following types of addressing modes Inherent or Accumulator Immediate Relative Direct and Extended Short Direct Bit Set or Clear Bit Test and Branch Register Indirect Move Immediate The registers in the M6804 68HC04 are memory locations and have addresses assigned to them The assembler has predefined locations a A FF b B 80 c C 81 This also means that for the 04 assembler clr x is equivalent to clrx since x is bot
16. WARE 2 9 2 3 ASSEMBLER OUTPUT The assembler output includes an optional listing of the source program and an object file which is in the Motorola S Record format Appendix E The assembler will normally suppress the printing of the source listing but this condition and others can be overridden via options supplied on the command line that invoked the assembler Each line of the listing contains a reference line number the address and bytes assembled and the original source input line If an input line causes more than 6 bytes to be output as in a long FCC directive additional bytes up to 64 are listed on succeeding lines with no address preceding them Optionally the assembly listing may contain a symbol table or a cross reference table of all symbols appearing in the program These are always printed at the end of the assembly listing if either the symbol table or cross reference table options paragraph 4 7 are in effect The symbol table contains the name of each symbol along with its defined value The cross reference table Appendix D also contains the assembler maintained source line number of every reference to every symbol PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE 2 10 CHAPTER 3 RUNNING THE ASSEMBLERS 3 1 INTRODUCTION The Motorola freeware assembly programs for the assembled code are named where is any of 0 1 4 5 9 or 11 depending on the processor family For examp
17. a value of zero an error will be generated PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE 4 5 APPENDIX A CHARACTER SET The character set recognized by the freeware assemblers is a subset of ASCII The ASCII code is shown in Table A 1 The following characters are recognized by the assembler 1 The upper case letters A through Z and lower case letters a through z 2 The digits O through 9 3 Five arithmetic operators and remainder after division 4 Three logical operators amp and 5 The special symbol characters underscore _ period and dollar sign Only the underscore and period may be used as the first character of a symbol 6 The characters used as prefixes for constants and addressing modes Immediate addressing Hexadecimal constant amp Decimal constant Octal constant Binary constant ASCII character constant 7 The characters used as suffixes for constants and addressing modes X Indexed addressing M6809 indexed addressing 5 M6809 indexed addressing U M6809 indexed addressing Y M6809 and M68HC11 indexed addressing PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE A 1 10 11 12 Three separator characters space carriage return and comma The character to indicate comments Comments may contain any printable characters from the ASCII set The special symbol backslash V to indicate line con
18. agraphs B 2 M6800 6801 ADDRESSING MODES The M6800 6801 uses the following types of addressing modes Inherent or Accumulator Immediate Relative Indexed Direct and Extended B 2 1 Inherent or Accumulator Addressing The M6800 includes some instructions which require no operands These instructions are self contained and employ the inherent addressing or the accumulator addressing mode B 2 2 Immediate Addressing Immediate addressing refers to the use of one or two bytes of information that immediately follow the operation code in memory Immediate addressing is indicated by preceding the operand field with the pound sign or number sign character The expression following the will be assigned one or two bytes of storage depending on the instruction B 2 3 Relative Addressing Relative addressing is used by branch instructions Branches can only be executed within the range 126 to 129 bytes relative to the first byte of the branch instruction For this mode the programmer specifies the branch address expression and places it in the operand field The actual branch offset is calculated by the assembler and put into the second byte of the branch instruction The offset is the two s complement of the difference between the location of the byte immediately following the branch instruction and the location of the destination of the branch Branches out of bounds are flagged as errors by the assembler PC COMPATIBLE 8 BIT CROSS ASSE
19. ax For M6809 MPU family devices the following operand formats are used Addressing Mode Accumulator and Inherent Direct Extended or Relative Immediate Indexed Forced Direct Forced Extended Extended Indirect Indexed Forced 8 Bit Offset Indexed Forced 16 Bit Offset Indexed Indexed Indirect Forced 8 Bit Offset Indexed Indirect Forced 16 Bit Offset Indexed Indirect Auto Increment by 1 Auto Increment by 2 Auto Increment Indirect Auto Decrement by 1 Auto Decrement by 2 Auto Decrement Indirect Immediate where R is one of the registers PCR S U X or Y and Q is one of the registers S U X or Y Wi i 1 to n is one of the symbols A B CC D DP PC S U X or Y Details of the M6809 addressing modes are in Appendix B PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE 2 5 2 2 3 5 M68HC11 Operand Syntax For M68HC11 MCU family devices the following operand formats are used Operand Format Addressing Mode no operand Accumulator and Inherent expression Direct Extended or Relative expression Immediate lt expression gt X Indexed with X Register expression Y Indexed with Y Register expression expression Bit Set or Clear expression expression expression Bit Test and Branch The bit manipulation instruction operands are separated by spaces in this case since the HC11 allows bit manipulation instructions on indexed addresses Thus X or Y may be added
20. e set or cleared is indicated by expression 1 gt It must be an absolute expression in the range 0 7 used in generating the operation code The expression 2 part of the operand is handled as a direct address as described Since the bit manipulation address is direct only the first 256 locations may be operated on by bit manipulation operations B 4 7 Bit Test and Branch This combines two addressing modes direct and relative The format of the operand is expression 1 expression 2 expression 3 The expression 1 and expression 2 entries are handled in the same manner as described in paragraph B 4 6 The expression 3 entry is used to generate a relative address as described in paragraph B 4 3 B 5 M6809 ADDRESSING MODES The M6809 uses the following types of addressing modes Inherent or Accumulator Immediate Relative Indexed Direct and Extended B 5 1 Inherent or Accumulator Addressing The M6809 includes some instructions which require no operands These instructions are self contained and employ the inherent or accumulator addressing mode B 5 2 Immediate Addressing Immediate addressing refers to the use of one or two bytes of information that immediately follow the operation code in memory Immediate addressing is indicated by preceding the operand field with the pound sign or number sign for example expression The expression following the will be assigned one or two bytes of storage
21. ecution by adding a one byte displacement to the current contents of the X register The displacement immediately follows the operation code in memory If the displacement is zero zero resides in the byte following the opcode Since no sign extension is performed on a one byte displacement the offset cannot be negative Indexed addressing is indicated by the characters X following the expression in the operand field The special case of X without a preceding expression is treated as 0 X PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE B 11 B 6 6 Direct and Extended Addressing Direct and extended addressing utilize one direct or two extended bytes to contain the address of the operand Direct addressing is limited to the first 256 bytes of memory Direct and extended addressing are indicated by having an expression only in the operand field Direct addressing will be used by the assembler whenever possible B 6 7 Bit s Set or Clear The addressing mode used for this type of instruction is direct although the format of the operand field is different from the direct addressing mode described previously The operand takes the form expression 1 expression 2 where the two expressions are separated by a blank The expression 1 signifies the operand address and may be either a direct or an indexed address When the address mode is indexed expression 1 gt is followed by R where R is either X or Y Th
22. ed For example the first S1 record above is sent as shown below TYPE LENGTH ADDRESS CODE DATA CHECKSUM 0101 0011 10011 0001 0011 0001 0011 0011 0011 0000 10011 0000 0011 10000 0011 10000 0011 0010 10011 11000 0011 0101 10100 0110 0011 10010 0100 0001 PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE E 3 Motorola reserves the right to make changes without further notice to any products herein to improve reliability function or design Motorola does not assume any liability arising out of the application or use of any product or circuit described herein neither does it convey any license under its patent rights nor the rights of others Motorola products are not authorized for use as components in life support devices or Systems intended for surgical implant into the body or intended to support or sustain life Buyer agrees to notify Motorola of any such intended end use whereupon Motorola shall determine availability and suitability of its product or products for the use intended Motorola and M are registered trademarks of Motorola Inc Motorola Inc is an Equal Employment Opportunity Affirmative Action Employer Literature Distribution Centers USA Motorola Literature Distribution P O Box 20912 Phoenix Arizona 85036 EUROPE Motorola Ltd European Literature Center 88 Tanners Drive Blakela
23. edded control characters may produce assembler errors The solution is to convert the source file to ASCII text Each source statement is processed completely before the next source statement is read As each statement is processed the assembler examines the label operation code and operand fields The operation code table is scanned for a match with a known opcode During the processing of a standard operation code mnemonic the standard machine code is inserted into the object file The action called for in an assembler directive occurs during the directive processing Any errors that are detected by the assembler are displayed before the actual line containing the error is printed If no source listing is being produced error messages are still displayed to indicate that the assembly process did not proceed normally PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE 1 2 CHAPTER 2 ASSEMBLY LANGUAGE PROGRAMS 2 1 INTRODUCTION Programs written in assembly language consist of a sequence of source statements Each source statement consists of a sequence of ASCII characters ending with a carriage return Appendix A contains a list of the supported character set 2 2 SOURCE STATEMENT FORMAT Each source statement may include up to four fields a label or for a comment line an operation instruction mnemonic or assembler directive an operand and a comment 2 2 1 Label Field The label field occurs as the f
24. er cases generate a 16 bit offset In the case where an 8 bit offset is generated the value is expanded to 16 bits with sign extension at execution time Regardless of these criteria it is possible to force the assembler to generate an 8 bit offset by preceding the operand with the character Similarly a 16 bit offset can be forced by preceding the operand with the gt character If the relative address calculated is not in the range 128 to 127 or if the expression references a symbol that has not yet been defined a two byte offset is generated after the postbyte A one byte offset is generated if the relative address is in the range 128 to 127 PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE Like the expression offset mode a one byte offset can be forced by preceding the operand with a A gt forces a two byte offset A byte overflow error is generated if a one byte offset is forced when the relative address is not in the range 128 to 127 The extended indirect mode has the form lt expression gt The extended indirect mode is implemented using an encoding of the post byte under the indexed addressing mode although extended indirect is a logical extension of the extended addressing mode A postbyte and a two byte offset which contains the value of the expression is generated B 5 5 Direct and Extended Addressing Direct and extended addressing utilize one direct or two extended byt
25. er gt Numeric constant lt string gt String of ASCII characters lt delimiter gt String delimiter lt option gt Assembler option lt symbol gt Assembler symbol lt sym gt Assembler symbol lt reg list gt M6809 register list lt reg exp gt M6809 register expression In the following descriptions of the various directives the syntax or format of the directive is given first This will be followed with the directive s description PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE 4 1 4 2 BSZ BLOCK STORAGE OF ZEROS label BSZ expression comment The BSZ and ZMB directives cause the assembler to allocate a block of bytes and each byte is assigned the initial value of zero The number of bytes allocated is given by the expression in the operand field If the expression contains symbols that are either undefined or forward referenced the definition occurs later on in the file or if the expression has a value of zero an error will be generated 4 3 EQU EQUATE SYMBOL TO A VALUE label EQU expression comment The EQU directive assigns the value other than the program counter value of the operand field expression to the label The label cannot be redefined anywhere else in the program The expression cannot contain any forward references or undefined symbols Equates with forward references are flagged with Phasing Errors 4 4 FCB FORM CONSTANT BYTE label FCB l
26. es to contain the address of the operand Direct and extended addressing are indicated by having an expression only in the operand field lt expression gt Direct addressing will be used whenever possible Regardless of these criteria it is possible to force the assembler to use the direct addressing mode by preceding the operand with the character Similarly extended addressing can be forced by preceding the operand with the gt character These two operand forms are lt lt expression gt and gt lt expression gt B 6 M68HC11 ADDRESSING MODES The M68HC11 uses the following types of addressing modes Prebyte Inherent or Accumulator Immediate Relative Indexed Direct and Extended Bit s Set or Clear Bit Test and Branch PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE B 10 B 6 1 Prebyte The number of combinations of instructions and addressing modes for the MC68HC11 is larger than that possible to be encoded in an 8 bit word 256 combinations To expand the opcode map certain opcodes 18 1A and CD cause the processor to fetch the next address to find the actual instruction These opcodes are known as prebytes and are inserted automatically by the assembler for those instructions that require it In general the instructions contained in the alternate maps are those involving the Y register or addressing modes that involve the Y index register Thus the programmer makes a tradeoff between t
27. h a register and a memory location The 04 series has separate program and data spaces There is no program memory in the range 10 7F Bytes assembled into that range will go into the data space PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE B 2 B 3 1 Inherent or Accumulator Addressing The M6804 includes some instructions which require no operands These instructions are self contained and employ the inherent addressing or the accumulator addressing mode B 3 2 Immediate Addressing Immediate addressing refers to the use of one byte of information that immediately follows the operation code in memory Immediate addressing is indicated by preceding the operand field with the pound sign or number sign character The expression following the will be assigned one byte of storage B 3 3 Relative Addressing Relative addressing is used by branch instructions Branches can only be executed within the range 15 to 16 bytes relative to the first byte of the branch instruction For this mode the programmer specifies the branch address expression and places it in the operand field The actual branch offset is calculated by the assembler and put into the second byte of the branch instruction The offset is the two s complement of the difference between the location of the byte immediately following the branch instruction and the location of the destination of the branch Branches out of bounds are flagged as errors by t
28. he convenience of using the second index register and the additional time and code space used by the prebyte B 6 2 Inherent or Accumulator Addressing The M68HC11 includes some instructions which require no operands These instructions are self contained and employ the inherent or the accumulator addressing mode B 6 3 Immediate Addressing Immediate addressing refers to the use of one or more bytes of information that immediately follow the operation code in memory Immediate addressing is indicated by preceding the operand field with the pound sign or number sign character The expression following the will be assigned one byte of storage B 6 4 Relative Addressing Relative addressing is used by branch instructions Branches can only be executed within the range 126 to 129 bytes relative to the first byte of the branch instruction For this mode the programmer specifies the branch address expression and places it in the operand field The actual branch offset is calculated by the assembler and put into the second byte of the branch instruction The offset is the two s complement of the difference between the location of the byte immediately following the branch instruction and the location of the destination of the branch Branches out of bounds are flagged as errors by the assembler B 6 5 Indexed Addressing Indexed addressing is relative one of the index registers X or Y The address is calculated at the time of instruction ex
29. he assembler B 3 4 Direct and Extended Addressing Direct and extended addressing utilize bytes to contain the address of the operand Direct addressing is limited to the first 256 bytes of memory Extended addressing concatenates the four least significant bits of the opcode with the byte following the opcode to form a 12 bit address Direct and extended addressing are indicated by having an expression only in the operand field Direct addressing will be used by the assembler whenever possible B 3 5 Short Direct Some opcodes allow four memory locations in data space RAM 80 81 82 and 83 to be referenced as part of the opcode The opcode determines the data space RAM location and the instruction is only one byte The X and Y registers are at locations 80 and 81 respectively An expression used with short direct addressing must not be forward referenced its definition must occur before not after this point in the file and must equate to the range 80 83 B 3 6 Bit Set or Clear In the bit set clear addressing mode the bit to be set or cleared is part of the opcode The byte following the opcode specifies the direct address of the byte which will have the bit set or cleared Any bit in the 256 byte data space memory that can be written with the exception of the data direction registers can be set or cleared with these two byte instructions PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE B 3 B 3 7 Bit
30. ield 5 eeu nti ex etie 2 2 2 2 2 1 OpCOde nenene aent cacao ae 2 2 2 2 2 2 Directive PP 2 2 2 2 3 Opoerantd FIeld J2 excea x ge ed 2 3 2 2 3 1 M6800 6801 Operand Syntax 2 3 2 2 3 2 M6804 68HC04 Operand Syntax 2 4 2 2 3 3 M6805 68HC05 Operand Syntax 2 4 2 2 3 4 M6809 Operand Syntax 2 5 2 2 3 5 M68HC11 Operand Syntax 2 6 2 2 3 6 EXBIeSSIOFIS lt icsciseceteresasstetascncsereusedsvessvecsseeseeease 2 6 2 2 3 7 Operators T 2 7 2 2 3 8 Symbols ccs eee aceto cta coe EE Ree eed 2 7 2 2 3 9 OMS LANES ca eoe robs tla 2 7 2 2 4 Comment Field ea He ERE NER ER een 2 9 2 3 ASSEMBLER OUTPUT 2 10 CHAPTER 3 RUNNING THE ASSEMBLERS 3 1 INTRODUG TION centre codes cede ae ded ue 3 1 3 2 ASSEMBLER INVOCATION 3 1 3 3 ERROR MESSAGES opido puppet 3 3 PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE CHAPTER 4 4 1 4 2 4 3 4 4 4 5 4 6 4 7 4 8 4 9 4 10 4 1 4 12 APPENDIX A APPENDIX B B 1 B 2 B 2 1 B 22 B 2 3 B 2 4 B 2 5 B 3 B 3 1 B 3 2 B 3 3 B 3 4 B 3 5 B 3 6 B 3 7 B 3 8 B 3 9 TABLE OF CONTENTS cont d PAGE ASSEMBLER DIRECTIVES INTRODUCTION oon Bart anak con neues 4 1 BSZ BLOCK STORAGE ZEROS iere ees 4 2 EQU EQUATE SYMBOL TO A VALUE
31. ine instructions PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE 2 2 2 2 3 Operand Field The operand field s interpretation is dependent on the contents of the operation field The operand field if required must follow the operation field and must be preceded by at least one whitespace character The operand field may contain a symbol an expression or a combination of symbols and expressions separated by commas The operand field of machine instructions is used to specify the addressing mode of the instruction as well as the operand of the instruction The following tables summarize the operand field formats for the various processor families NOTE In these tables parenthesis signify optional elements and angle brackets lt gt denote an expression is inserted These syntax elements are present only for clarification of the format and are not inserted as part of the actual source program All other characters are significant and must be used when required 2 2 3 1 M6800 6801 Operand Syntax For M6800 6801 MPU family devices the following operand formats are used Operand Format Addressing Mode no operand Accumulator and Inherent expression Direct Extended or Relative expression Immediate lt expression gt X Indexed Details of the M6800 6801 addressing modes are in Appendix B rrr a OMRMN AKDA PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER
32. irst field of a source statement The label field can take one of the following forms 1 An asterisk as the first character in the label field indicates that the rest of the source statement is a comment Comments are ignored by the assembler and are printed on the source listing only for programming information 2 A whitespace character blank or tab as the first character indicates that the label field is empty The line has no label and is not a comment 3 A symbol character as the first character indicates that the line has a label Symbol characters are the upper or lower case letters a z digits 0 9 and the special characters period dollar sign and underscore _ Symbols consist of one to fifteen characters the first of which must be alphabetic or the special characters period or underscore _ All characters are significant and upper and lower case letters are distinct A symbol may occur only once in the label field If a symbol does occur more than once in a label field then each reference to that symbol will be flagged with an error PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE 2 1 With the exception of some directives a label is assigned the value of the program counter of the first byte of the instruction or data being assembled The value assigned to the label is absolute Optionally labels may be ended with a colon If the colon is used it is not part of the label but mere
33. is allows bit manipulation instructions to operate across the complete 64K address map The expression 2 is the mask byte The bit s to be set or cleared are indicated by ones in the corresponding location s in the mask byte The mask byte must be an expression in the range 0 255 and is encoded by the programmer B 6 8 Bit Test and Branch This combines two addressing modes direct or indexed and relative The format of the operand is expression 1 expression 2 expression 3 where the expressions are separated by blanks The expression 1 gt identifies the operand and may indicate either a direct or indexed address Indexed addresses are signified with R following the expression where R is either X or Y The expression 2 is the mask byte and bit s to be set or cleared are indicated by ones in the corresponding location s in the mask byte The mask byte must be an expression in the range 0 255 and is encoded by the programmer The expression 3 generates a relative address as described in paragraph B 6 4 PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE B 12 APPENDIX C DIRECTIVE SUMMARY A complete description of all directives are provided in Chapter 4 Assembly Control ORG Origin program counter Symbol Definition EQU Assign permanent value Data Definition Storage Allocation BSZ Block storage of zero single bytes FCB Form constant byte FCC Form constant character string
34. lds which comprise an S record are TYPE RECORD LENGTH ADDRESS CODE DATA CHECKSUM The fields are defined as follows Field Characters Contents Type 2 S record type S1 S9 etc Record Length 2 The count of the character pairs in the record length excluding the type and record length Address 4 6 or 8 The 2 3 or 4 byte address at which the data field is to be loaded into memory Code data 0 2n From 0 to n bytes of executable code memory loadable data or descriptive information Checksum 2 The least significant byte of the one s complement of the sum of the values represented by the pairs of characters making up the record length address and the code data fields Each record may be terminated with a CR LF NULL PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE E 1 E 3 S RECORD TYPES Eight types of s records have been defined to accommodate various encoding transportation and decoding needs The freeware assemblers use only two types the S1 and S9 S1 Arecord containing code data and the 2 byte address at which the code data is to reside S9 Atermination record for a block of S1 records The address field may optionally contain the 2 byte address of the instruction to which control is to be passed If not specified the first entry point specification encountered in the object module input will be used There is no code data field E 4 S RECORD EXAMPLE The following is a
35. le to generate M6800 code run the 0 program To generate M68HCO05 code run the as5 exe program and so forth 3 1 ASSEMBLER INVOCATION To run the assembler enter the following command line as file1 file2 option1 option2 where file1 file2 etc are the names of the source files you want to assemble The source filenames may have extensions but the assembler does not check for any particular extension however do not use the S19 extension since that is the extension of the object file created by the assembler Its creation would overwrite the source file when it is written to the disk The options are one or more of the following Enables output listing no Disables output listing default cre Enables the cross reference table generation S Enables the symbol table generation C Enables cycle counting noc Disables cycle counting Use a space before the minus sign preceding the option to separate the option from the last file name These options also may be indicated to the assembler by the use of the OPT directive in the source file The OPT directive is described in paragraph 4 7 PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE 3 1 The object file created is written to disk and given the name FILENAME S 19 where FILENAME is the name of the first source file specified on the command line Any errors and the optional listing if specified are displayed on the screen
36. le ASEMBLER DOC available with the cross assemblers briefly describes the differences between these assemblers and earlier non pc based versions Assemblers are programs that process assembly language source program statements and translate them into executable machine language object files Cross assemblers allow source programs written and edited on one computer the host to generate executable code for another computer the target The executable object file can then be downloaded and run on the target system In this case the host is an IBM PC or compatible and the target system is based on a Motorola 8 bit microprocessor unit MPU and or microcontroller unit MCU family devices i e M6800 6801 6804 68HC04 6805 68HCO5 6809 or 68HC11 These assemblers will run on any IBM PC XT AT PS 2 or true compatible The assemblers may be used with a floppy disk drive or they may be copied onto a hard drive for execution DOS 2 0 or later is required The details of executing the assembler programs are found in Chapter 3 1 2 ASSEMBLY LANGUAGE The symbolic language used to code source programs to be processed by the assembler is called assembly language The language is a collection of mnemonic symbols representing operations machine instruction mnemonics or directives to the assembler symbolic names operators and special symbols The assembly language provides mnemonic operation codes for all machine instructions in the instructio
37. ly acts to set the label off from the rest of the source line Thus the following code fragments are equivalent here deca bne here here deca bne here A label may appear on a line by itself The assembler interprets this as set the value of the label equal to the current value of the program counter The symbol table has room for at least 2000 symbols of length 8 characters or less Additional characters up to 15 are permissible at the expense of decreasing the maximum number of symbols possible in the table 2 2 2 Operation Field The operation field occurs after the label field and must be preceded by at least one whitespace character The operation field must contain a legal opcode mnemonic or an assembler directive Upper case characters in this field are converted to lower case before being checked as a legal mnemonic Thus nop NOP and NoP are recognized as the same mnemonic Entries in the operation field may be one of two types 2 2 2 1 Opcode These correspond directly to the machine instructions The operation code includes any register name associated with the instruction These register names must not be separated from the opcode with any whitespace characters Thus clra means clear accumulator A but clr a means clear memory location identified by the label a 2 2 2 2 Directive These are special operation codes known to the assembler which control the assembly process rather than being translated into mach
38. n set The instructions are defined and explained in the programming reference manuals for the specific devices available from Motorola The assembly language also contains mnemonic directives which specify auxiliary actions to be performed by the assembler These directives are not always translated into machine language A programmer writes a source program in assembly language using any text editor or word processor that can produce an ASCII text output With some word processors this is known as non document mode Non document mode produces a file without the non printable embedded control characters that are used in document formatting Once the source code is written the source file is assembled by processing the file via the assembler PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE 1 1 The assembly language format and syntax for the various processors is very similar with slight variations due to varied programming resources instructions addressing modes and registers These variations are explained in Appendix B 1 3 ASSEMBLER PROCESSING This cross assembler is a two pass assembler During the first pass the source program is read to develop the symbol table During the second pass the object file is created assembled with reference to the table developed in pass one It is during the second pass that the source program listing is also produced NOTE Assembling a file that has been formatted with emb
39. nds Milton Keynes MK14 5BP England ASIA PACIFIC Motorola Semiconductors H K Ltd P O Box 80300 Cheung Sha Wan Post Office Kowloon Hong Kong JAPAN Nippon Motorola Ltd 3 20 1 Minamiazabu Minato ku Tokyo 106 Japan A25637 2 Printed in USA 7 91 BBR 7568 10 000 MCU YGACAA
40. ng the execution of a program Constants may be presented to the assembler in one of five formats decimal hexadecimal binary octal or ASCII The programmer indicates the number format to the assembler with the following prefixes HEX BINARY OCTAL ASCII Unprefixed constants are interpreted as decimal The assembler converts all constants to binary machine code that are displayed in the assembly listing as hexadecimal PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE 2 7 A decimal constant consists of a string of numeric digits The value of a decimal constant must fall in the range 0 65535 inclusive The following example shows both valid and invalid decimal constants Valid Invalid 12 123456 12345 12 3 Reason Invalid more than 5 digits invalid character A hexadecimal constant consists of a maximum of four characters from the set of digits 0 9 and the upper case alphabetic letters A F and is preceded by a dollar sign Hexadecimal constants must be in the range 0000 to FFFF The following example shows both valid and invalid hexadecimal constants Valid Invalid 12 ABCD ABCD G2A 001F 2F018 Reason Invalid no preceding invalid character too many digits A binary constant consists of a maximum of 16 ones or zeros preceded by a percent sign The following example shows both valid and invalid binary constants Valid Invalid 00101 1010101 701 10011000101010111
41. odes Inherent or Accumulator Immediate Relative Indexed Direct and Extended Bit Set or Clear Bit Test and Branch PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE B 4 B 4 1 Inherent or Accumulator Addressing The M6805 includes some instructions which require no operands These instructions are self contained and employ the inherent or accumulator addressing mode B 4 2 Immediate Addressing Immediate addressing refers to the use of one byte of information that immediately follows the operation code in memory Immediate addressing is indicated by preceding the operand field with the pound sign or number sign character The expression following the will be assigned one byte of storage B 4 3 Relative Addressing Relative addressing is used by branch instructions Branches can only be executed within the range 126 to 129 bytes relative to the first byte of the branch instruction For this mode the programmer specifies the branch address expression and places it in the operand field The actual branch offset is calculated by the assembler and put into the second byte of the branch instruction The offset is the two s complement of the difference between the location of the byte immediately following the branch instruction and the location of the destination of the branch Branches out of bounds are flagged as errors by the assembler B 4 4 Indexed Addressing Indexed addressing is relative to the index
42. s calculated by the assembler and put into the operand field of the branch instruction The offset is the two s complement of the difference between the location of the byte immediately following the branch instruction and the location of the destination of the branch B 5 4 Indexed Addressing Indexed addressing is relative to one of the index registers The general form is lt expression gt R The address is calculated at the time of instruction execution by adding the value of expression to the current contents of the index register The other general form is lt expression gt R In this indirect form the address is calculated at the time of instruction execution by first adding the value of expression to the current contents of the index register and then retrieving the two bytes from the calculated address and address 1 This two byte value is used as the effective address of the operand The accumulator offset mode allows one of the accumulators to be specified instead of an expression In the valid forms R refers to one of the index registers S U X or Y Valid forms are lt acc gt R and lt acc gt R where lt acc gt is one of the accumulators A B or D This form generates a one byte operand postbyte only When accumulator A or B is specified sign extension occurs prior to adding the value in the accumulator to the index register PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE B 8
43. ss two but is an indication of a possible problem Error messages are meant to be self explanatory If more than one file is being assembled the file name precedes the error File name Line number Description of error Some errors are classed as fatal and cause an immediate termination of the assembly Generally this happens when a temporary file cannot be created or is lost during assembly PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE 3 3 CHAPTER 4 ASSEMBLER DIRECTIVES 4 1 INTRODUCTION The assembler directives are instructions to the assembler rather than instructions to be directly translated into object code This chapter describes the directives that are recognized by the freeware assemblers and detailed descriptions of each directive are arranged alphabetically The notations used in this chapter are Parentheses denote an optional element XYZ Names of the directives are printed in capital letters lt gt Element names are printed in lower case and contained in angle brackets All elements outside of the angle brackets lt gt must be specified as is For example the syntactical element lt number gt requires the comma to be specified if the optional element number is selected The following elements are used in the subsequent descriptions comment Statement comment field lt label gt Statement label lt expression gt Assembler expression lt expr gt Assembler expression lt numb
44. t gt lt gt lt gt comment The FCB directive may have one or more operands separated by commas The value of each operand is truncated to eight bits and is stored in a single byte of the object program Multiple operands are stored in successive bytes The operand may be a numeric constant a character constant a symbol or an expression If multiple operands are present one or more of them can be null two adjacent commas in which case a single byte of zero will be assigned for that operand An error will occur if the upper eight bits of the evaluated operands values are not all ones or all zeros PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE 4 2 4 5 FCC FORM CONSTANT CHARACTER STRING label FCC lt delimiter gt lt string gt lt delimiter gt lt comment gt The FCC directive is used to store ASCII strings into consecutive bytes of memory The byte storage begins at the current program counter The label is assigned to the first byte in the string Any of the printable ASCII characters can be contained in the string and the string is specified between two identical delimiters which can be any printable ASCII character The first non blank character after the FCC directive is used as the delimiter Example LABEL1 FCC ABC assembles ASCII ABC at location LABEL1 4 6 FDB FORM DOUBLE BYTE CONSTANT lt label gt FDB lt gt lt gt
45. tinuation When the assembler encounters the line continuation character it fetches the next line and adds it to the end of the first line This continues until a line is seen which does not end with a backslash or until the system maximum buffer size has been collected typically greater than or equal to 256 For the M6809 assembler the character preceding an expression to indicate direct addressing mode or 8 bit offset in indexed mode Also the character gt preceding an expression to indicate extended addressing mode or 16 bit offset in indexed mode For the M6809 assembler the characters used to indicate auto increment and auto decrement in the indexed mode PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE A 2 0 1 2 B 3 4 T 5 S 6 7 0 8 t 9 3 B C D E F NUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO SI Table A 1 ASCII Character Codes DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US BITS 4 to 6 PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE gt E 0 m F O Z Zg TU N lt X Z lt C DEL A 3 APPENDIX B ADDRESSING MODES B 1 INTRODUCTION The addressing modes for the M6800 6801 M6804 68HC04 M6805 68HC05 M6809 and M68HC11 microprocessor and or microcontroller units are discussed in the following par
46. to the first expression in the final two formats above to form the indexed effective address calculation Details of the M68HC11 addressing modes are in Appendix B The operand fields of assembler directives are described in Chapter 4 2 2 3 6 Expressions An expression is a combination of symbols constants algebraic operators and parentheses The expression specifies a value which is to be used as an operand Expressions may consist of symbols constants or the character denoting the current value of the program counter joined together by one of the operators amp PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE 2 6 2 2 3 7 Operators The operators are the same as in C programming language add subtract multiply divide remainder after division bitwise and bitwise or bitwise exclusive or gt 50 Expressions are evaluated left to right and there is no provision for parenthesized expressions Arithmetic is carried out in signed twos complement integer precision 16 bits on the IBM PC 2 2 3 8 Symbols Each symbol is associated with a 16 bit integer value which is used in place of the symbol during the expression evaluation The asterisk used in an expression as a symbol represents the current value of the location counter the first byte of a multi byte instruction 2 2 3 9 Constants Constants represent quantities of data that do not vary in value duri
47. two registers must be the same size For the TFR instruction the two registers must be the same size or the first can be a 16 bit register and the second an 8 bit register In the case where the transfer is from a 16 bit register to an 8 bit register the least significant 8 bits are transferred The 8 bit registers are A B CC and DP The 16 bit registers are D PC S U X and Y The one byte immediate value assigned to the operand by the assembler is determined by the register names The most significant four bits of the immediate byte contain the value of the first register name the least significant four bits contain the value of the second register as shown on the following page PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE B 7 Register Value Hexadecimal OOUDUOC UuUu UO WronmnnkRwWn O B 5 3 Relative Addressing Relative addressing is used by branch instructions There are two forms of the branch instruction the short branch and the long branch The short branch can only be executed within the range 126 to 129 bytes relative to the first byte of the branch instruction For this mode the programmer specifies the branch address expression and places it in the operand field The actual branch offset is calculated by the assembler and put into the second byte of the branch instruction The long branch can execute in the full range of addressing from 0000 FFFF hexadecimal because a two byte offset i
48. typical S record module 130000285F245F2212226A000424290008237C2A 1300100002000800082629001853812341001813 13002041E900084E42234300182342000824A952 107003000144ED492 9030000FC 0 The above module consists of four code data records and S9 termination record The first S1 code data record is explained as follows S1 S record type S1 indicating a code data record to be loaded verified at a 2 byte address 13 Hexadecimal 13 decimal 19 indicating 19 character pairs representing 19 bytes of binary data follow 00 Four character 2 byte address field hexadecimal address 0000 indicates location where the following data is to be loaded The next 16 character pairs are the ASCII bytes of the actual program code data 2A Checksum of the first S1 record PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE E 2 The second and third S1 code data records each also contain 13 character pairs and end with checksums The fourth S1 code data record contains 7 character pairs The S9 termination record is explained as follows S9 _ S record type S9 indicating a termination record O3 Hexadecimal 03 indicating three character pairs 3 bytes to follow 0000 Four character 2 byte address field zeroes FC Checksum of S9 record Each printable character in an S record is encoded in hexadecimal ASCII in this example representation of the binary bits which are actually transmitt
49. with the new program counter value If no ORG directive is encountered in a source program the program counter is initialized to zero Expressions cannot contain forward references or undefined symbols PC COMPATIBLE 8 BIT CROSS ASSEMBLERS USER S MANUAL MOTOROLA FREEWARE 4 4 4 10 PAGE TOP OF PAGE PAGE The PAGE directive causes the assembler to advance the paper to the top of the next page If no source listing is being produced the PAGE directive will have no effect The directive is not printed on the source listing 4 11 RMB RESERVE MEMORY BYTES label RMB expression lt comment gt The RMB directive causes the location counter to be advanced by the value of the expression in the operand field This directive reserves a block of memory whose length in bytes is equal to the value of the expression The block of memory reserved is not initialized to any given value The expression cannot contain any forward references or undefined symbols This directive is commonly used to reserve a scratchpad or table area for later use 4 12 ZMB ZERO MEMORY BYTES label ZMB expression lt comment gt The ZMB and BSZ directives cause the assembler to allocate a block of bytes and each byte is assigned the initial value of zero The number of bytes allocated is given by the expression in the operand field If the expression contains symbols that are either undefined or are forward references or if the expression has
50. zed from the command line that invoked the assembler however the options contained in the source file take precedence over any entered on the command line In the following descriptions the parenthetical inserts specify DEFAULT if the option is the default condition All options must be entered in lower case C Enable cycle counting in the listing The total cycle count for that instruction will appear in the listing after the assembled bytes and before the source code cre X Print a cross reference table at the end of the source listing This option if used must be specified before the first symbol in the source program is encountered The cross reference listing format is in Appendix D Print the listing from this point on A description of the listing format is in Appendix D noc DEFAULT Disable cycle counting in the listing If the c option was used previously in the program this option will cause cycle counting to cease until the next OPT c statement nol DEFAULT Do not print the listing from this point on An OPT l can re enable the listing at a later point in the program S Print symbol table at end of the source listing The symbol table format is in Appendix D 4 9 ORG SET PROGRAM COUNTER TO ORIGIN ORG expression comment The ORG directive changes the program counter to the value specified by the expression in the operand field Subsequent statements are assembled into memory locations starting

Download Pdf Manuals

image

Related Search

Related Contents

研究室責任者・坂入正敏准教授 研究室技術職員・鈴木啓太  Samsung DM-Z60 User Manual  一般高圧ガス - 一般社団法人 静岡県高圧ガス保安協会    Instruction Manual RP78K - Support  E4000-SRB (セーフティリレーBOX)  Trust Raina 2.1  Samsung SM-E700H User Manual    Blodgett KLT-20G User's Manual  

Copyright © All rights reserved.
Failed to retrieve file