1
0
mirror of https://github.com/fadden/6502bench.git synced 2025-08-07 22:25:09 +00:00

Change the way ASCII is handled for 64tass

The documentation for 64tass says you're required to pass "--ascii"
when the source file is ASCII (as opposed to PETSCII).  We were
ignoring this, but it turns out that everything works a bit better
if we don't.

So we now pass "--ascii" on the command line, and add a two-line
character encoding definition to every file that is generated with
ASCII as the default encoding.  The sg_petscii and sg_screen
encodings go away, as PETSCII is now the default, and we can use the
built-in "screen" encoding.
This commit is contained in:
Andy McFadden
2019-08-20 11:21:30 -07:00
parent 0abea2beac
commit 149e763821
26 changed files with 77 additions and 41 deletions

View File

@@ -279,26 +279,30 @@ namespace SourceGen.AsmGen {
TextScanMode textMode = Project.ProjectProps.AnalysisParams.DefaultTextScanMode;
switch (textMode) {
case TextScanMode.C64Petscii:
OutputLine(string.Empty, ".enc", "sg_petscii", string.Empty);
OutputLine(string.Empty, ".cdef", "\" @\", $20", string.Empty);
OutputLine(string.Empty, ".cdef", "\"AZ\", $c1", string.Empty);
OutputLine(string.Empty, ".cdef", "\"az\", $41", string.Empty);
OutputLine(string.Empty, ".cdef", "\"[[\", $5b", string.Empty);
OutputLine(string.Empty, ".cdef", "\"]]\", $5d", string.Empty);
// With "--ascii", this is the default.
//OutputLine(string.Empty, ".enc", "sg_petscii", string.Empty);
//OutputLine(string.Empty, ".cdef", "\" @\", $20", string.Empty);
//OutputLine(string.Empty, ".cdef", "\"AZ\", $c1", string.Empty);
//OutputLine(string.Empty, ".cdef", "\"az\", $41", string.Empty);
//OutputLine(string.Empty, ".cdef", "\"[[\", $5b", string.Empty);
//OutputLine(string.Empty, ".cdef", "\"]]\", $5d", string.Empty);
break;
case TextScanMode.C64ScreenCode:
OutputLine(string.Empty, ".enc", "sg_screen", string.Empty);
OutputLine(string.Empty, ".cdef", "\" ?\", $20", string.Empty);
OutputLine(string.Empty, ".cdef", "\"@@\", $00", string.Empty);
OutputLine(string.Empty, ".cdef", "\"AZ\", $41", string.Empty);
OutputLine(string.Empty, ".cdef", "\"az\", $01", string.Empty);
OutputLine(string.Empty, ".cdef", "\"[[\", $1b", string.Empty);
OutputLine(string.Empty, ".cdef", "\"]]\", $1d", string.Empty);
// With "--ascii", we can use the built-in screen encoding.
OutputLine(string.Empty, ".enc", "screen", string.Empty);
//OutputLine(string.Empty, ".enc", "sg_screen", string.Empty);
//OutputLine(string.Empty, ".cdef", "\" ?\", $20", string.Empty);
//OutputLine(string.Empty, ".cdef", "\"@@\", $00", string.Empty);
//OutputLine(string.Empty, ".cdef", "\"AZ\", $41", string.Empty);
//OutputLine(string.Empty, ".cdef", "\"az\", $01", string.Empty);
//OutputLine(string.Empty, ".cdef", "\"[[\", $1b", string.Empty);
//OutputLine(string.Empty, ".cdef", "\"]]\", $1d", string.Empty);
break;
case TextScanMode.LowAscii:
case TextScanMode.LowHighAscii:
default:
// ASCII in, ASCII out
OutputLine(string.Empty, ".enc", "sg_ascii", string.Empty);
OutputLine(string.Empty, ".cdef", "$20,$7e,$20", string.Empty);
break;
}
}
@@ -718,11 +722,12 @@ namespace SourceGen.AsmGen {
/// Cross-assembler execution interface.
/// </summary>
public class AsmTass64 : IAssembler {
// Standard options. Note we're not using --ascii, which causes all character data
// to be converted to PETSCII by default. By keeping things "raw" we can define our
// character encoding explicitly. Anybody who wants to move the code to native
// assembly can generate for PETSCII and then just delete the sg_petscii .cdefs.
public const string OPTIONS = "--case-sensitive --nostart --long-address -Wall";
// Standard options. For historical reasons the assembler expects PETSCII input by
// default, and requires "--ascii" for ASCII/UTF-8 input. This flag switches the
// default "none" encoding from "raw" to something that converts characters to
// PETSCII, so if you want to output strings in another format (such as ASCII) an
// explicit encoding must be specified.
public const string OPTIONS = "--ascii --case-sensitive --nostart --long-address -Wall";
// Paths from generator.
private List<string> mPathNames;

View File

@@ -159,15 +159,14 @@ code, but also needs to know how to handle the corner cases.</p>
that they plan to move to carets.)</li>
<li>The arguments to COP and BRK require immediate-mode syntax
(<code>COP #$03</code> rather than <code>COP $03</code>).
<li>By default, the assembler assumes that the input is PETSCII, but
doesn't convert characters in text strings. So PETSCII source files
generate PETSCII strings, and ASCII source files generate ASCII
strings. However, if you use the built-in "screen" encoding, you will
get the wrong behavior if you compile an ASCII source without the
"--ascii" command-line flag, because it expects to convert from
PETSCII. To get the behavior expected of a cross-assembler, the
recommended approach seems to be to pass "--ascii" and explicitly
define an ASCII encoding for use with ASCII text strings.</li>
<li>For historical reasons, the default behavior of the assembler is to
assume that the source file is PETSCII, and the desired encoding for
strings is also PETSCII. No character conversion is done, so anybody
assembling ASCII files will get ASCII strings (which works out pretty
well if you're assembling code for a non-Commodore target). However,
the documentation says you're required to pass the "--ascii" flag when
the input is ASCII/UTF-8, so to build files that want ASCII operands
an explicit character encoding definition must be provided.</li>
</ul>
<p>Notes:</p>

View File

@@ -1,4 +1,6 @@
.cpu "65816"
.enc sg_ascii
.cdef $20,$7e,$20
* = $1000
.as
.xs

View File

@@ -1,4 +1,6 @@
.cpu "65816"
.enc sg_ascii
.cdef $20,$7e,$20
* = $1000
.as
.xs

View File

@@ -1,4 +1,6 @@
.cpu "65816"
.enc sg_ascii
.cdef $20,$7e,$20
* = $1000
.as
.xs

View File

@@ -1,4 +1,6 @@
.cpu "65816"
.enc sg_ascii
.cdef $20,$7e,$20
* = $1000
.as
.xs

View File

@@ -1,4 +1,6 @@
.cpu "65816"
.enc sg_ascii
.cdef $20,$7e,$20
* = $1000
.as
.xs

View File

@@ -1,4 +1,6 @@
.cpu "6502i"
.enc sg_ascii
.cdef $20,$7e,$20
* = $1000
jsr L1035
jsr L1038

View File

@@ -1,4 +1,6 @@
.cpu "6502i"
.enc sg_ascii
.cdef $20,$7e,$20
* = $1000
jsr L1035
jsr L1038

View File

@@ -1,4 +1,6 @@
.cpu "65c02"
.enc sg_ascii
.cdef $20,$7e,$20
* = $1000
jsr L1014
jsr L108A

View File

@@ -1,4 +1,6 @@
.cpu "65c02"
.enc sg_ascii
.cdef $20,$7e,$20
* = $1000
jsr L1014
jsr L108A

View File

@@ -1,5 +1,7 @@
;Project file was edited to get all big-endian data types.
.cpu "6502"
.enc sg_ascii
.cdef $20,$7e,$20
* = $1000
rts

View File

@@ -1,5 +1,7 @@
;Project file was edited to get zero-length strings and reverse DCI.
.cpu "6502"
.enc sg_ascii
.cdef $20,$7e,$20
* = $1000
rts

View File

@@ -1,5 +1,7 @@
;Project file was edited for some ASCII operands.
.cpu "65816"
.enc sg_ascii
.cdef $20,$7e,$20
* = $1000
.as
.xs

View File

@@ -1,6 +1,8 @@
;Project was edited to add a label in the middle of a dense hex region, and add
;a duplicate label.
.cpu "65816"
.enc sg_ascii
.cdef $20,$7e,$20
zip = $cd
absl = $1029
plataddr = $3000 ;address only in platform file

View File

@@ -1,4 +1,6 @@
.cpu "65816"
.enc sg_ascii
.cdef $20,$7e,$20
* = $1000
.as
.xs

View File

@@ -1,4 +1,6 @@
.cpu "65816"
.enc sg_ascii
.cdef $20,$7e,$20
longsym = $123456
* = $1000

View File

@@ -1,4 +1,6 @@
.cpu "65816"
.enc sg_ascii
.cdef $20,$7e,$20
* = $1000
.as
.xs

View File

@@ -1,4 +1,6 @@
.cpu "6502"
.enc sg_ascii
.cdef $20,$7e,$20
* = $1000
.byte $03
.byte $02

View File

@@ -1,4 +1,6 @@
.cpu "65816"
.enc sg_ascii
.cdef $20,$7e,$20
REALLYLONGLABELNAME = $8888 ;that's a long name
* = $1000

View File

@@ -14,6 +14,8 @@
;* *
;***************************************
.cpu "6502"
.enc sg_ascii
.cdef $20,$7e,$20
plataddr = $3000 ;address only in platform file
;Short, unboxed comment here!!

View File

@@ -1,5 +1,7 @@
;6502bench SourceGen v1.1.0-dev1
.cpu "65816"
.enc sg_ascii
.cdef $20,$7e,$20
* = $1000
.as
.xs

View File

@@ -1,4 +1,6 @@
.cpu "6502"
.enc sg_ascii
.cdef $20,$7e,$20
* = $0000
nop
nop

View File

@@ -1,5 +1,7 @@
;Project edited to mark some non-ASCII operands as ASCII.
.cpu "65816"
.enc sg_ascii
.cdef $20,$7e,$20
* = $1000
.as
.xs

View File

@@ -1,11 +1,5 @@
;Project edited to mark some non-ASCII operands as ASCII.
.cpu "65816"
.enc sg_petscii
.cdef " @", $20
.cdef "AZ", $c1
.cdef "az", $41
.cdef "[[", $5b
.cdef "]]", $5d
* = $1000
.as
.xs

View File

@@ -1,12 +1,6 @@
;Project edited to mark some non-ASCII operands as ASCII.
.cpu "65816"
.enc sg_screen
.cdef " ?", $20
.cdef "@@", $00
.cdef "AZ", $41
.cdef "az", $01
.cdef "[[", $1b
.cdef "]]", $1d
.enc screen
* = $1000
.as
.xs