From cafa94f82a0f62fe0beca034a897ae100371ca5b Mon Sep 17 00:00:00 2001 From: "A. Fachat" Date: Wed, 20 Aug 2014 21:53:15 +0200 Subject: [PATCH] merge Cameron's 2.3.6 official release into master --- xa/ChangeLog | 9 +++ xa/Makefile | 11 ++- xa/misc/Makefile | 3 +- xa/misc/file65.c | 15 ++-- xa/misc/ldo65.c | 4 +- xa/misc/printcbm.c | 4 +- xa/misc/reloc65.c | 4 +- xa/misc/uncpk.c | 4 +- xa/src/xa.c | 12 ++-- xa/src/xah.h | 24 +++---- xa/src/xap.c | 11 +-- xa/tests/README | 8 +++ xa/tests/adrm/02.ok | Bin 0 -> 60 bytes xa/tests/adrm/816.ok | Bin 0 -> 50 bytes xa/tests/adrm/Makefile | 20 ++++++ xa/tests/adrm/c02.ok | Bin 0 -> 58 bytes xa/tests/adrm/zab.ok | Bin 0 -> 47 bytes xa/tests/adrm/zpa.ok | Bin 0 -> 47 bytes xa/tests/binclude/Makefile | 12 ++++ xa/tests/binclude/sd/README.2nd | 117 ++++++++++++++++++++++++++++++++ xa/tests/binclude/test.ok | Bin 0 -> 299 bytes xa/tests/binclude/test2.ok | Bin 0 -> 266 bytes xa/tests/binclude/test3.asm | 21 ++++++ xa/tests/chardelimiter/ok | 1 + xa/tests/chardelimiter/test.s | 16 +++++ xa/tests/charset/Makefile | 12 ++++ xa/tests/charset/high.o | Bin 0 -> 87 bytes xa/tests/charset/no-charset.o | Bin 0 -> 87 bytes xa/tests/charset/petscii.o | Bin 0 -> 87 bytes xa/tests/charset/petscreen.o | Bin 0 -> 87 bytes xa/tests/charset/test.s | 16 +++++ xa/tests/chppch/Makefile | 6 ++ xa/tests/chppch/ok.out | 5 ++ xa/tests/comcom/Makefile | 14 ++++ xa/tests/comcom/comcom.ok | Bin 0 -> 17 bytes xa/tests/comcom/comcomm.ok | Bin 0 -> 9 bytes xa/tests/comcom/scomcomm.ok | 1 + xa/tests/cpp/Makefile | 8 ++- xa/tests/cpp/expected.o | Bin 0 -> 18 bytes xa/tests/cpp/over.c | 4 ++ xa/tests/fordef/Makefile | 14 ++++ xa/tests/fordef/ok.out | 4 ++ xa/tests/fordef/test1.ok | Bin 0 -> 17 bytes xa/tests/fordef/test3.ok | Bin 0 -> 11 bytes xa/tests/harness | 67 ++++++++++++++++++ xa/tests/hextool | 57 ++++++++++++++++ xa/tests/incerr/Makefile | 8 +++ xa/tests/ldoreloc/Makefile | 19 +++--- xa/tests/nonl/ok | Bin 0 -> 6 bytes xa/tests/nonl/test.s | 3 + xa/tests/recmac/Makefile | 12 ++++ xa/tests/recmac/test.asm | 4 +- xa/tests/recmac/test.ok | 1 + xa/tests/recmac/testi.ok | 1 + xa/tests/relocundef/Makefile | 27 +++++--- xa/tests/relocundef/a.ok | Bin 0 -> 9 bytes xa/tests/relocundef/b.ok | Bin 0 -> 9 bytes 57 files changed, 509 insertions(+), 70 deletions(-) create mode 100644 xa/tests/adrm/02.ok create mode 100644 xa/tests/adrm/816.ok create mode 100644 xa/tests/adrm/Makefile create mode 100644 xa/tests/adrm/c02.ok create mode 100644 xa/tests/adrm/zab.ok create mode 100644 xa/tests/adrm/zpa.ok create mode 100644 xa/tests/binclude/Makefile create mode 100644 xa/tests/binclude/sd/README.2nd create mode 100644 xa/tests/binclude/test.ok create mode 100644 xa/tests/binclude/test2.ok create mode 100644 xa/tests/binclude/test3.asm create mode 100644 xa/tests/chardelimiter/ok create mode 100644 xa/tests/chardelimiter/test.s create mode 100644 xa/tests/charset/Makefile create mode 100644 xa/tests/charset/high.o create mode 100644 xa/tests/charset/no-charset.o create mode 100644 xa/tests/charset/petscii.o create mode 100644 xa/tests/charset/petscreen.o create mode 100644 xa/tests/charset/test.s create mode 100644 xa/tests/chppch/Makefile create mode 100644 xa/tests/chppch/ok.out create mode 100644 xa/tests/comcom/Makefile create mode 100644 xa/tests/comcom/comcom.ok create mode 100644 xa/tests/comcom/comcomm.ok create mode 100644 xa/tests/comcom/scomcomm.ok create mode 100644 xa/tests/cpp/expected.o create mode 100644 xa/tests/fordef/Makefile create mode 100644 xa/tests/fordef/ok.out create mode 100644 xa/tests/fordef/test1.ok create mode 100644 xa/tests/fordef/test3.ok create mode 100755 xa/tests/harness create mode 100755 xa/tests/hextool create mode 100644 xa/tests/incerr/Makefile create mode 100644 xa/tests/nonl/ok create mode 100644 xa/tests/nonl/test.s create mode 100644 xa/tests/recmac/Makefile create mode 100644 xa/tests/recmac/test.ok create mode 100644 xa/tests/recmac/testi.ok create mode 100644 xa/tests/relocundef/a.ok create mode 100644 xa/tests/relocundef/b.ok diff --git a/xa/ChangeLog b/xa/ChangeLog index a5eb775..7314462 100644 --- a/xa/ChangeLog +++ b/xa/ChangeLog @@ -295,3 +295,12 @@ xa-2.3.5 * Documentation updated. -- Cameron Kaiser 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 11 July 2014 diff --git a/xa/Makefile b/xa/Makefile index 92a1610..8fa1583 100644 --- a/xa/Makefile +++ b/xa/Makefile @@ -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? @@ -58,5 +60,8 @@ 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.6A.tar xa-2.3.6 ; gzip xa-2.3.6A.tar + cd .. ; tar cvf xa-2.3.6.tar xa-2.3.6 ; gzip xa-2.3.6.tar + +test: + cd tests && ./harness -make="$(MAKE)" -cc="$(CC)" -cflags="$(CFLAGS)" diff --git a/xa/misc/Makefile b/xa/misc/Makefile index b93b7fd..2b450e0 100644 --- a/xa/misc/Makefile +++ b/xa/misc/Makefile @@ -1,7 +1,8 @@ XCBMLIB = .. -CFLAGS = -Wall -O2 -ansi -W +# -Wall -ansi et al. cause compile problems. +CFLAGS = -O2 LIBS = #-lncurses -ltermcap -lm diff --git a/xa/misc/file65.c b/xa/misc/file65.c index e96add1..5eb03b5 100644 --- a/xa/misc/file65.c +++ b/xa/misc/file65.c @@ -18,12 +18,13 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include -#include -#include #ifndef _MSC_VER #include #endif +#include +#include +#include +#include #include #include @@ -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"); } diff --git a/xa/misc/ldo65.c b/xa/misc/ldo65.c index b176bcc..7dd6cdc 100644 --- a/xa/misc/ldo65.c +++ b/xa/misc/ldo65.c @@ -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; diff --git a/xa/misc/printcbm.c b/xa/misc/printcbm.c index 1ab7c23..6a075e5 100644 --- a/xa/misc/printcbm.c +++ b/xa/misc/printcbm.c @@ -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", diff --git a/xa/misc/reloc65.c b/xa/misc/reloc65.c index 9b528f7..eeb64cf 100644 --- a/xa/misc/reloc65.c +++ b/xa/misc/reloc65.c @@ -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; diff --git a/xa/misc/uncpk.c b/xa/misc/uncpk.c index 353d1d4..5f2a2b6 100644 --- a/xa/misc/uncpk.c +++ b/xa/misc/uncpk.c @@ -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]; diff --git a/xa/src/xa.c b/xa/src/xa.c index 1bebcf8..f0e4d1e 100644 --- a/xa/src/xa.c +++ b/xa/src/xa.c @@ -55,9 +55,9 @@ #define ANZWARN 13 #define programname "xa" -#define progversion "v2.3.5" +#define progversion "v2.3.6" #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-2014 Andre Fachat, Jolse Maginnis, David Weinehall\nand Cameron Kaiser." /* exported globals */ int ncmos, cmosfl, w65816, n65816; @@ -87,7 +87,7 @@ static int pass2(void); static int puttmp(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); @@ -763,7 +763,7 @@ static int pass1(void) temp_er = 0; /*FIXIT*/ - while(!(er=xagetline(s))) + while(!(er=xa_getline(s))) { er=t_p1((signed char*)s,o,&l,&al); switch(segment) { @@ -898,7 +898,7 @@ static char *ertxt[] = { "DSB", "NewLine", "NewFile", - "CMOS-Befehl", + "CMOS instruction used with -C", "pp:Wrong parameter count", "Illegal pointer arithmetic", "Illegal segment", @@ -1002,7 +1002,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; diff --git a/xa/src/xah.h b/xa/src/xah.h index 8b98bc8..6744ef8 100644 --- a/xa/src/xah.h +++ b/xa/src/xah.h @@ -112,19 +112,19 @@ 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 */ -#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 */ +/* warnings 75-77 are placeholders */ #define T_VALUE -1 #define T_LABEL -2 diff --git a/xa/src/xap.c b/xa/src/xap.c index a261a5d..da8e3c3 100644 --- a/xa/src/xap.c +++ b/xa/src/xap.c @@ -214,20 +214,13 @@ int pp_endif(char *t) /* stub for handling CPP directives */ int pp_cpp(char *t) { - char *fname = NULL; - if(sscanf(t, " %d \"%ms\"", &filep->fline, &fname) == 2) { + if(sscanf(t, " %d \"%s\"", &filep->fline, filep->fname) == 2) { /* massage it into our parameters and drop last quote */ char *u = ""; filep->fline--; - if((u = (char *)strrchr(fname, '"'))) + if((u = (char *)strrchr(filep->fname, '"'))) *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; return (0); } else { return(E_SYNTAX); diff --git a/xa/tests/README b/xa/tests/README index 58442e8..22c5f67 100644 --- a/xa/tests/README +++ b/xa/tests/README @@ -2,6 +2,14 @@ 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. + adrm/ Addressing mode test (especially the optimizer and quantity prefixes) nonl/ Patryk's no-new-line-on-last-line cases ;) diff --git a/xa/tests/adrm/02.ok b/xa/tests/adrm/02.ok new file mode 100644 index 0000000000000000000000000000000000000000..f6bd5e1a06534accf1e87b22af020fba4eaf0d06 GIT binary patch literal 60 zcmZQzX=Me$W310um$LS;GV}sbYJ1@t| literal 0 HcmV?d00001 diff --git a/xa/tests/adrm/816.ok b/xa/tests/adrm/816.ok new file mode 100644 index 0000000000000000000000000000000000000000..218516c921d89e81e10c67e8c7bb4ce449844e2c GIT binary patch literal 50 vcmZQzX=R1LURDMWN^S3FWnchf=hXHDpGSXU9{ri=qr(!T!@`ho;bH;+WtI?j literal 0 HcmV?d00001 diff --git a/xa/tests/adrm/Makefile b/xa/tests/adrm/Makefile new file mode 100644 index 0000000..692ff88 --- /dev/null +++ b/xa/tests/adrm/Makefile @@ -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 diff --git a/xa/tests/adrm/c02.ok b/xa/tests/adrm/c02.ok new file mode 100644 index 0000000000000000000000000000000000000000..f6b29d110919f49afe2afed85808983600c03e71 GIT binary patch literal 58 zcmZQzX=Me$W310u`&b!zfhe`TZ_dPbtPE1;oSLnA4PD+nsO;gAR(SH?=g}V@6Ba)O Kg@l9)Cldfu>lS_h literal 0 HcmV?d00001 diff --git a/xa/tests/adrm/zab.ok b/xa/tests/adrm/zab.ok new file mode 100644 index 0000000000000000000000000000000000000000..357f4d346352c12f5352167b23c8f9a027610a6d GIT binary patch literal 47 zcmV+~0MP#cK&_Pk(EFkdzau~ZodqDu(DtbSg&?T{g(0c`g(9gFg(FM@AWT{wOrRc2 F00GTE5lsL9 literal 0 HcmV?d00001 diff --git a/xa/tests/adrm/zpa.ok b/xa/tests/adrm/zpa.ok new file mode 100644 index 0000000000000000000000000000000000000000..b3392207b1a1cdf9a19c73b745acac25c281a6eb GIT binary patch literal 47 zcmV+~0MP#c0Iih((EFkdzaszuodqDu(DtbSg&?T{g(0c`g(9gFg(FM@AWT{wOrRc2 F00Fqa5X}Gp literal 0 HcmV?d00001 diff --git a/xa/tests/binclude/Makefile b/xa/tests/binclude/Makefile new file mode 100644 index 0000000..7590097 --- /dev/null +++ b/xa/tests/binclude/Makefile @@ -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 diff --git a/xa/tests/binclude/sd/README.2nd b/xa/tests/binclude/sd/README.2nd new file mode 100644 index 0000000..57a3ecf --- /dev/null +++ b/xa/tests/binclude/sd/README.2nd @@ -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 + diff --git a/xa/tests/binclude/test.ok b/xa/tests/binclude/test.ok new file mode 100644 index 0000000000000000000000000000000000000000..6dd1a4b3e890936a29f952559b7e114e450c6480 GIT binary patch literal 299 zcmYMu!AiqG5C-6$a@eQ%y|s`AZL#z!Ig~(%72AWyO?FBaHrcQ8IHZ2#|^6vBN`v+&GVln^# literal 0 HcmV?d00001 diff --git a/xa/tests/binclude/test2.ok b/xa/tests/binclude/test2.ok new file mode 100644 index 0000000000000000000000000000000000000000..5f92052cc8ab911b8e436bb4144b040c6a136a89 GIT binary patch literal 266 zcmcgnK?=e!5X>ouzG99Ft*Bt}?zIO6eZXqAG?1E-4bf-RpZOv&75W92JDslXa(aX9am<#|TWOXS6=xNhJuk;6*AD;r{A4{FKR9@77z;-DI%e)Hob3f<@+q u;b0R*n^=~s95N*nq$lS}wDgA)5=#s|M9PH`AHEuLeatU3YHZZ&{rLidc~%<$ literal 0 HcmV?d00001 diff --git a/xa/tests/binclude/test3.asm b/xa/tests/binclude/test3.asm new file mode 100644 index 0000000..f047df4 --- /dev/null +++ b/xa/tests/binclude/test3.asm @@ -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 * + diff --git a/xa/tests/chardelimiter/ok b/xa/tests/chardelimiter/ok new file mode 100644 index 0000000..2c00b0b --- /dev/null +++ b/xa/tests/chardelimiter/ok @@ -0,0 +1 @@ +©A©A1234512345"''" \ No newline at end of file diff --git a/xa/tests/chardelimiter/test.s b/xa/tests/chardelimiter/test.s new file mode 100644 index 0000000..f219d34 --- /dev/null +++ b/xa/tests/chardelimiter/test.s @@ -0,0 +1,16 @@ + + *=$033c + + lda #"A" + lda #'A' + + .asc "12345" + .asc '12345' + + .asc "^"" ; ^ is escape character + .asc '^'' + .asc "'" + .asc '"' + + .asc "^n" + diff --git a/xa/tests/charset/Makefile b/xa/tests/charset/Makefile new file mode 100644 index 0000000..712df74 --- /dev/null +++ b/xa/tests/charset/Makefile @@ -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 diff --git a/xa/tests/charset/high.o b/xa/tests/charset/high.o new file mode 100644 index 0000000000000000000000000000000000000000..597c59510589427510b8549fc6f7843c2e8e07ad GIT binary patch literal 87 zcmZRW5R#EutN=tM8L0|Isfj7MsS0Tbv69r{5~E}9-yeGT$t^$MDX|E`c1+}ga1knj Pa%uVbK#7$HR~`faMdKzF literal 0 HcmV?d00001 diff --git a/xa/tests/charset/no-charset.o b/xa/tests/charset/no-charset.o new file mode 100644 index 0000000000000000000000000000000000000000..c40bd10e4a8c5434253914b9d2bd2be0e626eff1 GIT binary patch literal 87 zcmZRW5R#EutN=tM8L0|Isfj7MsS0Tbv69r{5+k?#e5b@BWYRH_3&KUH1gc2O&j(7Z IbX@5O07}#!6#xJL literal 0 HcmV?d00001 diff --git a/xa/tests/charset/petscii.o b/xa/tests/charset/petscii.o new file mode 100644 index 0000000000000000000000000000000000000000..72ae310bd9c52e8770e54416c85064bafc0c4080 GIT binary patch literal 87 zcmZRW5R#EutN=tM8L0|Isfj7MsS0Tbv69r{5~DPK|0KsCxBPsk#3BgWF_8vz>Rwk}Y1OPXb9@PK< literal 0 HcmV?d00001 diff --git a/xa/tests/charset/petscreen.o b/xa/tests/charset/petscreen.o new file mode 100644 index 0000000000000000000000000000000000000000..f5efd395dd869d2a3250de38224289da9d06db45 GIT binary patch literal 87 zcmZRW5R#EutN=tM8L0|Isfj7MsS0Tbv69r{5+gT$ekVpDxBPsk#3BgWF_8 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 diff --git a/xa/tests/cpp/expected.o b/xa/tests/cpp/expected.o new file mode 100644 index 0000000000000000000000000000000000000000..61adb5e427c8dac9bfc1d3c0eb7b500fc2be7fcc GIT binary patch literal 18 acmZ3<=p)3Cu#&Zxf#t%_g!Kmw8~^}08VA4t literal 0 HcmV?d00001 diff --git a/xa/tests/cpp/over.c b/xa/tests/cpp/over.c index 5990b0c..1f42a85 100644 --- a/xa/tests/cpp/over.c +++ b/xa/tests/cpp/over.c @@ -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 diff --git a/xa/tests/fordef/Makefile b/xa/tests/fordef/Makefile new file mode 100644 index 0000000..cc483b1 --- /dev/null +++ b/xa/tests/fordef/Makefile @@ -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 + diff --git a/xa/tests/fordef/ok.out b/xa/tests/fordef/ok.out new file mode 100644 index 0000000..7480db3 --- /dev/null +++ b/xa/tests/fordef/ok.out @@ -0,0 +1,4 @@ +Copyright (C) 1989-2014 Andre Fachat, Jolse Maginnis, David Weinehall +and Cameron Kaiser. +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 diff --git a/xa/tests/fordef/test1.ok b/xa/tests/fordef/test1.ok new file mode 100644 index 0000000000000000000000000000000000000000..83316d9f3106767bc74fcf8178a8b01f17ce1649 GIT binary patch literal 17 YcmZQzS1Aix$mGM$k^le;Spo+D literal 0 HcmV?d00001 diff --git a/xa/tests/harness b/xa/tests/harness new file mode 100755 index 0000000..fdc7d53 --- /dev/null +++ b/xa/tests/harness @@ -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; + } +} diff --git a/xa/tests/hextool b/xa/tests/hextool new file mode 100755 index 0000000..7ea574c --- /dev/null +++ b/xa/tests/hextool @@ -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*", ); + 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*", $_); +} diff --git a/xa/tests/incerr/Makefile b/xa/tests/incerr/Makefile new file mode 100644 index 0000000..f463f1e --- /dev/null +++ b/xa/tests/incerr/Makefile @@ -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 diff --git a/xa/tests/ldoreloc/Makefile b/xa/tests/ldoreloc/Makefile index 301ec80..cf70ac2 100644 --- a/xa/tests/ldoreloc/Makefile +++ b/xa/tests/ldoreloc/Makefile @@ -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 diff --git a/xa/tests/nonl/ok b/xa/tests/nonl/ok new file mode 100644 index 0000000000000000000000000000000000000000..06b7249b416ca4e03c482efe6995f83762904661 GIT binary patch literal 6 NcmZ3<(#y(_000KF0iXZ? literal 0 HcmV?d00001 diff --git a/xa/tests/nonl/test.s b/xa/tests/nonl/test.s new file mode 100644 index 0000000..0e7fb25 --- /dev/null +++ b/xa/tests/nonl/test.s @@ -0,0 +1,3 @@ + lda #4 + sta !$0005 + rts \ No newline at end of file diff --git a/xa/tests/recmac/Makefile b/xa/tests/recmac/Makefile new file mode 100644 index 0000000..ec05283 --- /dev/null +++ b/xa/tests/recmac/Makefile @@ -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 + diff --git a/xa/tests/recmac/test.asm b/xa/tests/recmac/test.asm index af88314..50b4cce 100644 --- a/xa/tests/recmac/test.asm +++ b/xa/tests/recmac/test.asm @@ -26,6 +26,6 @@ start /* this should bug out */ -/* +#ifdef FAIL POKE(NOGOOD, 7) -*/ +#endif diff --git a/xa/tests/recmac/test.ok b/xa/tests/recmac/test.ok new file mode 100644 index 0000000..1fa4b06 --- /dev/null +++ b/xa/tests/recmac/test.ok @@ -0,0 +1 @@ +©…©…©…©…©…©…^©…Ðâ` \ No newline at end of file diff --git a/xa/tests/recmac/testi.ok b/xa/tests/recmac/testi.ok new file mode 100644 index 0000000..f06be7d --- /dev/null +++ b/xa/tests/recmac/testi.ok @@ -0,0 +1 @@ +Bª \ No newline at end of file diff --git a/xa/tests/relocundef/Makefile b/xa/tests/relocundef/Makefile index 39eab67..79c6968 100644 --- a/xa/tests/relocundef/Makefile +++ b/xa/tests/relocundef/Makefile @@ -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 diff --git a/xa/tests/relocundef/a.ok b/xa/tests/relocundef/a.ok new file mode 100644 index 0000000000000000000000000000000000000000..948763fe1f92efb10ac4d10ac912d051c056e600 GIT binary patch literal 9 QcmZ3)xR!z8)P-LO01|2hMF0Q* literal 0 HcmV?d00001 diff --git a/xa/tests/relocundef/b.ok b/xa/tests/relocundef/b.ok new file mode 100644 index 0000000000000000000000000000000000000000..394ff7786283ae0c9ff23677336c6e81d95568ee GIT binary patch literal 9 QcmZ3)xR#OO)P-LO01|KnMgRZ+ literal 0 HcmV?d00001