1
0
mirror of https://github.com/fadden/6502bench.git synced 2026-04-25 21:18:25 +00:00

Progress toward 64tass support

Most tests pass, but 2007-labels-and-symbols fails because the
expressions recognized by 64tass don't match up with either of the
other assemblers.

This is currently using a workaround for the local label syntax.
64tass uses '_' as the prefix, which is unfortunate since SourceGen
explicitly allowed underscores in labels.  (So does 64tass for that
matter, but it treats labels specially when the '_' comes first.)
We will need to rename any non-local user labels that start with '_'.

(issue #16)
This commit is contained in:
Andy McFadden
2018-10-23 16:06:29 -07:00
parent eec37b684e
commit f7e5cf2f45
32 changed files with 3684 additions and 13 deletions
+99
View File
@@ -24,6 +24,7 @@ for each.</p>
<p>SourceGen currently supports the following cross-assemblers:</p>
<ul>
<li><a href="https://sourceforge.net/projects/tass64/">64tass</a> v1.53.1515 or later</li>
<li><a href="https://cc65.github.io/">cc65</a> v2.17 or later</li>
<li><a href="https://www.brutaldeluxe.fr/products/crossdevtools/merlin/">Merlin 32</a> v1.0.0 or later</li>
</ul>
@@ -105,6 +106,104 @@ and report any differences.</p>
SourceGen. However, SourceGen can generally work around assembler bugs,
so any failure is an opportunity for improvement.</p>
<h2><a name="quirks">Assembler-Specific Bugs &amp; Quirks</a></h2>
<p>This is a list of bugs and quirky behavior in cross-assemblers that
SourceGen works around when generating code.</p>
<p>Every assembler seems to have a different way of dealing with expressions.
Most of them will let you group expressions with parenthesis, but that
doesn't always help. For example, <code>PEA label >> 8 + 1</code> is
perfectly valid, but writing <code>PEA (label >> 8) + 1</code> will cause
most assemblers to assume you're trying to use an alterate form of PEA
with indirect addressing (which doesn't exist). The code generator needs
to understand expression syntax and operator precedence to generate correct
code, but also needs to know how to handle the corner cases.</p>
<h3><a name="64tass">64tass</a></h3>
<p>Code is generated for 64tass v1.53.1515.</p>
<p>Bugs:</p>
<ul>
<li>Undocumented opcodes: <code>SHA (ZP),Y</code> ($93) is not supported;
the assembler appears to be expecting <code>SHA ABS,X</code> instead.</li>
<li>BRK, COP, and WDM are not allowed to have operands.</li>
</ul>
<p>Quirks:</p>
<ul>
<li>The underscore character ('_') is allowed as a character in labels,
but when used as the first character in a label it indicates the
label is local. If you create labels with leading underscores that
are not local, the labels must be altered to start with some other
character, and made unique.</li>
<li>By default, 64tass sets the first two bytes of the output file to
the load address. The <code>--nostart</code> flag is used to
suppress this.</li>
<li>By default, 64tass is case-insensitive, but SourceGen treats labels
as case-sensitive. The <code>--case-sensitive</code> must be passed to
the assembler.</li>
<li>If you set the <code>--case-sensitive</code> flag, <b>all</b> opcodes
and operands must be lower-case. Most of the flags used to show
things in upper case must be disabled.</li>
<li>For 65816, selecting the bank byte is done with the back-quote ('`')
rather than the caret ('^'). (There's a note in the docs to the effect
that they plan to move to carets.)</li>
</ul>
<h3><a name="cc65">cc65</a></h3>
<p>Code is generated for cc65 v2.27.</p>
<p>Bugs:</p>
<ul>
<li>The arguments to MVN/MVP are reversed.</li>
<li>PC relative branches don't wrap around at bank boundaries.</li>
<li>BRK &lt;arg&gt; is assembled to opcode $05 rather than $00.</li>
<li>WDM is not supported.</li>
</ul>
<p>Quirks:</p>
<ul>
<li>Operator precedence is unusual. Consider <code>label >> 8 - 16</code>.
cc65 puts shift higher than subtraction, whereas languages like C
and assemblers like 64tass do it the other way around. So cc65
regards the expression as <code>(label >> 8) - 16</code>, while the
more common interpretation would be <code>label >> (8 - 16)</code>.
(This is actually somewhat convenient, since many common expressions
don't require parenthesis.)</li>
<li>Undocumented opcodes: SBX ($cb) uses the mnemonic AXS. All other
opcodes match up with the "unintended opcodes" document.</li>
</ul>
<h3><a name="merlin32">Merlin 32</a></h3>
<p>Code is generated for Merlin 32 v1.0.</p>
<p>Bugs:</p>
<ul>
<li>PC relative branches don't wrap around at bank boundaries.</li>
<li>For some failures, an exit code of zero is returned.</li>
</ul>
<p>Quirks:</p>
<ul>
<li>Operator precedence is unusual. Expressions are processed from
left to right, with no operator precedence.</li>
<li>The byte selection operators ('&lt;', '&gt;', '^') are actually
word-selection operators, yielding 16-bit values when wide registers
are enabled on the 65816.</p>
<li>The assembler tracks register widths when it sees SEP/REP instructions,
but doesn't attempt to track the emulation flag. So if the registers
are long when you switch to emulation, incorrect code is generated.
(Really I just want to be able to turn the auto-tracking off.)</li>
<li>Non-unique local labels don't cause an error.</li>
</ul>
</div>
<div id="footer">
+6
View File
@@ -85,6 +85,12 @@ and 65816 code. The official web site is
<li><a href="codegen.html#localizer">Label Localizer</a></li>
</ul></li>
<li><a href="codegen.html#assemble">Cross-Assembling Generated Code</a></li>
<li><a href="codegen.html#quirks">Assembler-Specific Bugs &amp; Quirks</a>
<ul>
<li><a href="codegen.html#64tass">64tass</a></li>
<li><a href="codegen.html#cc65">cc65</a></li>
<li><a href="codegen.html#merlin32">Merlin 32</a></li>
</ul></li>
</ul></li>
<li><a href="settings.html">Properties &amp; Settings</a>