XASM Cross Assemblers Users Guide Release 2.51 Revised 16-Feb-99 Dunfield Development Systems ---------------------------- High quality tools for Embedded Development at low prices. http://www.dunfield.com Copyright 1983-2005 Dave Dunfield All rights reserved XASM Cross Assemblers TABLE OF CONTENTS Page 1. INTRODUCTION 1 2. ASSEMBLER 2 2.1 Using the assemblers 2 2.2 Redirecting the listing file 4 2.3 Source file format 5 2.4 Expressions 5 2.5 Addressing Modes 7 2.6 Assembler directives 9 2.7 Error Messages 12 2.8 Error message summary 13 2.9 Additional notes on ASM86 15 3. MACRO PREPROCESSOR 16 3.1 Substitution macros 16 3.2 Instruction macros 17 3.3 Macro directives 18 3.4 Source File Synchronization 21 4. APPENDICES 22 4.1 Object file formats 22 4.2 ASCII code chart 23 XASM Cross Assemblers Page: 1 1. INTRODUCTION This package contains one or more of the DDS XASM cross assemblers, and related utility programs. DDS XASM is a series of cross assemblers for a number of popular microprocessor families: asm00 - Motorola 6800/02 family asm01 - Motorola 6801/6803 family asm02 - Mostek/Synertek 6502 family asm05 - Motorola 6805 family asm08 - Motorola 68HC08 family asm09 - Motorola 6809 family asm11 - Motorola 68HC11 family asm12 - Motorola 68HC12 family asm16 - Motorola 68HC16 family asm320 - Dallas 80C320/520 family asm48 - Intel 8048 family asm51 - Intel 8051/52 family asm85 - Intel 8080/8085 family asm86 - Intel 8086 family asm186 - Intel 80186 family asm96 - Intel 8096 family asmAVR - Atmel AVR family asmH8 - Hitachi H8/300 family asmP5X - Microchip PIC-16C5x family asmST7 - St Microelectronics ST-7 family asmZ80 - Zilog Z80 family asmZ8 - Zilog Z8 family asmCF - DDS C-FLEA Virtual Machine macro - Macro pre-processor hexfmt - HEX file manipulator cref - Cross reference utility psource - Porting source generator retab - Source file (re)tabulator int2xasm - Convert "Intel" style source to XASM style xasm2int - Convert XASM style source in "Intel" style Dunfield Development Systems offers complete low cost C and Assembly language development packages for many different 8 and 16 bit embedded processors, as well as other related development software tools. For more information, please contact: Dunfield Development Systems 115 Manion Heights Cres. RR#2 Carp, Ontario Canada K0A 1L0 http://wwww.dunfield.com FAX: 613-256-5821 XASM is provided on an "as is" basis, with no warranty of any kind. In no event shall the author be liable for any damages arising from its use or distribution. Throughout this document, angle braces ('<>') are used to indicate operands for which a value must be supplied by the user. Square braces ('[]') are used to identify operands which are optional. XASM Cross Assemblers Page: 2 2. ASSEMBLER XASM cross assemblers read a source file (.ASM), and produce a code file (.HEX) containing either MOTOROLA or INTEL format ASCII-HEX download records. A optional listing file (.LST) may also be produced. 2.1 Using the assemblers An assembler is invoked by entering its name at the command prompt, in the following format: ASMxx [options] The operand is the name of the file to be assembled, it is assumed to have the extension ".ASM" if none is supplied. Unless otherwise specified, the code produced by the assembler is written to a file with the name '.HEX', and the listing is written to a file with the name '.LST'. 2.1.1 Command line options The following options may be specified on the command line, following the operand: -A - [A]lternate jumps/calls (51,320,AVR) Causes 8051 family assemblers to use AJMP/ACALL instructions in place of LJMP/LCALL. Causes the AVR assembler to use RJMP/RCALL in place of JMP/CALL when an explicit page number is not supplied. -C - [C]ase sensitive Causes the assembler to make a distinction between upper and lower case characters in symbol names. If this option is not used, the assembler will ignore case differences, and assume that the symbols are the same. NOTE: When using this option, you must enter any register names in UPPER case. C= - Specify [C]ode file This option allows you to specify the file to which the output code is written. If no extension is supplied as part of , it defaults to ".HEX". -F - Generate [F]ull listing Causes the assembler to output a full source listing to the '.LST' file. By default, only lines containing errors are written to the listing file. XASM Cross Assemblers Page: 3 -I - Generate [I]ntel format HEX file Causes the assembler to output the code to the '.HEX' file in INTEL hex format. By default the code is written to the file in MOTOROLA hex format. L= - Specify [L]isting file This option allows you to specify the file to which the listing is written. If no extension is supplied as part of , it defaults to ".LST". O= - [O]ptimization (00,01,02,05,08,09,11,12,16,96) This option allows you to set a limit to the maximum number of optimization passes which the assembler will perform while attempting to minimize code size and resolve forward referenced symbols. If a symbol can not be resolved within this many passes, the assembler will terminate with an error message. You may specify between 0 and 127 optimization passes to be run, with 0 being a special case in which no optimization is performed. Without optimization, all non-specified memory references and offsets default to their largest form, and forward references in EQU, ORG, or RMB statements will not work. The code generated will not be optimal, but assembly time is reduced. This feature is most useful when initially testing and debugging a program. The default maximum number of optimization passes is 3. NOTE: The assemblers which do not support the 'O=' option do not permit forward references in EQU, ORG or RMB. P= - Set page length This option specifies the number of lines which will be printed on each page. The default number of lines per page is 60. -Q - [Q]uiet mode Causes the assembler to be quiet, inhibiting the display of the progress messages. -S - Generate [S]ymbol table Causes the assembler to sort and display the symbol table at the end of the listing file. By default, the symbol table is not displayed. -T - Output to [T]erminal Causes the assembler to output the listing to the terminal, (via stdout) instead of the usual '.LST' file. XASM Cross Assemblers Page: 4 -W - Wrap relative addresses (AVR) Causes the AVR assembler to allow RJMP/RCALL to "wrap", making the entire 1st 8K available. This option should only be used with CPU's that perform this wrapping (ie: those with only 8K of code memory, and which do not support JMP/CALL). W= - Set page width This option control the number of columns which will be used for the printing of page titles and the symbol table listing. Default page width is 80 columns. -X - Translate eXternal reads (51,320) Causes 8051 family assemblers to translate all occurrences of "MOVX A,[DPTR]" into "CLR A / MOVC A,[A+DPTR]", for use in systems with simplified memory decoding logic. 2.2 Redirecting the listing file When the listing file is directed to the terminal with the '-t' option on the command line, it is displayed through the standard output file, allowing it to be redirected to a printer etc. via the shell '>' redirection operator (EG: ASMxx filename -f -t >LPT1:). The progress messages ('First pass...' etc) are output through stderr, and will therefore not be redirected with the listing. NOTE that the listing may be more efficiently redirected with the 'L=' option. XASM Cross Assemblers Page: 5 2.3 Source file format NOTE: All XASM assemblers follow a consistent generic syntax, which is as close as possible to that published by the majority of CPU makers. In a few cases, this differs significantly from a unique syntax published for a specific CPU or vendor. Please read this section carefully, and refer to the EXAMPLE PROGRAMS to become familiar with the XASM syntax. The assembly source input lines are in the following format: '