mirror of
https://github.com/pfusik/xasm.git
synced 2025-01-03 01:30:56 +00:00
767 lines
29 KiB
HTML
767 lines
29 KiB
HTML
<HTML><HEAD><TITLE>X-Assembler 2.3 Manual</TITLE></HEAD>
|
|
<BODY BACKGROUND="6502proc.gif">
|
|
<CENTER>
|
|
<H1>X-Assembler version 2.3</H1>
|
|
by <A HREF="mailto:pfusik@elka.pw.edu.pl">Fox/Taquart</A><P>
|
|
<HR>
|
|
<H2>TABLE OF CONTENTS</H2>
|
|
<TABLE><TR><TD>
|
|
<UL><LI><A HREF="#intro">INTRODUCTION</A>
|
|
<UL><LI><A HREF="#changes">Changes</A>
|
|
<UL><LI><A HREF="#ver23">Version 2.3</A>
|
|
<LI><A HREF="#ver22">Version 2.2</A>
|
|
<LI><A HREF="#ver20">Version 2.0</A>
|
|
<LI><A HREF="#ver12">Version 1.2</A>
|
|
</UL></UL><LI><A HREF="#usage">USAGE</A>
|
|
<UL><LI><A HREF="#sysreq">System requirements</A>
|
|
<LI><A HREF="#srcreq">Source code requirements</A>
|
|
<LI><A HREF="#convqa">Converting Quick Assembler files</A>
|
|
<LI><A HREF="#asm">Assembling a source program</A>
|
|
<LI><A HREF="#opts">Assembling options</A>
|
|
<LI><A HREF="#exitcod">Exit codes</A>
|
|
<LI><A HREF="#listing">Listing structure</A>
|
|
<LI><A HREF="#labtab">Label table structure</A>
|
|
</UL>
|
|
</TD><TD><UL><LI><A HREF="#syntax">SYNTAX</A>
|
|
<UL><LI><A HREF="#fields">Fields</A>
|
|
<UL><LI><A HREF="#label">Label field</A>
|
|
<LI><A HREF="#repeat">Repeat count</A>
|
|
<LI><A HREF="#instr">Instruction field</A>
|
|
<LI><A HREF="#operand">Operand field</A>
|
|
<LI><A HREF="#comment">Comment</A>
|
|
</UL><LI><A HREF="#expr">Expressions</A>
|
|
<UL><LI><A HREF="#numbers">Numbers</A>
|
|
<LI><A HREF="#operators">Operators</A>
|
|
</UL><LI><A HREF="#directives">Directives</A>
|
|
<LI><A HREF="#pseudocom">Pseudo-commands</A>
|
|
<LI><A HREF="#adrmod">Addressing modes</A>
|
|
</UL><LI><A HREF="#faq">FAQ</A>
|
|
</UL>
|
|
</TD></TR></TABLE></CENTER>
|
|
<P><HR>
|
|
<A NAME="intro"><H2>INTRODUCTION</H2>
|
|
The X-Assembler is a cross-assembler generating code for the 6502 processor.
|
|
It has been designed to be easy to use for Quick Assembler programmers,
|
|
therefore its syntax is an extension of QA's one.<BR>
|
|
<A NAME="changes"><H3>Changes</H3>
|
|
<A NAME="ver23"><H4>Version 2.3</H4>
|
|
<UL>
|
|
<LI> double skip (e.g. <TT>SCC:SNE</TT>) bug fixed
|
|
<LI> real number two-digit exponent bug fixed
|
|
<LI> truncating line trailing spaces in listing
|
|
<LI> <A HREF="#new_labdef">label definitions allowed in blank,
|
|
comment and repeated lines</A>
|
|
<LI> <A HREF="#new_unary">unary operators</A>
|
|
<LI> <A HREF="#new_dta"><TT>DTA</TT> implied byte mode</A>
|
|
<LI> <A HREF="#new_op_op">operand can be skipped for some op-codes</A>
|
|
</UL>
|
|
<A NAME="ver22"><H4>Version 2.2</H4>
|
|
<UL>
|
|
<LI> invalid absolute <TT>CPX</TT> and <TT>CPY</TT> op-codes bug fixed
|
|
<LI> branch addressing mode not checking bug fixed
|
|
<LI> <TT>ICL</TT> in last line bug fixed
|
|
<LI> <TT>OPT H-H+</TT> bug fixed
|
|
<LI> first <TT>ORG *</TT> bug fixed
|
|
<LI> origin setting not required until not used
|
|
<LI> Unix ($0a), Macintosh ($0d) and Atari ($9b) EOLs allowed in source
|
|
<LI> value of 'true' changed to 1
|
|
<LI> <A HREF="#new_environment">
|
|
setting environment variables on error option</A>
|
|
<LI> <A HREF="#new_newer">
|
|
assembling only if source newer than object option</A>
|
|
<LI> <A HREF="#new_opcode">op-code extracting</A>
|
|
<LI> <A HREF="#new_linerep">line repeating</A>
|
|
<LI> <A HREF="#new_pairing">instructions pairing</A>
|
|
<LI> <A HREF="#new_repskip">conditional repeat and skip pseudo commands</A>
|
|
<LI> <A HREF="#new_adrmodes">
|
|
<TT>(),0+</TT> and <TT>(),0-</TT> pseudo addressing modes</A>
|
|
</UL>
|
|
<A NAME="ver20"><H4>Version 2.0</H4>
|
|
<UL>
|
|
<LI> truncating name of object bug fixed
|
|
<LI> <TT>EQU</TT> and <TT>DTA</TT> forward reference bugs fixed
|
|
<LI> hex number recognizing bug fixed
|
|
<LI> now <TT>.OBX</TT> is default extension for Atari executables
|
|
<LI> assembling options (switches and <TT>OPT</TT> directive)
|
|
<LI> listing generation
|
|
<LI> label table generation
|
|
<LI> conditional assembling
|
|
<LI> user errors
|
|
<LI> warnings
|
|
<LI> improved headers generation
|
|
<LI> improved expressions - 19 operators and brackets, 32-bit arithmetic
|
|
<LI> improved signed numbers
|
|
<LI> 6 new pseudo commands (memory-to-memory move)
|
|
<LI> 8 pseudo addressing modes
|
|
<LI> indirect conditional jumps
|
|
<LI> Atari floating-point numbers generation
|
|
<LI> improved <TT>INS</TT>: inserting specified part of file
|
|
</UL>
|
|
<A NAME="ver12"><H4>Version 1.2</H4>
|
|
<UL>
|
|
<LI> first release
|
|
</UL>
|
|
|
|
<HR>
|
|
<A NAME="usage"><H2>USAGE</H2>
|
|
<A NAME="sysreq"><H3>System requirements</H3>
|
|
<UL>
|
|
<LI> a PC compatible computer with 386 or better CPU
|
|
(a numeric coprocessor is required for generating sinus tables)
|
|
<LI> a MS-DOS compatible OS
|
|
</UL>
|
|
<A NAME="srcreq"><H3>Source code requirements</H3>
|
|
<UL>
|
|
<LI> Source file should be plain ASCII file.
|
|
Although different EOLs are supported,
|
|
CR/LF is recommended because it is standard for text files on PC.
|
|
<LI> No line of source can be longer than 256 characters.
|
|
<LI> There is no limitation on the length of the source.
|
|
<LI> Tabulators can be used in place of spaces.
|
|
<LI> The assembler is not case-sensitive.
|
|
</UL>
|
|
<A NAME="convqa"><H3>Converting Quick Assembler files</H3>
|
|
Because of possible editor-associated problems you had better convert
|
|
an Atari text file to a regular PC text file, i.e. EOLs from $9b to $0d/$0a
|
|
and ATASCII specific characters to their integer representation.<BR>
|
|
You have to change all <TT>OPT</TT> directives,
|
|
but usually you only need to remove them.<BR>
|
|
<A NAME="asm"><H3>Assembling a source program</H3>
|
|
The common syntax of invoking command line is following:<BR>
|
|
<PRE>XASM source [options]
|
|
</PRE><TT>source</TT> is the name of source file.
|
|
If no extension is given, the .ASX is implied.<P>
|
|
Default action on invoking without options is to compile
|
|
writing to a file with the .OBX extension.<P>
|
|
<A NAME="opts"><H3>Assembling options</H3>
|
|
Following options are supported:
|
|
<DL>
|
|
<DT><TT>/c</TT>
|
|
<DD>Enable listing false conditionals.<BR>
|
|
By default lines skipped due to false condition are not listed.<P>
|
|
<A NAME="new_environment">
|
|
<DT><TT>/e</TT>
|
|
<DD>Enable setting environment variables pointing to the error location.<BR>
|
|
With this option, X-Asm sets two environment variables:
|
|
ERRFILE and ERRLINE.
|
|
They may be used in a batch file to locate error and set editor's
|
|
insertion point on it. For example, in my batch file I use such a construction:
|
|
<PRE>XASM %1 /e
|
|
IF NOT ERRORLEVEL 1 GOTO ok
|
|
NCE +%ERRLINE% %ERRFILE%
|
|
</PRE>
|
|
NCE stands for Norton Classic Editor.<P>
|
|
If there was no error, variables point at last issued warning.
|
|
If no warning occured, they are removed from the environment.<P>
|
|
<DT><TT>/i</TT>
|
|
<DD>Disable listing included source. Only main source file will be listed.<P>
|
|
<DT><TT>/l[:fname]</TT>
|
|
<DD>Enable generating listing.
|
|
If no <TT>fname</TT> given, listing is written to <TT>source.lst.</TT><P>
|
|
<A NAME="new_newer">
|
|
<DT><TT>/n</TT>
|
|
<DD>Check source and object modification times and assemble only
|
|
if source is newer than object file. X-Asm does NOT check included
|
|
nor inserted files but only main source, so be careful with this option.<P>
|
|
<DT><TT>/o:fname</TT>
|
|
<DD>Specify object name. Default is <TT>source.obx</TT>.<P>
|
|
<DT><TT>/s</TT>
|
|
<DD>Disable converting spaces to tabs in listing.
|
|
Using tabs makes listing file shorter.<BR>
|
|
Tab stops are assumed to be every 8 characters.<P>
|
|
<DT><TT>/t[:fname]</TT>
|
|
<DD>List label table.
|
|
If no <TT>fname</TT> given, table is written at the end of listing or to
|
|
<TT>source.tab</TT>.<P>
|
|
</DL>
|
|
If source is incorrect, X-Asm stops on first encountered error.<P>
|
|
<A NAME="exitcod"><H3>Exit codes</H3>
|
|
Meaning of exit codes returned by X-Asm:<BR>
|
|
3 = bad parameters, assembling not started<BR>
|
|
2 = error occured<BR>
|
|
1 = warning(s) only<BR>
|
|
0 = no errors, no warnings<BR>
|
|
<A NAME="listing"><H3>Listing structure</H3>
|
|
Line of listing includes:
|
|
<UL>
|
|
<LI> decimal number of line of source file (if source is different than in
|
|
previous listed line, appropriate message line is issued)
|
|
<LI> hexadecimal origin value
|
|
<LI> hexadecimal bytes written to object file<BR>
|
|
Listed are also generated headers. A <TT>xxxx-yyyy></TT> in place of origin
|
|
represents generated header: <TT>$xxxx</TT> is the first and <TT>$yyyy</TT>
|
|
is the last byte of the block.
|
|
A <TT>FFFF></TT> represents two $ff bytes written as a header prefix.<BR>
|
|
A plus sign placed after hex numbers stands for more bytes written to object
|
|
in this line, not listed through lack of space.
|
|
<LI> remaining part of listing line is a copy of source line
|
|
</UL>
|
|
<A NAME="labtab"><H3>Label table structure</H3>
|
|
Line of label table includes:
|
|
<UL>
|
|
<LI> some label attributes:<BR>
|
|
<TT>n</TT> - label defined but not used elsewhere<BR>
|
|
<TT>2</TT> - label value known in pass 2 only (label definition uses forward
|
|
reference and thus you can't make forward references to that label)
|
|
<LI> hexadecimal value of the label
|
|
<LI> name of the label
|
|
</UL>
|
|
|
|
<HR>
|
|
<A NAME="syntax"><H2>SYNTAX</H2>
|
|
|
|
<A NAME="fields"><H3>Fields</H3>
|
|
Source code is line-oriented. Every line of source consists of <I>fields</I>.
|
|
Same sequence of characters used in different fields has completely different meaning.
|
|
Fields are separated with one or more blank characters.
|
|
There can't be any space within a field excluding strings and comments.<P>
|
|
There are following types of fields:
|
|
<UL>
|
|
<LI> <A HREF="#label">label field</A>
|
|
<LI> <A HREF="#repeat">repeat count</A>
|
|
<LI> <A HREF="#instr">instruction field</A>
|
|
<LI> <A HREF="#operand">operand</A>
|
|
<LI> <A HREF="#comment">comment</A>
|
|
</UL>
|
|
<A NAME="new_labdef">Every line of source must match one of two general forms:
|
|
<UL>
|
|
<LI> <TT>LABEL *COMMENT</TT>
|
|
<LI> <TT>LABEL :COUNT CMD:CMD OP1 OP2 COMMENT</TT>
|
|
</UL>
|
|
In the first form, both fields are optional. Blank lines are ignored of course.
|
|
Comment must here start with one of these characters: <TT>; |</TT> or <TT>*</TT>
|
|
(semicolon, pipe or asterisk). Any information in the line following
|
|
such character is ignored.<P>
|
|
In the latter form, you must use a minimum of an instruction field.
|
|
It depends on the instruction, how many operands it takes.
|
|
Every instruction takes constant number of operands, therefore
|
|
there's no need to use a special character at the start of a comment, because after
|
|
succesfully taking operands, X-Asm discards the remaining part of line.<P>
|
|
|
|
<A NAME="label"><H4>Label field</H4>
|
|
This field is optional. It must start at first character in line, without
|
|
any blank characters before. The purpose of using label field is to define a label.<BR>
|
|
Label is a symbol representing an integer of range -$ffff..$ffff.<BR>
|
|
Name of a label can contain letters, digits and underscores (<TT>_</TT>).
|
|
Digit can not be label's first character.
|
|
Name of a label can be as long as you want and all the characters
|
|
are meaningful. In Quick Assembler only 6 leading characters were recognized
|
|
and some sources may not compile under X-Asm for this reason.<BR>
|
|
Defining a label without using <TT>EQU</TT> makes it equal to current value
|
|
of the origin counter.<BR>
|
|
Label can't be redefined.<P>
|
|
|
|
<A NAME="new_linerep"><A NAME="repeat"><H4>Repeat count</H4>
|
|
Repeating means assembling single line several times as if
|
|
there were several identical lines. Note it is not just duplicating
|
|
bytes written to object.<BR>
|
|
Repeat count, which can be any valid expression, has to be preceded
|
|
with a colon.<BR>
|
|
Examples:
|
|
<PRE>:4 asl @
|
|
:2 dta a(*)
|
|
</PRE>
|
|
In the latter example each <TT>DTA</TT> has different operand value.<BR>
|
|
If repeat count equals zero, remaining part of line is not assembled.
|
|
This allows conditional assembly on single line to be more compact.
|
|
|
|
<A NAME="new_pairing"><A NAME="instr"><H4>Instruction field</H4>
|
|
If this is the first field in a line, the line must start with at least
|
|
one blank character. Instruction field consists of one or two instructions.
|
|
The latter case is called instructions pairing, because a pair
|
|
of instructions have shared operand. You separate instructions
|
|
with a colon.<BR>
|
|
Example:
|
|
<PRE> adc:sta $80
|
|
</PRE>is equivalent to
|
|
<PRE> adc $80
|
|
sta $80
|
|
</PRE>
|
|
Note that
|
|
<PRE> lda:tax $80
|
|
</PRE>is correct, because <TT>$80</TT> is a comment for <TT>TAX</TT>.<P>
|
|
Single instruction always consists of 3 letters. It can be:
|
|
<OL TYPE=a>
|
|
<LI> 6502 command - standard mnemonics are used
|
|
<LI> <A HREF="#directives">directive
|
|
<LI> <A HREF="#pseudocom">pseudo-command
|
|
</OL>
|
|
|
|
<A NAME="operand"><H4>Operand field</H4>
|
|
Some instructions don't need any operand,
|
|
other need two operands.<BR>
|
|
6502 commands require operand with proper
|
|
<A HREF="#adrmod">addressing mode</A>.<P>
|
|
|
|
<A NAME="comment"><H4>Comment</H4>
|
|
Comment in a statement does not start from any special character
|
|
like <TT>;</TT> for example. Comment field is implied when appropriate
|
|
number of operands was taken.<P>
|
|
|
|
<P><HR><P>
|
|
<A NAME="expr"><H3>Expressions</H3>
|
|
Expressions are numbers combined with operators and brackets.
|
|
You should use square brackets, because parentheses are reserved
|
|
for 6502 indirect addressing.
|
|
|
|
<A NAME="numbers"><H4>Numbers</H4>
|
|
Numbers are 32-bit signed integers, in the range of -$7fffffff..$7fffffff.
|
|
A number can be:
|
|
<TABLE>
|
|
<TR><TD WIDTH=300><UL><LI> a decimal number</TD><TD><TT>-12345</TT></TD></TR>
|
|
<TR><TD><UL><LI> a hexadecimal number</TD><TD><TT>$abcd</TT></TD></TR>
|
|
<TR><TD><UL><LI> a binary number</TD><TD><TT>%10100101</TT></TD></TR>
|
|
<TR><TD><UL><LI> an ASCII character</TD><TD><TT>'a'</TT> or <TT>"a"</TT></TD></TR>
|
|
<TR><TD><UL><LI> an origin counter</TD><TD><TT>*</TT></TD></TR>
|
|
<TR><TD><UL><LI> a hardware register</TD><TD><TT>^31</TT></TD></TR>
|
|
</UL></TABLE>
|
|
<DIV STYLE="MARGIN-LEFT: 54">
|
|
An abbreviation of Atari hardware register:<BR>
|
|
<TT>^0x</TT> means <TT>$d00x</TT><BR>
|
|
<TT>^1x</TT> means <TT>$d01x</TT><BR>
|
|
<TT>^2x</TT> means <TT>$d20x</TT><BR>
|
|
<TT>^3x</TT> means <TT>$d30x</TT><BR>
|
|
<TT>^4x</TT> means <TT>$d40x</TT><BR>
|
|
where x is a hexadecimal digit.
|
|
</DIV>
|
|
<A NAME="new_opcode">
|
|
<TABLE>
|
|
<TR><TD WIDTH=300><UL><LI> an op-code</TD><TD><TT>{lda #0}</TT></TD></TR>
|
|
</UL></TABLE>
|
|
<DIV STYLE="MARGIN-LEFT: 54">
|
|
Byte op-code of instruction inside braces. Operand is discarded
|
|
and is necessary only for identifying addressing mode.
|
|
Instruction should begin right after left brace and right brace should
|
|
immediately follow the operand or the command in implied addressing mode.<BR>
|
|
<A NAME="new_op_op">You can skip the operand, if the addressing mode is fixed.
|
|
Examples:<BR>
|
|
<TT>{lda #}</TT>, <TT>{jsr}</TT>, <TT>{bne}</TT>, <TT>{jmp ()}</TT>,
|
|
<TT>{sta a:,x}</TT>.
|
|
</DIV>
|
|
<P>
|
|
|
|
<A NAME="operators"><H4>Operators</H4>
|
|
<I>Binary operators:</I><P>
|
|
<TABLE>
|
|
<TR><TD><TT>+ </TT></TD><TD>Addition</TD></TR>
|
|
<TR><TD><TT>- </TT></TD><TD>Subtraction</TD></TR>
|
|
<TR><TD><TT>* </TT></TD><TD>Multiplication</TD></TR>
|
|
<TR><TD><TT>/ </TT></TD><TD>Division</TD></TR>
|
|
<TR><TD><TT>% </TT></TD><TD>Remainder</TD></TR>
|
|
<TR><TD><TT>& </TT></TD><TD>Bitwise and</TD></TR>
|
|
<TR><TD><TT>| </TT></TD><TD>Bitwise or</TD></TR>
|
|
<TR><TD><TT>^ </TT></TD><TD>Bitwise xor</TD></TR>
|
|
<TR><TD><TT><< </TT></TD><TD>Arithmetic shift left</TD></TR>
|
|
<TR><TD><TT>>> </TT></TD><TD>Arithmetic shift right</TD></TR>
|
|
<TR><TD><TT>= </TT></TD><TD>Equal</TD></TR>
|
|
<TR><TD><TT><> </TT></TD><TD>Not equal</TD></TR>
|
|
<TR><TD><TT>!= </TT></TD><TD>Not equal (same as <TT><></TT>)</TD></TR>
|
|
<TR><TD><TT>< </TT></TD><TD>Less than</TD></TR>
|
|
<TR><TD><TT>> </TT></TD><TD>Greater than</TD></TR>
|
|
<TR><TD><TT><= </TT></TD><TD>Less or equal</TD></TR>
|
|
<TR><TD><TT>>= </TT></TD><TD>Greater or equal</TD></TR>
|
|
<TR><TD><TT>&& </TT></TD><TD>Logical and</TD></TR>
|
|
<TR><TD><TT>|| </TT></TD><TD>Logical or</TD></TR>
|
|
</TABLE><P>
|
|
<A NAME="new_unary">
|
|
<I>Unary operators:</I><P>
|
|
<TABLE>
|
|
<TR><TD><TT>+</TT></TD><TD>Plus (does nothing)</TD></TR>
|
|
<TR><TD><TT>-</TT></TD><TD>Minus (changes sign)</TD></TR>
|
|
<TR><TD><TT>~</TT></TD><TD>Bitwise not (complements all bits)</TD></TR>
|
|
<TR><TD><TT>!</TT></TD><TD>Logical not (changes true to false and vice versa)</TD></TR>
|
|
<TR><TD><TT><</TT></TD><TD>Low (extracts low byte)</TD></TR>
|
|
<TR><TD><TT>></TT></TD><TD>High (extracts high byte)</TD></TR>
|
|
</TABLE><P>
|
|
<I>Operator precedence:</I><P>
|
|
<TABLE>
|
|
<TR><TD>first</TD><TD><TT>[]</TT><TD>(brackets)</TD></TR>
|
|
<TR><TD> </TD><TD><TT>+ - ~ < ></TT><TD>(unary)</TD></TR>
|
|
<TR><TD> </TD><TD><TT>* / % & << >></TT><TD>(binary)</TD></TR>
|
|
<TR><TD> </TD><TD><TT>+ - | ^</TT><TD>(binary)</TD></TR>
|
|
<TR><TD> </TD><TD><TT>= <> != < > <= >=</TT><TD>(binary)</TD></TR>
|
|
<TR><TD> </TD><TD><TT>!</TT><TD>(unary)</TD></TR>
|
|
<TR><TD> </TD><TD><TT>&&</TT><TD>(binary)</TD></TR>
|
|
<TR><TD>last </TD><TD><TT>||</TT><TD>(binary)</TD></TR>
|
|
</TABLE><P>
|
|
Operators are similar to used in C language, but their priorities are different
|
|
than in C.<P>
|
|
Compare and logical operators assume that zero is false and non-zero is true.
|
|
They return 1 for true.<P>
|
|
While calculating expression, signed 32-bit arithmetic is used. When range of 32 bits
|
|
is exceeded, <TT>'Arithmetic overflow'</TT> error is generated.<P>
|
|
|
|
<P><HR><P>
|
|
<A NAME="directives"><H3>Directives</H3>
|
|
<DL>
|
|
<DT><TT><B>EQU</B></TT> - assign a value of an expression to the label
|
|
<DD>Note that label represents a number, not a text macro.<BR>
|
|
Examples:
|
|
<PRE>five equ 5
|
|
here equ *
|
|
</PRE>
|
|
|
|
<DT><TT><B>OPT</B></TT> - set assembling options
|
|
<DD>Currently there are two options: generating listing and generating headers.
|
|
You can turn any of these on or off.<BR>
|
|
Default (if no <TT>OPT</TT> specified) is <TT>opt l+h+</TT>.<BR>
|
|
Examples:
|
|
<PRE> opt l- listing off
|
|
opt h- headers off
|
|
opt l+h- listing on, headers off
|
|
</PRE>
|
|
|
|
<DT><TT><B>ORG</B></TT> - set new origin counter
|
|
<DD>You can set some options applied to new header (if headers are on):
|
|
<UL>
|
|
<LI><TT>a:</TT> tells X-Asm to always make a header, even it is unnecessary,
|
|
like in <TT>ORG *</TT>.
|
|
<LI><TT>f:</TT> works same as <TT>a:</TT>, but additionally tells to generate
|
|
a $ff,$ff prefix before header. X-Asm adds it at the beginning of file
|
|
by default, so use this option only if you want the $ff's somewhere inside.<BR>
|
|
</UL>
|
|
Examples:
|
|
<PRE> org $600
|
|
org f:$700
|
|
table org *+100
|
|
</PRE>
|
|
In the latter example <TT>table</TT> points to 100 bytes
|
|
of uninitialized data (label is assigned to <TT>*</TT>
|
|
before <TT>ORG</TT> directive is executed).<P>
|
|
|
|
<A NAME="new_dta">
|
|
<DT><TT><B>DTA</B></TT> - define data
|
|
<DD>There are various data types:
|
|
<UL>
|
|
<LI> integers
|
|
<UL>
|
|
<LI> bytes: <TT>b(200)</TT> or simply <TT>200</TT>
|
|
<LI> words: <TT>a(10000)</TT>
|
|
<LI> low bytes of words: <TT>l(511)</TT> defines byte 255
|
|
<LI> high bytes of words: <TT>h(511)</TT> defines byte 1
|
|
</UL>
|
|
You may enter many expressions in parentheses and combine different types
|
|
of data in single line, separating things with commas.<BR>
|
|
You may also define a sinus table. Syntax is:<BR>
|
|
<TT>sin(centre,amp,size,first,last)</TT><BR>
|
|
where:
|
|
<UL>
|
|
<LI> <TT>centre</TT> is a number which is added to every sinus value
|
|
<LI> <TT>amp</TT> is the amplitude of sinus
|
|
<LI> <TT>size</TT> is the period of sinus
|
|
<LI> <TT>first,last</TT> define range of values in the table.
|
|
They are optional. Default are <TT>0,size-1</TT>.
|
|
</UL>
|
|
Example: <TT>dta a(sin(0,1000,256,0,63))</TT> defines table of 64 words
|
|
representing a quarter of sinus with amplitude of 1000.<P>
|
|
<LI> real numbers: <TT>r(-1.23456e12)</TT><BR>
|
|
Real numbers are written in 6-byte Atari Floating-Point format. You can't
|
|
combine reals with operators, as you can integers.<P>
|
|
<LI> text strings
|
|
<UL>
|
|
<LI> ASCII strings: <TT>c'Text'</TT> or <TT>c"Text"</TT>
|
|
<LI> ANTIC strings: <TT>d'Text'</TT> or <TT>d"Text"</TT>
|
|
</UL>
|
|
A character string consists of any of characters surrounded by quotation
|
|
marks. Within a string, a single quotation mark character is
|
|
represented by two succesive quotation marks.<BR>
|
|
Placing a <TT>*</TT> character after a string inverts
|
|
high bit in every byte of string.<P>
|
|
</UL>
|
|
Examples of <TT>DTA</TT>:
|
|
<PRE>
|
|
dta b(1,2),3,a(1000,-1),l(12345,sin(0,127,256))
|
|
dta d"ANTIC"*,c'It''s a string',$9b
|
|
</PRE>
|
|
|
|
<DT><TT><B>ICL</B></TT> - include another source file
|
|
<DD>Specifies another file to be included in the assembly as if the contents of
|
|
the referenced file appeared in place of the <TT>ICL</TT> statement.
|
|
The included file may contain other <TT>ICL</TT> statements.
|
|
The <TT>.ASX</TT> extension is added if none given.<P>
|
|
Examples:
|
|
<PRE>
|
|
icl 'macros.asx'
|
|
icl 'c:\atari\xasm\fileio'
|
|
</PRE>
|
|
|
|
<DT><TT><B>END</B></TT> - end assembling file
|
|
<DD>Remaining part of the file is not assembled. If this statement does
|
|
not occur, assembler stops assembling when encounters end of file.<BR>
|
|
Example:
|
|
<PRE>
|
|
end
|
|
</PRE>
|
|
|
|
<DT><TT><B>INS</B></TT> - insert contents of file
|
|
<DD>Copies every byte of specified file into object file and moves origin
|
|
counter, as if these bytes were defined with <TT>DTA</TT>.<BR>
|
|
You may specify range of inserted file. Syntax is following:
|
|
<PRE>
|
|
ins 'file'[,offset[,length]]
|
|
</PRE>
|
|
First byte in file has offset 0.<BR>
|
|
If offset is negative, it is counted from the end of file.<BR>
|
|
Examples:
|
|
<PRE>
|
|
ins 'picture.raw'
|
|
ins 'file',-256 insert last 256 bytes of file
|
|
ins 'file',10,10 insert bytes 10..19 of file
|
|
</PRE>
|
|
|
|
<DT><TT><B>RUN</B></TT> - generate run address
|
|
<DD>The Atari executable program should have run address specified.
|
|
A program may be loaded in many areas of memory and started from any address.
|
|
<PRE> run addr
|
|
</PRE>
|
|
is equivalent to:
|
|
<PRE> org $2e0
|
|
dta a(addr)
|
|
</PRE>
|
|
Examples:
|
|
<PRE> run start
|
|
run program
|
|
</PRE>
|
|
|
|
<DT><TT><B>INI</B></TT> - generate init address
|
|
<DD>The Atari executable program may have some routines which are executed
|
|
during loading process. There may be many init blocks in one file.<BR>
|
|
Examples:
|
|
<PRE> ini init
|
|
ini showpic
|
|
</PRE>
|
|
|
|
<DT><TT><B>ERT</B></TT> - generate error if expression is true
|
|
<DD>Examples:
|
|
<PRE> ert *>$c000
|
|
ert len1>$ff||len2>$ff
|
|
</PRE>
|
|
|
|
<DT><TT><B>IFT</B></TT> - assemble if expression is true<BR>
|
|
<TT><B>ELS</B></TT> - else<BR>
|
|
<TT><B>EIF</B></TT> - end if<BR>
|
|
<DD>With these directives you can construct fragments which
|
|
are assembled when a condition is met.
|
|
Conditional constructions can be nested.<BR>
|
|
Example:
|
|
<PRE>noscr equ 1
|
|
ift noscr
|
|
lda #0
|
|
els
|
|
lda #$22
|
|
eif
|
|
sta $22f
|
|
</PRE>
|
|
Above example can be rewritten using line repeating feature:
|
|
<PRE>noscr equ 1
|
|
:noscr lda #0
|
|
:!noscr lda #$22
|
|
sta $22f
|
|
</PRE>
|
|
|
|
</DL>
|
|
<HR>
|
|
<A NAME="pseudocom"><H3>Pseudo-commands</H3>
|
|
Pseudo-commands are built-in macros.
|
|
They are not illegal instructions and work on typical 6502.<P>
|
|
<DL>
|
|
<DT><TT><B>ADD</B></TT> - addition without carry
|
|
<DD>If you have ever programmed 6502, you must have noticed that you had
|
|
to use a <TT>CLC</TT> before <TT>ADC</TT> for every simple addition.<BR>
|
|
X-Asm can do it for you. <TT>ADD</TT> replaces two instructions:
|
|
<TT>CLC</TT> and <TT>ADC</TT>.<P>
|
|
|
|
<DT><TT><B>SUB</B></TT> - subtraction
|
|
<DD>It is <TT>SEC</TT> and <TT>SBC</TT>.<P>
|
|
|
|
<A NAME="new_repskip">
|
|
<DT><TT><B>RCC, RCS, REQ, RMI, RNE, RPL, RVC, RVS</B></TT> - conditional repeat
|
|
<DD>These are branches to the previous instruction.
|
|
They take no operand, because the branch target
|
|
is the address of previously assembled instruction.<BR>
|
|
Example:
|
|
<PRE> ldx #0
|
|
mva:rne $500,x $600,x+
|
|
</PRE>
|
|
The example code copies memory $500-$5ff to $600-$6ff.
|
|
Here is the same written with standard 6502 commands only:
|
|
<PRE> ldx #0
|
|
loop lda $500,x
|
|
sta $600,x
|
|
inx
|
|
bne loop
|
|
</PRE>
|
|
|
|
<DT><TT><B>SCC, SCS, SEQ, SMI, SNE, SPL, SVC, SVS</B></TT> - conditional skip
|
|
<DD>These are branches over the next instructions. No operand is required,
|
|
because the target is the address of instruction following
|
|
the next instruction.<BR>
|
|
Example:
|
|
<PRE> lda #40
|
|
add:sta $80
|
|
scc:inc $81
|
|
</PRE>
|
|
In the above example word-sized variable $80 is incremented by 40.<BR>
|
|
Nor conditional repeat nor skip pseudo-commands require operand,
|
|
thus they can be paired with any other command.<P>
|
|
|
|
<DT><TT><B>JCC, JCS, JEQ, JMI, JNE, JPL, JVC, JVS</B></TT> - conditional jumps
|
|
<DD>They are a kind of 'long' branches. While standard branches
|
|
(<TT>BNE, BEQ</TT>) have range of -128..+127, these jumps have range
|
|
of all 64 kB.<BR>
|
|
Example:
|
|
<PRE> jne dest
|
|
</PRE>is equivalent to:
|
|
<PRE> seq:jmp dest
|
|
</PRE>
|
|
|
|
<DT><TT><B>INW</B></TT> - increment word
|
|
<DD>It is a 16-bit memory increment command.<BR>
|
|
Example:
|
|
<PRE> inw dest
|
|
</PRE>is equivalent to:
|
|
<PRE> inc dest
|
|
sne:inc dest+1
|
|
</PRE>
|
|
|
|
<DT><TT><B>MVA, MVX, MVY</B></TT> - move byte using accumulator, X or Y
|
|
<DD>Each of these pseudo-commands requires two operands
|
|
and substitutes two commands:
|
|
<PRE> mva source dest = lda source : sta dest
|
|
mvx source dest = ldx source : stx dest
|
|
mvy source dest = ldy source : sty dest
|
|
</PRE>
|
|
|
|
<DT><TT><B>MWA, MWX, MWY</B></TT> - move word using accumulator, X or Y
|
|
<DD>These pseudo-commands require two operands
|
|
and are combinations of two <TT>MV*</TT>'s:
|
|
one to move low byte, and the other to move high byte.<BR>
|
|
You can't use indirect nor pseudo addressing mode with <TT>MW*</TT>.
|
|
Destination must be absolute address (optionally indexed).<BR>
|
|
When source is also absolute, a <TT>MW* SOURCE DEST</TT> will be:
|
|
<PRE> mv* source dest
|
|
mv* source+1 dest+1
|
|
</PRE>
|
|
When source is an immediate, a <TT>MW* #IMMED DEST</TT> will be:
|
|
<PRE> mv* <immed dest
|
|
mv* >immed dest+1
|
|
</PRE>
|
|
When <TT><immed</TT> equals <TT>>immed</TT> and <TT>immed</TT>
|
|
is not forward-referenced, X-Asm uses optimization:
|
|
<PRE> mv* <immed dest
|
|
st* dest+1
|
|
</PRE>
|
|
</DL>
|
|
</OL>
|
|
|
|
<HR>
|
|
<A NAME="adrmod"><H3>Addressing modes</H3>
|
|
All addressing modes are entered in standard convention except
|
|
the accumulator addressing mode, which should be marked with a
|
|
<TT>@</TT> character (as in Quick Assembler).<P>
|
|
|
|
There are two extra immediate addressing modes:
|
|
<TT><</TT> and <TT>></TT>,
|
|
which use low/high byte of word rather than byte value.
|
|
They are for Quick Assembler compatibility.
|
|
You can use traditional <TT>#<</TT> and <TT>#></TT>.
|
|
Note <NOBR><TT>lda >$ff+5</TT></NOBR> loads 1 (<TT>>$104</TT>),
|
|
while <NOBR><TT>lda #>$ff+5</TT></NOBR>
|
|
loads 5 (<TT>0+5</TT>) to accumulator, because unary operator <TT>></TT> has higher
|
|
priority than plus has.<P>
|
|
|
|
In absolute addressing modes, X-Asm examines expression and uses zero-page
|
|
addressing mode if it supposes it is possible. You may override it with
|
|
<TT>a:</TT> and <TT>z:</TT> prefixes.<P>
|
|
|
|
Examples:
|
|
<PRE>
|
|
nop
|
|
asl @
|
|
lda >$1234 assembles to lda #$12
|
|
lda $100,x
|
|
lda a:0 generates 16-bit address
|
|
jmp ($0a)
|
|
lda ($80),y
|
|
</PRE>
|
|
|
|
There are also pseudo addressing modes, which are similar to
|
|
pseudo-commands. You may use them just like standard addressing modes
|
|
in all 6502 commands and pseudo-commands excluding
|
|
<TT>MWA</TT>, <TT>MWX</TT> and <TT>MWY</TT> only:
|
|
<PRE> cmd a,x+ = cmd a,x : inx
|
|
cmd a,x- = cmd a,x : dex
|
|
cmd a,y+ = cmd a,y : iny
|
|
cmd a,y- = cmd a,y : dey
|
|
cmd (z),y+ = cmd (z),y : iny
|
|
cmd (z),y- = cmd (z),y : dey
|
|
cmd (z,0) = ldx #0 : cmd (z,x)
|
|
cmd (z),0 = ldy #0 : cmd (z),y
|
|
<A NAME="new_adrmodes"> cmd (z),0+ = ldy #0 : cmd (z),y : iny
|
|
cmd (z),0- = ldy #0 : cmd (z),y : dey
|
|
</PRE>
|
|
|
|
<HR>
|
|
<A NAME="faq"><H2>FAQ</H2>
|
|
<UL>
|
|
<LI><B>Q:</B> Why does X-Asm ignore <TT>+2</TT> in following line?
|
|
<PRE>label equ 1 +2
|
|
</PRE>
|
|
<B>A:</B> X-Asm treats space as operand terminator. Remaining part of line
|
|
is a comment. You should write <TT>1+2</TT> without any spaces.<P>
|
|
|
|
<LI><B>Q:</B> Why does <TT>lda >$abcd</TT> assemble to
|
|
<TT>lda #$ab</TT>?<P>
|
|
<B>A:</B> <TT><</TT> and <TT>></TT> are not only 'low' and 'high'
|
|
operators, but also 'low of immediate' and 'high of immediate'
|
|
addressing modes indicators.
|
|
In order to get <TT>lda $ab</TT>, write <TT>lda +>$abcd</TT><P>
|
|
|
|
<LI><B>Q:</B> What's wrong with <TT>asl a</TT> ?<P>
|
|
<B>A:</B> You should use <TT>@</TT> for accumulator addressing mode.<P>
|
|
|
|
<LI><B>Q:</B> What's wrong in following line?
|
|
<PRE>label: lda #0
|
|
</PRE>
|
|
<B>A:</B> Label definition can not include a colon.<P>
|
|
|
|
<LI><B>Q:</B> I wrote <TT>end start</TT>, where <TT>start</TT> points
|
|
to program beginning, but program seems not to start there. Why?<P>
|
|
<B>A:</B> You should have explicit run address specified.
|
|
Use <TT>run start</TT> directive. <TT>end</TT> takes no operand.<P>
|
|
|
|
<LI><B>Q:</B> Why this construction does not work:
|
|
<PRE>three equ one+two
|
|
two equ one+one
|
|
one equ 1
|
|
</PRE>
|
|
while this does:
|
|
<PRE>
|
|
two equ one+one
|
|
one equ 1
|
|
</PRE>
|
|
<B>A:</B> X-Asm reads source twice (in pass 1 and pass 2)
|
|
from the beginning until the end.<BR>
|
|
This allows forward references, but not too complex.<BR>
|
|
Keep in mind that assembler should know all the values in second pass.<P>
|
|
Example:
|
|
<PRE>two equ one+one This value is known in 2nd pass only
|
|
one equ 1 This value is known as early as in 1st pass
|
|
</PRE>
|
|
These values can be fixed in two passes.<BR>
|
|
If you insert following statement as first line:
|
|
<PRE>three equ one+two
|
|
</PRE>
|
|
X-Asm will generate an error because it can't fix
|
|
the value of <TT>three</TT> in second pass.<P>
|
|
|
|
<LI><B>Q:</B> X-Asm displayed single error while assembling my program.
|
|
When I fixed it, another error appeared. Why?<P>
|
|
<B>A:</B> X-Asm displays only first error.<BR>
|
|
When you were assembling for the first time, both errors might exist,
|
|
but X-Asm stopped on the first one.<P>
|
|
|
|
<LI> If you have other questions/problems,
|
|
<A HREF=mailto:pfusik@elka.pw.edu.pl>write to me</A>.
|
|
</UL>
|
|
</BODY></HTML> |