1
0
mirror of https://github.com/fachat/xa65.git synced 2024-06-08 23:29:30 +00:00

merge fixed code

This commit is contained in:
Andre Fachat 2019-10-29 22:01:39 +01:00
commit 7bc7e5d4dc
100 changed files with 4186 additions and 140 deletions

2
README
View File

@ -10,7 +10,7 @@ Due to current time constraints Cameron can not do any updates, so I decided to
These are the directories:
xa - contains the main source. The master branch is the stable version (currently 2.3.5)
xa - contains the main source. The master branch is the stable version
These are the current branches:

View File

@ -296,6 +296,46 @@ xa-2.3.5
-- Cameron Kaiser <ckaiser@floodgap.com> 7 February, 2009
xa-2.3.6
* 'make test' for regression testing framework (requires Perl).
* Changed getline() to xa_getline() to avoid collision with glibc 2.10+
* Fixed compile problems with misc/.
* Fixed message offsets.
-- Cameron Kaiser <ckaiser@floodgap.com> 11 July 2014
xa-2.3.7
* Fixed buffer overflow and test failure with gcc 4.9 (thanks Adam Sampson).
* mvn and mvp now use the standard syntax (thanks Alessandro Gatti).
* Copyright message is no longer put in the error log to simplify testing.
* Makefile properly triggers a relink for testing or source changes.
* Spurious messages quelled.
* Documentation updated.
* Testsuite expanded.
-- Cameron Kaiser <ckaiser@floodgap.com> 29 December 2014
xa-2.3.8
* Fixed issue with colons in string literals being treated as separators
(thanks Simon Rowe).
* Testsuite expanded.
-- Cameron Kaiser <ckaiser@floodgap.com> 29 June 2017
xa-2.3.9
* Fixed issue on Windows and DOS systems with the .bin pseudo-op (thanks
Bago Zonde).
* Documentation updated.
* Testsuite expanded.
* For the thirty year anniversary of xa, we're changing the name to xxxa.
(Just kidding.)
-- Cameron Kaiser <ckaiser@floodgap.com> 31 January 2019
xa-2.x.x
* Add -E commandline option to not stop after 20 errors, but show all

View File

@ -2,7 +2,9 @@
#
CC = gcc
LD = gcc
CFLAGS = -O2 -W -Wall -pedantic -std=c99 -g
# for testing. not to be used; build failures in misc/.
#CFLAGS = -O2 -W -Wall -pedantic -ansi
CFLAGS = -O2
LDFLAGS = -lc
# for DOS?
@ -24,7 +26,10 @@ DOCDIR = $(DESTDIR)/share/doc
MKDIR = mkdir -p
INSTALL = install
all: xa uncpk
all: killxa xa uncpk
killxa:
rm -f xa
xa:
(cd src && LD=${LD} CC="${CC} ${CFLAGS}" ${MAKE})
@ -58,5 +63,7 @@ install: xa uncpk
#$(MKDIR) $(DOCDIR)/xa65
dist: clean
#cd .. ; tar cvf xa-2.3.5A.tar xa-2.3.5 ; gzip xa-2.3.5A.tar
cd .. ; tar cvf xa-2.3.5.tar xa-2.3.5 ; gzip xa-2.3.5.tar
cd .. ; tar cvf xa-2.3.9.tar xa-2.3.9 ; gzip xa-2.3.9.tar
test: xa uncpk
cd tests && ./harness -make="$(MAKE)" -cc="$(CC)" -cflags="$(CFLAGS)"

View File

@ -3,8 +3,7 @@ derivatives). xa is a small, fast, portable two-pass assembler that compiles
under most ANSI C compilers. It is distributed under the GNU Public License
(see COPYING).
The current version is 2.3.4, which implements multiple improvements on
2.3.2, a bug fix to the 2.3.0 version. 2.3.0 itself features many
The current version is 2.3.9, a bug fix to the long-lived 2.3.0, itself with
compatibility improvements and new man-based documentation. It also completed
the merge of the 65816 and 6502/R65C02 versions and thus the current xa can
generate code for all targets now.
@ -12,6 +11,7 @@ generate code for all targets now.
To install on a generic Unixy thing, you should be able to just type
% make # to build the executable, and if it works ...
% make test # if you have Perl, make and prerequisites, otherwise
% make install # to install man pages and binaries into the system
This will create xa along with its various support utilities. Try assembling

View File

@ -1,4 +1,4 @@
.TH XA "1" "7 February 2009"
.TH XA "1" "31 January 2019"
.SH NAME
xa \- 6502/R65C02/65816 cross-assembler
@ -10,8 +10,7 @@ xa \- 6502/R65C02/65816 cross-assembler
.SH DESCRIPTION
.B xa
is a multi-pass cross-assembler for the 8-bit processors in the 6502 series
(such as
the 6502, 65C02, 6504, 6507,
(such as the 6502, 65C02, 6504, 6507,
6510, 7501, 8500, 8501 and 8502), the Rockwell R65C02, and
the 16-bit 65816 processor. For a description of syntax, see
.B ASSEMBLER SYNTAX
@ -34,7 +33,7 @@ and
This option is now deprecated.
.TP
.B \-C
No CMOS opcodes (default is to allow R65C02 opcodes)
No CMOS opcodes (default is to allow R65C02 opcodes).
.TP
.B \-W
No 65816 opcodes (default).
@ -255,6 +254,21 @@ for block instructions). A label may also be hard-specified with the
.B \-L
command line option.
.LP
Redefining a label does not change previously assembled code that used the
earlier value. Therefore, because the program counter is a special type of
label, changing the program counter to a lower value does not reorder code
assembled previously and changing it to a higher value does not issue
padding to put subsequent code at the new location. This is intentional
behaviour to facilitate generating relocatable and position-independent code,
but can differ from other assemblers which use this behaviour for
linking. However, it is possible to use pseudo-ops to simulate other
assemblers' behaviour and use
.B xa
as a linker; see
.B PSEUDO-OPS
and
.BR LINKING .
.LP
For those instructions where the accumulator is the implied argument (such as
.B asl
and
@ -265,7 +279,7 @@ and
on R65C02; etc.), the idiom of explicitly specifying the accumulator with
.B a
is unnecessary as the proper form will be selected if there is no explicit
argument. In fact, for consistency with label handing, if there is a label
argument. In fact, for consistency with label handling, if there is a label
named
.BR a ,
this will actually generate code referencing that label as a memory
@ -491,7 +505,9 @@ repetitions of
will be inserted into the assembled object. For example,
.B .dsb 5,$10
will insert five bytes, each being 16 decimal, into the object. The arguments
may be expressions.
may be expressions. See
.B LINKING
for how to use this pseudo-op to link multiple objects.
.TP
.B .bin offset,length,"filename"
Inlines a binary file without further interpretation specified by
@ -506,7 +522,9 @@ file's object. If
.B length
is zero, then the length of
.BR filename ,
minus the offset, is used instead. The arguments may be expressions.
minus the offset, is used instead. The arguments may be expressions. See
.B LINKING
for how to use this pseudo-op to link multiple objects.
.TP
.B \&.(
Opens a new block for scoping. Within a block, all labels defined are local to
@ -816,6 +834,107 @@ you might use something like this in your library's code:
.br
.B #endif
.SH LINKING
.B xa
is oriented towards generating sequential binaries. Code is strictly
emitted in order even if the program counter is set to a lower location
than previously assembled code, and padding is not automatically emitted
if the program counter is set to a higher location. Changing the program
location only changes new labels for code that is subsequently emitted;
previous emitted code remains unchanged. Fortunately, for many object files
these conventions have no effect on their generation.
.LP
However, some applications may require generating an object file built
from several previously generated components, and/or submodules which
may need to be present at specific memory locations. With a minor amount of
additional specification, it is possible to use
.B xa
for this purpose as well.
.LP
The first means of doing so uses the o65 format to make relocatable objects
that in turn can be linked by
.BR ldo65 (1)
(q.v.).
.LP
The second means involves either assembled code, or insertion of
previously built object or data files with
.BR .bin ,
using
.B .dsb
pseudo-ops with computed expression arguments to insert any necessary padding
between them, in the sequential order they are to reside in memory. Consider
this example:
.LP
.br
.word $1000
.br
* = $1000
.br
.br
; this is your code at $1000
.br
part1 rts
.br
; this label marks the end of code
.br
endofpart1
.br
.br
; DON'T PUT A NEW .word HERE!
.br
* = $2000
.br
.dsb (*-endofpart1), 0
.br
; yes, set it again
.br
* = $2000
.br
.br
; this is your code at $2000
.br
part2 rts
.br
.LP
This example, written for Commodore microcomputers using a 16-bit starting
address, has two "modules" in it: one block of code at $1000 (4096),
indicated by the code between labels
.B part1
and
.BR endofpart1 ,
and a second block at $2000 (8192) starting at label
.BR part2 .
.LP
The padding is computed by the
.B .dsb
pseudo-op between the two modules. Note that the program counter is set
to the new address and then a computed expression inserts the proper number
of fill bytes from the end of the assembled code in part 1 up to the new
program counter address. Since this itself advances the program counter,
the program counter is reset again, and assembly continues.
.LP
When the object this source file generates is loaded, there will be an
.B rts
instruction at address 4096 and another at address 8192, with null bytes
between them.
.LP
Should one of these areas need to contain a pre-built file, instead of
assembly code, simply use a
.B .bin
pseudo-op to load whatever portions of the file are required into the
output. The computation of addresses and number of necessary fill bytes
is done in the same fashion.
.LP
Although this example used the program counter itself to compute the
difference between addresses, you can use any label for this purpose,
keeping in mind that only the program counter determines where relative
addresses within assembled code are resolved.
.SH ENVIRONMENT
.B xa
@ -844,6 +963,16 @@ and
.B dec
instructions respectively.
.LP
The 65816 instructions
.B mvn
and
.B mvp
use two eight bit parameters, the only instructions in the entire
instruction set to do so. Older versions of
.B xa
took a single 16-bit absolute value. Since 2.3.7, the standard syntax is
now accepted and the old syntax is deprecated (a warning will be generated).
.LP
Forward-defined labels -- that is, labels that are defined after the current
instruction is processed -- cannot be optimized into zero
page instructions even if the label does end up being defined as a zero page
@ -889,8 +1018,11 @@ This manual page was written by David Weinehall <tao@acc.umu.se>,
Andre Fachat <fachat@web.de>
and Cameron Kaiser <ckaiser@floodgap.com>.
Original xa package (C)1989-1997 Andre Fachat. Additional changes
(C)1989-2011 Andre Fachat, Jolse Maginnis, David Weinehall,
(C)1989-2019 Andre Fachat, Jolse Maginnis, David Weinehall,
Cameron Kaiser. The official maintainer is Cameron Kaiser.
.SH 30 YEARS OF XA
Yay us?
.SH WEBSITE
http://www.floodgap.com/retrotech/xa/

View File

@ -1,7 +1,8 @@
XCBMLIB = ..
CFLAGS = -Wall -O2 -ansi -W
# -Wall -ansi et al. cause compile problems.
CFLAGS = -O2
LIBS = #-lncurses -ltermcap -lm

View File

@ -18,12 +18,13 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#ifndef _MSC_VER
#include <unistd.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <string.h>
@ -33,8 +34,8 @@
#define programname "file65"
#define progversion "v0.2.1"
#define author "Written by André Fachat"
#define copyright "Copyright (C) 1997-2002 André Fachat."
#define author "Written by Andre Fachat"
#define copyright "Copyright (C) 1997-2002 Andre Fachat."
int read_options(FILE *fp);
int print_labels(FILE *fp, int offset);
@ -160,11 +161,11 @@ int main(int argc, char *argv[]) {
}
if(rompar==1) {
printf("-A %lu ", (unsigned long)((hdr[9]*256+hdr[8])
-hlen +romoff +fbuf.st_size));
-hlen +romoff +(fbuf.st_size)));
} else
if(rompar==2) {
printf("%lu ", (unsigned long)((hdr[9]*256+hdr[8])
-hlen +romoff +fbuf.st_size));
-hlen +romoff +(fbuf.st_size)));
}
printf("\n");
}

View File

@ -35,8 +35,8 @@
#define programname "ldo65"
#define progversion "v0.1.1"
#define author "Written by André Fachat"
#define copyright "Copyright (C) 1997-2002 André Fachat. Formerly ld65."
#define author "Written by Andre Fachat"
#define copyright "Copyright (C) 1997-2002 Andre Fachat. Formerly ld65."
typedef struct {
char *name;

View File

@ -26,8 +26,8 @@
#define programname "printcbm"
#define progversion "v1.0.0"
#define author "Written by André Fachat"
#define copyright "Copyright (C) 1997-2002 André Fachat."
#define author "Written by Andre Fachat"
#define copyright "Copyright (C) 1997-2002 Andre Fachat."
char *cmd[] = {
"end", "for", "next", "data", "input#", "input", "dim", "read",

View File

@ -31,8 +31,8 @@
#define programname "reloc65"
#define progversion "v0.2.1"
#define author "Written by André Fachat"
#define copyright "Copyright (C) 1997-2002 André Fachat."
#define author "Written by Andre Fachat"
#define copyright "Copyright (C) 1997-2002 Andre Fachat."
typedef struct {
char *fname;

View File

@ -29,8 +29,8 @@
#define programname "uncpk"
#define progversion "v0.2.1"
#define author "Written by André Fachat"
#define copyright "Copyright (C) 1997-2002 André Fachat."
#define author "Written by Andre Fachat"
#define copyright "Copyright (C) 1997-2002 Andre Fachat."
FILE *fp;
char name[100];

View File

@ -56,9 +56,9 @@
#define ANZWARN 13
#define programname "xa"
#define progversion "v2.3.5+af"
#define progversion "v2.3.9+af"
#define authors "Written by Andre Fachat, Jolse Maginnis, David Weinehall and Cameron Kaiser"
#define copyright "Copyright (C) 1989-2009 Andre Fachat, Jolse Maginnis, David Weinehall\nand Cameron Kaiser."
#define copyright "Copyright (C) 1989-2019 Andre Fachat, Jolse Maginnis, David Weinehall\nand Cameron Kaiser."
/* exported globals */
int ncmos, cmosfl, w65816, n65816;
@ -96,7 +96,7 @@ static int puttmp(int);
static int puttmpw(int);
static int puttmps(signed char *, int);
static void chrput(int);
static int xagetline(char *);
static int xa_getline(char *);
static void lineout(void);
static long ga_p1(void);
static long gm_p1(void);
@ -402,6 +402,7 @@ int main(int argc,char *argv[])
if(setfext(old_o,".obj")==0) ofile = old_o;
if(setfext(old_l,".lab")==0) lfile = old_l;
}
if(verbose) fprintf(stderr, "%s\n",copyright);
if (printfile!=NULL && !strcmp(printfile, "-")) {
printfile=NULL;
@ -424,7 +425,6 @@ int main(int argc,char *argv[])
if(verbose) fprintf(stderr, "%s\n",copyright);
if(1 /*!m_init()*/)
{
if(1 /*!b_init()*/)
@ -435,7 +435,7 @@ int main(int argc,char *argv[])
{
if(!x_init())
{
if(fperr) fprintf(fperr,"%s\n",copyright);
/* if(fperr) fprintf(fperr,"%s\n",copyright); */
if(verbose) logout(ctime(&tim1));
list_setfile(fplist);
@ -785,7 +785,7 @@ fprintf(stderr, "offset = %i length = %i fstart = %i flen = %i charo = %c\n",
fprintf(stderr, "fnam = %s\n", binfnam);
*/
/* primitive insurance */
if (!(foo = fopen(binfnam, "r"))) {
if (!(foo = fopen(binfnam, "rb"))) {
errout(E_FNF);
ner++;
} else {
@ -829,7 +829,7 @@ static int pass1(void)
ner=0;
/*FIXIT*/
while(!(er=xagetline(s)))
while(!(er=xa_getline(s)))
{
er=t_p1((signed char*)s,o,&l,&al);
switch(segment) {
@ -870,7 +870,6 @@ static int pass1(void)
}
if(er!=E_EOF) {
fprintf(stderr, "foul through\n");
errout(er);
}
@ -931,7 +930,7 @@ static void usage(int default816, FILE *fp)
" -G suppress list of exported globals\n");
fprintf(fp,
" -DDEF=TEXT defines a preprocessor replacement\n"
" -Ocharset set output charset (PETSCII or ASCII), case-sensitive\n"
" -Ocharset set output charset (PETSCII, ASCII, etc.), case-sensitive\n"
" -Idir add directory `dir' to include path (before XAINPUT)\n"
" --version output version information and exit\n"
" --help display this help and exit\n");
@ -972,7 +971,7 @@ static char *ertxt[] = {
"DSB",
"NewLine",
"NewFile",
"CMOS-Befehl",
"CMOS instruction used with -C",
"pp:Wrong parameter count",
"Illegal pointer arithmetic (-26)",
"Illegal segment",
@ -1024,10 +1023,10 @@ static char *ertxt[] = {
"Open preprocessor directive at end of file (intentional?)",
"Included binary data exceeds 64KB",
"Included binary data exceeds 16MB",
"MVN/MVP $XXXX syntax is deprecated and will be removed",
/* more placeholders */
"",
"",
"",
};
@ -1097,7 +1096,7 @@ static int puttmps(signed char *s, int l)
static char l[MAXLINE];
static int xagetline(char *s)
static int xa_getline(char *s)
{
static int ec;
@ -1146,11 +1145,11 @@ static int xagetline(char *s)
do {
c=s[j]=l[i++];
if (c=='\"') {
if (!(hkfl&2) && c=='\"')
hkfl^=1;
}
if (!comcom && !(hkfl&1) && c=='\'')
hkfl^=2;
if (c==';' && !hkfl) {
// start of comment
comcom = 1;
}
if (c=='\0') {

View File

@ -136,19 +136,20 @@ typedef struct {
#define E_OUTOFDATA -34 /* out of data */
#define E_ILLQUANT -35 /* generic illegal quantity error */
#define E_BIN -36 /* okdef */
/* errors thru 63 are placeholders */
/* errors thru 64 are placeholders available for use */
#define W_ADRRELOC -64 /* word relocation in byte value */
#define W_BYTRELOC -65 /* byte relocation in word value */
#define E_WPOINTER -66 /* illegal pointer arithmetic! */
#define W_ADDRACC -67 /* addr access to low or high byte pointer */
#define W_HIGHACC -68 /* high byte access to low byte pointer */
#define W_LOWACC -69 /* low byte access to high byte pointer */
#define W_FORLAB -70 /* no zp-optimization for a forward label */
#define W_OPENPP -71 /* warning about open preprocessor directive */
#define W_OVER64K -72 /* included binary over 64K in 6502 mode */
#define W_OVER16M -73 /* included binary over 16M in 65816 mode */
/* warnings 74-76 are placeholders */
#define W_ADRRELOC -65 /* word relocation in byte value */
#define W_BYTRELOC -66 /* byte relocation in word value */
#define E_WPOINTER -67 /* illegal pointer arithmetic! */
#define W_ADDRACC -68 /* addr access to low or high byte pointer */
#define W_HIGHACC -69 /* high byte access to low byte pointer */
#define W_LOWACC -70 /* low byte access to high byte pointer */
#define W_FORLAB -71 /* no zp-optimization for a forward label */
#define W_OPENPP -72 /* warning about open preprocessor directive */
#define W_OVER64K -73 /* included binary over 64K in 6502 mode */
#define W_OVER16M -74 /* included binary over 16M in 65816 mode */
#define W_OLDMVNS -75 /* use of old mv? $xxxx syntax */
/* warnings 76-77 are placeholders available for use */
/* Meta-values for the token list. Note must not overlap with the
* K* definitions in xat.c, which have outgrown the positive numbers

View File

@ -215,21 +215,22 @@ int pp_endif(char *t)
/* stub for handling CPP directives */
int pp_cpp(char *t) {
char name[MAXLINE];
char *fname = NULL;
if(sscanf(t, " %d \"%ms\"", &filep->fline, &fname) == 2) {
if(sscanf(t, " %d \"%s\"", &filep->fline, name) == 2) {
/* massage it into our parameters and drop last quote */
char *u = "";
char *u;
filep->fline--;
if((u = (char *)strrchr(fname, '"')))
if((u = (char *)strrchr(name, '"')))
*u = '\0';
// overwrite the original filename
// this may create a memory leak, but we do not know
// whether the file name has already been used in the cross
// reference list. So we just accept that...
filep->fname = fname;
free(filep->fname);
filep->fname = strdup(name);
if(!filep->fname) {
fprintf(stderr,"Oops, no more memory!\n");
exit(1);
}
return (0);
} else {
return(E_SYNTAX);

View File

@ -21,9 +21,12 @@
*/
/* enable this to turn on (copious) optimization output */
/* #define DEBUG_AM */
#undef LISTING_DEBUG
#undef DEBUG_CONV
/*
#define DEBUG_AM
*/
#include <ctype.h>
#include <stdio.h>
@ -114,6 +117,10 @@ char *arith_ops[] = {
/* length of arithmetic operators indexed by operator number */
static int lp[]= { 0,1,1,1,1,2,2,1,1,1,2,2,2,1,1,1,2,2 };
/* mvn and mvp are handled specially, they have a weird syntax */
#define Kmvp 38
#define Kmvn Kmvp+1
/* index into token array for pseudo-ops */
/* last valid mnemonic */
#define Lastbef 93
@ -730,7 +737,7 @@ printf(" wrote %02x %02x %02x %02x %02x %02x, %02x, %02x\n",
"binclude1 offset = %i len = %i filename = %s endchar = %i\n",
offset, length, binfnam, i);
#endif
if (!(foo = fopen(binfnam, "r"))) {
if (!(foo = fopen(binfnam, "rb"))) {
er = E_FNF;
} else {
fseek(foo, 0, SEEK_END);
@ -790,7 +797,7 @@ printf(" wrote %02x %02x %02x %02x %02x %02x, %02x, %02x\n",
/* optimization okay on pass 1: use 0 for fl */
{
#ifdef DEBUG_AM
fprintf(stderr, "E_OK ... t_p2 xat.c\n");
fprintf(stderr, "E_OK ... t_p2 xat.c %i %i\n", t[0], *ll);
#endif
/* this actually calls pass2 on the current tokenization stream,
* but without including the Klisting token listing */
@ -819,7 +826,7 @@ fprintf(stderr, "E_NODEF pass1 xat.c\n");
/* choose addressing mode; add commas found */
if(n>=0 && n<=Lastbef)
if(n>=0 && n<=Lastbef && n != Kmvn && n != Kmvp) /* not for mvn/p */
{
int inp = 1; /* input pointer */
@ -968,6 +975,11 @@ fprintf(stderr, "E_NODEF pass1 xat.c\n");
}
er=E_NOLINE;
} else
if(n==Kmvn || n==Kmvp)
{
bl=3;
if (!w65816) er = E_65816;
} else
if(n==Kbyt || n==Kasc || n==Kaasc)
{
#ifdef DEBUG_AM
@ -1224,7 +1236,9 @@ int t_p2(signed char *t, int *ll, int fl, int *al)
}
*ll=j;
bl=j;
} else if (n == Kbin) {
} else
if (n == Kbin)
{
int j;
int l;
@ -1308,7 +1322,7 @@ int t_p2(signed char *t, int *ll, int fl, int *al)
"binclude2 offset = %i len = %i filename = %s endchar = %i\n",
offset, length, binfnam, i);
#endif
if (!(foo = fopen(binfnam, "r"))) {
if (!(foo = fopen(binfnam, "rb"))) {
er = E_FNF;
} else {
fseek(foo, 0, SEEK_END);
@ -1342,6 +1356,61 @@ int t_p2(signed char *t, int *ll, int fl, int *al)
er = E_BIN;
}
}
} else
if (n==Kmvn || n==Kmvp)
{
/* special case these instructions' syntax */
int wide=0;
i=1;
j=1;
/* write opcode */
t[0] = ((n == Kmvp) ? 0x44 : 0x54);
while(!er && t[i]!=T_END)
{
if (wide) /* oops */
er = E_SYNTAX;
#ifdef DEBUG_AM
fprintf(stderr, "mvn mvp: %i %i %i %i %i\n", t[0], t[i], wide, i, j);
#endif
if(!(er=a_term(t+i,&v,&l,pc[segment],&afl,&label,1)))
{
/*if(afl) printf("relocation 1 %04x at pc=$%04x, value now =$%04x\n",
afl,pc[segment],v); */
if(afl) u_set(pc[segment]+j, afl, label, 2);
i+=l;
/* for backwards compatibility, accept the old
mv? $xxxx syntax, but issue a warning.
mv? $00xx can be legal, so accept that too. */
if ((v & 0xff00) || (j==1 && t[i]==T_END)) {
errout(W_OLDMVNS);
wide = 1;
t[j++] = ((v & 0xff00) >> 8);
t[j++] = (v & 0x00ff);
} else {
t[j++] = v;
}
}
if (j > 3)
er=E_SYNTAX;
if(t[i]!=T_END && t[i]!=',')
er=E_SYNTAX;
else
if(t[i]==',')
i++;
}
if (j != 3) er = E_SYNTAX; /* oops */
/* before we leave, swap the bytes. although disassembled as
mv? src,dest it's actually represented as
mv? $ddss -- see
http://6502org.wikidot.com/software-65816-memorymove */
i = t[2];
t[2] = t[1];
t[1] = i;
*ll = j;
bl = j;
if (!w65816) er = E_65816;
} else if(n==Kasc || n==Kbyt || n==Kaasc) {
i=1;
j=0;
@ -1476,7 +1545,7 @@ fprintf(stderr, "Kdsb E_DSB %i\n", j);
if(n>=0 && n<=Lastbef)
{
int inp = 1; /* input pointer */
signed char cast = '\0'; /* cast value */
signed char cast = '\0'; /* cast value */
c = t[inp];
@ -2026,7 +2095,7 @@ static int t_conv(signed char *s, signed char *t, int *l, int pc, int *nk,
}
if(n>=0 && n<=Lastbef)
if(n != Kmvn && n != Kmvp && ((n & 0xff) <=Lastbef))
mk=1; /* 1= nur 1 Komma erlaubt *//* = only 1 comma ok */
}

View File

@ -2,12 +2,22 @@ This is a directory of test suites for complex or pathological cases that
have been repaired (?) in the current version. It is primarily for internal
testing, but is here for your interest.
Starting with 2.3.6, you should not normally need to run these directly
unless 'make test' fails. If you do, use harness:
./harness -cc=... -cflags=... -make=... -tests=testdir,testdir,testdir,...
If -tests is omitted, all tests are run.
Don't run the makefiles directly, if they exist; they may not work properly.
If a Makefile is not present, then the test harness assembles "test.s" and
compares it with "ok".
adrm/ Addressing mode test (especially the optimizer and quantity
prefixes)
nonl/ Patryk's no-new-line-on-last-line cases ;)
fordef/ Optimizer warnings for forward defined labels
relocundef/ Tests for the detection of undefined references during a
reloc65 export.
reloc65 export
ldoreloc/ Test case for the relocation table reading of ldo when undef'd
refs are involved
comcom/ Comments-with-comments-with-commands-etc. for testing -M
@ -15,12 +25,20 @@ recmac/ Recursive macro evaluation testing
openpp/ Testing of open #if*s in pp
cpp/ Random preprocessor tests, mostly crap
incerr/ 1) .xl/.al should error without -w 2) error should be in
the correct file
the correct file ('816)
binclude/ Binary include code with some weird casing
chppch/ Changing preprocessor characters (-p)
charset/ Tests of when charsets should be honoured and when not
cc65/ Compatibility tests for ca65 compatibility
ca65/ Compatibility tests for ca65 compatibility
relmode/ tests concerning switches between segments and absolute mode
mvnmvp/ Test MVN MVP unusual addressing mode ('816)
dos51/ Regression test, label scoping, "real world code"
cpktest/ Regression test, label listing, "real world code"
op816/ Regression test for '816 opcodes (thanks Alessandro Gatti)
branch/ Branch range test
masmcom/ Another test for -M that generates totally valid code
quotch/ Test quoting problematic characters (thanks Simon Rowe)
linkr/ Test linking using .dsb and generated code
Cameron Kaiser, André Fachat

BIN
xa/tests/adrm/02.ok Normal file

Binary file not shown.

20
xa/tests/adrm/Makefile Normal file
View File

@ -0,0 +1,20 @@
default:
# xa should not allow this to happen. if it does, this test is no good.
../../xa 816.asm || exit 0 && exit 1
../../xa zab.asm || exit 0 && exit 1
../../xa zpa.asm || exit 0 && exit 1
../../xa -C c02.asm || exit 0 && exit 1
# expected-to-fail tests did fail. should be no more errors now.
../../xa -C 02.asm -o 02.o
../hextool -cmp=02.ok < 02.o
../../xa c02.asm -o c02.o
../hextool -cmp=c02.ok < c02.o
../../xa -w 816.asm -o 816.o
../hextool -cmp=816.ok < 816.o
../../xa -w zab.asm -o zab.o
../hextool -cmp=zab.ok < zab.o
../../xa -w zpa.asm -o zpa.o
../hextool -cmp=zpa.ok < zpa.o
clean:
rm -f *.o

BIN
xa/tests/adrm/c02.ok Normal file

Binary file not shown.

BIN
xa/tests/adrm/zab.ok Normal file

Binary file not shown.

BIN
xa/tests/adrm/zpa.ok Normal file

Binary file not shown.

View File

@ -0,0 +1,12 @@
default:
../../xa test.asm -o test.o
../hextool -cmp=test.ok < test.o
../../xa -w test.asm -o test816.o
../hextool -cmp=test.ok < test816.o
../../xa test2.asm -o test2.o
../hextool -cmp=test2.ok < test2.o
../../xa test3.asm -o test3.o
../hextool -cmp=test.ok < test3.o
clean:
rm -f *.o

View File

@ -0,0 +1,117 @@
This is the readme for xa, a cross-assembler for the 6502 and 65816 CPUs (and
derivatives). xa is a small, fast, portable two-pass assembler that compiles
under most ANSI C compilers. It is distributed under the GNU Public License
(see COPYING).
The current version is 2.3.3, which implements several compatibility
improvements on 2.3.2, a bug fix to the 2.3.0 version.
2.3.0 itself features many compatibility improvements and new man-based
documentation. It also completed the merge of the 65816 and 6502/R65C02
versions and thus the current xa can generate code for all targets now.
To install on a generic Unixy thing, you should be able to just type
% make # to build the executable, and if it works ...
% make install # to install man pages and binaries into the system
This will create xa along with its various support utilities. Try assembling
the cpk depacker in examples/ as a test. xa also comes with uncpk (a program
for generating cpk archives) and printcbm (a program for listing Commodore
BASIC test) and file65, ldo65 and reloc65 for displaying, linking and
relocating o65 files in Andre's relocatable format (see doc/fileformats.txt).
The loader/ directory also has goodies for managing relocatable binaries.
Don't forget the man pages in man/. Install these into your MANPATH at your
leisure, or read them with nroff -man (and/or groff -man).
xa is no longer broadly supported outside of Unix due to my inability to test
it, but has nothing that should impair it from compiling elsewhere. To wit,
DOS compilation is still supported with the GO32 package. You should just be
able to type
C:\> make dos
In addition, there are compatibility updates to allow it to compile under
Microsoft Visual Studio and mingw. It should compile under VS2005 as written;
look in the vstudio directory for solution and project files provided by
Fabian Nunez. For mingw, use
make mingw
Similarly, Amiga and Atari ST compilation should still also function with
their particular compatible packages.
xa has a companion disassembler, the dxa package. dxa is not included in the
standard xa distribution, but can be downloaded from the xa home page at
http://www.floodgap.com/retrotech/xa/
Please check by periodically for the latest version of both packages.
xa was originally written and maintained by Andre Fachat. The current version
is maintained by Cameron Kaiser.
Please send me your comments at ckaiser@floodgap.com -- Andre's original
readme follows and applies generally to the present version.
-------------------------------------------------------------------------------
XA is a 6502 cross compiler:
- under GNU public license
- can produce _relocatable_ binaries
- The full fileformat description and 6502 file loader included.
- also included relocation and info utilites, as well as linker
- for any ANSI-C compliant computer (only utilities need 'stat' call
for file size).
- fast by hashtables
- Rockwell CMOS opcodes
- running under DOS and any ANSI C system (Unix, Amiga, Atari ST)
I developed this cross assembler for the 6502 CPU family quite some time
ago on my Atari ST. The assembler has successfully been ported to Amiga
and Unix computer (ported? just compiled... :-)
Lately I came across the problem to need relocatable 6502 binary files, so
I revised the assembler from version 2.0.7 to 2.1.0, adding a (admittedly
proprietary) 6502 relocatable binary format. But there are not many other
formats around and they didn't fit my needs. I have developed this format
myself and it is under the GNU public license.
With version 2.1.1 the 'official' version of the fileformat is supported.
To compile it, just type "make" (if you have the GNU gcc. If not, edit the
Makefile for the compiler options). This produces "xa", the cross assembler;
"uncpk", a small packing utility (where the C64 counterpart is in the
examples subdirectory), "printcbm", that lists C64 BASIC files and
'file65' that prints some information about o65 files. The "loader" in
the loader subdirectory is a basic 6502 implementation of a relocating
binary loader.
"file65" prints file information on 'o65' relocatable files. "reloc65"
can relocate 'o65' files.
If you want to use it under DOS, you have to have the GO32 DOS crosscompiling
tools to compile. Then just type "make dos" and you'll end up with the
appropriate DOS binaries. This has been tested only under i386 Linux, however.
Another archive with the DOS binaries included is provided.
One problem on the Atari was it's broken "malloc". Therefore I used to
alloc everything in one chunk and divide the memory by hand. So everything
was kind of statically allocated. This is almost gone now. Only the
temporary storage between pass1 and pass2 and the preprocessor are still
allocated in one chunk (size definitions in xah.h). The rest is allocated
as needed.
The docs are in the 'doc' subdir. There also is a description of the
6502 relocatable binary format. If you think some things could be
expressed in a better way, feel free and mail me to improve my english ;-)
[ The documentation is now maintained in man(1) format in man/ . -- CK ]
Andre

BIN
xa/tests/binclude/test.ok Normal file

Binary file not shown.

BIN
xa/tests/binclude/test2.ok Normal file

Binary file not shown.

View File

@ -0,0 +1,21 @@
/* This should be the same as test.ok */
.word $9000
* = $9000
w = 10
glorb
.dsb 9,10 ; +9
.byt 6, 6, 6, "devil", 'Q' ; +9 => 18
.bin 0,5,'sd/README.2nd' ; +5 => 23
.bin w,w+256,'sd/README.2nd' ; +266 => 289 ($0121)
gleeb
; $0123
jmp glorb
; should be $9121 (remember the SA)
jmp gleeb
bne *

9
xa/tests/branch/Makefile Normal file
View File

@ -0,0 +1,9 @@
default:
# xa should not allow this to happen. if it does, this test is no good.
../../xa bor.s || exit 0 && exit 1
# expected-to-fail tests did fail. should be no more errors now.
../../xa -w bir.s -o test.o
../hextool -cmp=bir.ok < test.o
clean:
rm -f *.o

BIN
xa/tests/branch/bir.ok Normal file

Binary file not shown.

14
xa/tests/branch/bir.s Normal file
View File

@ -0,0 +1,14 @@
/* just in range */
bcc pdq
pdq
bne xyz
.dsb 124,6
xyz
beq pdq
bcs xyz
bvs xyz
bvc xyz
bpl xyz
bmi xyz

14
xa/tests/branch/bor.s Normal file
View File

@ -0,0 +1,14 @@
/* just in range */
bcc pdq
pdq
bne xyz
.dsb 125,6
xyz
beq pdq
bcs xyz
bvs xyz
bvc xyz
bpl xyz
bmi xyz

View File

@ -1 +0,0 @@
©A©A1234512345"''"

View File

@ -0,0 +1 @@
©A©A1234512345"''"

View File

@ -12,5 +12,5 @@
.asc "'"
.asc '"'
.asc "^1"
.asc "^n"

12
xa/tests/charset/Makefile Normal file
View File

@ -0,0 +1,12 @@
default:
../../xa test.s
../hextool -cmp=no-charset.o < a.o65
../../xa -O PETSCII test.s
../hextool -cmp=petscii.o < a.o65
../../xa -O PETSCREEN test.s
../hextool -cmp=petscreen.o < a.o65
../../xa -O HIGH test.s
../hextool -cmp=high.o < a.o65
clean:
rm -rf a.o65

BIN
xa/tests/charset/high.o Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

6
xa/tests/chppch/Makefile Normal file
View File

@ -0,0 +1,6 @@
default:
../../xa -p'~' -e test.out test.c
../hextool -cmp=ok.out < test.out
clean:
rm -f a.o65 test.out

View File

@ -1 +0,0 @@
`

3
xa/tests/chppch/ok.out Normal file
View File

@ -0,0 +1,3 @@
12+12=12+12=24
10+10=10+10=20
5+5=5+5=10

View File

@ -1,10 +0,0 @@
# 1 "test.c"
# 1 "qwerty.h" 1
rts
#print 12+12
~print 10+10
# 1 "test.c" 2
~print 5+5

14
xa/tests/comcom/Makefile Normal file
View File

@ -0,0 +1,14 @@
default:
# this should fail.
../../xa scomcom.asm || exit 0 && exit 1
# it did fail. these should now all succeed.
../../xa -M scomcom.asm
../hextool -cmp=scomcomm.ok < a.o65
../../xa comcom.asm
../hextool -cmp=comcom.ok < a.o65
../../xa -M comcom.asm
../hextool -cmp=comcomm.ok < a.o65
clean:
rm -f a.o65

BIN
xa/tests/comcom/comcom.ok Normal file

Binary file not shown.

View File

@ -0,0 +1 @@
<EFBFBD><01>

10
xa/tests/cpktest/Makefile Normal file
View File

@ -0,0 +1,10 @@
default:
../../xa -l test.l -o test.o pack_eng.a65
cmp test.l english.l || exit 1
../hextool -cmp=eng.ok < test.o
../../xa -l test.l -o test.o pack_ger.a65
cmp test.l deutsch.l || exit 1
../hextool -cmp=de.ok < test.o
clean:
rm -f *.o test.l

309
xa/tests/cpktest/c64def.def Normal file
View File

@ -0,0 +1,309 @@
/* VIC 6567 */
#define VIC_S0_X 0
#define VIC_S0_Y 1
#define VIC_S1_X 2
#define VIC_S1_Y 3
#define VIC_S2_X 4
#define VIC_S2_Y 5
#define VIC_S3_X 6
#define VIC_S3_Y 7
#define VIC_S4_X 8
#define VIC_S4_Y 9
#define VIC_S5_X 10
#define VIC_S5_Y 11
#define VIC_S6_X 12
#define VIC_S6_Y 13
#define VIC_S7_X 14
#define VIC_S7_Y 15
#define VIC_SP_MSB 16
#define VIC_SR1 17
#define VIC_IRQ_RASTER 18
#define VIC_LP_X 19
#define VIC_LP_Y 20
#define VIC_SP_EN 21
#define VIC_SR2 22
#define VIC_SP_EXPY 23
#define VIC_BASEADR 24
#define VIC_IRR 25
#define VIC_IMR 26
#define VIC_SP_PRIOR 27
#define VIC_SP_MCOLOR 28
#define VIC_SP_EXPX 29
#define VIC_SP_SCOLL 30
#define VIC_SP_BCOLL 31
#define VIC_EXTCOL 32
#define VIC_BCKCOL0 33
#define VIC_BCKCOL1 34
#define VIC_BCKCOL2 35
#define VIC_BCKCOL3 36
#define VIC_SP_MCOL0 37
#define VIC_SP_MCOL1 38
#define VIC_S0_COL 39
#define VIC_S1_COL 40
#define VIC_S2_COL 41
#define VIC_S3_COL 42
#define VIC_S4_COL 43
#define VIC_S5_COL 44
#define VIC_S6_COL 45
#define VIC_S7_COL 46
#define COL_SCHWARZ 0
#define COL_WEISS 1
#define COL_ROT 2
#define COL_TUERKIS 3
#define COL_VIOLETT 4
#define COL_GRUEN 5
#define COL_BLAU 6
#define COL_GELB 7
#define COL_ORANGE 8
#define COL_BRAUN 9
#define COL_HELLROT 10
#define COL_GRAU1 11
#define COL_GRAU2 12
#define COL_HELLGRUEN 13
#define COL_HELLBLAU 14
#define COL_GRAU3 15
#define VIC $d000
/* SID 6581 */
#define SID_0FREQL 0
#define SID_0FREQH 1
#define SID_0PULSL 2
#define SID_0PULSH 3
#define SID_0SR 4
#define SID_0ATTDEC 5
#define SID_0SUSREL 6
#define SID_1FREQL 7
#define SID_1FREQH 8
#define SID_1PULSL 9
#define SID_1PULSH 10
#define SID_1SR 11
#define SID_1ATTDEC 12
#define SID_1SUSREL 13
#define SID_2FREQL 14
#define SID_2FREQH 15
#define SID_2PULSL 16
#define SID_2PULSH 17
#define SID_2SR 18
#define SID_2ATTDEC 19
#define SID_2SUSREL 20
#define SID_FILTL 21
#define SID_FILTH 22
#define SID_SR1 23
#define SID_SR2 24
#define SID $d800
/* CIA 6526 */
#define CIA_DRA 0
#define CIA_DRB 1
#define CIA_DDRA 2
#define CIA_DDRB 3
#define CIA_TAL 4
#define CIA_TAH 5
#define CIA_TBL 6
#define CIA_TBH 7
#define CIA_TOD_THS 8
#define CIA_TOD_SEC 9
#define CIA_TOD_MIN 10
#define CIA_TOD_HR 11
#define CIA_SDR 12
#define CIA_ICR 13
#define CIA_CRA 14
#define CIA_CRB 15
#define CIA1 $dc00
#define CIA2 $dd00
/* ACIA 6551 */
#define ACIA_DR 0
#define ACIA_SR 1
#define ACIA_CMD 2
#define ACIA_CTRL 3
#define ACIA $d600
/* Basic */
#define INT $14
#define PRGANF $2b
#define VARANF $2d
#define ARRANF $2f
#define ARREND $31
#define STRANF $33
#define STRPTR $35
#define RAMEND $37
#define VARNAME $45
#define VARADR $47
#define AKKU3 $57
#define AKKU4 $5c
#define FAC $61
#define ARG $69
#define CHRGET $73
#define CHRGOT $79
#define PRGPTR $7a
#define V_ERR $0300
#define V_WARM $0302
#define V_CONV2CODE $0304
#define V_CONV2ASC $0306
#define V_GETBEFADR $0308
#define V_GETAUSDR $030a
#define SYS_AKKU $030c
#define SYS_XR $030d
#define SYS_YR $030e
#define SYS_SR $030f
#define READY $a474
#define LINEIN $a560
#define INTOUT $bdcd
/* Betriebssystem */
#define STATUS $90
#define FNAMLEN $b7
#define LOGFNR $b8
#define SECADR $b9
#define DEVADR $ba
#define FNAMPTR $bb
#define IOANF $c1
#define IOEND $c3
#define LASTKEY $c5
#define NUMKEY $c6
#define REVFL $c7
#define INLINEEND $c8
#define INZEILE $c9
#define INSPALTE $ca
#define PRESSEDKEY $cb
#define CRSRFLASH $cc
#define CRSRFLASHCNT $cd
#define CHARUNDERCRSR $ce
#define CRSRFLASHFL $cf
#define KEYINPUTFL $d0
#define LINEADR $d1
#define CRSRSPALTE $d3
#define HKFL $d4
#define LENGTHOFLINE $d5
#define CRSRZEILE $d6
#define DIV $d7
#define NUMOFINS $d8
#define RS232INBUFPTR $f7
#define RS232OUTBUFPTR $f9
#define P1 $fb /* freier Pointer */
#define P2 $fd /* freier Pointer */
#define INBUF $200
#define V_USR $0311
#define V_IRQ $0314
#define V_BRK $0316
#define V_NMI $0318
#define V_OPEN $031a
#define V_CLOSE $031c
#define V_CHKIN $031e
#define V_CKOUT $0320
#define V_CLRCH $0322
#define V_INPUT $0324
#define V_OUTPUT $0326
#define V_STOP $0328
#define V_GET $032a
#define V_CLALL $032c
#define V_WARMSTART $032e
#define V_LOAD $0330
#define V_SAVE $0332
#define SENDNAM $f3d5
#define CLSFIL $f642
#define INICIA $ff84
#define INIRAM $ff87
#define INIIO $ff8a
#define INIIOVEC $ff8d
#define SETST $ff90
#define SECLISTEN $ff93
#define SECTALK $ff96
#define RAMEND $ff99
#define RAMSTART $ff9c
#define GETKEY $ff9f
#define IECTIMEOUT $ffa2
#define IECIN $ffa5
#define IECOUT $ffa8
#define UNTALK $ffab
#define UNLISTEN $ffae
#define LISTEN $ffb1
#define TALK $ffb4
#define GETST $ffb7
#define SETFPAR $ffba
#define SETFNPAR $ffbd
#define OPEN $ffc0
#define CLOSE $ffc3
#define CHKIN $ffc6
#define CKOUT $ffc9
#define CLRCH $ffcc
#define BASIN $ffcf
#define BSOUT $ffd2
#define LOAD $ffd5
#define SAVE $ffd8
#define SETTI $ffdb
#define GETTI $ffde
#define GETSTP $ffe1
#define GET $ffe4
#define CLALL $ffe7
#define INCTI $ffea
#define SCREEN $ffed
#define CURSOR $fff0
#define GETIOBASE $fff3
/* Terminal-Commands */
#define TC_SCO 8
#define TC_SCF 9
#define TC_LF 13 /*10*/
#define TC_CR 13
#define TC_LCH $0e
#define TC_REV 18
#define TC_F1 $85
#define TC_F3 $86
#define TC_F5 $87
#define TC_F7 $88
#define TC_F2 $89
#define TC_F4 $8a
#define TC_F6 $8b
#define TC_F8 $8c
#define TC_HCH $8e
#define TC_REO $92
#define TC_FF $93
#define TC_HELLGRUEN $99
#define TC_CRL $9d

BIN
xa/tests/cpktest/de.ok Normal file

Binary file not shown.

180
xa/tests/cpktest/deutsch.l Normal file
View File

@ -0,0 +1,180 @@
basicend, 0x080b, 1, 0x0000
iniscreen, 0x10b6, 1, 0x0000
inipar, 0x1085, 1, 0x0000
menu1, 0x0819, 2, 0x0000
m1atxt, 0x0897, 2, 0x0000
Txtout, 0x10a0, 1, 0x0000
quellpfad, 0x10c6, 1, 0x0000
m1btxt, 0x08e2, 2, 0x0000
quelldrv, 0x10c4, 1, 0x0000
m1ctxt, 0x08f6, 2, 0x0000
zielpfad, 0x10ee, 1, 0x0000
m1dtxt, 0x0908, 2, 0x0000
zieldrv, 0x10c5, 1, 0x0000
m1etxt, 0x091c, 2, 0x0000
next, 0x085a, 2, 0x0000
l1, 0x0861, 2, 0x0000
befkeys, 0x088f, 2, 0x0000
exe, 0x086d, 2, 0x0000
Anzbefs, 0x0008, 2, 0x0000
exec, 0x0873, 2, 0x0000
madr, 0x087f, 2, 0x0000
pack, 0x0b2f, 1, 0x0000
unpack, 0x0966, 1, 0x0000
quelle, 0x0fe2, 1, 0x0000
ziel, 0x1023, 1, 0x0000
switch, 0x1063, 1, 0x0000
dir, 0x0efe, 1, 0x0000
qdrv, 0x0fc2, 1, 0x0000
zdrv, 0x0fd2, 1, 0x0000
openarcrd, 0x0afc, 1, 0x0000
cls, 0x0997, 12, 0x0000
rcnt, 0x1320, 1, 0x0000
rbyte, 0x0c06, 1, 0x0000
verr, 0x099d, 12, 0x0000
loop, 0x097a, 12, 0x0000
unpackfile, 0x09d6, 1, 0x0000
t1, 0x09c1, 12, 0x0000
waitkey, 0x0f5c, 1, 0x0000
verrtxt, 0x09a7, 12, 0x0000
wcnt, 0x131e, 1, 0x0000
l1, 0x09e7, 15, 0x0000
endx, 0x0a20, 15, 0x0000
filetab, 0x1324, 1, 0x0000
endnam, 0x09fd, 15, 0x0000
ask, 0x0a84, 15, 0x0000
nounpack, 0x0a23, 15, 0x0000
tok, 0x0ec6, 1, 0x0000
fxopen, 0x0ab4, 1, 0x0000
Getzst, 0x0d67, 1, 0x0000
xa, 0x0a2a, 15, 0x0000
lo, 0x0a2e, 15, 0x0000
end, 0x0a83, 15, 0x0000
tno, 0x0ebd, 1, 0x0000
cls, 0x0a64, 15, 0x0000
xb, 0x0a5a, 15, 0x0000
wxanz, 0x121a, 1, 0x0000
wxbyt, 0x1219, 1, 0x0000
ly, 0x0a4c, 15, 0x0000
wbyte, 0x0d0c, 1, 0x0000
wbuf, 0x0d22, 1, 0x0000
t1, 0x0a9c, 15, 0x0000
incwcnt, 0x0aab, 1, 0x0000
l1, 0x0ab3, 20, 0x0000
l1, 0x0ab8, 21, 0x0000
l2, 0x0acf, 21, 0x0000
l1a, 0x0ac9, 21, 0x0000
l1b, 0x0acb, 21, 0x0000
l3, 0x0ad3, 21, 0x0000
err, 0x0afb, 21, 0x0000
clrwrbuf, 0x0d03, 1, 0x0000
l0, 0x0afe, 22, 0x0000
l1, 0x0b08, 22, 0x0000
err, 0x0b2d, 22, 0x0000
Getqst, 0x0d61, 1, 0x0000
clrrdbuf, 0x0c67, 1, 0x0000
getlist, 0x0da4, 1, 0x0000
anzfiles, 0x1116, 1, 0x0000
end, 0x0b63, 23, 0x0000
openarcwr, 0x0ccd, 1, 0x0000
cls, 0x0b5b, 23, 0x0000
l1, 0x0b45, 23, 0x0000
setfadr, 0x0ecf, 1, 0x0000
packfile, 0x0b67, 1, 0x0000
lft, 0x0bac, 24, 0x0000
l1, 0x0b70, 24, 0x0000
fopen, 0x0bb6, 1, 0x0000
le, 0x0b97, 24, 0x0000
clrwxbyt, 0x0c94, 1, 0x0000
l2, 0x0b89, 24, 0x0000
l3, 0x0b94, 24, 0x0000
wxbyte, 0x0c73, 1, 0x0000
savwxbyt, 0x0c9a, 1, 0x0000
l1, 0x0bba, 26, 0x0000
l2, 0x0bd1, 26, 0x0000
l1a, 0x0bcb, 26, 0x0000
l1b, 0x0bcd, 26, 0x0000
l3, 0x0bd5, 26, 0x0000
err, 0x0bfc, 26, 0x0000
incrcnt, 0x0bfd, 1, 0x0000
l1, 0x0c05, 27, 0x0000
ro, 0x121c, 1, 0x0000
ri, 0x121b, 1, 0x0000
leerbuf, 0x0c16, 28, 0x0000
rb, 0x121e, 1, 0x0000
rf, 0x121d, 1, 0x0000
ldbuf, 0x0c1d, 28, 0x0000
lok, 0x0c2e, 28, 0x0000
l0, 0x0c47, 28, 0x0000
le, 0x0c5c, 28, 0x0000
add, 0x0c8d, 31, 0x0000
ad2, 0x0c83, 31, 0x0000
adx, 0x0c90, 31, 0x0000
nosav, 0x0ccc, 33, 0x0000
savs, 0x0cb6, 33, 0x0000
l1, 0x0caa, 33, 0x0000
l0, 0x0ccf, 34, 0x0000
l1, 0x0cd9, 34, 0x0000
err, 0x0d01, 34, 0x0000
wi, 0x1117, 1, 0x0000
wo, 0x1118, 1, 0x0000
wb, 0x1119, 1, 0x0000
nowr, 0x0d21, 36, 0x0000
l1, 0x0d2a, 37, 0x0000
end, 0x0d55, 37, 0x0000
l0, 0x0d4e, 37, 0x0000
Getst, 0x0d6a, 1, 0x0000
l1, 0x0d87, 38, 0x0000
l2, 0x0d95, 38, 0x0000
err, 0x0d9f, 38, 0x0000
l4x, 0x0da1, 39, 0x0000
l4, 0x0e7d, 39, 0x0000
setdirnam, 0x0f62, 1, 0x0000
l0, 0x0dc4, 39, 0x0000
l1, 0x0dc6, 39, 0x0000
la, 0x0de0, 39, 0x0000
l3x, 0x0dee, 39, 0x0000
l3, 0x0e59, 39, 0x0000
lb, 0x0e01, 39, 0x0000
lc, 0x0e16, 39, 0x0000
ld, 0x0e1b, 39, 0x0000
lf, 0x0e32, 39, 0x0000
lg, 0x0e46, 39, 0x0000
testkeys, 0x0e83, 1, 0x0000
lh, 0x0e50, 39, 0x0000
l2, 0x0e69, 39, 0x0000
l5, 0x0e76, 39, 0x0000
ok, 0x0e8c, 40, 0x0000
t1, 0x0ead, 40, 0x0000
ja, 0x0ea2, 40, 0x0000
l0, 0x0f19, 45, 0x0000
l1, 0x0f1b, 45, 0x0000
l4, 0x0f56, 45, 0x0000
l3, 0x0f35, 45, 0x0000
l2, 0x0f45, 45, 0x0000
l5, 0x0f52, 45, 0x0000
p1, 0x0014, 46, 0x0000
l1, 0x0f6d, 46, 0x0000
nodp, 0x0f7b, 46, 0x0000
dp, 0x0f81, 46, 0x0000
dp1, 0x0f83, 46, 0x0000
end, 0x0f9b, 46, 0x0000
l2a, 0x0f93, 46, 0x0000
l2, 0x0f95, 46, 0x0000
ok, 0x0fd1, 47, 0x0000
ok, 0x0fe1, 48, 0x0000
quelltxt, 0x1001, 49, 0x0000
q1, 0x0fee, 49, 0x0000
end, 0x1000, 49, 0x0000
quelltxt, 0x1042, 51, 0x0000
q1, 0x102f, 51, 0x0000
end, 0x1041, 51, 0x0000
l1, 0x1071, 53, 0x0000
noval, 0x1097, 54, 0x0000
ok, 0x1099, 54, 0x0000
p, 0x0022, 55, 0x0000
l1, 0x10a4, 55, 0x0000
le, 0x10b5, 55, 0x0000
sysmem, 0x1324, 1, 0x0000
ecnt, 0x1322, 1, 0x0000
ende, 0x10c4, 1, 0x0000

BIN
xa/tests/cpktest/eng.ok Normal file

Binary file not shown.

180
xa/tests/cpktest/english.l Normal file
View File

@ -0,0 +1,180 @@
basicend, 0x080b, 1, 0x0000
iniscreen, 0x10c4, 1, 0x0000
inipar, 0x1093, 1, 0x0000
menu1, 0x0819, 2, 0x0000
m1atxt, 0x0897, 2, 0x0000
Txtout, 0x10ae, 1, 0x0000
quellpfad, 0x10d4, 1, 0x0000
m1btxt, 0x08e1, 2, 0x0000
quelldrv, 0x10d2, 1, 0x0000
m1ctxt, 0x08f6, 2, 0x0000
zielpfad, 0x10fc, 1, 0x0000
m1dtxt, 0x090d, 2, 0x0000
zieldrv, 0x10d3, 1, 0x0000
m1etxt, 0x0923, 2, 0x0000
next, 0x085a, 2, 0x0000
l1, 0x0861, 2, 0x0000
befkeys, 0x088f, 2, 0x0000
exe, 0x086d, 2, 0x0000
Anzbefs, 0x0008, 2, 0x0000
exec, 0x0873, 2, 0x0000
madr, 0x087f, 2, 0x0000
pack, 0x0b32, 1, 0x0000
unpack, 0x0970, 1, 0x0000
quelle, 0x0fe5, 1, 0x0000
ziel, 0x102b, 1, 0x0000
switch, 0x1071, 1, 0x0000
dir, 0x0f01, 1, 0x0000
qdrv, 0x0fc5, 1, 0x0000
zdrv, 0x0fd5, 1, 0x0000
openarcrd, 0x0aff, 1, 0x0000
cls, 0x09a1, 12, 0x0000
rcnt, 0x132e, 1, 0x0000
rbyte, 0x0c09, 1, 0x0000
verr, 0x09a7, 12, 0x0000
loop, 0x0984, 12, 0x0000
unpackfile, 0x09dd, 1, 0x0000
t1, 0x09c9, 12, 0x0000
waitkey, 0x0f5f, 1, 0x0000
verrtxt, 0x09b1, 12, 0x0000
wcnt, 0x132c, 1, 0x0000
l1, 0x09ee, 15, 0x0000
endx, 0x0a27, 15, 0x0000
filetab, 0x1332, 1, 0x0000
endnam, 0x0a04, 15, 0x0000
ask, 0x0a8b, 15, 0x0000
nounpack, 0x0a2a, 15, 0x0000
tok, 0x0ec9, 1, 0x0000
fxopen, 0x0ab7, 1, 0x0000
Getzst, 0x0d6a, 1, 0x0000
xa, 0x0a31, 15, 0x0000
lo, 0x0a35, 15, 0x0000
end, 0x0a8a, 15, 0x0000
tno, 0x0ec0, 1, 0x0000
cls, 0x0a6b, 15, 0x0000
xb, 0x0a61, 15, 0x0000
wxanz, 0x1228, 1, 0x0000
wxbyt, 0x1227, 1, 0x0000
ly, 0x0a53, 15, 0x0000
wbyte, 0x0d0f, 1, 0x0000
wbuf, 0x0d25, 1, 0x0000
t1, 0x0aa0, 15, 0x0000
incwcnt, 0x0aae, 1, 0x0000
l1, 0x0ab6, 20, 0x0000
l1, 0x0abb, 21, 0x0000
l2, 0x0ad2, 21, 0x0000
l1a, 0x0acc, 21, 0x0000
l1b, 0x0ace, 21, 0x0000
l3, 0x0ad6, 21, 0x0000
err, 0x0afe, 21, 0x0000
clrwrbuf, 0x0d06, 1, 0x0000
l0, 0x0b01, 22, 0x0000
l1, 0x0b0b, 22, 0x0000
err, 0x0b30, 22, 0x0000
Getqst, 0x0d64, 1, 0x0000
clrrdbuf, 0x0c6a, 1, 0x0000
getlist, 0x0da7, 1, 0x0000
anzfiles, 0x1124, 1, 0x0000
end, 0x0b66, 23, 0x0000
openarcwr, 0x0cd0, 1, 0x0000
cls, 0x0b5e, 23, 0x0000
l1, 0x0b48, 23, 0x0000
setfadr, 0x0ed2, 1, 0x0000
packfile, 0x0b6a, 1, 0x0000
lft, 0x0baf, 24, 0x0000
l1, 0x0b73, 24, 0x0000
fopen, 0x0bb9, 1, 0x0000
le, 0x0b9a, 24, 0x0000
clrwxbyt, 0x0c97, 1, 0x0000
l2, 0x0b8c, 24, 0x0000
l3, 0x0b97, 24, 0x0000
wxbyte, 0x0c76, 1, 0x0000
savwxbyt, 0x0c9d, 1, 0x0000
l1, 0x0bbd, 26, 0x0000
l2, 0x0bd4, 26, 0x0000
l1a, 0x0bce, 26, 0x0000
l1b, 0x0bd0, 26, 0x0000
l3, 0x0bd8, 26, 0x0000
err, 0x0bff, 26, 0x0000
incrcnt, 0x0c00, 1, 0x0000
l1, 0x0c08, 27, 0x0000
ro, 0x122a, 1, 0x0000
ri, 0x1229, 1, 0x0000
leerbuf, 0x0c19, 28, 0x0000
rb, 0x122c, 1, 0x0000
rf, 0x122b, 1, 0x0000
ldbuf, 0x0c20, 28, 0x0000
lok, 0x0c31, 28, 0x0000
l0, 0x0c4a, 28, 0x0000
le, 0x0c5f, 28, 0x0000
add, 0x0c90, 31, 0x0000
ad2, 0x0c86, 31, 0x0000
adx, 0x0c93, 31, 0x0000
nosav, 0x0ccf, 33, 0x0000
savs, 0x0cb9, 33, 0x0000
l1, 0x0cad, 33, 0x0000
l0, 0x0cd2, 34, 0x0000
l1, 0x0cdc, 34, 0x0000
err, 0x0d04, 34, 0x0000
wi, 0x1125, 1, 0x0000
wo, 0x1126, 1, 0x0000
wb, 0x1127, 1, 0x0000
nowr, 0x0d24, 36, 0x0000
l1, 0x0d2d, 37, 0x0000
end, 0x0d58, 37, 0x0000
l0, 0x0d51, 37, 0x0000
Getst, 0x0d6d, 1, 0x0000
l1, 0x0d8a, 38, 0x0000
l2, 0x0d98, 38, 0x0000
err, 0x0da2, 38, 0x0000
l4x, 0x0da4, 39, 0x0000
l4, 0x0e80, 39, 0x0000
setdirnam, 0x0f65, 1, 0x0000
l0, 0x0dc7, 39, 0x0000
l1, 0x0dc9, 39, 0x0000
la, 0x0de3, 39, 0x0000
l3x, 0x0df1, 39, 0x0000
l3, 0x0e5c, 39, 0x0000
lb, 0x0e04, 39, 0x0000
lc, 0x0e19, 39, 0x0000
ld, 0x0e1e, 39, 0x0000
lf, 0x0e35, 39, 0x0000
lg, 0x0e49, 39, 0x0000
testkeys, 0x0e86, 1, 0x0000
lh, 0x0e53, 39, 0x0000
l2, 0x0e6c, 39, 0x0000
l5, 0x0e79, 39, 0x0000
ok, 0x0e8f, 40, 0x0000
t1, 0x0eb0, 40, 0x0000
ja, 0x0ea5, 40, 0x0000
l0, 0x0f1c, 45, 0x0000
l1, 0x0f1e, 45, 0x0000
l4, 0x0f59, 45, 0x0000
l3, 0x0f38, 45, 0x0000
l2, 0x0f48, 45, 0x0000
l5, 0x0f55, 45, 0x0000
p1, 0x0014, 46, 0x0000
l1, 0x0f70, 46, 0x0000
nodp, 0x0f7e, 46, 0x0000
dp, 0x0f84, 46, 0x0000
dp1, 0x0f86, 46, 0x0000
end, 0x0f9e, 46, 0x0000
l2a, 0x0f96, 46, 0x0000
l2, 0x0f98, 46, 0x0000
ok, 0x0fd4, 47, 0x0000
ok, 0x0fe4, 48, 0x0000
quelltxt, 0x1004, 49, 0x0000
q1, 0x0ff1, 49, 0x0000
end, 0x1003, 49, 0x0000
quelltxt, 0x104a, 51, 0x0000
q1, 0x1037, 51, 0x0000
end, 0x1049, 51, 0x0000
l1, 0x107f, 53, 0x0000
noval, 0x10a5, 54, 0x0000
ok, 0x10a7, 54, 0x0000
p, 0x0022, 55, 0x0000
l1, 0x10b2, 55, 0x0000
le, 0x10c3, 55, 0x0000
sysmem, 0x1332, 1, 0x0000
ecnt, 0x1330, 1, 0x0000
ende, 0x10d2, 1, 0x0000

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,7 @@
default:
cc -E over.c > over.asm
../../xa over.asm
$(CC) -E over.c > over.asm
../../xa -w over.asm
../hextool -cmp=expected.o < a.o65
clean:
rm -f over.asm a.o65

BIN
xa/tests/cpp/expected.o Normal file

Binary file not shown.

View File

@ -1,22 +0,0 @@
# 1 "over.c"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "over.c"
# 13 "over.c"
lda #1
jmp buggy
rts
# 1 "over.h" 1
fuzz lda #5
sta $0400
bne fuzz
rts
lda @$c0c0c0
# 18 "over.c" 2

View File

@ -10,6 +10,8 @@
/* This has a .c extension for those cc -E's that won't deal with .asm */
* = $0000
lda #AA
jmp buggy
rts
@ -17,3 +19,5 @@
#include "over.h"
/* the buggy will force a line number to be printed */
buggy

9
xa/tests/dos51/Makefile Normal file
View File

@ -0,0 +1,9 @@
default:
# xa should not allow this to happen. if it does, this test is no good.
../../xa -DBUG test.s || exit 0 && exit 1
# expected-to-fail tests did fail. should be no more errors now.
../../xa test.s -o test.o
../hextool -cmp=ok < test.o
clean:
rm -f *.o

136
xa/tests/dos51/dos51.inc Normal file
View File

@ -0,0 +1,136 @@
/* dos wedge code for inlining into routines */
/* define SA51 to allow stand-alone generation */
#ifdef SA51
.word SA51
* = SA51
#endif
/* otherwise assume this has been inlined via #include <> */
/* define BASIC51 to use BASIC interface stub */
#ifdef BASIC51
jsr $aefd
jsr $ad9e
jsr $b6a3 ; leaving a=len x=lb y=hb
#endif
/* otherwise load a with length, x/y = lb/hb */
.(
crunchsrv = $a57c
setlfs = $ffba
setnam = $ffbd
open = $ffc0
close = $ffc3
clall = $ffe7
chkin = $ffc6
chkout = $ffc9
clrchn = $ffcc
chrin = $ffcf
getin = $ffe4
print = $ffd2
readst = $ffb7
chrout = print
ready = $e37b
cnvrtdec = $bdcd
erasealine = 59903
workzp = $a5
sta work1
sty workzp+1
stx workzp
; set the filename (directory, error channel and commands)
; a, x and y already setup for us
jsr setnam
; are we requesting just the error channel?
ldx work1
beq errchn ; yes
; are we requesting a disk directory?
ldy #0
lda (workzp),y
cmp #"$"
bne errchn ; no
; yes, display directory
lda #$01
ldx 186
ldy #$00
jsr setlfs
jsr open ; open 1,dev,0 to read as BASIC formatted text
lda #147
jsr print
clc
ldx #01
jsr chkin
bcs dirdone
jsr chrin
jsr chrin
lda #$0d
jsr print
; routine to print each line of the directory
dirpll jsr chrin
jsr chrin ; skip line link
jsr chrin ; grab length (as line #)
sta work1
jsr chrin
sta work2 ; stash for later
jsr readst ; EOF or other error?
bne dirdone ; yes, end directory
lda work2 ; no, print this line
ldx work1
jsr cnvrtdec ; first the number/length
lda #$20
jsr print ; and a space
jsr chrin
dirpl jsr print ; then the filename in quotes and filetype until a null
jsr chrin
adc #0
bne dirpl ; no null yet
lda #13 ; yes, null, print CR
jsr print
jmp dirpll ; and do next line
; finish directory and clear channel, then fall through to errchn
dirdone lda #1
jsr close
jsr clall
lda #0
jsr setnam
; common routine for error channel and disk commands
errchn lda #15
ldx $ba
ldy #15
jsr setlfs ; open 15,8,15,command
jsr open
lda #18
jsr print ; rvson
; read until there's a null, adding $0d for devices that don't
errchnl ldx #15
jsr chkin
jsr chrin
sta work1
jsr readst ; power 64 sucks sometimes =-(
sta work2 ; its emulated messages have no $0d
lda work1
jsr print
lda work2
beq errchnl
lda work1
cmp #13
beq errchnd
lda #13
jsr print
errchnd lda #15
jsr close
jsr clall
lda #146
jsr print ; rvsoff
rts
work1 .byt 0
work2 .byt 0
.)

BIN
xa/tests/dos51/ok Normal file

Binary file not shown.

6
xa/tests/dos51/test.s Normal file
View File

@ -0,0 +1,6 @@
#define SA51 $c123
#include "dos51.inc"
#ifdef BUG
jsr crunchsrv
#endif

14
xa/tests/fordef/Makefile Normal file
View File

@ -0,0 +1,14 @@
default:
# this must not pass.
../../xa -DFAIL test3.asm || exit 0 && exit 1
# these must pass.
../../xa test3.asm
../hextool -cmp=test3.ok < a.o65
# testing warnings.
../../xa -e test.out test.asm
../hextool -cmp=ok.out < test.out
../hextool -cmp=test1.ok < a.o65
clean:
rm -f a.o65 test.out

2
xa/tests/fordef/ok.out Normal file
View File

@ -0,0 +1,2 @@
test.asm:line 6: 0400: Warning - Can't optimize forward-defined label; using absolute addressing
test.asm:line 7: 0403: Warning - Can't optimize forward-defined label; using absolute addressing

BIN
xa/tests/fordef/test1.ok Normal file

Binary file not shown.

67
xa/tests/harness Executable file
View File

@ -0,0 +1,67 @@
#!/usr/bin/perl -s
$make ||= "make";
$cc ||= "cc";
$cflags ||= '';
$ENV{'MAKE'} = $make;
$ENV{'CC'} = $cc;
$ENV{'CFLAGS'} = $cflags;
$|++;
$dtests = $tests || "ALL";
print <<"EOF";
CC = $cc
CFLAGS = $cflags
MAKE = $make
tests to run: $dtests
EOF
# Get a list of all directories. If there is a Makefile there, do it.
# If there is not, see if there is an .s file and an ok binary to cmp to.
# Otherwise, do nothing (acknowledge and ignore directories we don't grok).
opendir(D, ".") || die("test harness failed: $!\n");
W: while($x = readdir(D)) {
next W if ($x =~ /^\./);
next W if (length($tests) && ($tests !~ /$x/));
next W if (!chdir($x));
$x = substr($x . " " . ("." x 79), 0, 50);
print STDOUT "$x > ";
if (-e "Makefile") {
print STDOUT "running Makefile\n";
print STDOUT "=" x 79, "\n";
system("$make clean");
print STDOUT "-" x 79, "\n";
system("$make");
print STDOUT "-" x 79, "\n";
if ($?) {
print STDOUT "## FAILURE (make clean NOT run) ##\n";
exit 1;
}
system("$make clean");
print STDOUT "=" x 35, " PASSED! ", "=" x 35, "\n";
} elsif (-e "ok" && -e "test.s") {
unlink("a.o65");
&failed("../../xa test.s");
&failed("../hextool -cmp=ok < a.o65");
unlink("a.o65");
print STDOUT "PASSED\n";
} else {
print STDOUT "ignored\n";
}
chdir("..");
}
closedir(D);
print STDOUT "\n## ALL TESTS PASS ##\n";
exit 0;
sub failed {
system(@_);
if ($?) {
print STDOUT "## FAILURE ##\n";
exit 1;
}
}

57
xa/tests/hextool Executable file
View File

@ -0,0 +1,57 @@
#!/usr/bin/perl -s
# This tool either emits hex in a machine or human parseable format, or
# compares two binaries in the form of cmp. It is mostly to deal with
# systems with an unreliable hexdump, that *lack* hexdump (or od), and/or
# emit non-standard output.
# "use bytes"
BEGIN { $^H |= 0x00000008 unless ($] < 5.006); }
if ($output || $noutput) {
# check output mode. If $output, there must be output. If there is
# $noutput there must NOT be output. Feed tee or something to this.
$wasoutput = 0;
while(<>) {
$wasoutput++;
}
exit (($wasoutput && $output) ? 0 :
($wasoutput && $noutput) ? 1 :
(!$wasoutput && !$noutput) ? 0 :
1);
}
if ($cmp) {
# compare mode. both files must fit in memory. to eliminate any
# weirdness about endianness, encoding, etc., we unpack them to
# hex bytes and just compare strings.
undef $/;
open(W, "$cmp") || die("can't open $cmp: $!\n");
$cmp = unpack("H*", <W>);
close(W);
$std = unpack("H*", <>);
if ($cmp ne $std) {
print <<"EOF";
FAILED!
received from stdin
-------------------
$std
expected to equal
-----------------
$cmp
FAILED!
EOF
exit 255;
}
exit 0;
}
# hexdump mode. accept data on stdin, spew a stream of hex bytes.
while(<>) {
print STDOUT unpack("H*", $_);
}

8
xa/tests/incerr/Makefile Normal file
View File

@ -0,0 +1,8 @@
default:
# in 6502 mode, it will fail.
../../xa test.s || exit 0 && exit 1
# in 65816 mode, it will pass.
../../xa -w test.s
clean:
rm -f a.o65

View File

@ -1,22 +1,23 @@
default: all
all: t
1.o65: 1.s
xa -R -c -o 1.o65 1.s
hexdump -C 1.o65 > 1.o65.hex
../../xa -R -c -o 1.o65 1.s
../hextool 1.o65 > 1.o65.hex
2.o65: 2.s
xa -R -c -o 2.o65 2.s
hexdump -C 2.o65 > 2.o65.hex
../../xa -R -c -o 2.o65 2.s
../hextool 2.o65 > 2.o65.hex
linked.o65: 1.o65 2.o65
ldo65 -o linked.o65 1.o65 2.o65
hexdump -C linked.o65 > linked.o65.hex
../../ldo65 -o linked.o65 1.o65 2.o65
../hextool linked.o65 > linked.o65.hex
t: linked.o65
reloc65 -bt 32768 -xt -o t linked.o65
hexdump -C t > t.hex
diff t t.ok
../../reloc65 -bt 32768 -xt -o t linked.o65
../hextool t > t.hex
../hextool -cmp=t < t.ok
clean:
rm -f *.o65 *.hex t

BIN
xa/tests/linkr/ok Normal file

Binary file not shown.

19
xa/tests/linkr/test.s Normal file
View File

@ -0,0 +1,19 @@
; Actual example from man page
.word $1000
* = $1000
; this is your code at $1000
part1 rts
; this label marks the end of code
endofpart1
; DON'T PUT A NEW .word HERE!
* = $2000
.dsb (*-endofpart1), 0
; yes, set it again
* = $2000
; this is your code at $2000
part2 rts

10
xa/tests/masmcom/Makefile Normal file
View File

@ -0,0 +1,10 @@
default:
# compile with masm mode on.
../../xa -M -o test.o test.s
../hextool -cmp=okmasm < test.o
# compile without
../../xa -o test.o test.s
../hextool -cmp=oknomasm < test.o
clean:
rm -f *.o

BIN
xa/tests/masmcom/okmasm Normal file

Binary file not shown.

BIN
xa/tests/masmcom/oknomasm Normal file

Binary file not shown.

3
xa/tests/masmcom/test.s Normal file
View File

@ -0,0 +1,3 @@
/* when assembled with/without -M, we get two different objects */
lda #00 ; and this: lda #01 ; is why : lda #":"

9
xa/tests/mvnmvp/Makefile Normal file
View File

@ -0,0 +1,9 @@
default:
# xa should not allow this to happen. if it does, this test is no good.
../../xa test.s || exit 0 && exit 1
# expected-to-fail tests did fail. should be no more errors now.
../../xa -w test.s -o test.o
../hextool -cmp=ok < test.o
clean:
rm -f *.o

BIN
xa/tests/mvnmvp/ok Normal file

Binary file not shown.

14
xa/tests/mvnmvp/test.s Normal file
View File

@ -0,0 +1,14 @@
; test instructions that failed during our testing
; and test instructions in the tokenizer bordering mvn/mvp
w = $01
lda $d020
lsr
mvn w, $02
mvn $0201
mvn $0066
mvp $03, w+3
mvp $0403
mvp $0088
nop
.byt $5a, $b6
.word $b65a

View File

BIN
xa/tests/nonl/ok Normal file

Binary file not shown.

9
xa/tests/op816/Makefile Normal file
View File

@ -0,0 +1,9 @@
default:
# xa should not allow this to happen. if it does, this test is no good.
../../xa test.s || exit 0 && exit 1
# expected-to-fail tests did fail. should be no more errors now.
../../xa -w test.s -o test.o
../hextool -cmp=ok < test.o
clean:
rm -f *.o

BIN
xa/tests/op816/ok Normal file

Binary file not shown.

336
xa/tests/op816/test.s Normal file
View File

@ -0,0 +1,336 @@
; Copyright (c) 2014, Alessandro Gatti - frob.it
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are met:
;
; 1. Redistributions of source code must retain the above copyright notice,
; this list of conditions and the following disclaimer.
;
; 2. Redistributions in binary form must reproduce the above copyright notice,
; this list of conditions and the following disclaimer in the documentation
; and/or other materials provided with the distribution.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
; POSSIBILITY OF SUCH DAMAGE.
#define ZEROPAGE_0 $0
#define ZEROPAGE_1 $1
#define ZEROPAGE_2 $2
#define ZEROPAGE_3 $3
#define ZEROPAGE_4 $4
#define ZEROPAGE_5 $5
#define ZEROPAGE_6 $6
#define ZEROPAGE_7 $7
#define ZEROPAGE_8 $8
#define ZEROPAGE_9 $9
#define ZEROPAGE_A $a
#define ZEROPAGE_B $b
#define ZEROPAGE_C $c
#define ZEROPAGE_D $d
#define ZEROPAGE_E $e
#define ZEROPAGE_F $f
*=$1000
row0 BRK
ORA (ZEROPAGE_0,X)
COP #$00
ORA ZEROPAGE_0,S
TSB ZEROPAGE_0
ORA ZEROPAGE_0
ASL ZEROPAGE_0
ORA [ZEROPAGE_0]
PHP
ORA #$00
ASL
PHD
TSB datablockabs
ORA datablockabs
ASL datablockabs
ORA @datablockabs+@$FF0000
JMP row1
row1 BPL row1_target
ORA (ZEROPAGE_1),Y
row1_target ORA (ZEROPAGE_1)
ORA (ZEROPAGE_1,S),Y
TRB ZEROPAGE_1
ORA ZEROPAGE_1,X
ASL ZEROPAGE_1,X
ORA [ZEROPAGE_1],Y
CLC
ORA datablockabs,Y
INC
TCS
TRB datablockabs
ORA datablockabs,X
ASL datablockabs,X
ORA @datablockabs+@$FF0000,X
JMP row2
row2 JSR farcode
AND (ZEROPAGE_2,X)
JSR @datablockabs+@$FF0000
AND ZEROPAGE_2,S
BIT ZEROPAGE_2
AND ZEROPAGE_2
ROL ZEROPAGE_2
AND [ZEROPAGE_2]
PLP
AND #$22
ROL
PLD
BIT datablockabs
AND datablockabs
ROL datablockabs
AND @datablockabs+@$FF0000
JMP row3
row3 BMI row3_target
AND (ZEROPAGE_3),Y
row3_target AND (ZEROPAGE_3)
AND (ZEROPAGE_3,S),Y
BIT ZEROPAGE_3,X
AND ZEROPAGE_3,X
ROL ZEROPAGE_3,X
AND [ZEROPAGE_3],Y
SEC
AND datablockabs,Y
DEC
TSC
BIT datablockabs,X
AND datablockabs,X
ROL datablockabs,X
AND @datablockabs+@$FF0000,X
JMP row4
row4 RTI
EOR (ZEROPAGE_4,X)
.byte $42 ; WDM
EOR ZEROPAGE_3,S
MVP $44,$44 ;$4444 ; Should be $44, $44 instead
EOR ZEROPAGE_4
LSR ZEROPAGE_4
EOR [ZEROPAGE_4]
PHA
EOR #$44
LSR
PHK
JMP farcode
EOR datablockabs
LSR datablockabs
EOR @datablockabs+@$FF0000
JMP row5
row5 BVC row5_target
EOR (ZEROPAGE_5),Y
row5_target EOR (ZEROPAGE_5)
EOR (ZEROPAGE_5,S),Y
MVN $55,$55 ; $5555 ; Should be $55, $55 instead
EOR ZEROPAGE_5,X
LSR ZEROPAGE_5,X
EOR [ZEROPAGE_5],Y
CLI
EOR datablockabs,Y
PHY
TCD
JMP @datablockabs+@$FF0000
EOR datablockabs,X
LSR datablockabs,X
EOR @datablockabs+@$FF0000,X
JMP row6
row6 RTS
ADC (ZEROPAGE_6,X)
PER datablockabs
ADC ZEROPAGE_6,S
STZ ZEROPAGE_6
ADC ZEROPAGE_6
ROR ZEROPAGE_6
ADC [ZEROPAGE_6]
PLA
ADC #$66
ROR
RTL
JMP (datablockabs)
ADC datablockabs
ROR datablockabs
ADC @datablockabs+@$FF0000
JMP row7
row7 BVS row7_target
ADC (ZEROPAGE_7),Y
row7_target ADC (ZEROPAGE_7)
ADC (ZEROPAGE_7,S),Y
STZ ZEROPAGE_7,X
ADC ZEROPAGE_7,X
ROR ZEROPAGE_7,X
ADC [ZEROPAGE_7],Y
SEI
ADC datablockabs,Y
PLY
TDC
JMP (datablockabs,X)
ADC datablockabs,X
ROR datablockabs,X
ADC @datablockabs+@$FF0000,X
JMP row8
row8 BRA row8_target
STA (ZEROPAGE_8,X)
row8_target BRL datablockabs
STA ZEROPAGE_8,S
STY ZEROPAGE_8
STA ZEROPAGE_8
STX ZEROPAGE_8
STA [ZEROPAGE_8]
DEY
BIT #$88
TXA
PHB
STY datablockabs
STA datablockabs
STX datablockabs
STA @datablockabs+@$FF0000
JMP row9
row9 BCC row9_target
STA (ZEROPAGE_9),Y
row9_target STA (ZEROPAGE_9)
STA (ZEROPAGE_9,S),Y
STY ZEROPAGE_9,X
STA ZEROPAGE_9,X
STX ZEROPAGE_9,Y
STA [ZEROPAGE_9],Y
TYA
STA datablockabs,Y
TXS
TXY
STA datablockabs,X
STZ datablockabs,X
STA @datablockabs+@$FF0000,X
JMP rowa
rowa LDY #$AA
LDA (ZEROPAGE_A,X)
LDX #$AA
LDA ZEROPAGE_A,S
LDY ZEROPAGE_A
LDA ZEROPAGE_A
LDX ZEROPAGE_A
LDA [ZEROPAGE_A]
TAY
LDA #$AA
TAX
PLB
LDY datablockabs
LDA datablockabs
LDX datablockabs
LDA @datablockabs+@$FF0000
JMP rowb
rowb BCS rowb_target
LDA (ZEROPAGE_B),Y
rowb_target LDA (ZEROPAGE_B)
LDA (ZEROPAGE_B,S),Y
LDY ZEROPAGE_B,X
LDA ZEROPAGE_B,X
LDX ZEROPAGE_B,Y
LDA [ZEROPAGE_B],Y
CLV
LDA datablockabs,Y
TSX
TYX
LDY datablockabs,X
LDA datablockabs,X
LDX datablockabs,Y
LDA @datablockabs+@$FF0000,X
JMP rowc
rowc CPY #$CC
CMP (ZEROPAGE_C,X)
REP #$CC
CMP ZEROPAGE_C,S
CPY ZEROPAGE_C
CMP ZEROPAGE_C
DEC ZEROPAGE_C
CMP [ZEROPAGE_C]
INY
CMP #$CC
DEX
WAI
CPY datablockabs
CMP datablockabs
DEC datablockabs
CMP @datablockabs+@$FF0000
JMP rowd
rowd BNE rowd_target
CMP (ZEROPAGE_D),Y
rowd_target CMP (ZEROPAGE_D)
CMP (ZEROPAGE_D,S),Y
PEI (ZEROPAGE_D)
CMP ZEROPAGE_D,X
DEC ZEROPAGE_D,X
CMP [ZEROPAGE_D],Y
CLD
CMP datablockabs,Y
PHX
STP
.byte $DC, $34, $12 ; JML (label)
CMP datablockabs,X
DEC datablockabs,X
CMP @datablockabs+@$FF0000,X
JMP rowe
rowe CPX #$EE
SBC (ZEROPAGE_E,X)
SEP #$EE
SBC ZEROPAGE_E,S
CPX ZEROPAGE_E
SBC ZEROPAGE_E
INC ZEROPAGE_E
SBC [ZEROPAGE_E]
INX
SBC #$EE
NOP
XBA
CPX datablockabs
SBC datablockabs
INC datablockabs
SBC @datablockabs+@$FF0000
JMP rowf
rowf BEQ rowf_target
SBC (ZEROPAGE_F),Y
rowf_target SBC (ZEROPAGE_F)
SBC (ZEROPAGE_F,S),Y
PEA $1000
SBC ZEROPAGE_F,X
INC ZEROPAGE_F,X
SBC [ZEROPAGE_F],Y
SED
SBC datablockabs,Y
PLX
XCE
JSR (datablockabs,X)
SBC datablockabs,X
INC datablockabs,X
SBC @datablockabs+@$FF0000,X
JMP end
end RTS
datablockabs .word $1234
farcode RTI

11
xa/tests/openpp/Makefile Normal file
View File

@ -0,0 +1,11 @@
default:
# xa should not allow this to happen. if it does, this test is no good.
../../xa test.inc || exit 0 && exit 1
# expected-to-fail tests did fail. should be no more errors now.
../../xa -DBUG test.s -o test.o
../hextool -cmp=ok < test.o
../../xa test.s -o test.o
../hextool -cmp=ok < test.o
clean:
rm -f *.o

BIN
xa/tests/openpp/ok Normal file

Binary file not shown.

View File

@ -10,7 +10,9 @@
#endif
/* comment this out to stop testing included gaffes */
#ifdef BUG
#include "test.inc"
#endif
#if 1
#if 2
@ -21,7 +23,5 @@
#ifdef X
/* comment this out for bugs in this file */
/*
#endif
*/

BIN
xa/tests/quotch/ok Normal file

Binary file not shown.

11
xa/tests/quotch/test.s Normal file
View File

@ -0,0 +1,11 @@
.word $9000
* = $9000
; test specific single characters can be quoted
LDA #';'
CMP #':'
AND #'"'
SBC #";"
ORA #":"
EOR #"'"

12
xa/tests/recmac/Makefile Normal file
View File

@ -0,0 +1,12 @@
default:
# this should fail.
../../xa -DFAIL test.asm || exit 0 && exit 1
# these should not fail.
../../xa test.asm
../hextool -cmp=test.ok < a.o65
../../xa testi.asm
../hextool -cmp=testi.ok < a.o65
clean:
rm -f a.o65

View File

@ -1 +0,0 @@
<EFBFBD>

View File

@ -26,6 +26,6 @@ start
/* this should bug out */
/*
#ifdef FAIL
POKE(NOGOOD, 7)
*/
#endif

1
xa/tests/recmac/test.ok Normal file
View File

@ -0,0 +1 @@
<EFBFBD><02><01><01><02><02><01><02><01><01><02><02>^<5E><05><03><>`

1
xa/tests/recmac/testi.ok Normal file
View File

@ -0,0 +1 @@
B<EFBFBD>

View File

@ -1,23 +1,28 @@
all: a.o65 b.o65
default: all
all: a.o65 b.o65 compare
a.o65: test1.o65
echo "********* This should give a warning about an undefined relocation table entry"
reloc65 -X test1.o65
hexdump -C a.o65 > a.o65.hex
@echo "********* This should give a warning about an undefined relocation table entry"
../../reloc65 -X test1.o65
../hextool a.o65 > a.o65.hex
b.o65: test2.o65
echo "********* This should NOT give a warning"
reloc65 -X -o b.o65 test2.o65
hexdump -C b.o65 > b.o65.hex
@echo "********* This should NOT give a warning"
../../reloc65 -X -o b.o65 test2.o65
../hextool b.o65 > b.o65.hex
test1.o65: test1.a65
xa -R -Lundefl -Ll2 -o test1.o65 test1.a65
hexdump -C test1.o65 > test1.o65.hex
../../xa -R -Lundefl -Ll2 -o test1.o65 test1.a65
../hextool test1.o65 > test1.o65.hex
test2.o65: test2.a65
xa -R -o test2.o65 test2.a65
hexdump -C test2.o65 > test2.o65.hex
../../xa -R -o test2.o65 test2.a65
../hextool test2.o65 > test2.o65.hex
compare:
../hextool -cmp=a.ok < a.o65
../hextool -cmp=b.ok < b.o65
clean:
rm -f test1.o65 a.o65 test1.o65.hex a.o65.hex

BIN
xa/tests/relocundef/a.ok Normal file

Binary file not shown.

BIN
xa/tests/relocundef/b.ok Normal file

Binary file not shown.