Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > 4ecb8e17318c451395e48730497a4da8 > files > 8

64tass-1.50.486-1.fc18.i686.rpm

<!DOCTYPE HTML>
<html lang="en">
<head>
<title>64tass v1.5x manual</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Description" content="64tass, an advanced multi pass macro assembler for the 65xx family of microprocessors">
<meta name="Keywords" content="6502 assembler, 65816, 6510, 65C02, dtv, c64 cross assembler">
<meta name="Author" content="Kajtar Zsolt">
<style>
dt {margin-top:0.5em}
dt + dt {margin-top:0em}
body {width:50em;font-size:12pt;}
h1, h2, h3, h4 {font-family:sans}
hr {display:none}
pre {border:1px dotted #eee;background-color:#ffe;padding:2px; border-radius: 4px;}
pre.make b {color:inherit;}
pre.make span {color:navy;}
pre.make span.cmd {color:green;}
pre b {color:navy;}
pre b.d {color:#f80;}
pre b.k, pre span.k, code span.k {color:blue;}
pre span, code span {color:#d00;}
pre span.s, code span.s {color:#f80;}
pre i {color:brown;}
pre u, code u {text-decoration:none;color:green;}
p, dd {text-align:justify;word-break:hypenate;}
p + p {text-indent:3ex;margin-top:-0.5em}
table {border-bottom:2px solid black;border-top:2px solid black;border-collapse:collapse;width:100%;margin-top:0.5em;margin-bottom:0.5em; border-spacing: 0px;}
td, th {padding: 0px 1ex 0px 1ex;border-left:1px solid silver;border-top:1px solid silver}
tr:nth-child(odd) {background: #fafaff;}
td:first-child, th:first-child {border-left: 0px;}
caption {caption-side:bottom;} 
table.opcodes th, table.opcodes td {text-align:left;table-layout:fixed;}
table.trans td:nth-child(1), table.trans td:nth-child(4) {text-align:center;}
dl.dir dt, table.oper td:first-child, table.trans td, table.esc td, table.opcodes th, table.opcodes td, code, pre {font-family:monospace;font-size:12pt;}

thead th {background-color:#eee;border-bottom:1px solid black;}

@media print {
   h1, h2, h3, h4 {page-break-after:avoid;}
   a {text-decoration:none;color:inherit;}
   body.body {width:auto;font-size:10pt;}
}

body { counter-reset: countcaption;}
h1 { counter-reset: counth2; font-size: 2em; margin: 0.67em 0; }

h2:before { content: counter(counth2) " "; counter-increment: counth2; min-width: 40pt;display:inline-block;}
h2 { counter-reset: counth3; }
h3:before { content: counter(counth2) "." counter(counth3) " "; counter-increment: counth3; min-width: 40pt;display:inline-block;}
h3 { counter-reset: counth4; }
h4:before { content: counter(counth2) "." counter(counth3) "." counter(counth4) " "; counter-increment: counth4; min-width: 40pt;display:inline-block;}
caption:before { content: "Table " counter(countcaption) ": "; counter-increment: countcaption; font-weight:bold;}

q { quotes: "\201C" "\201D" "\2018" "\2019"; }

</style>
</head>
<body class="body">
<h1>64tass v1.5x r484 manual</h1>

<p>This is the manual for 64tass, the multi pass optimizing macro assembler for
the 65xx series of processors. Key features:</p>

<ul>
<li>Open source, mostly portable C
<li>Familiar syntax to Omicron TASS and TASM.
<li>Supports 6502, 65C02, R65C02, W65C02, 65CE02, 65816, DTV, 65EL02
<li>Integer, floating point, string and array arithmetic available
<li>Handles UTF-8, UTF-16 and 8&nbsp;bit RAW encoded sources and strings
<li>Built in <q>linker</q> with section support
<li>CPU or flat address space for creating huge binaries (e.g. cartridges)
<li>Conditional compilation, macros, struct/union structures, scopes.
</ul>

<p><b>This is a development version, features or syntax may change over time.
Not everything is backwards compatible.</b></p>

<p>Project page: <a href="http://sourceforge.net/projects/tass64/">http://sourceforge.net/projects/tass64/</a></p>

<hr>
<h2>Usage tips</h2>
<p>64tass is a command line assembler, the source can be written in any text
editor. As a minimum the source filename must be given on the command line. The
<q><tt>-a</tt></q> parameter is highly recommended if the source is Unicode or
ASCII.</p>
<pre width=80>
64tass -a src.asm
</pre>
<p>There are also some useful parameters which are described later.</p>
<p>For comfortable compiling I use such <q>Makefile</q>s (for <a href="http://en.wikipedia.org/wiki/Make_%28software%29">make</a>):</p>
<pre width=80 class="make">
<span>demo.prg:</span> source.asm makros.asm pic.drp music.bin
        <span class="cmd">64tass -C -a -B -i source.asm -o demo.tmp</span>
        <span class="cmd">pucrunch -ffast -x 2048 demo.tmp &gt;demo.prg</span>
</pre>
<p>This way <q>demo.prg</q> is recreated by compiling <q>source.asm</q>
whenever <q>source.asm</q>, <q>makros.asm</q>, <q>pic.drp</q> or <q>music.bin</q> had changed.</p>
<p>Of course it's not much harder to create something similar for win32 (make.bat),
however this will always compile and compress:</p>
<pre width=80>
64tass.exe -C -a -B -i source.asm -o demo.tmp
pucrunch.exe -ffast -x 2048 demo.tmp &gt;demo.prg
</pre>
<p>Here's a slightly more advanced Makefile example with default action as
testing in VICE, clean target for removal of temporary files and compressing
using an intermediate temporary file:</p>
<pre width=80 class="make">
<span>all:</span> demo.prg
        <span class="cmd">x64 -autostartprgmode 1 -autostart-warp +truedrive +cart</span> $&lt;

<span>demo.prg:</span> demo.tmp
	<span class="cmd">pucrunch -ffast -x 2048</span> $&lt; &gt;$@

<span>demo.tmp:</span> source.asm makros.asm pic.drp music.bin
        <span class="cmd">64tass -C -a -B -i</span> $&lt; <span class="cmd">-o</span> $@

<b>.INTERMEDIATE:</b> demo.tmp
<b>.PHONY:</b> all clean
<span>clean:</span>
        $(RM) <span class="cmd">demo.prg demo.tmp</span>
</pre>
<p>It's useful to add a basic header to your source files like the one below,
so that the resulting file is directly runnable without additional
compression:</p>
<pre width=80>
        <b>*=</b> <span>$0801</span>
        <b class="d">.word</b> (<u>+</u>), <span>2005</span>  <i>;pointer, line number</i>
        <b class="d">.null</b> <span>$9e</span>, ^<u>start</u><i>;will be sys 4096</i>
+	<b class="d">.word</b> <span>0</span>          <i>;basic line end</i>

        <b>*=</b> <span>$1000</span>

start	<b>rts</b>
</pre>

<p>A frequently comming up question is, how to automatically allocate
memory, without hacks like <code>*=*+1</code>? Sure
there's <code>.byte</code> and friends for variables with initial values
but what about zero page, or RAM outside of program area? The solution
is to not use an initial value by using '<code>?</code>' or not
giving a fill byte value to <code>.fill</code>.</p>
<pre width=80>
        <b>*=</b> <span>$02</span>
p1	<b class="d">.word</b> <span>?</span>         <i>;a zero page pointer</i>
temp	<b class="d">.fill</b> <span>10</span>        <i>;a 10 byte temporary area</i>
</pre>
<p>Space allocated this way
is not saved in the output as there's no data to save at those
addresses.</p>
<p>What about some code running on zero page for speed? It needs to be
relocated, and the length must be known to copy it there. Here's
an example:</p>
<pre width=80>
        <b>ldx</b> #<span class="k">size</span>(<u>zpcode</u>)-<span>1</span><i>;calculate length</i>
-       <b>lda</b> <u>zpcode</u>,x
        <b>sta</b> <u>wrbyte</u>,x
        <b>dex</b>             <i>;install to zeropage</i>
        <b>bpl</b> <u>-</u>
        <b>jsr</b> <u>wrbyte</u>
        <b>rts</b>
<i>;code continues here but is compiled to run from $02</i>
zpcode  <b class="k">.logical</b> <span>$02</span>
wrbyte  <b>sta</b> <span>$ffff</span>       <i>;quick byte writer at $02</i>
        <b>inc</b> <u>wrbyte</u>+<span>1</span>
        <b>bne</b> <u>+</u>
        <b>inc</b> <u>wrbyte</u>+<span>2</span>
+	<b>rts</b>
	<b class="k">.here</b>
</pre>
<p>The assembler supports lists and tuples, which does not seems interesting at
first as it sound like something which is only useful when heavy scripting is
involved. But as normal arithmetic operations also apply on all their elements at
once, this could spare quite some typing and repetition.</p>
<p>Let's take a simple example of a low/high byte jump table of return
addresses, this usually involves some unnecessary copy/pasting to create a pair
of tables with constructs like <code>&gt;(label-1)</code>.</p>
<pre width=80>
jumpcmd <b>lda</b> <u>hibytes</u>,x   <i>; selected routine in X register</i>
        <b>pha</b>
        <b>lda</b> <u>lobytes</u>,x   <i>; push address to stack</i>
        <b>pha</b>
        <b>rts</b>             <i>; jump, rts will increase pc by one!</i>
<i>; Build an anonymous list of jump addresses minus 1</i>
-	<b>=</b> (<u>cmd_p</u>, <u>cmd_c</u>, <u>cmd_m</u>, <u>cmd_s</u>, <u>cmd_r</u>, <u>cmd_l</u>, <u>cmd_e</u>)-<span>1</span>
lobytes <b class="d">.byte</b> &lt;(<u>-</u>)      <i>; low bytes of jump addresses</i>
hibytes <b class="d">.byte</b> &gt;(<u>-</u>)      <i>; high bytes</i>
</pre>

<p>There are some other tips below in the descriptions.</p>

<hr>
<h2>Expressions and data types</h2>

<h3>Integer constants</h3>

<p>Integer constants can be entered as decimal (<code>[0-9]+</code>),
hexadecimal (<code>$[0-9a-f]*</code>) or binary (<code>%[01]*</code>).
The following operations are accepted:</p>

<table border="0" class="oper">
<caption>Integer operators and functions</caption>
<tr><td width="60">x + y<td>add x to y<td><code><span>2</span> + <span>2</span></code> is <code><span>4</span></code>
<tr><td>x - y<td>substract y from x<td><code><span>4</span> - <span>1</span></code> is <code><span>3</span></code>
<tr><td>x * y<td>multiply x with y<td><code><span>2</span> * <span>3</span></code> is <code><span>6</span></code>
<tr><td>x / y<td>integer divide x by y<td><code><span>7</span> / <span>2</span></code> is <code><span>3</span></code>
<tr><td>x % y<td>integer modulo of x divided by y<td><code><span>5</span> % <span>2</span></code> is <code><span>1</span></code>
<tr><td>x ** y<td>x raised t power of y<td><code><span>2</span> ** <span>4</span></code> is <code><span>16</span></code>
<tr><td>-x<td>negated value<td><code>-<span>2</span></code> is <code><span>-2</span></code>
<tr><td>+x<td>unchanged<td><code>+<span>2</span></code> is <code><span>2</span></code>
<tr><td>&lt;<td>lower byte<td><code>&lt;<span>$1234</span></code> is <code><span>$34</span></code>
<tr><td>&gt;<td>higher byte<td><code>&gt;<span>$1234</span></code> is <code><span>$12</span></code>
<tr><td>`<td>bank byte<td><code>`<span>$123456</span></code> is <code><span>$12</span></code>
<tr><td>&lt;&gt;<td>lower word<td><code>&lt;&gt;<span>$123456</span></code> is <code><span>$3456</span></code>
<tr><td>&gt;`<td>higher word<td><code>&lt;`<span>$123456</span></code> is <code><span>$1234</span></code>
<tr><td>&gt;&lt;<td>lower byte swapped word<td><code>&gt;&lt;<span>$123456</span></code> is <code><span>$5634</span></code>
<tr><td>x &lt;=&gt; y<td>x compares to y<td><code><span>2</span> &lt;=&gt; <span>5</span></code> is -1
<tr><td>x == y<td>x equals to y<td><code><span>2</span> == <span>3</span></code> is false
<tr><td>x != y<td>x does not equal to y<td><code><span>2</span> != <span>3</span></code> is true
<tr><td>x &lt; y<td>x is less than y<td><code><span>2</span> &lt; <span>3</span></code> is true
<tr><td>x &gt; y<td>x is more than y<td><code><span>2</span> &gt; <span>3</span></code> is false
<tr><td>x &gt;= y<td>x is more than y or equals<td><code><span>2</span> &gt;= <span>3</span></code> is false
<tr><td>x &lt;= y<td>x is less than y or equals<td><code><span>2</span> &lt;= <span>3</span></code> is true
<tr><td>x | y<td>bitwise or<td><code><span>2</span> | <span>6</span></code> is <code><span>6</span></code>
<tr><td>x ^ y<td>bitwise xor<td><code><span>2</span> ^ <span>6</span></code> is <code><span>4</span></code>
<tr><td>x &amp; y<td>bitwise and<td><code><span>2</span> &amp; <span>6</span></code> is <code><span>2</span></code>
<tr><td>x &lt;&lt; y<td>logical shift left<td><code><span>1</span> &lt;&lt; <span>3</span></code> is <code><span>8</span></code>
<tr><td>x &gt;&gt; y<td>arithmetic shift right<td><code><span>-8</span> &gt;&gt; <span>3</span></code> is <code><span>-1</span></code>
<tr><td>~x<td>invert bits<td><code>~<span>%101</span></code> is <code><span>%010</span></code>
<tr><td>..<td>concatenate bits<td><code><span>$a</span>..<span>$b</span></code> is <code><span>$ab</span></code>
<tr><td>x[n]<td>extract bit(s)<td><code><span>$a</span>[<span>1</span>]</code> is <code><span>0</span></code>
<tr><td>x[s]<td>slice bits<td><code><span>$1234</span>[<span>4</span>:<span>8</span>]</code> is <code><span>$3</span></code>
<tr><td>len(a)<td>length in bits<td><code><span class="k">len</span>(<span>$034</span>)</code> is <code><span>12</span></code>
<tr><td>float(a)<td>convert to floating point<td><code><span class="k">float</span>(<span>1</span>)</code> is <code><span>1.0</span></code>
</table>

<p>An integer has a truth value of true if it's non-zero. The
true value is the same as 1.</p>

<p>Length of a numeric constants are defined in bits and is calculated from the
number of digits used for hexadecimal (4 each) and binary (1 each) definitions. It's
also set when slicing, bit (1), byte (8) or word (16) extraction is
used.</p>

<p>Integers are automatically promoted to float as necessary in expressions.</p>

<p><b>The precision is limited to 32 bits in this version. This might change in
the future, so don't rely on clipping of higher bits.</b></p>

<pre width=80>
        <b class="d">.byte</b> <span>23</span>        <i>; decimal</i>
        <b class="d">.byte</b> <span>$33</span>       <i>; hex</i>
        <b class="d">.byte</b> <span>%00011111</span> <i>; binary</i>

        <b>lda</b> #&lt;<u>label</u>
        <b>ldy</b> #&gt;<u>label</u>
        <b>jsr</b> <span>$ab1e</span>

        <b>ldx</b> #&lt;&gt;<u>source</u>   <i>; word extraction</i>
        <b>ldy</b> #&lt;&gt;<u>dest</u>
        <b>lda</b> #<span class="k">size</span>(<u>source</u>)-<span>1</span>
        <b>mvn</b> `<u>source</u>, `<u>dest</u><i>; bank extraction</i>

        <b>lda</b> #((<u>bitmap</u> &amp; <span>$2000</span>) &gt;&gt; <span>10</span>) | ((<u>screen</u> &amp; <span>$3c00</span>) &gt;&gt; <span>6</span>)
        <b>sta</b> <span>$d018</span>
        <b>lda</b> <span>$d015</span>
        <b>and</b> #~<span>%00100000</span>
        <b>sta</b> <span>$d015</span>
</pre>

<h3>Floating point constants</h3>

<p>Floating point constants have a radix point in them and optionally
an exponent. A decimal exponent is <q>e</q> while a binary one is <q>p</q>. The
following operations can be used:</p>

<table border="0" class="oper">
<caption>Floating point operators and functions</caption>
<tr><td width="80">x + y<td>add x to y<td><code><span>2.2</span> + <span>2.2</span></code> is <code><span>4.4</span></code>
<tr><td>x - y<td>substract y from x<td><code><span>4.1</span> - <span>1.1</span></code> is <code><span>3.0</span></code>
<tr><td>x * y<td>multiply x with y<td><code><span>1.5</span> * <span>3</span></code> is <code><span>4.5</span></code>
<tr><td>x / y<td>integer divide x by y<td><code><span>7.0</span> / <span>2.0</span></code> is <code><span>3.5</span></code>
<tr><td>x % y<td>integer modulo of x divided by y<td><code><span>5.0</span> % <span>2.0</span></code> is <code><span>1.0</span></code>
<tr><td>x ** y<td>x raised t power of y<td><code><span>2.0</span> ** <span>-1</span></code> is <code><span>0.5</span></code>
<tr><td>-x<td>negated value<td><code>-<span>2.0</span></code> is <code><span>-2.0</span></code>
<tr><td>+x<td>unchanged<td><code>+<span>2.0</span></code> is <code><span>2.0</span></code>
<tr><td>x &lt;=&gt; y<td>x compares to y<td><code><span>5.0</span> &lt;=&gt; <span>3.0</span></code> is 1
<tr><td>x == y<td>x equals to y<td><code><span>2.0</span> == <span>3.0</span></code> is false
<tr><td>x != y<td>x does not equal to y<td><code><span>2.0</span> != <span>3.0</span></code> is true
<tr><td>x &lt; y<td>x is less than y<td><code><span>2.0</span> &lt; <span>3.0</span></code> is true
<tr><td>x &gt; y<td>x is more than y<td><code><span>2.0</span> &gt; <span>3.0</span></code> is false
<tr><td>x &gt;= y<td>x is more than y or equals<td><code><span>2.0</span> &gt;= <span>3.0</span></code> is false
<tr><td>x &lt;= y<td>x is less than y or equals<td><code><span>2.0</span> &lt;= <span>3.0</span></code> is true
<tr><td>x | y<td>bitwise or<td><code><span>2.5</span> | <span>6.5</span></code> is <code><span>6.5</span></code>
<tr><td>x ^ y<td>bitwise xor<td><code><span>2.5</span> ^ <span>6.5</span></code> is <code><span>4.0</span></code>
<tr><td>x &amp; y<td>bitwise and<td><code><span>2.5</span> &amp; <span>6.5</span></code> is <code><span>2.5</span></code>
<tr><td>x &lt;&lt; y<td>logical shift left<td><code><span>1.0</span> &lt;&lt; <span>3.0</span></code> is <code><span>8.0</span></code>
<tr><td>x &gt;&gt; y<td>arithmetic shift right<td><code><span>-8.0</span> &gt;&gt; <span>4</span></code> is <code><span>-0.5</span></code>
<tr><td>~x<td>almost &minus;x<td><code>~<span>2.1</span></code> is almost <code><span>-2.1</span></code>
<tr><td>abs(a)<td>absolute value<td><code><span class="k">abs</span>(<span>-1.0</span>)</code> is <code><span>1.0</span></code>
<tr><td>sign(a)<td>sign value (&minus;1, 0, 1)<td><code><span class="k">sign</span>(<span>-4.0</span>)</code> is <code><span>-1</span></code>
<tr><td>floor(a)<td>round down<td><code><span class="k">floor</span>(<span>-4.8</span>)</code> is <code><span>-5.0</span></code>
<tr><td>round(a)<td>round to nearest away from zero<td><code><span class="k">floor</span>(<span>4.8</span>)</code> is <code><span>5.0</span></code>
<tr><td>ceil(a)<td>round up<td><code><span class="k">ceil</span>(<span>1.1</span>)</code> is <code><span>2.0</span></code>
<tr><td>trunc(a)<td>round down towards zero<td><code><span class="k">trunc</span>(<span>-1.9</span>)</code> is <code><span>-1</span></code>
<tr><td>frac(a)<td>fractional part<td><code><span class="k">frac</span>(<span>1.1</span>)</code> is <code><span>0.1</span></code>
<tr><td>sqrt(a)<td>square root<td><code><span class="k">sqrt</span>(<span>16.0</span>)</code> is <code><span>4.0</span></code>
<tr><td>cbrt(a)<td>cube root<td><code><span class="k">cbrt</span>(<span>27.0</span>)</code> is <code><span>3.0</span></code>
<tr><td>log10(a)<td>common logarithm<td><code><span class="k">log10</span>(<span>100.0</span>)</code> is <code><span>2.0</span></code>
<tr><td>log(a)<td>natural logarithm<td><code><span class="k">log</span>(<span>1</span>)</code> is <code><span>0.0</span></code>
<tr><td>exp(a)<td>exponential<td><code><span class="k">exp</span>(<span>0</span>)</code> is <code><span>1.0</span></code>
<tr><td>pow(a,&nbsp;b)<td>a raised to power of b<td><code><span class="k">pow</span>(<span>2.0, 3.0</span>)</code> is <code><span>8.0</span></code>
<tr><td>sin(a)<td>sine<td><code><span class="k">sin</span>(<span>0.0</span>)</code> is <code><span>0.0</span></code>
<tr><td>asin(a)<td>arc sine<td><code><span class="k">asin</span>(<span>0.0</span>)</code> is <code><span>0.0</span></code>
<tr><td>sinh(a)<td>hyperbolic sine<td><code><span class="k">sinh</span>(<span>0.0</span>)</code> is <code><span>0.0</span></code>
<tr><td>cos(a)<td>cosine<td><code><span class="k">cos</span>(<span>0.0</span>)</code> is <code><span>1.0</span></code>
<tr><td>acos(a)<td>arc cosine<td><code><span class="k">acos</span>(<span>1.0</span>)</code> is <code><span>0.0</span></code>
<tr><td>cosh(a)<td>hyperbolic cosine<td><code><span class="k">cosh</span>(<span>0.0</span>)</code> is <code><span>1.0</span></code>
<tr><td>tan(a)<td>tangent<td><code><span class="k">tan</span>(<span>0.0</span>)</code> is <code><span>0.0</span></code>
<tr><td>atan(a)<td>arc tangent<td><code><span class="k">atan</span>(<span>0.0</span>)</code> is <code><span>0.0</span></code>
<tr><td>tanh(a)<td>hyperbolic tangent<td><code><span class="k">tanh</span>(<span>0.0</span>)</code> is <code><span>0.0</span></code>
<tr><td>rad(a)<td>degrees to radian<td><code><span class="k">rad</span>(<span>0.0</span>)</code> is <code><span>0.0</span></code>
<tr><td>deg(a)<td>radian to degrees<td><code><span class="k">deg</span>(<span>0.0</span>)</code> is <code><span>0.0</span></code>
<tr><td>hypot(y,&nbsp;x)<td>polar distance<td><code><span class="k">hypot</span>(<span>4.0</span>, <span>3.0</span>)</code> is <code><span>5.0</span></code>
<tr><td>atan2(y,&nbsp;x)<td>polar angle<td><code><span class="k">atan2</span>(<span>0.0</span>, <span>3.0</span>)</code> is <code><span>0.0</span></code>
<tr><td>int(a)<td>convert to integer<td><code><span class="k">int</span>(<span>3.8</span>)</code> is <code><span>3</span></code>
</table>

<p>A floating point number has a truth value of true if it's non-zero.</p>

<p>As usual comparing floating point numbers for (non) equality is a bad idea due to rounding errors.</p>

<p>There are no predefined floating point constants, define them as necessary. Hint: pi is <code>rad(180)</code>
and e is <code>exp(1)</code>.</p>

<p>Floating point numbers are automatically truncated to integer as necessary.</p>

<p>Fixed point conversion can be done by using the shift operators for example
a 8.16 fixed point number can be calculated as <code>(3.14 &lt;&lt; 16) &amp; $ffffff</code>.
The binary operators operate like if the floating point number would be a fixed
point one. This is the reason for the strange definiton of inversion.</p>

<pre width=80>
        <b class="d">.byte</b> <span>3.66e1</span>       <i>; 36.6, truncated to 36</i>
        <b class="d">.byte</b> <span>$1.8p4</span>       <i>; 4:4 fixed point number (1.5)</i>
        <b class="d">.int</b> <span>12.2p8</span>        <i>; 8:8 fixed point number (12.2)</i>
</pre>

<h3>Character string constants</h3>

<p>Strings are enclosed in single or double quotes and can hold any unicode
character. Operations like indexing or slicing are always done on the original
representation. The current encoding is only applied when it's used in
expressions as numeric constants or in context of text data directives.
Doubling the quotes inside the strings escapes them.</p>

<table border="0" class="oper">
<caption>String operators and functions</caption>
<tr><td>..<td>concatenate strings<td><code><span class="s">"a"</span>..<span class="s">"b"</span></code> is <code><span class="s">"ab"</span></code>
<tr><td>in<td>is substring of<td><code><span class="s">"b"</span> <span class="k">in</span> <span class="s">"abc"</span></code> is true
<tr><td>%<td>string formatting<td><code><span class="s">"<span>%02x</span>"</span> % (<span>12</span>,)</code> is <code><span class="s">"0c"</span></code>
<tr><td>x<td>repeat<td><code><span class="s">"ab"</span> <span class="k">x</span> <span>3</span></code> is <code><span class="s">"ababab"</span></code>
<tr><td>x[i]<td>character from start<td><code><span class="s">"abc"</span>[<span>1</span>]</code> is <code><span class="s">"b"</span></code>
<tr><td>x[i]<td>character from end<td><code><span class="s">"abc"</span>[<span>-1</span>]</code> is <code><span class="s">"c"</span></code>
<tr><td>x[s]<td>no change<td><code><span class="s">"abc"</span>[:]</code> is <code><span class="s">"abc"</span></code>
<tr><td>x[s]<td>cut off start<td><code><span class="s">"abc"</span>[<span>1</span>:]</code> is <code><span class="s">"bc"</span></code>
<tr><td>x[s]<td>cut off end<td><code><span class="s">"abc"</span>[:<span>-1</span>]</code> is <code><span class="s">"ab"</span></code>
<tr><td>x[s]<td>reverse<td><code><span class="s">"abc"</span>[::<span>-1</span>]</code> is <code><span class="s">"cba"</span></code>
<tr><td>len(x)<td>number of characters<td><code><span class="k">len</span>(<span class="s">"abc"</span>)</code> is <code><span>3</span></code>
</table>

<p>A string has a truth value of true if it contains at least one character.</p>

<p>Strings are converted to numeric constants as necessary using the current
encoding and escape rules, for example when using a sane encoding <code>"z" - "a"</code> is
<code>25</code>.</p>

<p>Indexing characters with positive integers start with zero. Negative indexes
are translated internally by adding the number of characters to them, therefore
&minus;1 can be used to access the last character. Indexing with list of integers is
possible as well so <code>"abc"[(-1, 0, 1)]</code> is <code>"cab"</code>.</p>

<p>Slicing is an operation when parts of string are extracted from a start
position to an end position with a step value. These parameters are separated
with colons enclosed in square brackets and are all optional. Their default
values are [start:maximum:step=1]. Negative start and end characters are
converted to positive internally by adding the length of string to them.
Negative step operates in reverse direction, non single steps will jump over
characters.</p>

<pre width=80>
mystr   <b>=</b> <span class="s">"oeU"</span>         <i>; text</i>
        <b class="d">.text</b> <span class="s">'it''s'</span>   <i>; text: it's</i>
        <b class="d">.word</b> <span class="s">"ab"</span>+<span>1</span>    <i>; character, results in "bb" usually</i>

        <b class="d">.text</b> <span class="s">"text"</span>[:<span>2</span>]     <i>; "te"</i>
        <b class="d">.text</b> <span class="s">"text"</span>[<span>2</span>:]     <i>; "xt"</i>
        <b class="d">.text</b> <span class="s">"text"</span>[:<span>-1</span>]    <i>; "tex"</i>
        <b class="d">.text</b> <span class="s">"reverse"</span>[::<span>-1</span>]<i>; "esrever"</i>
</pre>

<p>String formatting can interpret a list of values and convert them to a string.
The converted values are inserted at the <code>%</code> sign which is followed by
conversion flags, minimum field length, and conversion type. The these flags
can be used:</p>

<table border="0" class="oper">
<caption>Formatting flags</caption>
<tr><td width="40">#<td>alternate form ($a, %10, 10.)
<tr><td>*<td>width/precision from list
<tr><td>.<td>precision
<tr><td>0<td>pad with zeros
<tr><td>-<td>left adjusted (default right)
<tr><td>&nbsp;<td>blank when positive or minus sign
<tr><td>+<td>sign even if positive
</table>

<p>The following conversions are implemented:</p>

<table border="0" class="oper">
<caption>Formatting conversions</caption>
<tr><td width="40">a&nbsp;A<td>hexadecimal floating point (uppercase)
<tr><td>b<td>binary
<tr><td>c<td>unicode character
<tr><td>d<td>decimal
<tr><td>e&nbsp;E<td>exponential float (uppercase)
<tr><td>f&nbsp;F<td>floating point (uppercase)
<tr><td>g&nbsp;G<td>exponential/floating point
<tr><td>s<td>string
<tr><td>x&nbsp;X<td>hexadecimal (uppercase)
<tr><td>%<td>percent sign
</table>

<pre width=80>
        <b class="d">.text</b> <span class="s">"<span>%#04x</span> bytes left"</span> % (<span>1000</span>,)   <i>; $03e8 bytes left</i>
</pre>

<h3>Byte string constants</h3>

<p>Byte strings are like strings, but hold bytes instead of characters. They
can be created by prefixing quoted strings with a <q>b</q>, this converts the
string using the current encoding to bytes.</p>

<table border="0" class="oper">
<caption>Byte string operators and functions</caption>
<tr><td>..<td>concatenate strings<td><code><span class="s">b"a"</span>..<span class="s">b"b"</span></code> is <code><span class="s">b"ab"</span></code>
<tr><td>in<td>is substring of<td><code><span class="s">b"b"</span> <span class="k">in</span> <span class="s">b"abc"</span></code> is true
<tr><td>x<td>repeat<td><code><span class="s">b"ab"</span> <span class="k">x</span> <span>3</span></code> is <code><span class="s">b"ababab"</span></code>
<tr><td>x[i]<td>byte from start<td><code><span class="s">b"abc"</span>[<span>1</span>]</code> is <code><span class="s">b"b"</span></code>
<tr><td>x[i]<td>byte from end<td><code><span class="s">b"abc"</span>[<span>-1</span>]</code> is <code><span class="s">b"c"</span></code>
<tr><td>x[s]<td>no change<td><code><span class="s">b"abc"</span>[:]</code> is <code><span class="s">b"abc"</span></code>
<tr><td>x[s]<td>cut off start<td><code><span class="s">b"abc"</span>[<span>1</span>:]</code> is <code><span class="s">b"bc"</span></code>
<tr><td>x[s]<td>cut off end<td><code><span class="s">b"abc"</span>[:<span>-1</span>]</code> is <code><span class="s">b"ab"</span></code>
<tr><td>x[s]<td>reverse<td><code><span class="s">b"abc"</span>[::<span>-1</span>]</code> is <code><span class="s">b"cba"</span></code>
<tr><td>len(x)<td>number of bytes<td><code><span class="k">len</span>(<span class="s">b"abc"</span>)</code> is <code><span>3</span></code>
</table>

<p>A byte string has a truth value of true if it contains at least one byte.</p>

<p>Indexing and slicing works as with character strings.</p>

<pre width=80>
        <b class="k">.enc</b> screen	<i>;use screen encoding</i>
mystr   <b>=</b> <span class="s">b"oeU"</span>        <i>;convert text to bytes</i>
        <b class="k">.enc</b> none	<i>;normal encoding</i>

        <b class="d">.text</b> <u>mystr</u>     <i>;text as originally encoded</i>
</pre>

<h3>List and tuples</h3>

<p>Lists and tuples can hold a collection of values. Lists are defined from
values separated by comma between square brackets <code>[1, 2, 3]</code>, an
empty list is <code>[]</code>. Tuples are similar but are enclosed in
parentheses instead. An empty tuple is <code>()</code>, a single element tuple
is <code>(4,)</code> to differentiate from normal numeric expression
parentheses. When nested they function similar to an array. Currently both
types are immutable.</p>

<table border="0" class="oper">
<caption>List and tuple operators and functions</caption>
<tr><td>..<td>concatenate lists<td><code>[<span>1</span>]..[<span>2</span>]</code> is <code>[<span>1</span>, <span>2</span>]</code>
<tr><td>in<td>is member of list<td><code><span>2</span> <span class="k">in</span> [<span>1</span>, <span>2</span>, <span>3</span>]</code> is true
<tr><td>x<td>repeat<td><code>[<span>1</span>, <span>2</span>] <span class="k">x</span> <span>2</span></code> is <code>[<span>1</span>, <span>2</span>, <span>1</span>, <span>2</span>]</code>
<tr><td>x[i]<td>element from start<td><code>(<span class="s">"1"</span>, <span>2</span>)[<span>1</span>]</code> is <code><span>2</span></code>
<tr><td>x[i]<td>element from end<td><code>(<span class="s">"1"</span>, <span>2</span>, <span>3</span>)[<span>-1</span>]</code> is <code><span>3</span></code>
<tr><td>x[s]<td>no change<td><code>(<span>1</span>, <span>2</span>, <span>3</span>)[:]</code> is <code>(<span>1</span>, <span>2</span>, <span>3</span>)</code>
<tr><td>x[s]<td>cut off start<td><code>(<span>1</span>, <span>2</span>, <span>3</span>)[<span>1</span>:]</code> is <code>(<span>2</span>, <span>3</span>)</code>
<tr><td>x[s]<td>cut off end<td><code>(<span>1</span>, <span>2.0</span>, <span>3</span>)[:<span>-1</span>]</code> is <code>(<span>1</span>, <span>2.0</span>)</code>
<tr><td>x[s]<td>reverse<td><code>(<span>1</span>, <span>2</span>, <span>3</span>)[::<span>-1</span>]</code> is <code>(<span>3</span>, <span>2</span>, <span>1</span>)</code>
<tr><td>len(x)<td>number of elements<td><code><span class="k">len</span>([<span>1</span>, <span>2</span>, <span>3</span>])</code> is <code><span>3</span></code>
<tr><td>range(s,e,t)<td>create a list with values from a range<td><code><span class="k">range</span>(<span>3</span>)</code> is <code>[<span>0</span>,<span>1</span>,<span>2</span>]</code>
</table>

<p>A list or tuple has a truth value of true if it contains at least one element.</p>

<p>Arithmetic operations are applied on the all elements recursively,
therefore <code>[1, 2] + 1</code> is <code>[2, 3]</code>, and <code>abs([1,
-1])</code> is <code>[1, 1]</code>.</p>

<p>Arithmetic operations between lists are applied one by one on their
elements, so <code>[1, 2] + [3, 4]</code> is <code>[4, 6]</code>.</p>

<p>When lists form an array and columns/rows are missing the smaller array is
stretched to fill in the gaps if possible, so <code>[[1],[2]] * [3, 4]</code>
is <code>[[3, 4], [6, 8]]</code>.</p>

<p>Indexing elements with positive integers start with zero. Negative indexes
are transformed to positive by adding the number of elements to them, therefor
&minus;1 is the last element. Indexing with list of integers is possible as well so
<code>[1, 2, 3][(-1, 0, 1)]</code> is <code>[3, 1, 2]</code>.</p>

<p>Slicing is an operation when parts of list or tuple are extracted from a
start position to an end position with a step value. These parameters are
separated with colons enclosed in square brackets and are all optional. Their
default values are [start:maximum:step=1].  Negative start and end elements are
converted to positive internally by adding the number of elements to them.
Negative step operates in reverse direction, non single steps will jump over
elements.</p>

<pre width=80>
mylist  <b>=</b> [<span>1</span>, <span>2</span>, <span class="s">"whatever"</span>]
mytuple <b>=</b> (<u>cmd_e</u>, <u>cmd_g</u>)

mylist  <b>=</b> (<span class="s">"e"</span>, <u>cmd_e</u>, <span class="s">"g"</span>, <u>cmd_g</u>, <span class="s">"i"</span>, <u>cmd_i</u>)
keys    <b class="d">.text</b> <u>mylist</u>[::<span>2</span>]    <i>; keys ("e", "g", "i")</i>
call_l  <b class="d">.byte</b> &lt;<u>mylist</u>[<span>1</span>::<span>2</span>]-<span>1</span><i>; routines (&lt;cmd_e-1, &lt;cmd_g-1, &lt;cmd_i-1)</i>
call_h  <b class="d">.byte</b> &gt;<u>mylist</u>[<span>1</span>::<span>2</span>]-<span>1</span><i>; routines (&gt;cmd_e-1, &gt;cmd_g-1, &gt;cmd_i-1)</i>
</pre>

<p>The <code>range(start, end, step)</code> built in function can be used to
create lists of integers in a range with a given step value. At least the end
must be given, the start defaults to 0 and the step to 1. Sounds not very
useful, so here are a few examples:</p>

<pre width=80>
<i>;Bitmask table, 8 bits from left to right</i>
        <b class="d">.byte</b> <span>%10000000</span> &gt;&gt; <span class="k">range</span>(<span>8</span>)
<i>;Classic 256 byte single period sinus table with values of 0-255.</i>
        <b class="d">.byte</b> <span>128.5</span> + <span>127</span> * <span class="k">sin</span>(<span class="k">range</span>(<span>256</span>) * <span class="k">rad</span>(<span>360.0</span>/<span>256</span>))
<i>;Screen row address tables</i>
-       <b>=</b> <span>$400</span> + <span class="k">range</span>(<span>0</span>, <span>1000</span>, <span>40</span>)
scrlo   <b class="d">.byte</b> &lt;(<u>-</u>)
scrhi   <b class="d">.byte</b> &gt;(<u>-</u>)
</pre>

<h3>Dictionaries</h3>

<p>Dictionaries are unsorted lists holding key and value pairs. Definition is
done by collecting key:value pairs separated by comma between braces <code>{1:"a",
"a":1}</code>. An empty dictionary is <code>{}</code>.  Currently this type is
immutable. Numeric and string keys are accepted, the value can be anything.</p>

<table border="0" class="oper">
<caption>Dictionary operators and functions</caption>
<tr><td>x[i]<td>value lookup<td><code>{<span class="s">"1"</span>:<span>2</span>}[<span class="s">"1"</span>]</code> is <code><span>2</span></code>
<tr><td>in<td>is a key<td><code><span>1</span> <span class="k">in</span> {<span>1</span>:<span>2</span>}</code> is true
<tr><td>len(x)<td>number of elements<td><code><span class="k">len</span>({<span>1</span>:<span>2</span>, <span>3</span>:<span>4</span>])</code> is <code><span>2</span></code>
</table>

<p>A dictionary has a truth value of true if it contains at least one key value pair.</p>

<pre width=80>
        <b class="d">.text</b> {<span>1</span>:<span class="s">"one"</span>, <span>2</span>:<span class="s">"two"</span>}[<span>2</span>]<i>; "two"</i>
</pre>

<h3>Labels</h3>
<p>Normal labels can be defined at the start of each line. Each of them is uniq
and can't be redefined. In arithmetic operations they represent the numeric
addresses of a memory location. Additionally they also hold the compiled code
and data definitions in binary format.</p>

<p>A label represents by default only the single line it is found on unless
block directives are used where it's extended till the end of block. The
content is not forward referencable, only the address of label. Usually the
size of a single element is a byte, but this can be more for data definitions.
Trying to <q>overwrite</q> the same memory locations later does not affect the
content anymore.</p>

<p><b>Indexing and slicing of labels to access the compiled content might be
implemented differently in future releases. Use this feature at your own
risk for now, you might need to update your code later.</b></p>

<table border="0" class="oper">
<caption>Label operators and functions</caption>
<tr><td>.<td>member<td><code><u>label</u>.<u>locallabel</u></code>
<tr><td>x[i]<td>element from start<td><code><u>label</u>[<span>1</span>]</code>
<tr><td>x[i]<td>element from end<td><code><u>label</u>[<span>-1</span>]</code>
<tr><td>x[s]<td>copy as tuple<td><code><u>label</u>[:]</code>
<tr><td>x[s]<td>cut off start, as tuple<td><code><u>label</u>[<span>1</span>:]</code>
<tr><td>x[s]<td>cut off end, as tuple<td><code><u>label</u>[:<span>-1</span>]</code>
<tr><td>x[s]<td>reverse, as tuple<td><code><u>label</u>[::<span>-1</span>]</code>
<tr><td>len(x)<td>number of elements<td><code><span class="k">len</span>(<u>label</u>)</code>
<tr><td>size(a)<td>size in bytes<td><code><span class="k">size</span>(<u>label</u>)</code>
</table>

<p>A label has a truth value of true when it's address is non-zero.</p>

<pre width=80>
mydata  <b class="d">.word</b> <span>1</span>, <span>4</span>, <span>3</span>
mycode  <b class="k">.block</b>
local   <b>lda</b> #<span>0</span>
        <b class="k">.bend</b>

        <b>ldx</b> #<span class="k">size</span>(<u>mydata</u>) <i>;6 bytes (3*2)</i>
        <b>ldx</b> #<span class="k">len</span>(<u>mydata</u>)  <i>;3 elements</i>
        <b>ldx</b> #<u>mycode</u>[<span>0</span>]    <i>;lda instruction, $a9</i>
        <b>ldx</b> #<u>mydata</u>[<span>1</span>]    <i>;2nd element, 4</i>
        <b>jmp</b> <u>mycode</u>.<u>local</u>  <i>;address of local label</i>
</pre>

<p>The assembler supports anonymous labels, also called as forward (<tt>+</tt>)
and backward (<tt>-</tt>) references. <q><tt>-</tt></q> means one backward,
<q><tt>--</tt></q> means two backward, etc. also the same for forward, but with
<q><tt>+</tt></q>.</p>

<pre width=80>
        <b>ldy</b> #<span>4</span>
-       <b>ldx</b> #<span>0</span>
-       <b>txa</b>
        <b>cmp</b> #<span>3</span>
	<b>bcc</b> +
        <b>adc</b> #<span>44</span>
+       <b>sta</b> <span>$400</span>,x
	<b>inx</b>
	<b>bne</b> -
	<b>dey</b>
	<b>bne</b> --
</pre>

<p>Excessive nesting or long distance references create a poorly readable code.
It's also very easy to insert a few new references in a way to break the old
ones around by mistake.</p>

<p>These references are also useful in segments, but this can create a nice traps, as segments are
copied into the code, with the internal references.
</p>
<pre>
	<b>bne</b> +
        <b class="k">#somemakro</b>      <i>;let's hope that this segment does</i>
+	<b>nop</b>             <i>;not contain forward references...</i>
</pre>

<h3>Constant and variable references</h3>

<p>References can reference labels, results from expressions or other
references.</p>

<p>Constant references can be created with the equal sign. These are not
redefinable. Forward referencing to them is allowed as they retain the
reference to constant objects over compilation passes.</p>

<pre width=80>
border  <b>=</b> <span>$d020</span>     <i>;a constant reference</i>
f       <b class="k">.block</b>
g        <b class="k">.block</b>
n        <b>nop</b>        <i>;jump here</i>
	 <b class="k">.bend</b>
	<b class="k">.bend</b>

        <b>inc</b> <u>border</u>  <i>;inc $d020</i>
        <b>jsr</b> <u>labelref</u>.<u>n</u>

labelref <b>=</b> <u>f</u>.<u>g</u>
</pre>

<p>Redefinable references can be created by the <code>.var</code> directive.
As it's redefinable it can only be used in code after it's definition. Even
tricks like using constant references on them will not help with forward
referencing. They simply don't carry their last reference over from the
previous pass.</p>

<pre width=80>
variabl	<b class="k">.var</b> <span>1</span>
        <b class="k">.rept</b> <span>10</span>
        <b class="d">.byte</b> <u>variabl</u>
variabl	<b class="k">.var</b> <u>variabl</u>+<span>1</span>
	<b class="k">.next</b>
</pre>

<h3>Uninitialized memory</h3>

<p>There's a special value for uninitialized memory, it's represented by a
question mark. Whenever it's used to generate data it creates a <q>hole</q>
where the previous content of memory is visible.</p>

<p>Uninitialized memory holes without previous content are not saved unless
it's really necessary for the output format, in that case it's replaced with
zeros.</p>

<p>It's not just data generation statements (e.g. <code>.byte</code>) that can
create uninitialized memory, but filling, alignment or address manipulation as
well.</p>

<pre width=80>
        <b>*=</b> <span>$200</span>         <i>;bytes as necessary</i>
	<b class="d">.word</b> <span>?</span>         <i>;2 bytes</i>
	<b class="d">.fill</b> <span>10</span>        <i>;10 bytes</i>
	<b class="k">.align</b> <span>64</span>       <i>;bytes as necessary</i>
	<b class="k">.offs</b> <span>16</span>        <i>;16 bytes</i>
</pre>

<h3>Conditional expressions</h3>
<p>Boolean conditional operators give false (0) or true (1) or one of the
operands as the result. True is defined as a non-zero number, a non-empty
string/tuple/list, anything else is false.</p>

<p>The ternary operator (<code>?:</code>) gives the first (x) result if c is
true or the second (y) if c is false.</p>

<table border="0" class="oper">
<caption>Logical and conditional operators</caption>
<tr><td width="80">x || y<td>if x is true then x otherwise y
<tr><td>x ^^ y <td>if both false or true then false otherwise x || y
<tr><td>x &amp;&amp; y<td>if x is true then y otherwise x
<tr><td>!x<td>if x is true then false otherwise true
<tr><td>!!x<td>if x is true then true otherwise false
<tr><td>c&nbsp;?&nbsp;x&nbsp;:&nbsp;y<td>if c is true then x otherwise y
</table>

<pre width=80>
<i>;Silly example for 1=>"simple", 2=>"advanced", else "normal"</i>
        <b class="d">.text</b> <u>MODE</u> == <span>1</span> &amp;&amp; <span class="s">"simple"</span> || <u>MODE</u> == <span>2</span> &amp;&amp; <span class="s">"advanced"</span> || <span class="s">"normal"</span>
        <b class="d">.text</b> <u>MODE</u> == <span>1</span> ? <span class="s">"simple"</span> : <u>MODE</u> == <span>2</span> ? <span class="s">"advanced"</span> : <span class="s">"normal"</span>
</pre>

<h3>Expressions</h3>

<p>Parenthesis (<code>( )</code>) can be used to override operator precedence.
Don't forget that they also denote indirect addressing mode for certain
opcodes.</p>

<pre width=80>
        <b>lda</b> #(<span>4</span>+<span>2</span>)*<span>3</span>
</pre>

<p>Built in functions are identifiers followed by parentheses. They accept
variable number of parameters separated by comma.</p>

<table border="0" class="oper">
<caption>Other built in functions</caption>
<tr><td width="150">min(a, b, ...)<td>Minimum of values
<tr><td>max(a, b, ...)<td>Maximum of values
<tr><td>repr(a)<td>Text representation of value
</table>

<p>Special addressing mode forcing operators in front of an expression can be
used to make sure the expected addressing mode is used.</p>

<table border="0" class="oper">
<caption>Address size forcing</caption>
<tr><td width="80">@b<td>to force 8 bit address
<tr><td>@w<td>to force 16 bit address
<tr><td>@l<td>to force 24 bit address (65816)
</table>

<pre width=80>
        <b>lda</b> @w<span>$0000</span>
</pre>

<hr>
<h2>Compiler directives:</h2>

<h3>Controlling the compile offset and program counter</h3>

<p>Two counters are used while assembling. The compile offset is where the data
and code ends up in memory, while the program counter is what labels will be
set or what the special star label gets when referenced.</p>

<dl class="dir">
<dt><b>*=</b> &lt;expression&gt;
<dd>The compile offset is moved so that the program counter will match the one
in the expression.
<dt><b>.offs</b> &lt;expression&gt;
<dd>Add an offset to the compile offset (create a gap). The program counter
stays the same as before.
<dt><b>.logical</b> &lt;expression&gt;
<dt><b>.here</b>
<dd>Changes the program counter, the compile offset is not changed. Can be nested.
<dt><b>.align</b> &lt;modulo&gt;[, &lt;fill&gt;]
<dd>Align code to a dividable program counter address by gap or filler bytes
</dl>
<pre width=80>
        <b>*=</b> <span>$1000</span>        <i>;set program counter (and offset)</i>

        <b class="k">.offs</b> <span>100</span>       <i>;gap of 100, PC still the same</i>

        <b class="k">.logical</b> <span>$300</span>   <i>;set PC to $300</i>
drive   <b>lda</b> #<span>$80</span>
        <b>sta</b> <span>$00</span>
        <b>jmp</b> <u>drive</u>       <i>;it's jmp $300</i>
	<b>rts</b>
	<b class="k">.here</b>

        <b class="k">.align</b> <span>$100</span>
irq     <b>inc</b> <span>$d019</span>       <i>;this will be on a page boundary, after skipping bytes</i>
        <b class="k">.align</b> <span>4</span>, <span>$ea</span>
loop    <b>adc</b> #<span>1</span>          <i>;padding with "nop" for DTV burst mode</i>
</pre>
<p>Here's an example how <code>.logical</code> and <code>*=</code> works together:</p>
<pre width=80>
        <b>*=</b> <span>$0800</span>       <i>;Compile: $0800, PC: $0800</i>
        <b class="k">.logical</b> <span>$1000</span> <i>;Compile: $0800, PC: $1000</i>
        <b>*=</b> <span>$1200</span>       <i>;Compile: $0a00, PC: $1200</i>
	<b class="k">.here</b>          <i>;Compile: $0a00, PC: $0a00</i>
</pre>

<h3>Dumping data</h3>
<h4>Storing numeric data</h4>
<p>Multi byte numeric data is stored in the little endian order, which is the
natural byte order for 65xx processors. Numeric ranges are enforced depending
on the directives used.</p>
<p>When using lists or tuples their values will be used one by one.
Uninitialized data creates holes of different sizes. Small string constants are
converted using the current encoding.</p>
<dl class="dir">
<dt><b>.byte</b> &lt;expression&gt;[, &lt;expression&gt;, ...]
<dd>Create bytes from 8&nbsp;bit unsigned constants (0 .. 255)
<dt><b>.char</b> &lt;expression&gt;[, &lt;expression&gt;, ...]
<dd>Create bytes from 8&nbsp;bit signed constants (-128 .. 127)
<pre width=80>
        <b class="d">.byte</b> <span>255</span>	<i>; $ff</i>
        <b class="d">.byte</b> <span>?</span>	        <i>; reserve 1 byte of space</i>

<i>;Compact computed jumps using self modifying code</i>
        <b>lda</b> <u>jumps</u>,x
        <b>sta</b> <u>smod</u>+<span>1</span>
smod    <b>bne</b> <u>*</u>

jumps   <b class="d">.char</b> (<u>routine1</u>, <u>routine2</u>)-<u>smod</u>-<span>2</span> <i>;Routines nearby (-128 .. 127 bytes)</i>
</pre>

<dt><b>.word</b> &lt;expression&gt;[, &lt;expression&gt;, ...]
<dd>Create bytes from 16&nbsp;bit unsigned constants (0 .. 65535)
<dt><b>.int</b> &lt;expression&gt;[, &lt;expression&gt;, ...]
<dd>Create bytes from 16&nbsp;bit signed constants (-32768 .. 32767)
<pre width=80>
        <b class="d">.word</b> <span>$2342</span>, <span>$4555</span>
        <b class="d">.word</b> <span>?</span>	        <i>; reserve 2 bytes of space</i>
        <b class="d">.int</b> <span>-533</span>, <span>4433</span>

<i>;Computed jumps with jump table</i>
        <b>lda</b> <u>jumps</u>,x
        <b>sta</b> <u>ind</u>
        <b>lda</b> <u>jumps</u>+<span>1</span>,x
        <b>sta</b> <u>ind</u>+<span>1</span>
        <b>jmp</b> (<u>ind</u>)

<i>;Computed jumps with jump table (65C02)</i>
        <b>jmp</b> (<u>jumps</u>,x)

jumps   <b class="d">.word</b> <u>routine1</u>, <u>routine2</u>
<i>;On 65816 substract the current program bank</i>
jumps2  <b class="d">.word</b> (<u>routine1</u>, <u>routine2</u>) - (<u>*</u> &amp; ~<span>$ffff</span>)
</pre>

<dt><b>.rta</b> &lt;expression&gt;[, &lt;expression&gt;, ...]
<dd>Create return address constants, which are 16&nbsp;bit unsigned
constants (usually addresses) but with one substracted.
<pre width=80>
<i>;Computed jumps by using stack</i>
	<b>asl</b>
	<b>tax</b>
        <b>lda</b> <u>rets</u>+<span>1</span>,x
	<b>pha</b>
        <b>lda</b> <u>rets</u>,x
	<b>pha</b>
	<b>rts</b>
rets	<b class="d">.rta</b> <span>$fce2</span>, <u>routine1</u>, <u>routine2</u>
<i>;On 65816 substract the current program bank</i>
rets2	<b class="d">.rta</b> (<span>$fce2</span>, <u>routine1</u>, <u>routine2</u>) - (<u>*</u> &amp; ~<span>$ffff</span>)
</pre>

<dt><b>.long</b> &lt;expression&gt;[, &lt;expression&gt;, ...]
<dd>Create bytes from 24&nbsp;bit unsigned constants (0 .. 16777215)
<dt><b>.lint</b> &lt;expression&gt;[, &lt;expression&gt;, ...]
<dd>Create bytes from 24&nbsp;bit signed constants (-8388608 .. 8388607)
<pre width=80>
        <b class="d">.long</b> <span>$123456</span>
        <b class="d">.long</b> <span>?</span>	        <i>; reserve 3 bytes of space</i>
        <b class="d">.lint</b> <span>-533</span>, <span>4433</span>

<i>;Computed long jumps with jump table (65816)</i>
        <b>lda</b> <u>jumps</u>,x
        <b>sta</b> <u>ind</u>
        <b>lda</b> <u>jumps</u>+<span>1</span>,x
        <b>sta</b> <u>ind</u>+<span>1</span>
        <b>lda</b> <u>jumps</u>+<span>2</span>,x
        <b>sta</b> <u>ind</u>+<span>2</span>
        <b>jmp</b> [<u>ind</u>]
jumps   <b class="d">.long</b> <u>routine1</u>, <u>routine2</u>
<i>;Store 8.16 signed fixed point constants</i>
        <b class="d">.lint</b> (<span>-3.44</span>, <span>3.4</span>, <span>3.52</span>) * (<span>1</span> &lt;&lt; <span>16</span>)
</pre>

<dt><b>.dword</b> &lt;expression&gt;[, &lt;expression&gt;, ...]
<dd>Create bytes from 32&nbsp;bit constants (0 .. 4294967295)
<dt><b>.dint</b> &lt;expression&gt;[, &lt;expression&gt;, ...]
<dd>Create bytes from 32&nbsp;bit signed constants (-2147483648 .. 2147483647)
<pre width=80>
        <b class="d">.dword</b> <span>$12345678</span>
        <b class="d">.dword</b> <span>?</span>        <i>; reserve 4 bytes of space</i>
<i>;Store 8.24 signed fixed point constants</i>
        <b class="d">.dint</b> (<span>-3.44</span>, <span>3.4</span>, <span>3.52</span>) * (<span>1</span> &lt;&lt; <span>24</span>)
</pre>

<dt><b>.fill</b> &lt;length&gt;[, &lt;fill&gt;]
<dd>Skip bytes (using uninitialized data), or fill with repeated bytes. For multi byte patterns use <code>.rept</code>!
<pre width=80>
        <b class="d">.fill</b> <span>$100</span>      <i>;no fill, just reserve $100 bytes</i>
        <b class="d">.fill</b> <span>$4000</span>, <span>0</span>  <i>;16384 bytes of 0</i>
</pre>
</dl>

<h4>Storing text data</h4>
<p>Texts are stored as a string of bytes. Small numeric constants can be mixed
in to represent control characters.</p>
<dl class="dir">
<dt><b>.text</b> &lt;expression&gt;[, &lt;expression&gt;, ...]
<dd>Assemble strings and small constants into bytes:
<pre width=80>
        <b class="d">.text</b> <span class="s">"oeU"</span>	<i>; text, "" means $22</i>
        <b class="d">.text</b> <span class="s">'oeU'</span>	<i>; text, '' means $27</i>
        <b class="d">.text</b> <span>23</span>, <span>$33</span>	<i>; bytes</i>
        <b class="d">.text</b> <span>%00011111</span>	<i>; more bytes</i>
        <b class="d">.text</b> ^<u>OEU</u>	<i>; the decimal value as string (^23 is $32,$33)</i>
</pre>

<dt><b>.shift</b> &lt;expression&gt;[, &lt;expression&gt;, ...]
<dd>Same as <code>.text</code>, but the last byte will have the highest bit set.
Any character which already has the most significiant bit set will cause an error.
<pre width=80>
        <b>ldx</b> #<span>0</span>
loop	<b>lda</b> <u>txt</u>,x
	<b>php</b>
        <b>and</b> #<span>$7f</span>
        <b>jsr</b> <span>$ffd2</span>
	<b>inx</b>
	<b>plp</b>
        <b>bpl</b> <u>loop</u>
	<b>rts</b>
txt	<b class="d">.shift</b> <span class="s">"some text"</span>
</pre>

<dt><b>.shiftl</b> &lt;expression&gt;[, &lt;expression&gt;, ...]
<dd>Same as <code>.text</code>, but all bytes are shifted to left, and the last
character gets the lowest bit set. Any character which already has the most significiant
bit set will cause an error as this would be cut off.
<pre width=80>
        <b>ldx</b> #<span>0</span>
loop	<b>lda</b> <u>txt</u>,x
	<b>lsr</b>
        <b>sta</b> <span>$400</span>,x      <i>;screen memory</i>
	<b>inx</b>
        <b>bcc</b> <u>loop</u>
	<b>rts</b>
	<b class="k">.enc</b> screen
txt	<b class="d">.shiftl</b> <span class="s">"some text"</span>
	<b class="k">.enc</b> none
</pre>

<dt><b>.null</b> &lt;expression&gt;[, &lt;expression&gt;, ...]
<dd>Same as <code>.text</code>, but adds a null at the end, null in string is an error.
<pre width=80>
txt	<b class="d">.text</b> <span class="s">"lot of stuff"</span>
        <b class="d">.null</b> <span class="s">"to write"</span>
        <b>lda</b> #&lt;<u>txt</u>
        <b>ldy</b> #&gt;<u>txt</u>
        <b>jsr</b> <span>$ab1e</span>
</pre>

<dt><b>.ptext</b> &lt;expression&gt;[, &lt;expression&gt;, ...]
<dd>Same as <code>.text</code>, but prepend the
number of bytes in front of the string (pascal style string). Longer than 255 bytes are not allowed.
<pre width=80>
        <b>lda</b> #&lt;<u>txt</u>
        <b>ldx</b> #&gt;<u>txt</u>
        <b>jsr</b> <u>print</u>
	<b>rts</b>

print	<b>sta</b> <span>$fb</span>
        <b>stx</b> <span>$fc</span>
        <b>ldy</b> #<span>0</span>
        <b>lda</b> (<span>$fb</span>),y
        <b>beq</b> <u>null</u>
	<b>tax</b>
-	<b>iny</b>
        <b>lda</b> (<span>$fb</span>),y
        <b>jsr</b> <span>$ffd2</span>
	<b>dex</b>
	<b>bne</b> -
null	<b>rts</b>

txt	<b class="d">.ptext</b> <span class="s">"note"</span>
</pre>
</dl>

<h3>Text encoding</h3>
<p>64tass supports sources written in utf8, utf16 (be/le) and raw 8-bit encoding. To take
advantage of this capability custom encodings can be defined to map unicode characters
to 8&nbsp;bit values in strings.</p>
<dl class="dir">
<dt><b>.enc</b> &lt;name&gt;
<dd>Selects text encoding, predefined encodings are <q>none</q> and
<q>screen</q> (screen code), anything else is user defined. All user encodings
start without any character or escape definitions, add some as required.
</dl>
<pre width=80>
	<b class="k">.enc</b> screen	<i>;screencode mode</i>
        <b class="d">.text</b> <span class="s">"text with screencodes"</span>
        <b>cmp</b> #<span class="s">"u"</span>	<i>;compare screencode</i>
	<b class="k">.enc</b> none	<i>;normal mode again</i>
        <b>cmp</b> #<span class="s">"u"</span>	<i>;compare ascii</i>
</pre>
<dl class="dir">
<dt><b>.cdef</b> &lt;start&gt;, &lt;end&gt;, &lt;coded&gt; [, &lt;start&gt;, &lt;end&gt;, &lt;coded&gt;, ...]
<dt><b>.cdef</b> "&lt;start&gt;&lt;end&gt;", &lt;coded&gt; [, "&lt;start&gt;&lt;end&gt;", &lt;coded&gt;, ...]
<dd>Defines a character range, and assigns all characters one by one from the 8&nbsp;bit value.
The start and end positions are unicode character codes either by numbers or by typing them.
<dt><b>.edef</b> "&lt;escapetext&gt;", &lt;code&gt; [, "&lt;escapetext&gt;", &lt;code&gt;, ...]
<dd>Defines an escape sequence, and assigns it to a 8&nbsp;bit value. When using
common prefixes the longest match wins. Useful for defining non-typeable control code aliases.
</dl>
<pre width=80>
        <b class="k">.enc</b> petscii	<i>;define an ascii->petscii encoding</i>
        <b class="k">.cdef</b> <span class="s">" @"</span>, <span>32</span>  <i>;characters</i>
        <b class="k">.cdef</b> <span class="s">"AZ"</span>, <span>$c1</span>
        <b class="k">.cdef</b> <span class="s">"az"</span>, <span>$41</span>
        <b class="k">.cdef</b> <span class="s">"[["</span>, <span>$5b</span>
        <b class="k">.cdef</b> <span class="s">"&pound;&pound;"</span>, <span>$5c</span>
        <b class="k">.cdef</b> <span class="s">"]]"</span>, <span>$5d</span>
        <b class="k">.cdef</b> <span class="s">"&pi;&pi;"</span>, <span>$5e</span>
        <b class="k">.cdef</b> <span>$2190</span>, <span>$2190</span>, <span>$1f</span><i>;left arrow</i>

        <b class="k">.edef</b> <span class="s">"\n"</span>, <span>13</span>  <i>;escape sequences</i>
        <b class="k">.edef</b> <span class="s">"{clr}"</span>, <span>147</span>

        <b class="d">.text</b> <span class="s">"<span>{clr}</span>Text in PETSCII<span>\n</span>"</span>
</pre>

<h3>Structured data</h3>

<p>Structures and unions can be defined to create complex data types. The
offset of fields are available by using the definition's name. The fields
themselves by using the instance name.</p>

<p>The initialization method is very similar to macro parameters, the
difference is that unset parameters always return uninitialized data (<q>?</q>)
instead of an error.</p>

<h4>Structure</h4>
<p>Structures are for organizing sequential data, so the length of a structure
is the sum of lengths of all items.</p>

<dl class="dir">
<dt><b>.struct</b> [&lt;name&gt;][=&lt;default&gt;]][,[&lt;name&gt;][=&lt;default&gt;] ...]
<dt><b>.ends</b> [&lt;result&gt;][,&lt;result&gt; ...]
<dd>Structure definition, with named parameters and default values
<dt><b>.dstruct</b> &lt;name&gt;[,&lt;initialization values&gt;]
<dt><b>.&lt;name&gt;</b> [&lt;initialization values&gt;]
<dd>Create instance of structure with initialization values
</dl>

<pre width=80>
        <b class="k">.struct</b>         <i>;anonymous struct</i>
x       <b class="d">.byte</b> <span>0</span>         <i>;labels are visible</i>
y       <b class="d">.byte</b> <span>0</span>         <i>;content compiled here</i>
        <b class="k">.ends</b>           <i>;useful inside unions</i>

nn_s    <b class="k">.struct</b> <u>col</u>,<u>row</u> <i>;named struct</i>
x       <b class="d">.byte</b> <span class="k">\col</span>      <i>;labels are not visible</i>
y       <b class="d">.byte</b> <span class="k">\row</span>      <i>;no content is compiled here</i>
        <b class="k">.ends</b>           <i>;it's just a definition</i>

nn      <b class="d">.dstruct</b> <u>nn_s</u>,<span>1</span>,<span>2</span><i>;struct instance, content here</i>

        <b>lda</b> <u>nn</u>.<u>x</u>        <i>;direct field access</i>
        <b>ldy</b> #<u>nn_s</u>.<u>x</u>     <i>;get offset of field</i>
        <b>lda</b> <u>nn</u>,y        <i>;and use it indirectly</i>
</pre>

<h4>Union</h4>
<p>Unions can be used for overlapping data as the compile offset and program
counter remains the same on each line. Therefore the length of a union is the
length of it's longest item.</p>

<dl class="dir">
<dt><b>.union</b> [&lt;name&gt;][=&lt;default&gt;]][,[&lt;name&gt;][=&lt;default&gt;] ...]
<dt><b>.endu</b>
<dd>Union definition, with named parameters and default values
<dt><b>.dunion</b> &lt;name&gt;[,&lt;initialization values&gt;]
<dt><b>.&lt;name&gt;</b> [&lt;initialization values&gt;]
<dd>Create instance of union with initialization values
</dl>

<pre width=80>
        <b class="k">.union</b>          <i>;anonymous union</i>
x       <b class="d">.byte</b> <span>0</span>         <i>;labels are visible</i>
y       <b class="d">.word</b> <span>0</span>         <i>;content compiled here</i>
	<b class="k">.endu</b>

nn_u    <b class="k">.union</b>          <i>;named union</i>
x       <b class="d">.byte</b> <span>?</span>         <i>;labels are not visible</i>
y       <b class="d">.word</b> <span class="k">\1</span>        <i>;no content is compiled here</i>
        <b class="k">.endu</b>           <i>;it's just a definition</i>

nn      <b class="d">.dunion</b> <u>nn_u</u>,<span>1</span>  <i>;union instance here</i>

        <b>lda</b> <u>nn</u>.<u>x</u>        <i>;direct field access</i>
        <b>ldy</b> #<u>nn_u</u>.<u>x</u>     <i>;get offset of field</i>
        <b>lda</b> <u>nn</u>,y        <i>;and use it indirectly</i>
</pre>

<h4>Combined use of structures and unions</h4>
<p>The example below shows how to define structure to a binary include.</p>

<pre width=80>
        <b class="k">.union</b>
        <b class="d">.binary</b> <span class="s">"pic.drp"</span>,<span>2</span>
        <b class="k">.struct</b>
color	<b class="d">.fill</b> <span>1024</span>
screen	<b class="d">.fill</b> <span>1024</span>
bitmap	<b class="d">.fill</b> <span>8000</span>
backg	<b class="d">.byte</b> <span>?</span>
        <b class="k">.ends</b>
	<b class="k">.endu</b>
</pre>

<p>Anonymous structures and unions in combination with sections are useful for
overlapping memory assignment. The example below shares zeropage allocations
for two separate parts of a bigger program. The common subroutine variables
are assigned after in the <q>zp</q> section.</p>

<pre width=80>
        <b>*=</b> <span>$02</span>
        <b class="k">.union</b>          <i>;spare some memory</i>
         <b class="k">.struct</b>
          <b class="d">.dsection</b> <u>zp1</u> <i>;declare zp1 section</i>
         <b class="k">.ends</b>
         <b class="k">.struct</b>
          <b class="d">.dsection</b> <u>zp2</u> <i>;declare zp2 section</i>
         <b class="k">.ends</b>
        <b class="k">.endu</b>
        <b class="d">.dsection</b> <u>zp</u>    <i>;declare zp section</i>
</pre>

<h3>Macros</h3>
<p>Macros can be used to reduce typing of frequently used source lines.
Each invocation is a copy of the macro's content with parameter references
replaced by the parameter texts.</p>

<dl class="dir">
<dt><b>.segment</b> [&lt;name&gt;][=&lt;default&gt;]][,[&lt;name&gt;][=&lt;default&gt;] ...]
<dt><b>.endm</b> [&lt;result&gt;][,&lt;result&gt; ...]
<dd>Copies the code segment as it is, so symbols can be used from
outside, but this also means multiple use will result in double defines
unless anonymous labels are used.
<dt><b>.macro</b> [&lt;name&gt;][=&lt;default&gt;]][,[&lt;name&gt;][=&lt;default&gt;] ...]
<dt><b>.endm</b> [&lt;result&gt;][,&lt;result&gt; ...]
<dd>The code is enclosed in it's own block so symbols inside are
non-accessible, unless a label is prefixed at the place of use, then local
labels can be accessed through that label.
<dt><b>#&lt;name&gt;</b> [&lt;param&gt;][[,][&lt;param&gt;] ...]
<dt><b>.&lt;name&gt;</b> [&lt;param&gt;][[,][&lt;param&gt;] ...]
<dd>Invoke the macro after <q>#</q> or <q>.</q> with the parameters. Normally the name of
the macro is used, but it can be any expression.
</dl>

<pre width=80>
;<i>A simple macro</i>
copy    <b class="k">.macro</b>
        <b>ldx</b> #<span class="k">size</span>(<span class="k">\1</span>)
lp      <b>lda</b> <span class="k">\1</span>,x
        <b>sta</b> <span class="k">\2</span>,x
	<b>dex</b>
        <b>bpl</b> <u>lp</u>
	<b class="k">.endm</b>

        <b class="k">#copy</b> <u>label</u>, <span>$500</span>

;<i>Use macro as an assembler directive</i>
lohi    <b class="k">.macro</b>
lo	<b class="d">.byte</b> &lt;(<span class="k">\@</span>)
hi	<b class="d">.byte</b> &gt;(<span class="k">\@</span>)
        <b class="k">.endm</b>

var     <b class="k">.lohi</b> <span>1234</span>, <span>5678</span>

        <b>lda</b> <u>var</u>.<u>lo</u>,y
        <b>ldx</b> <u>var</u>.<u>hi</u>,y
</pre>

<h4>Parameter references</h4>
<p>The first 9 parameters can be referenced by <code>\1</code>...<code>\9</code>.
The entire parameter list including separators is <code>\@</code>.</p>
<pre width=80>
name	<b class="k">.macro</b>
        <b>lda</b> #<span class="k">\1</span> 	<i>;first parameter 23+1</i>
	<b class="k">.endm</b>

        <b class="k">#name</b> <span>23</span>+<span>1</span>	<i>;call macro</i>
</pre>

<p>Parameters can be named, and it's possible to set a default value after an
equal sign which is used as a replacement when the parameter is missing.</p>

<p>These named parameters can be referenced by <code>\name</code> or
<code>\{name}</code>. Names must match completely, if unsure use the quoted
name reference syntax.</p>
<pre width=80>
name	<b class="k">.macro</b> first,b=<span>2</span>,,last
        <b>lda</b> #<span class="k">\first</span>	<i>;first parameter</i>
        <b>lda</b> #<span class="k">\b</span> 	<i>;second parameter</i>
        <b>lda</b> #<span class="k">\3</span> 	<i>;third parameter</i>
        <b>lda</b> #<span class="k">\last</span> 	<i>;fourth parameter</i>
	<b class="k">.endm</b>

        <b class="k">#name</b> <span>1</span>, , <span>3</span>, <span>4</span>	<i>;call macro</i>
</pre>

<h4>Text references</h4>
<p>In the original turbo assembler normal references are passed by value and
can only appear in place of one. Text references on the other hand can appear
everywhere and will work in place of eg quoted text or opcodes and labels. The
first 9 parameters can be referenced as text by
<code>@1</code>...<code>@9</code>.</p>
<pre width=80>
name    <b class="k">.macro</b>
        <b>jsr</b> <u>print</u>
        <b class="d">.null</b> <span class="s">"Hello <span>@1</span>!"</span><i>;first parameter</i>
	<b class="k">.endm</b>

        <b class="k">#name</b> <span class="s">"wth?"</span>	<i>;call macro</i>
</pre>

<h3>Custom functions</h3>
<p>Beyond the built in functions mentioned earlier it's possible to define
custom ones for frequently used calculations.</p>

<dl class="dir">
<dt><b>.function</b> &lt;name&gt;[=&lt;default&gt;]][,&lt;name&gt;[=&lt;default&gt;] ...]
<dt><b>.endf</b> [&lt;result&gt;][,&lt;result&gt; ...]
<dd>Defines a user function
<dt><b>#&lt;name&gt;</b> [&lt;param&gt;][[,][&lt;param&gt;] ...]
<dt><b>.&lt;name&gt;</b> [&lt;param&gt;][[,][&lt;param&gt;] ...]
<dt><b>&lt;name&gt;</b> [&lt;param&gt;][[,][&lt;param&gt;] ...]
<dd>Invoke a function like a macro, directive or pseudo instruction.
</dl>

<p>Parameters are assigned to constant references. It's possible to use less
parameters if the missing ones have a default value, but more parameters are
not accepted. Multiple values are returned as a tuple.</p>
<p>Functions can span multiple lines but unlike macros they can't create new
code. Only those external variables and functions are available which were
accessible at the place of definition, but not those at the place of
invocation.</p>
<pre width=80>
wpack   <b class="k">.function</b> <u>a</u>,<u>b</u>=<span>0</span>
        <b class="k">.endf</b> <u>a</u>+<u>b</u>*<span>256</span>

        <b class="d">.word</b> <span class="k">wpack</span>(<span>1</span>), <span class="k">wpack</span>(<span>2</span>,<span>3</span>)
</pre>

<p>If a function is used as macro, directive or pseudo instruction and there's
a label in front then the returned value is assigned to it. If nothing is
returned then it's used as regular label. Of course when used like this it can
create code and access local variables.</p>

<pre width=80>
mva     <b class="k">.function</b> <u>s</u>,<u>d</u>
        <b>lda</b> <u>s</u>
        <b>sta</b> <u>d</u>
        <b class="k">.endf</b>

        <b class="k">mva</b> #<span>1</span>, <u>label</u>
</pre>

<h3>Conditional assembly</h3>
<p>To prevent parts of source from compiling conditional constructs can be
used. This is useful when multiple slightly different versions needs to be
compiled from the same source.</p>
<h4>If, elsif, else</h4>
<dl class="dir">
<dt><b>.if</b> &lt;expression&gt;
<dd>Compile, if result is true (not zero)
<dt><b>.elsif</b> &lt;expression&gt;
<dd>Compile if the previous conditions were all skipped and the result is true (not zero)
<dt><b>.else</b>
<dd>Compile if the previous conditions were all skipped
<dt><b>.fi</b>
<dt><b>.endif</b>
<dd>End of conditional compile
<dt><b>.ifne</b> &lt;value&gt;
<dd>Compile, if value is not zero (or true)
<dt><b>.ifeq</b> &lt;value&gt;
<dd>Compile, if value is zero (or false)
<dt><b>.ifpl</b> &lt;value&gt;
<dd>Compile, if value is greater or equal zero
<dt><b>.ifmi</b> &lt;value&gt;
<dd>Compile, if value is less than zero
</dl>

<p>The <code>.ifne</code>, <code>.ifeq</code>, <code>.ifpl</code> and
<code>.ifmi</code> directives exists for compatibility only, in practice it's
better to use comparison operators instead.</p>

<pre width=80>
        <b class="k">.if</b> <u>wait</u>==<span>2</span>	<i>;2 cycles</i>
	<b>nop</b>
        <b class="k">.elsif</b> <u>wait</u>==<span>3</span>	<i>;3 cycles</i>
        <b>bit</b> <span>$ea</span>
        <b class="k">.elsif</b> <u>wait</u>==<span>4</span>	<i>;4 cycles</i>
        <b>bit</b> <span>$eaea</span>
        <b class="k">.else</b>		<i>;else 5 cycles</i>
        <b>inc</b> <span>$2</span>
	<b class="k">.fi</b>
</pre>

<h4>Switch, case, default</h4>
<p>Similar to the <code>.if</code>/<code>.elsif</code>/<code>.else</code>
construct, but the compared value needs to be written only once in the switch
statement.</p>

<dl class="dir">
<dt><b>.switch</b> &lt;expression&gt;
<dd>Evaluate expression and remember it
<dt><b>.case</b> &lt;expression&gt;[,&lt;expression&gt; ...]
<dd>Compile if the previous conditions were all skipped and one of the values equals
<dt><b>.default</b>
<dd>Compile if the previous conditions were all skipped
<dt><b>.endswitch</b>
<dd>End of conditional compile
</dl>

<pre width=80>
        <b class="k">.switch</b> <u>wait</u>
        <b class="k">.case</b> <span>2</span>	        <i>;2 cycles</i>
	<b>nop</b>
        <b class="k">.case</b> <span>3</span>	        <i>;3 cycles</i>
        <b>bit</b> <span>$ea</span>
        <b class="k">.case</b> <span>4</span>	        <i>;4 cycles</i>
        <b>bit</b> <span>$eaea</span>
        <b class="k">.default</b>	<i>;else 5 cycles</i>
        <b>inc</b> <span>$2</span>
	<b class="k">.endswitch</b>
</pre>

<h3>Repetitions</h3>
<dl class="dir">
<dt><b>.for</b> &lt;variable&gt;=&lt;expression&gt;,&lt;expression&gt;,&lt;variable&gt;=&lt;expression&gt;
<dt><b>.next</b>
<dd>Compile loop, only anonymous references are allowed as labels inside
<pre width=80>
        <b>ldx</b> #<span>0</span>
        <b>lda</b> #<span>32</span>
lp      <b class="k">.for</b> <u>ue</u> = <span>0</span>, <u>ue</u> &lt; <span>$400</span>, <u>ue</u>=<u>ue</u>+<span>$100</span>
        <b>sta</b> <u>ue</u>,x
	<b class="k">.next</b>
        <b>dex</b>
        <b>bne</b> <u>lp</u>
</pre>

<dt><b>.rept</b> &lt;expression&gt;
<dt><b>.next</b>
<dd>Repeated compile, only anonymous references are allowed as labels inside
<pre width=80>
        <b class="k">.rept</b> <span>100</span>
	<b>nop</b>
	<b class="k">.next</b>
</pre>

<dt><b>.lbl</b>
<dd>Creates a special jump label that can be referenced by <code>.goto</code>
<dt><b>.goto</b> &lt;labelname&gt;
<dd>Causes assembler to continue assembling from the jump label. No
forward references of course, handle with care. Typically used in
classic TASM sources for creating loops.

<pre width=80>
i	<b class="k">.var</b> <span>100</span>
loop	<b class="k">.lbl</b>
        <b>nop</b>
i       <b class="k">.var</b> <u>i</u> - <span>1</span>
        <b class="k">.ifne</b> <u>i</u>
        <b class="k">.goto</b> <u>loop</u>       <i>;generates 100 nops</i>
        <b class="k">.fi</b>
</pre>

</dl>
<h3>Including files</h3>

<p>Longer sources are usually separated into multiple files for easier
handling. Precomputed binary data can also be included directly without
converting it into source code first.</p>

<p>Search path is relative to the location of current source file. If it's not
found there the include search path is consulted for further possible
locations.</p>

<p>To make your sources portable please always use forward slashes
(<code>/</code>) as a directory separator and use lower/uppercase consistently
in filenames!</p>

<dl class="dir">
<dt><b>.include</b> &lt;filename&gt;
<dd>Include source file here.
<dt><b>.binclude</b> &lt;filename&gt;
<dd>Include source file here in it's local block. If the directive is prefixed
with a label then all labels are local and are accessible through that label
only, otherwise not reachable at all.
<pre width=80>

	<b class="k">.include</b> <span class="s">"macros.asm"</span>       <i>;include macros</i>
menu    <b class="k">.binclude</b> <span class="s">"menu.asm"</span>        <i>;include in a block</i>
	<b>jmp</b> <u>menu</u>.<u>start</u>
</pre>

<dt><b>.binary</b> &lt;filename&gt;[, &lt;offset&gt;[, &lt;length&gt;]]
<dd>Include raw binary data from file. By using offset and length it's possible to break out chunks of data from a
file separately, like bitmap and colors for example.
<pre width=80>
        <b class="d">.binary</b> <span class="s">"stuffz.bin"</span>        <i>;simple include, all bytes</i>
        <b class="d">.binary</b> <span class="s">"stuffz.bin"</span>,<span>2</span>      <i>;skip start address</i>
        <b class="d">.binary</b> <span class="s">"stuffz.bin"</span>,<span>2</span>,<span>1000</span> <i>;skip start address, 1000 bytes max</i>

        <b>*=</b> <span>$1000</span>	            <i>;load music to $1000 and</i>
        <b class="d">.binary</b> <span class="s">"music.sid"</span>,<span>$7e</span>     <i>;strip SID header</i>
</pre>

</dl>
<h3>Blocks</h3>
<dl class="dir">
<dt><b>.proc</b>
<dt><b>.pend</b>
<dd>Procedure start and end of procedure. If it's label is not used then
the code won't be compiled at all!  All labels inside are local and are
accessible through the prefixed label. Useful for building libraries.
<pre width=80>
ize     <b class="k">.proc</b>
	<b>nop</b>
cucc    <b>nop</b>
	<b class="k">.pend</b>

        <b>jsr</b> <u>ize</u>
        <b>jmp</b> <u>ize</u>.<u>cucc</u>
</pre>

<dt><b>.block</b>
<dt><b>.bend</b>
<dd>Block start and block end. All labels inside a block are local. If prefixed
with a label local variables are accessible through that label, otherwise not
at all.
<pre width=80>
	<b class="k">.block</b>
        <b>inc</b> <u>count</u> + <span>1</span>
count	<b>ldx</b> #<span>0</span>
	<b class="k">.bend</b>
</pre>

<dt><b>.comment</b>
<dt><b>.endc</b>
<dd>Comment block start and comment block end.
<pre width=80>
	<b class="k">.comment</b>
<i>        lda #1          ;this won't be compiled</i>
<i>	sta $d020</i>
	<b class="k">.endc</b>
</pre>
</dl>

<h3>Sections</h3>

<p>Sections can be used to collect data or code into separate memory areas
without moving source code lines around. This is achieved by having separate
compile offset and program counters for each defined section.</p>

<dl class="dir">
<dt><b>.section</b> &lt;name&gt;
<dt><b>.send</b> [&lt;name&gt;]
<dd>Defines a section fragment. The name at <code>.send</code> must match but
it's optional.
<dt><b>.dsection</b> &lt;name&gt;
<dd>Collect the section fragments here.
</dl>

<p>All <code>.section</code> fragments are compiled to the memory area
allocated by the <code>.dsection</code> directive. Compilation happens as the
code appears, this directive only assigns enough space to hold all the content
in the section fragments.</p>

<p>The space used by section fragments is calculated from the difference of
starting compile offset and the maximum compile offset reached. It is possible
to manipulate the compile offset in fragments, but putting code before the
start of <code>.dsection</code> is not allowed.</p>

<pre width=80>
        <b>*=</b> <span>$02</span>
        <b class="d">.dsection</b> <u>zp</u>   <i>;declare zeropage section</i>
        <b class="k">.cerror</b> *&gt;<span>$30</span>,<span class="s">"Too many zeropage variables"</span>

        <b>*=</b> <span>$334</span>
        <b class="d">.dsection</b> <u>bss</u>   <i>;declare uninitialized variable section</i>
        <b class="k">.cerror</b> *&gt;<span>$400</span>,<span class="s">"Too many variables"</span>

        <b>*=</b> <span>$0801</span>
        <b class="d">.dsection</b> <u>code</u>   <i>;declare code section</i>
        <b class="k">.cerror</b> *&gt;<span>$1000</span>,<span class="s">"Program too long!"</span>

        <b>*=</b> <span>$1000</span>
        <b class="d">.dsection</b> <u>data</u>   <i>;declare data section</i>
        <b class="k">.cerror</b> *&gt;<span>$2000</span>,<span class="s">"Data too long!"</span>
<i>;--------------------</i>
        <b class="k">.section</b> <u>code</u>
        <b class="d">.word</b> <u>ss</u>, <span>2005</span>
        <b class="d">.null</b> <span>$9e</span>, ^<u>start</u>
ss	<b class="d">.word</b> <span>0</span>

start   <b>sei</b>
        <b class="k">.section</b> <u>zp</u>     <i>;declare some new zeropage variables</i>
p2	<b class="d">.word</b> <span>?</span>         <i>;a pointer</i>
        <b class="k">.send</b> <u>zp</u>
        <b class="k">.section</b> <u>bss</u>    <i>;new variables</i>
buffer	<b class="d">.fill</b> <span>10</span>        <i>;temporary area</i>
        <b class="k">.send</b> <u>bss</u>

        <b>lda</b> (<u>p2</u>),y
        <b>lda</b> #&lt;<u>label</u>
        <b>ldy</b> #&gt;<u>label</u>
        <b>jsr</b> <u>print</u>

        <b class="k">.section</b> <u>data</u>   <i>;some data</i>
label   <b class="d">.null</b> <span class="s">"message"</span>
        <b class="k">.send</b> <u>data</u>

        <b>jmp</b> <u>error</u>
        <b class="k">.section</b> <u>zp</u>     <i>;declare some more zeropage variables</i>
p3	<b class="d">.word</b> <span>?</span>         <i>;a pointer</i>
        <b class="k">.send</b> <u>zp</u>
        <b class="k">.send</b> <u>code</u>
</pre>
<p>The compiled code will look like:</p>
<pre width=80>
&gt;0801	 0b 08 d5 07			        .word ss, 2005   
&gt;0805	 9e 32 30 36 31 00		        .null $9e, ^start
&gt;080b	 00 00				ss      .word 0          

.080d	 78				start   sei

&gt;0002					p2      .word ?         ;a pointer
&gt;0334					buffer  .fill 10        ;temporary area

.080e	 b1 02				        lda (p2),y
.0810	 a9 00				        lda #&lt;label
.0812	 a0 10				        ldy #&gt;label
.0814	 20 1e ab			        jsr print

&gt;1000	 6d 65 73 73 61 67 65 00	label   .null "message"

.0817	 4c e2 fc			        jmp error

&gt;0004					p2      .word ?         ;a pointer
</pre>

<p>Sections can form a hierarchy by nesting a <code>.dsection</code> into
another section. The section names must only be unique within a section but can
be reused otherwise. Parent section names are visible for children, siblings can be
reached through parents.</p>

<p>In the following example the included sources don't have to know which
<q>code</q> and <q>data</q> sections they use, while the <q>bss</q> section is
shared for all banks.</p>

<pre width=80>
<i>;First 8K bank at the beginning, PC at $8000</i>
        <b>*=</b> <span>$0000</span>
        <b class="k">.logical</b> <span>$8000</span>
        <b class="d">.dsection</b> <u>bank1</u>
        <b class="k">.cerror</b> *&gt;<span>$a000</span>, <span class="s">"Bank1 too long"</span>
	<b class="k">.here</b>

bank1	<b class="k">.block</b>          <i>;Make all symbols local</i>
        <b class="k">.section</b> <u>bank1</u>
        <b class="d">.dsection</b> <u>code</u>  <i>;Code and data sections in bank1</i>
        <b class="d">.dsection</b> <u>data</u>
        <b class="k">.section</b> <u>code</u>   <i>;Pre-open code section</i>
	<b class="k">.include</b> <span class="s">"code.asm"</span><i>; see below</i>
	<b class="k">.include</b> <span class="s">"iter.asm"</span>
        <b class="k">.send</b> <u>code</u>
        <b class="k">.send</b> <u>bank1</u>
	<b class="k">.bend</b>

<i>;Second 8K bank at $2000, PC at $8000</i>
        <b>*=</b> <span>$2000</span>
        <b class="k">.logical</b> <span>$8000</span>
        <b class="d">.dsection</b> <u>bank2</u>
        <b class="k">.cerror</b> *&gt;<span>$a000</span>, <span class="s">"Bank2 too long"</span>
	<b class="k">.here</b>

bank2	<b class="k">.block</b>          <i>;Make all symbols local</i>
        <b class="k">.section</b> <u>bank2</u>
        <b class="d">.dsection</b> <u>code</u>  <i>;Code and data sections in bank2</i>
        <b class="d">.dsection</b> <u>data</u>
        <b class="k">.section</b> <u>code</u>   <i>;Pre-open code section</i>
	<b class="k">.include</b> <span class="s">"scr.asm"</span>
        <b class="k">.send</b> <u>code</u>
        <b class="k">.send</b> <u>bank2</u>
	<b class="k">.bend</b>

<i>;Common data, avoid initialized variables here!</i>
        <b>*=</b> <span>$c000</span>
        <b class="d">.dsection</b> <u>bss</u>
        <b class="k">.cerror</b> *&gt;<span>$d000</span>, <span class="s">"Too much common data"</span>
<i>;------------- The following is in "code.asm"</i>
code    <b>sei</b>

        <b class="k">.section</b> <u>bss</u>   <i>;Common data section</i>
buffer	<b class="d">.fill</b> <span>10</span>
        <b class="k">.send</b> <u>bss</u>

        <b class="k">.section</b> <u>data</u>  <i>;Data section (in bank1)</i>
routine <b class="d">.word</b> <u>print</u>
        <b class="k">.send</b> <u>bss</u>
</pre>

<h3>65816 related</h3>
<dl class="dir">
<dt><b>.as</b>
<dt><b>.al</b>
<dd>Select short (8&nbsp;bit) or long (16&nbsp;bit) accumulator immediate constants.

<pre width=80>
	<b class="k">.al</b>
        <b>lda</b> #<span>$4322</span>
</pre>

<dt><b>.xs</b>
<dt><b>.xl</b>
<dd>Select short (8&nbsp;bit) or long (16&nbsp;bit) index register immediate constants.
<pre width=80>
	<b class="k">.xl</b>
        <b>ldx</b> #<span>$1000</span>
</pre>

<dt><b>.databank</b> &lt;expression&gt;
<dd>Set databank (65816). Absolute addressing is used only for symbols in this
bank, anything else (except direct page) is using long addressing.
<pre width=80>
        <b class="k">.databank</b> <span>$10</span>   <i>;$10xxxx</i>
</pre>

<dt><b>.dpage</b> &lt;expression&gt;
<dd>Set directpage. Direct or zero page addressing is only used for addresses
in the following 256 byte range, anything else is using absolute or long
addressing.
<pre width=80>
        <b class="k">.dpage</b> <span>$400</span>
</pre>

</dl>
<h3>Controlling errors</h3>
<dl class="dir">

<dt><b>.page</b>
<dt><b>.endp</b>
<dd>Gives an error on page boundary crossing, eg. for timing sensitive code.

<pre width=80>
	<b class="k">.page</b>
table   <b class="d">.byte</b> <span>0</span>,<span>1</span>,<span>2</span>,<span>3</span>,<span>4</span>,<span>5</span>,<span>6</span>,<span>7</span>
	<b class="k">.endp</b>
</pre>

<dt><b>.option</b> allow_branch_across_page
<dd>Switches error generation on page boundary crossing during relative branch.
Such a condition on 6502 adds 1 extra cycle to the execution time, which
can ruin the timing of a carefuly cycle counted code.
<pre width=80>
        <b class="k">.option</b> allow_branch_across_page = <span>0</span>
        <b>ldx</b> #<span>3</span>          <i>;now this will execute in</i>
-       <b>dex</b>             <i>;16 cycles for sure</i>
	<b>bne</b> -
        <b class="k">.option</b> allow_branch_across_page = <span>1</span>
</pre>

<dt><b>.error</b> &lt;message&gt; [, &lt;message&gt;, ...]
<dt><b>.cerror</b> &lt;condition&gt;, &lt;message&gt; [, &lt;message&gt;, ...]
<dd>Exit with error or conditionally exit with error
<pre width=80>
        <b class="k">.error</b> <span class="s">"Unfinished here..."</span>
        <b class="k">.cerror</b> *&gt;<span>$1200</span>, <span class="s">"Program too long by "</span>, *-<span>$1200</span>, <span class="s">" bytes"</span>
</pre>

<dt><b>.warn</b> &lt;message&gt; [, &lt;message&gt;, ...]
<dt><b>.cwarn</b> &lt;condition&gt;, &lt;message&gt; [, &lt;message&gt;, ...]
<dd>Display a warning message always or depending on a condition
<pre width=80>
        <b class="k">.warn</b> <span class="s">"FIXME: handle negative values too!"</span>
        <b class="k">.cwarn</b> *&gt;<span>$1200</span>, <span class="s">"This may not work!"</span>
</pre>

</dl>
<h3>Target</h3>
<dl class="dir">

<dt><b>.cpu</b> &lt;cpuname&gt;
<dd>Selects cpu
<pre width=80>
	<b class="k">.cpu</b> 6502	<i>;standard 65xx</i>
	<b class="k">.cpu</b> 65c02	<i>;CMOS 65C02</i>
	<b class="k">.cpu</b> 65ce02	<i>;CSG 65CE02</i>
	<b class="k">.cpu</b> 6502i	<i>;NMOS 65xx</i>
	<b class="k">.cpu</b> 65816	<i>;W65C816</i>
	<b class="k">.cpu</b> 65dtv02	<i>;65dtv02</i>
	<b class="k">.cpu</b> 65el02	<i>;65el02</i>
	<b class="k">.cpu</b> r65c02	<i>;R65C02</i>
	<b class="k">.cpu</b> w65c02	<i>;W65C02</i>
	<b class="k">.cpu</b> default	<i>;cpu set on commandline</i>
</pre>

</dl>
<h3>Misc</h3>
<dl class="dir">

<dt><b>.end</b>
<dd>Terminate assembly. Any content after this directive is ignored.

<dt><b>.eor</b> &lt;expression&gt;
<dd>Eor output with some 8&nbsp;bit value. Useful for reverse screencode text for example,
or for silly <q>encryption</q>.

<dt><b>.var</b> &lt;expression&gt;
<dd>Defines a variable identified by the label preceeding, which
is set to the value of expression or reference of variable.

<dt><b>.assert</b>
<dt><b>.check</b>
<dd>Do not use these, the syntax will change in next version!

</dl>
<h3>Printer control</h3>
<dl class="dir">

<dt><b>.pron</b>
<dt><b>.proff</b>
<dd>Turn on or off source listing on part of the file.

<pre width=80>
        <b class="k">.proff</b>           <i>;Don't put filler bytes into listing</i>
        <b>*=</b> <span>$8000</span>
        <b class="d">.fill</b> <span>$2000</span>, <span>$ff</span> <i>;Pre-fill ROM area</i>
	<b class="k">.pron</b>
        <b>*=</b> <span>$8000</span>
        <b class="d">.word</b> <u>reset</u>, <u>restore</u>
        <b class="d">.text</b> <span class="s">"CBM80"</span>
reset   <b>cld</b>
</pre>

<dt><b>.hidemac</b>
<dt><b>.showmac</b>
<dd>Ignored for compatibility
</dl>

<hr>
<h2>Pseudo instructions</h2>

<p>For writing short code there are some special pseudo instructions for always
taken branches. These are automatically compiled as relative branches when the
jump distance is short enough and as <code>JMP</code> or <code>BRL</code> when
longer. The names are derived from conditional branches and are:
<code>GEQ</code>, <code>GNE</code>, <code>GCC</code>, <code>GCS</code>,
<code>GPL</code>, <code>GMI</code>, <code>GVC</code>, and <code>GVS</code>.</p>

<p>There's one more called <code>GRA</code> for CPUs supporting
<code>BRA</code>, which is expanded to <code>BRL</code> (if available) or
<code>JMP</code>.</p>

<pre>
.0000    a9 03          lda #$03        in1     <b>lda</b> #<span>3</span>
.0002    d0 02          gne $0006               <b>gne</b> <u>at</u>          <i>;branch always</i>
.0004    a9 02          lda #$02        in2     <b>lda</b> #<span>2</span>
.0006    4c 00 10       gne $1000       at      <b>gne</b> <span>$1000</span>       <i>;branch further</i>
</pre>

<p>If the branch would skip only one byte then the opposite condition is compiled
and only the first byte is emitted. This is now a never executed jump, and the
relative distance byte after the opcode is the jumped over byte.</p>

<p>If the branch would not skip anything at all then no code is generated.</p>

<pre>
.0009                   geq $0009               <b>geq</b> <u>in3</u>         <i>;zero length "branch"</i>
.0009    18             clc             in3     <b>clc</b>
.000a    b0             gcc $000c               <b>gcc</b> <u>at2</u>         <i>;one byte skip, as bcs</i>
.000b    38             sec             in4     <b>sec</b>             <i>;sec is skipped!</i>
.000c    20 0f 00       jsr $000f       at2     <b>jsr</b> <u>func</u>
.000f                                   func
</pre>

<p>Please note that expressions like <code>Gxx *+2</code> or <code>Gxx
*+3</code> are not allowed as the compiler can't figure out if it has to create
no code at all, the 1 byte variant or the 2 byte one. Therefore use normal or
anonymous labels defined after the jump instruction when jumping forward!</p>

<p>To avoid branch too long errors the assembler also supports long branches,
it can automatically convert conditional relative branches to it's opposite and
a <code>JMP</code> or <code>BRL</code>. This can be enabled on the command
line using the <q>--long-branch</q> option.</p>

<pre>
.0000    ea             nop                     <b>nop</b>
.0001    b0 03 4c 00 10 bcc $1000               <b>bcc</b> <span>$1000</span>      <i>;long branch</i>
.0006    ea             nop                     <b>nop</b>
</pre>

<p>Please note that forward jump expressions like <code>Bxx *+130</code>,
<code>Bxx *+131</code> and <code>Bxx *+132</code> are not allowed as the
compiler can't decide between a short/long branch. Of course these destinations
can be used, but only with normal or anonymous labels defined after the jump
instruction.</p>

<hr>
<h2>Original turbo assembler compatibility</h2>
<h3>How to convert source code for use with 64tass</h3>
<p>Currently there are two options, either use <q>TMPview</q> by Style to convert the
sourcefile directly, or do the following:</p>
<ul>
<li>load turbo assembler, start (by sys9*4096 or sys8*4096 depending on version)
<li><- (arrow left) then l to load a sourcefile
<li><- (arrow left) then w to write a sourcefile in petscii format
<li>convert the result to ASCII using petcat (from the vice package)
</ul>
<p>The resulting file should then (with the restrictions below) assemble using the
following commandline:</p>
<pre width=80>
64tass -C -T -a -W -i source.asm -o outfile.prg
</pre>

<h3>Differences to the original turbo ass macro on the C64</h3>
<p>64tass is nearly 100% compatible with the original <q>Turbo Assembler</q>, and supports
most of the features of the original <q>Turbo Assembler Macro</q>.
The remaining notable differences are listed here.</p>
<h3>Labels</h3>
<p>The original turbo assembler uses case sensitive labels, use the <tt>-C, --case-sensitive</tt>
option to enable this behaviour.</p>
<p>Another thing worth noting is that the original turbo assembler lets you create
an interesting ambiguous construct using a label called <q>a</q>.</p>
<pre width=80>
        <b>lsr a</b>    <i>; uses accu ! (or does it really?)</i>
a
        <b>jmp</b> <u>a</u>    <i>; uses the label address</i>
        <b class="d">.word</b> <u>a</u>  <i>; uses the label address</i>
</pre>
<p>If you get a warning like <q><tt>warning: Possibly incorrectly used A "lsr a"</tt></q>, then there
is such an ambiguous situation in your code and you should fix it (by renaming the label).</p>

<h3>Expression evaluation</h3>

<p>There are a few differences which can be worked around by the <tt>-T, --tasm-compatible</tt> option.
These are:</p>

<p>The original expression parser has no operator precedence, but 64tass has. That
means that you will have to fix expressions using braces accordingly, for example
<code>1+2*3</code> becomes <code>(1+2)*3</code>.</p>

<p>The following operators used by the original Turbo Assembler are different:</p>

<table border="0" class="oper">
<caption>TASM Operator differences</caption>
<tr><td width="80">.<td>bitwise or, now <code>|</code>
<tr><td>:<td>bitwise eor, now <code>^</code>
<tr><td>!<td>force 16&nbsp;bit address, now <code>@w</code>
</table>

<p>The default expression evaluation is not limited to 16&nbsp;bit unsigned numbers anymore.</p>

<h3>Macros</h3>
<p>Macro parameters are referenced by <code>\1</code>...<code>\9</code> instead of using the pound sign.</p>
<p>Parameters are always copied as text into the macro and not passed by value as the
original turbo assembler does, which sometimes may lead to unexpected behaviour. You may
need to make use of braces around arguments and/or references to fix this.</p>

<h3>Bugs</h3>
<p>Some versions of the original turbo assembler had bugs that are not reproduced
by 64tass, you will have to fix the code instead.</p>
<p>In some versions labels used in the first <code>.block</code> are globally available. If
you get a related error move the respective label out of the <code>.block</code></p>

<hr>
<h2>Command line options</h2>

<h3>Output options</h3>

<dl class="dir">
<dt><b>-o</b> &lt;filename&gt;
<dd>Place output into &lt;filename&gt;. The default output filename is <q>a.out</q>. This option changes it.
<pre width=80>
64tass a.asm -o a.prg
</pre>

<dt><b>-b</b>, <b>--nostart</b>
<dd>Strip starting address. Strips the 2 or 3 byte starting address before the
resulting binary.  Useful for creating small ROM images.

<dt><b>-f</b>, <b>--flat</b>
<dd>Flat output mode. Output the plain binary image from offset 0. The image
size can be much larger than the processor address space. Useful for creating
huge multi bank ROM files.

<dt><b>-n</b>, <b>--nonlinear</b>
<dd>Generate nonlinear output file. Generates non-linear output for linkers.
<pre width=80>
64tass --nonlinear a.asm
        <b>*=</b> <span>$1000</span>
        <b>lda</b> #<span>2</span>
        <b>*=</b> <span>$2000</span>
	<b>nop</b>
</pre>
<table border="0">
<caption>Result of compilation</caption>
<tr><td><tt>$02, $00</tt><td>little endian length, 2 bytes
<tr><td><tt>$00, $10</tt><td>little endian start $1000
<tr><td><tt>$a9, $02</tt><td>code
<tr><td><tt>$01, $00</tt><td>little endian length, 1 byte
<tr><td><tt>$00, $20</tt><td>little endian start $2000
<tr><td><tt>$ea</tt><td>code
<tr><td><tt>$00, $00</tt><td>end marker (length=0)
</table>

<dt><b>-W</b>, <b>--wordstart</b>
<dd>Force 2 byte start address. If 16&nbsp;MiB address space is used for a
65816, then the starting address of file will be 3 bytes long. This option
makes it 2 bytes long.
<pre width=80>
64tass --wordstart --m65816 a.asm
</pre>

</dl>

<h3>Operation options</h3>

<dl class="dir">
<dt><b>-a</b>, <b>--ascii</b>
<dd>Use ASCII/Unicode text encoding instead of raw 8-bit
<p>Normally no conversion takes place, this is for backwards compatibility with
a DOS based Turbo Assembler editor, which could create PETSCII files for
6502tass. (including control characters of course)</p>
<p>Using this option will change the default <q>none</q> and <q>screen</q> encodings to
map 'a'-'z' and 'A'-'Z' into the correct PETSCII range of $41-$5A and $C1-$DA,
which is more suitable for an ASCII editor. It also adds predefined petcat style
PETASCII literals to the default encodings.</p>
<p><b>For writing sources in utf8/utf16 encodings this option is required!</b> The
symbol names are still limited to ASCII, but custom string encodings can take
advantage of the full unicode set.</p>
<pre width=80>
64tass a.asm

.0000    a9 61          lda #$61        <b>lda</b> #<span class="s">"a"</span>

&gt;0002    31 61 41                       <b class="d">.text</b> <span class="s">"1aA"</span>
&gt;0005    7b 63 6c 65 61 72 7d 74        <b class="d">.text</b> <span class="s">"{clear}text{return}more"</span>
&gt;000e    65 78 74 7b 72 65 74 75
&gt;0016    72 6e 7d 6d 6f 72 65

64tass --ascii a.asm

.0000    a9 41          lda #$41        <b>lda</b> #<span class="s">"a"</span>
&gt;0002    31 41 c1                       <b class="d">.text</b> <span class="s">"1aA"</span>
&gt;0005    93 54 45 58 54 0d 4d 4f        <b class="d">.text</b> <span class="s">"<span>{clear}</span>text<span>{return}</span>more"</span>
&gt;000e    52 45
</pre>

<dt><b>-B</b>, <b>--long-branch</b>
<dd>Automatic <code>BXX *+5 JMP xxx</code>. Branch too long messages can be annoying
sometimes, usually they'll need to be rewritten to <code>BXX *+5 JMP xxx</code>.
64tass can do this automatically if this option is used. But <code>BRA</code>
is not converted.
<pre width=80>
64tass a.asm
        <b>*=</b> <span>$1000</span>
        <b>bcc</b> <span>$1233</span>	<i>;error...</i>

64tass a.asm
        <b>*=</b> <span>$1000</span>
        <b>bcs</b> *+<span>5</span>		<i>;opposite condition</i>
        <b>jmp</b> <span>$1233</span>	<i>;as simple workaround</i>

64tass --long-branch a.asm
        <b>*=</b> <span>$1000</span>
        <b>bcc</b> <span>$1233</span>	<i>;no error, automatically converted to the above one.</i>
</pre>

<dt><b>-C</b>, <b>--case-sensitive</b>
<dd>Case sensitive labels. Labels are non case sensitive by default, this
option changes that.
<pre>
64tass a.asm
label	<b>nop</b>
Label	<b>nop</b>	<i>;double defined...</i>

64tass --case-sensitive a.asm
label   <b>nop</b>
Label	<b>nop</b>	<i>;Ok, it's a different label...</i>
</pre>

<dt><b>-D</b> &lt;label&gt;=&lt;value&gt;
<dd>Define &lt;label&gt; to &lt;value&gt;. Defines a label to a value. Same
syntax is allowed as in source files. Be careful with string quoting, the shell
might eat some of the characters.
<pre width=80>
64tass -D ii=2 a.asm
        <b>lda</b> #<u>ii</u> <i>;result: $a9, $02</i>
</pre>

<dt><b>-w</b>, <b>--no-warn</b>
<dd>Suppress warnings. Disables warnings during compile.
<pre width=80>
64tass --no-warn a.asm
</pre>

<dt><b>-q</b>, <b>--quiet</b>
<dd>Suppress messages. Disables header and summary messages.
<pre width=80>
64tass --quiet a.asm
</pre>

<dt><b>-T</b>, <b>--tasm-compatible</b>
<dd>Enable TASM compatible operators and precedence
<p>Switches the expression evaluator into compatibility mode. This
enables <q>.</q>, <q>:</q> and <q>!</q> operators and disables 64tass specific extensions, disables precedence handling
and forces 16&nbsp;bit unsigned evaluation (see <q>differences to original Turbo Assembler</q> below)</p>

<dt><b>-I</b> &lt;path&gt;
<dd>Specify include search path
<p>If an included source or binary file can't be found in the directory of the
source file then this path is tried. More than one directories can be specified
by repeating this option. If multiple matches exist the first one is used.</p>
</dl>

<h3>Target selection on command line</h3>
<p>These options will select the default architecture. It can be overridden by
using the <code>.cpu</code> directive in the source.</p>

<dl class="dir">
<dt><b>--m65xx</b>
<dd>Standard 65xx (default). For writing compatible code, no extra codes. This
is the default.
<pre width=80>
64tass --m65xx a.asm
        <b>lda</b> <span>$14</span>		<i>;regular instructions</i>
</pre>

<dt><b>-c</b>, <b>--m65c02</b>
<dd>CMOS 65C02. Enables extra opcodes and addressing modes specific to this
CPU.
<pre width=80>
64tass --m65c02 a.asm
        <b>stz</b> <span>$d020</span>	<i>;65c02 instruction</i>
</pre>

<dt><b>-c</b>, <b>--m65ce02</b>
<dd>CSG 65CE02. Enables extra opcodes and addressing modes specific to this
CPU.
<pre width=80>
64tass --m65ce02 a.asm
        <b>inz</b>
</pre>

<dt><b>-i</b>, <b>--m6502</b>
<dd>NMOS 65xx. Enables extra illegal opcodes. Useful for demo coding for C64,
disk drive code, etc.
<pre width=80>
64tass --m6502 a.asm
        <b>lax</b> <span>$14</span>		<i>;illegal instruction</i>
</pre>

<dt><b>-t</b>, <b>--m65dtv02</b>
<dd>65DTV02. Enables extra opcodes specific to DTV.
<pre width=80>
64tass --m65dtv02 a.asm
        <b>sac</b> #<span>$00</span>
</pre>

<dt><b>-x</b>, <b>--m65816</b>
<dd>W65C816. Enables extra opcodes, and full 16&nbsp;MiB address space.  Useful
for SuperCPU projects. Don't forget to use <q>--word-start</q> for small ones
;)
<pre width=80>
64tass --m65816 a.asm
        <b>lda</b> <span>$123456</span>,x
</pre>

<dt><b>-e</b>, <b>--m65el02</b>
<dd>65EL02. Enables extra opcodes, useful <a href="http://www.eloraam.com/nonwp/redcpu.php">RedPower CPU</a> projects. Probably you'll need <q>--nostart</q> as well.
<pre width=80>
64tass --m65el02 a.asm
        <b>lda</b> <span>0</span>,r
</pre>

<dt><b>--mr65c02</b>
<dd>R65C02. Enables extra opcodes and addressing modes specific to this CPU.
<pre width=80>
64tass --mr65c02 a.asm
        <b>rmb</b> <span>7</span>,<span>$20</span>
</pre>

<dt><b>--mw65c02</b>
<dd>W65C02. Enables extra opcodes and addressing modes specific to this CPU.
<pre width=80>
64tass --mw65c02 a.asm
        <b>wai</b>
</pre>
</dl>

<h3>Source listing options</h3>

<dl class="dir">
<dt><b>-l</b> &lt;file&gt;
<dd>List labels into &lt;file&gt;. List global used labels to a file.
<pre width=80>
64tass -l labels.txt a.asm
        <b>*=</b> <span>$1000</span>
label   <b>jmp</b> <u>label</u>

result (labels.txt):
label           = $1000
</pre>

<dt><b>-L</b> &lt;file&gt;
<dd>List into &lt;file&gt;. Dumps source code and compiled code into file.
Useful for debugging, it's much easier to identify the code in memory within
the source files.
<pre width=80>
64tass -L list.txt a.asm
        <b>*=</b> <span>$1000</span>
        <b>ldx</b> #<span>0</span>
loop	<b>dex</b>
        <b>bne</b> <u>loop</u>
	<b>rts</b>

result (list.txt):

;64tass Turbo Assembler Macro V1.5x listing file of "a.asm"
;done on Fri Dec  9 19:08:55 2005


.1000	 a2 00		ldx #$00		ldx #0
.1002	 ca		dex		loop	dex
.1003	 d0 fd		bne $1002		bne loop
.1005	 60		rts			rts

;******  end of code
</pre>

<dt><b>-m</b>, <b>--no-monitor</b>
<dd>Don't put monitor code into listing. There won't be any monitor listing in the list file.
<pre width=80>
64tass --no-monitor -L list.txt a.asm

result (list.txt):

;64tass Turbo Assembler Macro V1.5x listing file of "a.asm"
;done on Fri Dec  9 19:11:43 2005


.1000	 a2 00					ldx #0
.1002	 ca				loop	dex
.1003	 d0 fd					bne loop
.1005	 60					rts

;******  end of code
</pre>

<dt><b>-s</b>, <b>--no-source</b>
<dd>Don't put source code into listing. There won't be any source listing in the list file.
<pre width=80>
64tass --no-source -L list.txt a.asm

result (list.txt):

;64tass Turbo Assembler Macro V1.5x listing file of "a.asm"
;done on Fri Dec  9 19:13:25 2005


.1000	 a2 00		ldx #$00
.1002	 ca		dex
.1003	 d0 fd		bne $1002
.1005	 60		rts

;******  end of code
</pre>
</dl>

<h3>Other options</h3>

<dl class="dir">
<dt><b>-?</b>, <b>--help</b>
<dd>Give this help list. Prints help about command line options.

<dt><b>--usage</b>
<dd>Give a short usage message. Prints short help about command line options.

<dt><b>-V</b>, <b>--version</b>
<dd>Print program version
</dl>

<hr>
<h2>Messages</h2>

<p>Faults and warnings encountered are sent to standard error for logging. The
format of messages is the following:</p>
<p>&lt;filename&gt;:&lt;line&gt;:&lt;character&gt;: &lt;severity&gt;: &lt;message&gt;</p>
<ul>
<li>filename: The name and path of source file where the error happened.
<li>line: Line number of file, starts from 1.
<li>character: Character in line, starts from 1. Tabs are not expanded.
<li>severity: Note, warning, error or fatal.
<li>message: The fault message itself.
</ul>

<pre width=80>a.asm:4:8: error: page error at $0007d0</pre>

<h3>Warnings</h3>
<dl>
<dt>Top of memory excedeed
<dd>compile continues at the bottom ($0000)
<dt>Possibly incorrectly used A
<dd>do not use <q>a</q> as label
<dt>Memory bank excedeed
<dd>compile continues in the next 64&nbsp;KiB bank, however execution may not
<dt>Possible jmp ($xxff) bug
<dd>yet another 65xx feature...
<dt>Long branch used
<dd>Branch too long, so long branch was used (bxx *+5 jmp)
<dt>Directive ignored
<dd>An assembler directive was ignored for compatibility reasons.
</dl>

<h3>Errors</h3>
<dl>
<dt>Double defined
<dd>double use of label/macro
<dt>Not defined
<dd>not defined label
<dt>Extra characters on line
<dd>there's some garbage on the end of line
<dt>Constant too large
<dd>the number was too big
<dt>General syntax
<dd>can't do anything with this
<dt>X expected
<dd>X may be missing
<dt>Expression syntax
<dd>syntax error
<dt>Branch too far
<dd>can't relative branch that far
<dt>Missing argument
<dd>no argument given
<dt>Illegal operand
<dd>can't be used here
<dt>Requirements not met:
<dd>Not all features are provided, at least one is missing
<dt>Conflict:
<dd>at least one feature is provided, which shouldn't be there
<dt>Division by zero
<dd>Cannot calculate value
</dl>

<h3>Fatal errors</h3>
<dl>
<dt>Can't locate file
<dd>cannot open file
<dt>Out of memory
<dd>won't happen ;)
<dt>Can't write object file:
<dd>cannot write the result
<dt>Can't write listing file:
<dd>cannot write the list file
<dt>Can't write label file:
<dd>cannot write the label file
<dt>File recursion
<dd>wrong use of .include
<dt>Macro recursion too deep
<dd>wrong use of nested macros
<dt>Unknown CPU
<dd>CPU type not known
<dt>Ooops! Too many passes...
<dd>With a carefuly crafted source file it's possible to create unresolvable situations. Fix your code.
</dl>

<hr>
<h2>Credits</h2>

<p>Original written for DOS by Marek Matula of Taboo, then ported to ansi C by
BigFoot/Breeze, and finally added 65816 support, DTV, illegal opcodes,
optimizations, multi pass compile and a lot of features by Soci/Singular.
Improved TASS compatibility, PETSCII codes by Groepaz.</p>

<p>Additional code: my_getopt command-line argument parser by Benjamin
Sittler, avl tree code by Franck Bui-Huu, ternary tree code by Daniel
Berlin, snprintf Alain Magloire, Amiga OS4 support files by Janne Per&auml;aho.</p>

<p>Main developer and maintainer: soci at c64.rulez.org</p>
<hr>
<h2>Default translation and escape sequences</h2>
<h3>Raw 8-bit source</h3>
<p>By default raw 8-bit encoding is used and nothing is translated or escaped.
This mode is for compiling sources which are already PETSCII.</p>
<h4>The <q>none</q> encoding for raw 8-bit</h4>
<p>Does no translation at all, no translation table, no escape sequences.</p>
<h4>The <q>screen</q> encoding for raw 8-bit</h4>
<p>The following translation table applies, no escape sequences.</p>
<table width="100%">
<caption>Built in PETSCII to PETSCII screen code translation table</caption>
<thead>
<tr><th>Input<th>Byte
<th>Input<th>Byte
</thead><tbody>
<tr><td>00...1F<td>80...9F
<td>20...3F<td>20...3F
<tr><td>40...5F<td>00...1F
<td>60...7F<td>40...5F
<tr><td>80...9F<td>80...9F
<td>A0...BF<td>60...7F
<tr><td>C0...FE<td>40...7E
<td>FF<td>5E
</tbody>
</table>

<h3>Unicode and ASCII source</h3>
<p>Unicode encoding is used when the <q><tt>-a</tt></q> option is given on the command line.</p>
<h4>The <q>none</q> encoding for Unicode</h4>
This is a Unicode to PETSCII mapping, including escape sequences for control codes.
<table width="100%" class="trans">
<caption>Built in Unicode to PETSCII translation table</caption>
<thead>
<tr><th>Glyph<th>Unicode<th>Byte
<th>Glyph<th>Unicode<th>Byte
</thead><tbody>
<tr><td>&nbsp;...&#x40;<td>U+0020...U+0040<td>20...40
<td>&#x41;...&#x5a;<td>U+0041...U+005A<td>C1...DA
<tr><td>&#x5b;<td>U+005B<td>5B
<td>&#x5d;<td>U+005D<td>5D
<tr><td>&#x61;...&#x7a;<td>U+0061...U+007A<td>41...5A
<td>&#xa3;<td>U+00A3<td>5C
<tr><td>&#x03c0;<td>U+03C0<td>FF
<td>&#x2190;<td>U+2190<td>5F
<tr><td>&#x2191;<td>U+2191<td>5E
<td>&#x2500;<td>U+2500<td>C0
<tr><td>&#x2502;<td>U+2502<td>DD
<td>&#x250c;<td>U+250C<td>B0
<tr><td>&#x2510;<td>U+2510<td>AE
<td>&#x2514;<td>U+2514<td>AD
<tr><td>&#x2518;<td>U+2518<td>BD
<td>&#x251c;<td>U+251C<td>AB
<tr><td>&#x2524;<td>U+2524<td>B3
<td>&#x252c;<td>U+252C<td>B2
<tr><td>&#x2534;<td>U+2534<td>B1
<td>&#x253c;<td>U+253C<td>DB
<tr><td>&#x256d;<td>U+256D<td>D5
<td>&#x256e;<td>U+256E<td>C9
<tr><td>&#x256f;<td>U+256F<td>CB
<td>&#x2570;<td>U+2570<td>CA
<tr><td>&#x2571;<td>U+2571<td>CE
<td>&#x2572;<td>U+2572<td>CD
<tr><td>&#x2573;<td>U+2573<td>D6
<td>&#x2581;<td>U+2581<td>A4
<tr><td>&#x2582;<td>U+2582<td>AF
<td>&#x2583;<td>U+2583<td>B9
<tr><td>&#x2584;<td>U+2584<td>A2
<td>&#x258c;<td>U+258C<td>A1
<tr><td>&#x258d;<td>U+258D<td>B5
<td>&#x258e;<td>U+258E<td>B4
<tr><td>&#x258f;<td>U+258F<td>A5
<td>&#x2592;<td>U+2592<td>A6
<tr><td>&#x2594;<td>U+2594<td>A3
<td>&#x2595;<td>U+2595<td>A7
<tr><td>&#x2596;<td>U+2596<td>BB
<td>&#x2597;<td>U+2597<td>AC
<tr><td>&#x2598;<td>U+2598<td>BE
<td>&#x259a;<td>U+259A<td>BF
<tr><td>&#x259d;<td>U+259D<td>BC
<td>&#x25cb;<td>U+25CB<td>D7
<tr><td>&#x25cf;<td>U+25CF<td>D1
<td>&#x25e4;<td>U+25E4<td>A9
<tr><td>&#x25e5;<td>U+25E5<td>DF
<td>&#x2660;<td>U+2660<td>C1
<tr><td>&#x2663;<td>U+2663<td>D8
<td>&#x2665;<td>U+2665<td>D3
<tr><td>&#x2666;<td>U+2666<td>DA
<td>&#x2713;<td>U+2713<td>BA
</tbody>
</table>

<table width="100%" class="esc">
<caption>Built in PETSCII escape sequences</caption>
<thead>
<tr><th>Escape<th>Byte
<th>Escape<th>Byte
<th>Escape<th>Byte
</thead><tbody>
<tr><td>{bell}<td>07
<td>{black}<td>90
<td>{blk}<td>90
<tr><td>{blue}<td>1F
<td>{blu}<td>1F
<td>{brn}<td>95
<tr><td>{brown}<td>95
<td>{cbm-*}<td>DF
<td>{cbm-+}<td>A6
<tr><td>{cbm--}<td>DC
<td>{cbm-0}<td>30
<td>{cbm-1}<td>81
<tr><td>{cbm-2}<td>95
<td>{cbm-3}<td>96
<td>{cbm-4}<td>97
<tr><td>{cbm-5}<td>98
<td>{cbm-6}<td>99
<td>{cbm-7}<td>9A
<tr><td>{cbm-8}<td>9B
<td>{cbm-9}<td>29
<td>{cbm-@}<td>A4
<tr><td>{cbm-^}<td>DE
<td>{cbm-a}<td>B0
<td>{cbm-b}<td>BF
<tr><td>{cbm-c}<td>BC
<td>{cbm-d}<td>AC
<td>{cbm-e}<td>B1
<tr><td>{cbm-f}<td>BB
<td>{cbm-g}<td>A5
<td>{cbm-h}<td>B4
<tr><td>{cbm-i}<td>A2
<td>{cbm-j}<td>B5
<td>{cbm-k}<td>A1
<tr><td>{cbm-l}<td>B6
<td>{cbm-m}<td>A7
<td>{cbm-n}<td>AA
<tr><td>{cbm-o}<td>B9
<td>{cbm-pound}<td>A8
<td>{cbm-p}<td>AF
<tr><td>{cbm-q}<td>AB
<td>{cbm-r}<td>B2
<td>{cbm-s}<td>AE
<tr><td>{cbm-t}<td>A3
<td>{cbm-up&nbsp;arrow}<td>DE
<td>{cbm-u}<td>B8
<tr><td>{cbm-v}<td>BE
<td>{cbm-w}<td>B3
<td>{cbm-x}<td>BD
<tr><td>{cbm-y}<td>B7
<td>{cbm-z}<td>AD
<td>{clear}<td>93
<tr><td>{clr}<td>93
<td>{control-0}<td>92
<td>{control-1}<td>90
<tr><td>{control-2}<td>05
<td>{control-3}<td>1C
<td>{control-4}<td>9F
<tr><td>{control-5}<td>9C
<td>{control-6}<td>1E
<td>{control-7}<td>1F
<tr><td>{control-8}<td>9E
<td>{control-9}<td>12
<td>{control-:}<td>1B
<tr><td>{control-;}<td>1D
<td>{control-=}<td>1F
<td>{control-@}<td>00
<tr><td>{control-a}<td>01
<td>{control-b}<td>02
<td>{control-c}<td>03
<tr><td>{control-d}<td>04
<td>{control-e}<td>05
<td>{control-f}<td>06
<tr><td>{control-g}<td>07
<td>{control-h}<td>08
<td>{control-i}<td>09
<tr><td>{control-j}<td>0A
<td>{control-k}<td>0B
<td>{control-left&nbsp;arrow}<td>06
<tr><td>{control-l}<td>0C
<td>{control-m}<td>0D
<td>{control-n}<td>0E
<tr><td>{control-o}<td>0F
<td>{control-pound}<td>1C
<td>{control-p}<td>10
<tr><td>{control-q}<td>11
<td>{control-r}<td>12
<td>{control-s}<td>13
<tr><td>{control-t}<td>14
<td>{control-up&nbsp;arrow}<td>1E
<td>{control-u}<td>15
<tr><td>{control-v}<td>16
<td>{control-w}<td>17
<td>{control-x}<td>18
<tr><td>{control-y}<td>19
<td>{control-z}<td>1A
<td>{cr}<td>0D
<tr><td>{cyan}<td>9F
<td>{cyn}<td>9F
<td>{delete}<td>14
<tr><td>{del}<td>14
<td>{dish}<td>08
<td>{down}<td>11
<tr><td>{ensh}<td>09
<td>{esc}<td>1B
<td>{f10}<td>82
<tr><td>{f11}<td>84
<td>{f12}<td>8F
<td>{f1}<td>85
<tr><td>{f2}<td>89
<td>{f3}<td>86
<td>{f4}<td>8A
<tr><td>{f5}<td>87
<td>{f6}<td>8B
<td>{f7}<td>88
<tr><td>{f8}<td>8C
<td>{f9}<td>80
<td>{gray1}<td>97
<tr><td>{gray2}<td>98
<td>{gray3}<td>9B
<td>{green}<td>1E
<tr><td>{grey1}<td>97
<td>{grey2}<td>98
<td>{grey3}<td>9B
<tr><td>{grn}<td>1E
<td>{gry1}<td>97
<td>{gry2}<td>98
<tr><td>{gry3}<td>9B
<td>{help}<td>84
<td>{home}<td>13
<tr><td>{insert}<td>94
<td>{inst}<td>94
<td>{lblu}<td>9A
<tr><td>{left&nbsp;arrow}<td>5F
<td>{left}<td>9D
<td>{lf}<td>0A
<tr><td>{lgrn}<td>99
<td>{lower&nbsp;case}<td>0E
<td>{lred}<td>96
<tr><td>{lt&nbsp;blue}<td>9A
<td>{lt&nbsp;green}<td>99
<td>{lt&nbsp;red}<td>96
<tr><td>{orange}<td>81
<td>{orng}<td>81
<td>{pi}<td>FF
<tr><td>{pound}<td>5C
<td>{purple}<td>9C
<td>{pur}<td>9C
<tr><td>{red}<td>1C
<td>{return}<td>0D
<td>{reverse&nbsp;off}<td>92
<tr><td>{reverse&nbsp;on}<td>12
<td>{rght}<td>1D
<td>{right}<td>1D
<tr><td>{run}<td>83
<td>{rvof}<td>92
<td>{rvon}<td>12
<tr><td>{rvs&nbsp;off}<td>92
<td>{rvs&nbsp;on}<td>12
<td>{shift&nbsp;return}<td>8D
<tr><td>{shift-*}<td>C0
<td>{shift-+}<td>DB
<td>{shift-,}<td>3C
<tr><td>{shift--}<td>DD
<td>{shift-.}<td>3E
<td>{shift-/}<td>3F
<tr><td>{shift-0}<td>30
<td>{shift-1}<td>21
<td>{shift-2}<td>22
<tr><td>{shift-3}<td>23
<td>{shift-4}<td>24
<td>{shift-5}<td>25
<tr><td>{shift-6}<td>26
<td>{shift-7}<td>27
<td>{shift-8}<td>28
<tr><td>{shift-9}<td>29
<td>{shift-:}<td>5B
<td>{shift-;}<td>5D
<tr><td>{shift-@}<td>BA
<td>{shift-^}<td>DE
<td>{shift-a}<td>C1
<tr><td>{shift-b}<td>C2
<td>{shift-c}<td>C3
<td>{shift-d}<td>C4
<tr><td>{shift-e}<td>C5
<td>{shift-f}<td>C6
<td>{shift-g}<td>C7
<tr><td>{shift-h}<td>C8
<td>{shift-i}<td>C9
<td>{shift-j}<td>CA
<tr><td>{shift-k}<td>CB
<td>{shift-l}<td>CC
<td>{shift-m}<td>CD
<tr><td>{shift-n}<td>CE
<td>{shift-o}<td>CF
<td>{shift-pound}<td>A9
<tr><td>{shift-p}<td>D0
<td>{shift-q}<td>D1
<td>{shift-r}<td>D2
<tr><td>{shift-space}<td>A0
<td>{shift-s}<td>D3
<td>{shift-t}<td>D4
<tr><td>{shift-up&nbsp;arrow}<td>DE
<td>{shift-u}<td>D5
<td>{shift-v}<td>D6
<tr><td>{shift-w}<td>D7
<td>{shift-x}<td>D8
<td>{shift-y}<td>D9
<tr><td>{shift-z}<td>DA
<td>{space}<td>20
<td>{sret}<td>8D
<tr><td>{stop}<td>03
<td>{swlc}<td>0E
<td>{swuc}<td>8E
<tr><td>{tab}<td>09
<td>{up&nbsp;arrow}<td>5E
<td>{up/lo&nbsp;lock off}<td>09
<tr><td>{up/lo&nbsp;lock on}<td>08
<td>{upper&nbsp;case}<td>8E
<td>{up}<td>91
<tr><td>{white}<td>05
<td>{wht}<td>05
<td>{yellow}<td>9E
<tr><td>{yel}<td>9E
<td><td>
<td><td>
</tbody>
</table>

<h4>The <q>screen</q> encoding for Unicode</h4>
This is a Unicode to PETSCII screen code mapping, including escape sequences for control code screen codes.
<table width="100%" class="trans">
<caption>Built in Unicode to PETSCII screen code translation table</caption>
<thead>
<tr><th>Glyph<th>Unicode<th>Translated
<th>Glyph<th>Unicode<th>Translated
</thead><tbody>
<tr><td>&nbsp;...&#x3f;<td>U+0020...U+003F<td>20...3F
<td>&#x40;<td>U+0040<td>00
<tr><td>&#x41;...&#x5a;<td>U+0041...U+005A<td>41...5A
<td>&#x5b;<td>U+005B<td>1B
<tr><td>&#x5d;<td>U+005D<td>1D
<td>&#x61;...&#x7a;<td>U+0061...U+007A<td>01...1A
<tr><td>&#xa3;<td>U+00A3<td>1C
<td>&#x03c0;<td>U+03C0<td>5E
<tr><td>&#x2190;<td>U+2190<td>1F
<td>&#x2191;<td>U+2191<td>1E
<tr><td>&#x2500;<td>U+2500<td>40
<td>&#x2502;<td>U+2502<td>5D
<tr><td>&#x250c;<td>U+250C<td>70
<td>&#x2510;<td>U+2510<td>6E
<tr><td>&#x2514;<td>U+2514<td>6D
<td>&#x2518;<td>U+2518<td>7D
<tr><td>&#x251c;<td>U+251C<td>6B
<td>&#x2524;<td>U+2524<td>73
<tr><td>&#x252c;<td>U+252C<td>72
<td>&#x2534;<td>U+2534<td>71
<tr><td>&#x253c;<td>U+253C<td>5B
<td>&#x256d;<td>U+256D<td>55
<tr><td>&#x256e;<td>U+256E<td>49
<td>&#x256f;<td>U+256F<td>4B
<tr><td>&#x2570;<td>U+2570<td>4A
<td>&#x2571;<td>U+2571<td>4E
<tr><td>&#x2572;<td>U+2572<td>4D
<td>&#x2573;<td>U+2573<td>56
<tr><td>&#x2581;<td>U+2581<td>64
<td>&#x2582;<td>U+2582<td>6F
<tr><td>&#x2583;<td>U+2583<td>79
<td>&#x2584;<td>U+2584<td>62
<tr><td>&#x258c;<td>U+258C<td>61
<td>&#x258d;<td>U+258D<td>75
<tr><td>&#x258e;<td>U+258E<td>74
<td>&#x258f;<td>U+258F<td>65
<tr><td>&#x2592;<td>U+2592<td>66
<td>&#x2594;<td>U+2594<td>63
<tr><td>&#x2595;<td>U+2595<td>67
<td>&#x2596;<td>U+2596<td>7B
<tr><td>&#x2597;<td>U+2597<td>6C
<td>&#x2598;<td>U+2598<td>7E
<tr><td>&#x259a;<td>U+259A<td>7F
<td>&#x259d;<td>U+259D<td>7C
<tr><td>&#x25cb;<td>U+25CB<td>57
<td>&#x25cf;<td>U+25CF<td>51
<tr><td>&#x25e4;<td>U+25E4<td>69
<td>&#x25e5;<td>U+25E5<td>5F
<tr><td>&#x2660;<td>U+2660<td>41
<td>&#x2663;<td>U+2663<td>58
<tr><td>&#x2665;<td>U+2665<td>53
<td>&#x2666;<td>U+2666<td>5A
<tr><td>&#x2713;<td>U+2713<td>7A
<td><td><td>
</tbody>
</table>

<table width="100%" class="esc">
<caption>Built in PETSCII screen code escape sequences</caption>
<thead>
<tr><th>Escape<th>Byte
<th>Escape<th>Byte
<th>Escape<th>Byte
</thead><tbody>
<tr><td>{cbm-*}<td>5F
<td>{cbm-+}<td>66
<td>{cbm--}<td>5C
<tr><td>{cbm-0}<td>30
<td>{cbm-9}<td>29
<td>{cbm-@}<td>64
<tr><td>{cbm-^}<td>5E
<td>{cbm-a}<td>70
<td>{cbm-b}<td>7F
<tr><td>{cbm-c}<td>7C
<td>{cbm-d}<td>6C
<td>{cbm-e}<td>71
<tr><td>{cbm-f}<td>7B
<td>{cbm-g}<td>65
<td>{cbm-h}<td>74
<tr><td>{cbm-i}<td>62
<td>{cbm-j}<td>75
<td>{cbm-k}<td>61
<tr><td>{cbm-l}<td>76
<td>{cbm-m}<td>67
<td>{cbm-n}<td>6A
<tr><td>{cbm-o}<td>79
<td>{cbm-pound}<td>68
<td>{cbm-p}<td>6F
<tr><td>{cbm-q}<td>6B
<td>{cbm-r}<td>72
<td>{cbm-s}<td>6E
<tr><td>{cbm-t}<td>63
<td>{cbm-up&nbsp;arrow}<td>5E
<td>{cbm-u}<td>78
<tr><td>{cbm-v}<td>7E
<td>{cbm-w}<td>73
<td>{cbm-x}<td>7D
<tr><td>{cbm-y}<td>77
<td>{cbm-z}<td>6D
<td>{left&nbsp;arrow}<td>1F
<tr><td>{pi}<td>5E
<td>{pound}<td>1C
<td>{shift-*}<td>40
<tr><td>{shift-+}<td>5B
<td>{shift-,}<td>3C
<td>{shift--}<td>5D
<tr><td>{shift-.}<td>3E
<td>{shift-/}<td>3F
<td>{shift-0}<td>30
<tr><td>{shift-1}<td>21
<td>{shift-2}<td>22
<td>{shift-3}<td>23
<tr><td>{shift-4}<td>24
<td>{shift-5}<td>25
<td>{shift-6}<td>26
<tr><td>{shift-7}<td>27
<td>{shift-8}<td>28
<td>{shift-9}<td>29
<tr><td>{shift-:}<td>1B
<td>{shift-;}<td>1D
<td>{shift-@}<td>7A
<tr><td>{shift-^}<td>5E
<td>{shift-a}<td>41
<td>{shift-b}<td>42
<tr><td>{shift-c}<td>43
<td>{shift-d}<td>44
<td>{shift-e}<td>45
<tr><td>{shift-f}<td>46
<td>{shift-g}<td>47
<td>{shift-h}<td>48
<tr><td>{shift-i}<td>49
<td>{shift-j}<td>4A
<td>{shift-k}<td>4B
<tr><td>{shift-l}<td>4C
<td>{shift-m}<td>4D
<td>{shift-n}<td>4E
<tr><td>{shift-o}<td>4F
<td>{shift-pound}<td>69
<td>{shift-p}<td>50
<tr><td>{shift-q}<td>51
<td>{shift-r}<td>52
<td>{shift-space}<td>60
<tr><td>{shift-s}<td>53
<td>{shift-t}<td>54
<td>{shift-up&nbsp;arrow}<td>5E
<tr><td>{shift-u}<td>55
<td>{shift-v}<td>56
<td>{shift-w}<td>57
<tr><td>{shift-x}<td>58
<td>{shift-y}<td>59
<td>{shift-z}<td>5A
<tr><td>{space}<td>20
<td>{up&nbsp;arrow}<td>1E
<td><td>
</tbody>
</table>

<hr>
<h2>Opcodes</h2>
<h3>Standard 6502 opcodes</h3>
<table width="100%" class="opcodes">
<caption>The standard 6502 opcodes</caption>
<tr><th width="4%">ADC<td width="46%">61 65 69 6D 71 75 79 7D
<th width="4%">AND<td width="46%">21 25 29 2D 31 35 39 3D
<tr><th>ASL<td>06 0A 0E 16 1E
<th>BCC<td>90
<tr><th>BCS<td>B0
<th>BEQ<td>F0
<tr><th>BIT<td>24 2C
<th>BMI<td>30
<tr><th>BNE<td>D0
<th>BPL<td>10
<tr><th>BRK<td>00
<th>BVC<td>50
<tr><th>BVS<td>70
<th>CLC<td>18
<tr><th>CLD<td>D8
<th>CLI<td>58
<tr><th>CLV<td>B8
<th>CMP<td>C1 C5 C9 CD D1 D5 D9 DD
<tr><th>CPX<td>E0 E4 EC
<th>CPY<td>C0 C4 CC
<tr><th>DEC<td>C6 CE D6 DE
<th>DEX<td>CA
<tr><th>DEY<td>88
<th>EOR<td>41 45 49 4D 51 55 59 5D
<tr><th>INC<td>E6 EE F6 FE
<th>INX<td>E8
<tr><th>INY<td>C8
<th>JMP<td>4C 6C
<tr><th>JSR<td>20
<th>LDA<td>A1 A5 A9 AD B1 B5 B9 BD
<tr><th>LDX<td>A2 A6 AE B6 BE
<th>LDY<td>A0 A4 AC B4 BC
<tr><th>LSR<td>46 4A 4E 56 5E
<th>NOP<td>EA
<tr><th>ORA<td>01 05 09 0D 11 15 19 1D
<th>PHA<td>48
<tr><th>PHP<td>08
<th>PLA<td>68
<tr><th>PLP<td>28
<th>ROL<td>26 2A 2E 36 3E
<tr><th>ROR<td>66 6A 6E 76 7E
<th>RTI<td>40
<tr><th>RTS<td>60
<th>SBC<td>E1 E5 E9 ED F1 F5 F9 FD
<tr><th>SEC<td>38
<th>SED<td>F8
<tr><th>SEI<td>78
<th>STA<td>81 85 8D 91 95 99 9D
<tr><th>STX<td>86 8E 96
<th>STY<td>84 8C 94
<tr><th>TAX<td>AA
<th>TAY<td>A8
<tr><th>TSX<td>BA
<th>TXA<td>8A
<tr><th>TXS<td>9A
<th>TYA<td>98
</table>
<table width="100%" class="opcodes">
<caption>Aliases, pseudo instructions</caption>
<tr><th width="4%">ASL<td width="46%">0A
<th width="4%">BGE<td width="46%">B0
<tr><th>BLT<td>90
<th>GCC<td>4C 90
<tr><th>GCS<td>4C B0
<th>GEQ<td>4C F0
<tr><th>GGE<td>4C B0
<th>GLT<td>4C 90
<tr><th>GMI<td>30 4C
<th>GNE<td>4C D0
<tr><th>GPL<td>10 4C
<th>GVC<td>4C 50
<tr><th>GVS<td>4C 70
<th>LSR<td>4A
<tr><th>ROL<td>2A
<th>ROR<td>6A
<tr><th>SHL<td>06 0A 0E 16 1E
<th>SHR<td>46 4A 4E 56 5E
</table>

<hr>
<h3>6502 illegal opcodes</h3>
<p>This processor is a standard 6502 with the NMOS illegal opcodes.</p>
<table width="100%" class="opcodes">
<caption>Additional opcodes</caption>
<tr><th width="4%">ANC<td width="46%">0B
<th width="4%">ANE<td width="46%">8B
<tr><th>ARR<td>6B
<th>ASR<td>4B
<tr><th>DCP<td>C3 C7 CF D3 D7 DB DF
<th>ISB<td>E3 E7 EF F3 F7 FB FF
<tr><th>JAM<td>02
<th>LAX<td>A3 A7 AB AF B3 B7 BF
<tr><th>LDS<td>BB
<th>NOP<td>04 0C 14 1C 80
<tr><th>RLA<td>23 27 2F 33 37 3B 3F
<th>RRA<td>63 67 6F 73 77 7B 7F
<tr><th>SAX<td>83 87 8F 97
<th>SBX<td>CB
<tr><th>SHA<td>93 9F
<th>SHS<td>9B
<tr><th>SHX<td>9E
<th>SHY<td>9C
<tr><th>SLO<td>03 07 0F 13 17 1B 1F
<th>SRE<td>43 47 4F 53 57 5B 5F
</table>
<table width="100%" class="opcodes">
<caption>Additional aliases</caption>
<tr><th width="4%">AHX<td width="46%">93 9F
<th width="4%">ALR<td width="46%">4B
<tr><th>AXS<td>CB
<th>DCM<td>C3 C7 CF D3 D7 DB DF
<tr><th>INS<td>E3 E7 EF F3 F7 FB FF
<th>ISC<td>E3 E7 EF F3 F7 FB FF
<tr><th>LAE<td>BB
<th>LAS<td>BB
<tr><th>LXA<td>AB
<th>TAS<td>9B
<tr><th>XAA<td>8B
<th><td>
</table>

<hr>
<h3>65DTV02 opcodes</h3>
<p>This processor is an enhanced version of standard 6502 with some illegal opcodes.</p>
<table width="100%" class="opcodes">
<caption>Additionally to 6502 illegal opcodes</caption>
<tr><th width="4%">BRA<td width="46%">12
<th width="4%">SAC<td width="46%">32
<tr><th>SIR<td>42
<th><td>
</table>
<table width="100%" class="opcodes">
<caption>Additional pseudo instruction</caption>
<tr><th width="4%">GRA<td width="46%">12 4C
<th width="4%">&nbsp;&nbsp;&nbsp;<td width="46%">
</table>
<table width="100%" class="opcodes">
<caption>These illegal opcodes are not valid</caption>
<tr><th width="4%">ANC<td width="46%">0B
<th width="4%">JAM<td width="46%">02
<tr><th>LDS<td>BB
<th>NOP<td>04 0C 14 1C 80
<tr><th>SBX<td>CB
<th>SHA<td>93 9F
<tr><th>SHS<td>9B
<th>SHX<td>9E
<tr><th>SHY<td>9C
<th><td>
</table>
<table width="100%" class="opcodes">
<caption>These aliases are not valid</caption>
<tr><th width="4%">AHX<td width="46%">93 9F
<th width="4%">AXS<td width="46%">CB
<tr><th>LAE<td>BB
<th>LAS<td>BB
<tr><th>TAS<td>9B
<th><td>
</table>

<hr>
<h3>Standard 65C02 opcodes</h3>
<p>This processor is an enhanced version of standard 6502.</p>
<table width="100%" class="opcodes">
<caption>Additional opcodes</caption>
<tr><th width="4%">ADC<td width="46%">72
<th width="4%">AND<td width="46%">32
<tr><th>BIT<td>34 3C 89
<th>BRA<td>80
<tr><th>CMP<td>D2
<th>DEC<td>3A
<tr><th>EOR<td>52
<th>INC<td>1A
<tr><th>JMP<td>7C
<th>LDA<td>B2
<tr><th>ORA<td>12
<th>PHX<td>DA
<tr><th>PHY<td>5A
<th>PLX<td>FA
<tr><th>PLY<td>7A
<th>SBC<td>F2
<tr><th>STA<td>92
<th>STZ<td>64 74 9C 9E
<tr><th>TRB<td>14 1C
<th>TSB<td>04 0C
</table>
<table width="100%" class="opcodes">
<caption>Additional aliases and pseudo instructions</caption>
<tr><th width="4%">CLR<td width="46%">64 74 9C 9E
<th width="4%">DEA<td width="46%">3A
<tr><th>GRA<td>4C 80
<th>INA<td>1A
</table>

<hr>
<h3>R65C02 opcodes</h3>
<p>This processor is an enhanced version of standard 65C02.</p>
<table width="100%" class="opcodes">
<caption>Additional opcodes</caption>
<tr><th width="4%">BBR<td width="46%">0F 1F 2F 3F 4F 5F 6F 7F
<th width="4%">BBS<td width="46%">8F 9F AF BF CF DF EF FF
<tr><th>RMB<td>07 17 27 37 47 57 67 77
<th>SMB<td>87 97 A7 B7 C7 D7 E7 F7
</table>

<hr>
<h3>W65C02 opcodes</h3>
<p>This processor is an enhanced version of R65C02.</p>
<table width="100%" class="opcodes">
<caption>Additional opcodes</caption>
<tr><th width="4%">STP<td width="46%">DB
<th width="4%">WAI<td width="46%">CB
</table>

<table width="100%" class="opcodes">
<caption>Additional aliases</caption>
<tr><th width="4%">HLT<td width="46%">DB
<th width="4%">&nbsp;&nbsp;&nbsp;<td width="46%">&nbsp;&nbsp;
</table>

<hr>
<h3>W65816 opcodes</h3>
<p>This processor is an enhanced version of W65C02.</p>
<table width="100%" class="opcodes">
<caption>Additional opcodes</caption>
<tr><th width="4%">ADC<td width="46%">63 67 6F 73 77 7F
<th width="4%">AND<td width="46%">23 27 2F 33 37 3F
<tr><th>BRL<td>82
<th>CMP<td>C3 C7 CF D3 D7 DF
<tr><th>COP<td>02
<th>EOR<td>43 47 4F 53 57 5F
<tr><th>JMP<td>5C DC
<th>JSL<td>22
<tr><th>JSR<td>FC
<th>LDA<td>A3 A7 AF B3 B7 BF
<tr><th>MVN<td>54
<th>MVP<td>44
<tr><th>ORA<td>03 07 0F 13 17 1F
<th>PEA<td>F4
<tr><th>PEI<td>D4
<th>PER<td>62
<tr><th>PHB<td>8B
<th>PHD<td>0B
<tr><th>PHK<td>4B
<th>PLB<td>AB
<tr><th>PLD<td>2B
<th>REP<td>C2
<tr><th>RTL<td>6B
<th>SBC<td>E3 E7 EF F3 F7 FF
<tr><th>SEP<td>E2
<th>STA<td>83 87 8F 93 97 9F
<tr><th>TCD<td>5B
<th>TCS<td>1B
<tr><th>TDC<td>7B
<th>TSC<td>3B
<tr><th>TXY<td>9B
<th>TYX<td>BB
<tr><th>XBA<td>EB
<th>XCE<td>FB
</table>

<table width="100%" class="opcodes">
<caption>Additional aliases</caption>
<tr><th width="4%">CSP<td width="46%">02
<th width="4%">CLP<td width="46%">C2
<tr><th>JML<td>5C DC
<th>SWA<td>EB
<tr><th>TAD<td>5B
<th>TAS<td>1B
<tr><th>TDA<td>7B
<th>TSA<td>3B
<tr><th><td>
</table>

<hr>
<h3>65EL02 opcodes</h3>
<p>This processor is an enhanced version of standard 65C02.</p>
<table width="100%" class="opcodes">
<caption>Additional opcodes</caption>
<tr><th width="4%">ADC<td width="46%">63 67 73 77
<th width="4%">AND<td width="46%">23 27 33 37
<tr><th>CMP<td>C3 C7 D3 D7
<th>DIV<td>4F 5F 6F 7F
<tr><th>ENT<td>22
<th>EOR<td>43 47 53 57
<tr><th>JSR<td>FC
<th>LDA<td>A3 A7 B3 B7
<tr><th>MMU<td>EF
<th>MUL<td>0F 1F 2F 3F
<tr><th>NXA<td>42
<th>NXT<td>02
<tr><th>ORA<td>03 07 13 17
<th>PEA<td>F4
<tr><th>PEI<td>D4
<th>PER<td>62
<tr><th>PHD<td>DF
<th>PLD<td>CF
<tr><th>REA<td>44
<th>REI<td>54
<tr><th>REP<td>C2
<th>RER<td>82
<tr><th>RHA<td>4B
<th>RHI<td>0B
<tr><th>RHX<td>1B
<th>RHY<td>5B
<tr><th>RLA<td>6B
<th>RLI<td>2B
<tr><th>RLX<td>3B
<th>RLY<td>7B
<tr><th>SBC<td>E3 E7 F3 F7
<th>SEA<td>9F
<tr><th>SEP<td>E2
<th>STA<td>83 87 93 97
<tr><th>STP<td>DB
<th>SWA<td>EB
<tr><th>TAD<td>BF
<th>TDA<td>AF
<tr><th>TIX<td>DC
<th>TRX<td>AB
<tr><th>TXI<td>5C
<th>TXR<td>8B
<tr><th>TXY<td>9B
<th>TYX<td>BB
<tr><th>WAI<td>CB
<th>XBA<td>EB
<tr><th>XCE<td>FB
<th>ZEA<td>8F
</table>
<table width="100%" class="opcodes">
<caption>Additional aliases</caption>
<tr><th width="4%">CLP<td width="46%">C2
<th width="4%">HLT<td width="46%">DB
</table>

<hr>
<h3>65CE02 opcodes</h3>
<p>This processor is an enhanced version of R65C02.</p>
<table width="100%" class="opcodes">
<caption>Additional opcodes</caption>
<tr><th width="4%">ASR<td width="46%">43 44 54
<th width="4%">ASW<td width="46%">CB
<tr><th>BCC<td>93
<th>BCS<td>B3
<tr><th>BEQ<td>F3
<th>BMI<td>33
<tr><th>BNE<td>D3
<th>BPL<td>13
<tr><th>BRA<td>83
<th>BSR<td>63
<tr><th>BVC<td>53
<th>BVS<td>73
<tr><th>CLE<td>02
<th>CPZ<td>C2 D4 DC
<tr><th>DEW<td>C3
<th>DEZ<td>3B
<tr><th>INW<td>E3
<th>INZ<td>1B
<tr><th>JSR<td>22 23
<th>LDA<td>E2
<tr><th>LDZ<td>A3 AB BB
<th>NEG<td>42
<tr><th>PHW<td>F4 FC
<th>PHZ<td>DB
<tr><th>PLZ<td>FB
<th>ROW<td>EB
<tr><th>RTS<td>62
<th>SEE<td>03
<tr><th>STA<td>82
<th>STX<td>9B
<tr><th>STY<td>8B
<th>TAB<td>5B
<tr><th>TAZ<td>4B
<th>TSY<td>0B
<tr><th>TYS<td>2B
<th>TZA<td>6B
</table>

<table width="100%" class="opcodes">
<caption>Additional aliases</caption>
<tr><th width="4%">ASR<td width="46%">43
<th width="4%">BGE<td width="46%">B3
<tr><th>BLT<td>93
<th>NEG<td>42
<tr><th>RTN<td>62
<th><td>
</table>

<table width="100%" class="opcodes">
<caption>This alias is not valid</caption>
<tr><th width="4%">CLR<td width="46%">64 74 9C 9E
<th width="4%">&nbsp;&nbsp;&nbsp;<td width="46%">&nbsp;&nbsp;
</table>
</body></html>