Package: xa Version: 2.3.8-2 Severity: normal Tags: patch pending Dear maintainer,
I've prepared an NMU for xa (versioned as 2.3.11-0.1) and uploaded it to the archive. Regards, Stephen
diff -Nru xa-2.3.8/ChangeLog xa-2.3.11/ChangeLog --- xa-2.3.8/ChangeLog 2017-06-30 07:01:10.000000000 +0200 +++ xa-2.3.11/ChangeLog 2020-05-03 23:06:29.000000000 +0200 @@ -324,3 +324,42 @@ * Testsuite expanded. -- Cameron Kaiser <[email protected]> 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 <[email protected]> 31 January 2019 + +xa-2.3.10 + + * Three fixes, all from Andre: + - Don't crash if a useless segment is referenced outside of relocating + mode (thanks Laszlo Barath for the report). + - Don't substitute within strings, for better cpp compatibility (thanks + Glenn Holmer for the report). I added the -S option for backwards + compatibility for the old behaviour; it will be removed in 2.4 and later. + - Fix underflow issue if a variable is late-bound (with -L) when that + variable is used in computations with negative offsets. + * Deprecated options will be removed in 2.4 and everything is warned. + * Documentation updated. + * Testsuite expanded. + + -- Cameron Kaiser <[email protected]> 9 November 2019 + +xa-2.3.11 + + * Compilation fix for gcc 10 (thanks Dan Horak). + * Allow pointer arithmetic in relocating mode within the same segment, since + the result is segmentless (thanks Andre for the report). + * .dsb with negative quantities shouldn't work (thanks Andre for the report). + * Stop a divide-by-zero floating point exception (thanks Frederic Cambus). + * Testsuite expanded. + + -- Cameron Kaiser <[email protected]> 4 May 2020 + diff -Nru xa-2.3.8/debian/changelog xa-2.3.11/debian/changelog --- xa-2.3.8/debian/changelog 2020-07-24 12:48:44.000000000 +0200 +++ xa-2.3.11/debian/changelog 2020-07-24 12:48:44.000000000 +0200 @@ -1,3 +1,14 @@ +xa (2.3.11-0.1) unstable; urgency=medium + + * Non-maintainer upload. + * New upstream release, which builds with GCC 10 (Closes: #957966). + * Override the build flags (the 2.3.11 build sets them unconditionnally, + unlike the 2.3.8 build). + * Set the linker so that the package can be cross-built; thanks to + Helmut Grohne for the patch (Closes: #948176). + + -- Stephen Kitt <[email protected]> Fri, 24 Jul 2020 12:46:11 +0200 + xa (2.3.8-2) unstable; urgency=low * debian/control: diff -Nru xa-2.3.8/debian/rules xa-2.3.11/debian/rules --- xa-2.3.8/debian/rules 2020-07-24 12:48:44.000000000 +0200 +++ xa-2.3.11/debian/rules 2020-07-24 12:48:44.000000000 +0200 @@ -1,5 +1,11 @@ #!/usr/bin/make -f +include /usr/share/dpkg/buildflags.mk +include /usr/share/dpkg/buildtools.mk + +override_dh_auto_build: + dh_auto_build -- CC='$(CC)' LD='$$(CC)' CFLAGS='$(CPPFLAGS) $(CFLAGS)' LDFLAGS='$(LDFLAGS)' + override_dh_auto_install: make install DESTDIR=$(CURDIR)/debian/xa65/usr diff -Nru xa-2.3.8/Makefile xa-2.3.11/Makefile --- xa-2.3.8/Makefile 2020-07-24 12:48:44.000000000 +0200 +++ xa-2.3.11/Makefile 2020-05-03 00:00:31.000000000 +0200 @@ -4,8 +4,8 @@ LD = gcc # for testing. not to be used; build failures in misc/. #CFLAGS = -O2 -W -Wall -pedantic -ansi -CFLAGS += -O2 -LDFLAGS += -lc +CFLAGS = -O2 +LDFLAGS = -lc # for DOS? # CC = gcc-go32 @@ -32,13 +32,13 @@ rm -f xa xa: - (cd src && LD=${LD} CC="${CC} ${CPPFLAGS} ${CFLAGS} ${LDFLAGS}" ${MAKE}) + (cd src && LD=${LD} CC="${CC} ${CFLAGS}" ${MAKE}) load: - (cd loader && CC="${CC} ${CPPFLAGS} ${CFLAGS} ${LDFLAGS}" ${MAKE}) + (cd loader && CC="${CC} ${CFLAGS}" ${MAKE}) uncpk: - (cd misc && CC="${CC} ${CPPFLAGS} ${CFLAGS} ${LDFLAGS}" ${MAKE}) + (cd misc && CC="${CC} ${CFLAGS}" ${MAKE}) dos: clean (cd src && LD=gcc-go32 CC=gcc-go32 CFLAGS="-W -Wall -pedantic" ${MAKE}) @@ -63,8 +63,7 @@ #$(MKDIR) $(DOCDIR)/xa65 dist: clean - #cd .. ; tar cvf xa-2.3.8A.tar xa-2.3.8 ; gzip xa-2.3.8A.tar - cd .. ; tar cvf xa-2.3.8.tar xa-2.3.8 ; gzip xa-2.3.8.tar + cd .. ; tar cvf xa-2.3.11.tar xa-2.3.11 ; gzip xa-2.3.11.tar test: xa uncpk cd tests && ./harness -make="$(MAKE)" -cc="$(CC)" -cflags="$(CFLAGS)" diff -Nru xa-2.3.8/man/xa.1 xa-2.3.11/man/xa.1 --- xa-2.3.8/man/xa.1 2017-06-30 07:01:06.000000000 +0200 +++ xa-2.3.11/man/xa.1 2019-11-09 20:08:02.000000000 +0100 @@ -1,4 +1,4 @@ -.TH XA "1" "29 June 2017" +.TH XA "1" "9 November 2019" .SH NAME xa \- 6502/R65C02/65816 cross-assembler @@ -10,8 +10,7 @@ .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 @@ -22,16 +21,8 @@ .B \-v Verbose output. .TP -.B \-x -Use old filename behaviour (overrides -.BR \-o , -.B \-e -and -.BR \-l ). -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). @@ -134,6 +125,23 @@ .TP .B \-\-version Show version of program. +.LP +The following options are +.BR deprecated +and will be removed in 2.4 and later versions: +.TP +.B \-x +Use old filename behaviour (overrides +.BR \-o , +.B \-e +and +.BR \-l ). +.TP +.B \-S +Allow preprocessor substitution within strings (this is now disallowed +for better +.BR cpp (1) +compatibility). .SH ASSEMBLER SYNTAX @@ -228,6 +236,21 @@ .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 @@ -238,7 +261,7 @@ 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 @@ -464,7 +487,9 @@ 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 @@ -479,7 +504,9 @@ .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 @@ -757,6 +784,107 @@ .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 @@ -827,6 +955,20 @@ prefix. Otherwise, the assembler will attempt to optimize to 16 bits, which may be undesirable. +.SH "IMMINENT DEPRECATION" +The following options and modes will be +.B REMOVED +in 2.4 and later versions of +.BR xa : +.LP +.B \-x +.LP +.B \-S +.LP +the original +.B mvn $xxxx +syntax + .SH "SEE ALSO" .BR file65 (1), .BR ldo65 (1), @@ -840,8 +982,11 @@ Andre Fachat <[email protected]> and Cameron Kaiser <[email protected]>. Original xa package (C)1989-1997 Andre Fachat. Additional changes -(C)1989-2017 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/ diff -Nru xa-2.3.8/README.1st xa-2.3.11/README.1st --- xa-2.3.8/README.1st 2017-06-30 06:22:22.000000000 +0200 +++ xa-2.3.11/README.1st 2019-11-09 02:20:26.000000000 +0100 @@ -3,7 +3,7 @@ under most ANSI C compilers. It is distributed under the GNU Public License (see COPYING). -The current version is 2.3.8, a bug fix to the long-lived 2.3.0, itself with +The current version is 2.3.10, 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. diff -Nru xa-2.3.8/src/Makefile xa-2.3.11/src/Makefile --- xa-2.3.8/src/Makefile 2020-07-24 12:48:44.000000000 +0200 +++ xa-2.3.11/src/Makefile 2019-11-09 01:11:32.000000000 +0100 @@ -8,7 +8,7 @@ all: xa xa: ${OBJ} - ${LD} ${CPPFLAGS} ${CFLAGS} -o ../xa ${OBJ} ${LDFLAGS} + ${LD} -o ../xa ${OBJ} ${LDFLAGS} clean: rm -f *.o *.o65 diff -Nru xa-2.3.8/src/xaa.c xa-2.3.11/src/xaa.c --- xa-2.3.8/src/xaa.c 2008-06-15 07:15:34.000000000 +0200 +++ xa-2.3.11/src/xaa.c 2020-05-03 23:00:05.000000000 +0200 @@ -98,7 +98,9 @@ afl = 0; -/*printf("ag_term(%02x %02x %02x %02x %02x %02x\n",s[0],s[1],s[2],s[3],s[4],s[5]);*/ +/* +printf("ag_term(%02x %02x %02x %02x %02x %02x\n",s[0],s[1],s[2],s[3],s[4],s[5]); +*/ while(s[pp]=='-') { pp++; @@ -119,8 +121,10 @@ if(s[pp]==T_LABEL) { er=l_get(cval(s+pp+1),v, &afl); -/* printf("label: er=%d, seg=%d, afl=%d, nolink=%d, fundef=%d\n", - er, segment, afl, nolink, fundef); */ +/* + printf("label: er=%d, seg=%d, afl=%d, nolink=%d, fundef=%d\n", + er, segment, afl, nolink, fundef); +*/ if(er==E_NODEF && segment != SEG_ABS && fundef ) { if( nolink || (afl==SEG_UNDEF)) { er = E_OK; @@ -136,7 +140,9 @@ { *v=lval(s+pp+1); pp+=4; -/* printf("value: v=%04x\n",*v); */ +/* +printf("value: v=%04x\n",*v); +*/ } else if(s[pp]==T_POINTER) @@ -144,7 +150,9 @@ afl = s[pp+1]; *v=cval(s+pp+2); pp+=4; -/* printf("pointer: v=%04x, afl=%04x\n",*v,afl); */ +/* +printf("pointer: v=%04x, afl=%04x\n",*v,afl); +*/ } else if(s[pp]=='*') @@ -178,9 +186,10 @@ if((afl && !*nafl) && o==2) { afl=(afl | *nafl); /* substract constant from pointer */ } else { - if(segment!=SEG_ABS) { + /* allow math in the same segment */ + if(segment!=SEG_ABS && segment != afl) { if(!dsb_len) { - er=E_ILLPOINTER; + er=E_ILLSEGMENT; } } afl=0; @@ -224,7 +233,7 @@ *w *=w2; break; case 4: - if (w!=0) + if (w2!=0) *w /=w2; else er =E_DIV; diff -Nru xa-2.3.8/src/xa.c xa-2.3.11/src/xa.c --- xa-2.3.8/src/xa.c 2017-06-30 06:24:04.000000000 +0200 +++ xa-2.3.11/src/xa.c 2020-05-06 23:39:58.000000000 +0200 @@ -55,13 +55,14 @@ #define ANZWARN 13 #define programname "xa" -#define progversion "v2.3.8" +#define progversion "v2.3.11" #define authors "Written by Andre Fachat, Jolse Maginnis, David Weinehall and Cameron Kaiser" -#define copyright "Copyright (C) 1989-2017 Andre Fachat, Jolse Maginnis, David Weinehall\nand Cameron Kaiser." +#define copyright "Copyright (C) 1989-2020 Andre Fachat, Jolse Maginnis, David Weinehall\nand Cameron Kaiser." /* exported globals */ int ncmos, cmosfl, w65816, n65816; int masm = 0; +int ppinstr = 0; int nolink = 0; int romable = 0; int romaddr = 0; @@ -210,6 +211,10 @@ case 'M': masm = 1; /* MASM compatibility mode */ break; + case 'S': + ppinstr = 1; /* preprocessor substitution in strings ok */ + fprintf(stderr, "Warning: -S is deprecated and will be removed in 2.4+!\n"); + break; case 'O': /* output charset */ { char *name = NULL; @@ -267,7 +272,7 @@ break; case 'x': /* old filename behaviour */ oldfile = 1; - fprintf(stderr, "Warning: -x is now deprecated and may disappear in future versions!\n"); + fprintf(stderr, "Warning: -x is now deprecated and will be removed in 2.4+!\n"); break; case 'I': if(argv[i][2]==0) { @@ -392,6 +397,8 @@ r_mode(RMODE_RELOC); segment = SEG_TEXT; } else { + /* prime old_segment in r_mode with SEG_TEXT */ + segment = SEG_ABS; r_mode(RMODE_ABS); } @@ -460,11 +467,13 @@ seg_pass2(); - if(!relmode) { - r_mode(RMODE_ABS); + if(relmode) { + r_mode(RMODE_RELOC); + segment = SEG_TEXT; } else { - r_mode(RMODE_RELOC); - segment = SEG_TEXT; + /* prime old_segment in r_mode with SEG_TEXT */ + segment = SEG_ABS; + r_mode(RMODE_ABS); } er=pass2(); } @@ -716,7 +725,7 @@ fprintf(stderr, "fnam = %s\n", binfnam); */ /* primitive insurance */ - if (!(foo = fopen(binfnam, "r"))) { + if (!(foo = fopen(binfnam, "rb"))) { errout(E_FNF); ner++; } else { @@ -825,8 +834,6 @@ programname); fprintf(fp, " -v verbose output\n" - " -x old filename behaviour (overrides `-o', `-e', `-l')\n" - " This is deprecated and may disappear in future versions!\n" " -C no CMOS-opcodes\n" " -W no 65816-opcodes%s\n" " -w allow 65816-opcodes%s\n", @@ -854,11 +861,16 @@ " Other segments must be specified with `-b?'\n" " -G suppress list of exported globals\n"); fprintf(fp, + " -p? set preprocessor character to ?, default is #\n" " -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"); + fprintf(fp, + "== These options are deprecated and will be removed in 2.4+! ==\n" + " -x old filename behaviour (overrides `-o', `-e', `-l')\n" + " -S allow preprocessor substitution within strings\n"); } /* diff -Nru xa-2.3.8/src/xa.h xa-2.3.11/src/xa.h --- xa-2.3.8/src/xa.h 2008-07-02 07:04:25.000000000 +0200 +++ xa-2.3.11/src/xa.h 2019-11-09 01:36:39.000000000 +0100 @@ -22,7 +22,7 @@ #include "xah.h" /* For SEG_MAX */ extern int ncmos, cmosfl, w65816, n65816; -extern int masm, nolink; +extern int masm, nolink, ppinstr; extern int noglob; extern int showblk; extern int relmode; diff -Nru xa-2.3.8/src/xap.c xa-2.3.11/src/xap.c --- xa-2.3.8/src/xap.c 2014-12-27 03:42:52.000000000 +0100 +++ xa-2.3.11/src/xap.c 2019-11-09 01:46:05.000000000 +0100 @@ -456,7 +456,25 @@ { while(t[0]!='\0') { - while(!isalpha(t[0]) && t[0]!='_') + /* find start of a potential token to be replaced */ + while(!isalpha(t[0]) && t[0]!='_') { + + /* escape strings quoted with " */ + if (!ppinstr && t[0] == '\"') { + do { + t++; + ti++; + } while (t[0] && t[0]!='\"'); + } + + /* escape strings quoted with ' */ + if (!ppinstr && t[0] == '\'') { + do { + t++; + ti++; + } while (t[0] && t[0]!='\''); + } + if(t[0]=='\0') break; /*return(E_OK);*/ else @@ -464,6 +482,7 @@ t++; ti++; } + } for(l=0;isalnum(t[l])||t[l]=='_';l++); ld=l; diff -Nru xa-2.3.8/src/xap.h xa-2.3.11/src/xap.h --- xa-2.3.8/src/xap.h 2012-07-24 22:08:53.000000000 +0200 +++ xa-2.3.11/src/xap.h 2020-05-03 00:01:54.000000000 +0200 @@ -35,7 +35,7 @@ long gm_ppm(void); long ga_ppm(void); -Datei *filep; -char s[MAXLINE]; +extern Datei *filep; +extern char s[MAXLINE]; #endif /* __XA65_XAP_H__ */ diff -Nru xa-2.3.8/src/xat.c xa-2.3.11/src/xat.c --- xa-2.3.8/src/xat.c 2014-12-28 03:11:28.000000000 +0100 +++ xa-2.3.11/src/xat.c 2020-05-03 01:13:18.000000000 +0200 @@ -479,48 +479,44 @@ dsb_len = 0; } else if(n==Ktext) { -/* if(segment!=SEG_ABS) { */ segment = relmode ? SEG_TEXT : SEG_ABS; t[0]=Ksegment; t[1]=segment; *ll=2; er=E_OKDEF; -/* } else { - er=E_ILLSEGMENT; - } */ } else if(n==Kdata) { -/* if(segment!=SEG_ABS) { */ + if(relmode) { segment = SEG_DATA; t[0]=Ksegment; t[1]=SEG_DATA; *ll=2; er=E_OKDEF; -/* } else { + } else { er=E_ILLSEGMENT; - } */ + } } else if(n==Kbss) { -/* if(segment!=SEG_ABS) { */ + if(relmode) { segment = SEG_BSS; t[0]=Ksegment; t[1]=SEG_BSS; *ll=2; er=E_OKDEF; -/* } else { + } else { er=E_ILLSEGMENT; - } */ + } } else if(n==Kzero) { -/* if(segment!=SEG_ABS) { */ + if(relmode) { segment = SEG_ZERO; t[0]=Ksegment; t[1]=SEG_ZERO; *ll=2; er=E_OKDEF; -/* } else { + } else { er=E_ILLSEGMENT; - } */ + } } else if (n==Kbin) { int j; @@ -601,7 +597,7 @@ "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); @@ -704,8 +700,14 @@ } else sy=4+nk; /* absolute or zero page */ - /* length counter set to maximum length + 1 */ - bl=Maxbyt+1; + /* length counter set to maximum length + 1 */ + if (w65816 || (t[l-1]=='@' || t[l-1] == '!')) { + /* for 65816 allow addressing modes up to 4 byte overall length */ + bl=Maxbyt+1; + } else { + /* for other modes only check for addressing modes up to 3 byte overall length */ + bl=Maxbyt; + } /* find best fit for length of this operand */ while(--bl) @@ -1027,7 +1029,7 @@ "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); @@ -1203,6 +1205,9 @@ dsb_len = 1; if(!(er=a_term(t+1,&j,&i,pc[segment],&afl,&label,0))) { + if (j<0) + er=E_SYNTAX; + else /* if(t[i+1]!=',') er=E_SYNTAX; @@ -1375,9 +1380,19 @@ } } } - - bl=Maxbyt+1; + /* set bl to maximum overall length +1 as while() below starts with decrementing it */ + if (w65816 || (t[*ll-1]=='@' || t[*ll-1] == '!')) { + /* for 65816 allow addressing modes up to 4 byte overall length */ + bl=Maxbyt+1; + } else { + /* for other modes only check for addressing modes up to 3 byte overall length */ + bl=Maxbyt; + } + +#ifdef DEBUG_AM + printf("--- trying to find am using: (max+1) bl=%d, sy=%d\n", bl, sy); +#endif while(--bl) { if((am=at[sy][bl-1])>=0) @@ -1415,8 +1430,8 @@ { #ifdef DEBUG_AM fprintf(stderr, -"b4: pc= %d, am = %d and vv[0] = %d, optimize = %d, bitmask = %d\n", - pc[segment], am, vv[0], fl, (vv[0]&0xffff00)); +"b4: pc= %d, am = %d and vv[0] = %d, optimize = %d, bitmask = %u, er=%d\n", + pc[segment], am, vv[0], fl, (vv[0]&0xffff00), er); #endif /* terrible KLUDGE!!!! OH NOES!!!1! @@ -1455,15 +1470,21 @@ else { bl=le[am]; + if ((am != 11 && am != 16) && (vv[0] > 255 || vv[0] < -256) && bl == 2) { + er = E_OVERFLOW; + } else + if ((am != 11 && am != 16) && (vv[0] > 65535 || vv[0] < -65536) && (bl == 2 || bl == 3)) { + er = E_OVERFLOW; + } else if( ((ct[n][am]&0x400) && memode) || ((ct[n][am]&0x800) && xmode)) { bl++; - } + } *ll=bl; } #ifdef DEBUG_AM -fprintf(stderr, "byte length is now %d\n", bl); +fprintf(stderr, "byte length is now %d, am=%d, er=%d\n", bl, am, er); #endif if(!er) @@ -1512,6 +1533,7 @@ } } else if(am==11 || am==16) { + /* relative, relative long */ if((segment!=SEG_ABS) && (!rlt[0])) { er=E_ILLPOINTER; } else { diff -Nru xa-2.3.8/tests/csapiec/Makefile xa-2.3.11/tests/csapiec/Makefile --- xa-2.3.8/tests/csapiec/Makefile 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.11/tests/csapiec/Makefile 2020-05-03 01:01:06.000000000 +0200 @@ -0,0 +1,12 @@ +default: + # xa should not allow this to happen. if it does, this test is no good. + ../../xa -DBUG=1 -o test.o test.s || exit 0 && exit 1 + ../../xa -R -DBUG=1 -o testseg.o test.s || exit 0 && exit 1 + # xa *should* allow this to happen. + ../../xa -o test.o test.s + ../hextool -cmp=test.ok < test.o + ../../xa -R -o testseg.o test.s + ../hextool -cmp=testseg.ok < testseg.o + +clean: + rm -f *.o Binary files /tmp/user/1000/KWOtsOxNdc/xa-2.3.8/tests/csapiec/test.ok and /tmp/user/1000/OSWa8ZGOHD/xa-2.3.11/tests/csapiec/test.ok differ diff -Nru xa-2.3.8/tests/csapiec/test.s xa-2.3.11/tests/csapiec/test.s --- xa-2.3.8/tests/csapiec/test.s 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.11/tests/csapiec/test.s 2020-05-03 00:51:34.000000000 +0200 @@ -0,0 +1,32 @@ + .text + +c0 =*-1 + +#ifdef BUG + .data +#endif + +cmdt .asc "$",0 +cow .asc "@",0 +c2 .asc "rename",0 +c3 .asc "scratch",0 +c4 .asc "copy",0 +c5 .asc "new",0 +c6 .asc "validate",0 +c7 .asc "initialize",0 +;c8 .asc "rmdir",0 +;c9 .asc "mkdir",0 +;c10 .asc "chdir",0 +c11 .asc "assign",0 +c12 .asc "cd",0 +c13 .asc "rd",0 +c14 .asc "md",0 +c15 .asc "drv",0 ; iec-bus-unit + +cmda .byt cmdt-c0 + .byt <c0 + .byt <cow-c0 + .word <cow-c0 + .byt c2-c0, c3-c0, c4-c0, c5-c0, c6-c0, c7-c0 /*,c8-c0*/ + .byt /*c9-c0,c10-c0,*/ c11-c0, c12-c0, c13-c0, c14-c0, c15-c0, 0 + Binary files /tmp/user/1000/KWOtsOxNdc/xa-2.3.8/tests/csapiec/testseg.ok and /tmp/user/1000/OSWa8ZGOHD/xa-2.3.11/tests/csapiec/testseg.ok differ Binary files /tmp/user/1000/KWOtsOxNdc/xa-2.3.8/tests/linkr/ok and /tmp/user/1000/OSWa8ZGOHD/xa-2.3.11/tests/linkr/ok differ diff -Nru xa-2.3.8/tests/linkr/test.s xa-2.3.11/tests/linkr/test.s --- xa-2.3.8/tests/linkr/test.s 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.11/tests/linkr/test.s 2019-11-09 01:11:32.000000000 +0100 @@ -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 + diff -Nru xa-2.3.8/tests/math/divzero2.s xa-2.3.11/tests/math/divzero2.s --- xa-2.3.8/tests/math/divzero2.s 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.11/tests/math/divzero2.s 2020-05-03 23:05:14.000000000 +0200 @@ -0,0 +1,6 @@ +.word $ +xyz = 2 +zyx = xyz - xyz + +* = $0/zyx + diff -Nru xa-2.3.8/tests/math/divzero.s xa-2.3.11/tests/math/divzero.s --- xa-2.3.8/tests/math/divzero.s 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.11/tests/math/divzero.s 2020-05-03 23:04:42.000000000 +0200 @@ -0,0 +1,3 @@ +.word $ +* = $0/00 + diff -Nru xa-2.3.8/tests/math/Makefile xa-2.3.11/tests/math/Makefile --- xa-2.3.8/tests/math/Makefile 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.11/tests/math/Makefile 2020-05-03 23:05:22.000000000 +0200 @@ -0,0 +1,7 @@ +default: + # xa should not allow this to happen. if it does, this test is no good. + ../../xa -o divzero.o divzero.s || exit 0 && exit 1 + ../../xa -o divzero2.o divzero2.s || exit 0 && exit 1 + +clean: + rm -f *.o Binary files /tmp/user/1000/KWOtsOxNdc/xa-2.3.8/tests/neg_offset/a.o65 and /tmp/user/1000/OSWa8ZGOHD/xa-2.3.11/tests/neg_offset/a.o65 differ diff -Nru xa-2.3.8/tests/neg_offset/Makefile xa-2.3.11/tests/neg_offset/Makefile --- xa-2.3.8/tests/neg_offset/Makefile 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.11/tests/neg_offset/Makefile 2020-05-03 01:03:57.000000000 +0200 @@ -0,0 +1,40 @@ +default: test0 test1 test2 test3 test4 test5 test6 test7 test8 + +test0: + # this test must fail. + ../../xa -o test0.o test0.s || exit 0 && exit 1 + +test1: + ../../xa -R -LLIB6502 test1.s -o test1.o + ../hextool -cmp=ok1 < test1.o + +test2: + ../../xa -R -LLIB6502 test2.s -o test2.o + ../hextool -cmp=ok2 < test2.o + +test3: + ../../xa -R -LLIB6502 test3.s -o test3.o + ../hextool -cmp=ok3 < test3.o + +test4: + ../../xa -R -LLIB6502 test4.s -o test4.o + ../hextool -cmp=ok4 < test4.o + +test5: + ../../xa -R -LLIB6502 test5.s -o test5.o + ../hextool -cmp=ok5 < test5.o + +test6: + # this test must fail. + ../../xa -R -LLIB6502 test6.s -o test6.o || exit 0 && exit 1 + +test7: + # this test must fail. + ../../xa -R -LLIB6502 test7.s -o test7.o || exit 0 && exit 1 + +test8: + # this test must fail. + ../../xa -R -LLIB6502 test8.s -o test8.o || exit 0 && exit 1 + +clean: + rm -f *.o Binary files /tmp/user/1000/KWOtsOxNdc/xa-2.3.8/tests/neg_offset/ok1 and /tmp/user/1000/OSWa8ZGOHD/xa-2.3.11/tests/neg_offset/ok1 differ Binary files /tmp/user/1000/KWOtsOxNdc/xa-2.3.8/tests/neg_offset/ok2 and /tmp/user/1000/OSWa8ZGOHD/xa-2.3.11/tests/neg_offset/ok2 differ Binary files /tmp/user/1000/KWOtsOxNdc/xa-2.3.8/tests/neg_offset/ok3 and /tmp/user/1000/OSWa8ZGOHD/xa-2.3.11/tests/neg_offset/ok3 differ Binary files /tmp/user/1000/KWOtsOxNdc/xa-2.3.8/tests/neg_offset/ok4 and /tmp/user/1000/OSWa8ZGOHD/xa-2.3.11/tests/neg_offset/ok4 differ Binary files /tmp/user/1000/KWOtsOxNdc/xa-2.3.8/tests/neg_offset/ok5 and /tmp/user/1000/OSWa8ZGOHD/xa-2.3.11/tests/neg_offset/ok5 differ diff -Nru xa-2.3.8/tests/neg_offset/test0.s xa-2.3.11/tests/neg_offset/test0.s --- xa-2.3.8/tests/neg_offset/test0.s 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.11/tests/neg_offset/test0.s 2020-05-03 01:03:22.000000000 +0200 @@ -0,0 +1,2 @@ + + .dsb -10, 32 diff -Nru xa-2.3.8/tests/neg_offset/test1.s xa-2.3.11/tests/neg_offset/test1.s --- xa-2.3.8/tests/neg_offset/test1.s 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.11/tests/neg_offset/test1.s 2019-11-09 01:21:07.000000000 +0100 @@ -0,0 +1,6 @@ + + .text + + jsr LIB6502-3 + + diff -Nru xa-2.3.8/tests/neg_offset/test2.s xa-2.3.11/tests/neg_offset/test2.s --- xa-2.3.8/tests/neg_offset/test2.s 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.11/tests/neg_offset/test2.s 2019-11-09 01:21:29.000000000 +0100 @@ -0,0 +1,9 @@ + +#define flib2osa_r LIB6502-3 + + .text + + jsr flib2osa_r + + + diff -Nru xa-2.3.8/tests/neg_offset/test3.s xa-2.3.11/tests/neg_offset/test3.s --- xa-2.3.8/tests/neg_offset/test3.s 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.11/tests/neg_offset/test3.s 2019-11-09 01:21:08.000000000 +0100 @@ -0,0 +1,6 @@ + + .text + + jsr LIB6502-255 + + diff -Nru xa-2.3.8/tests/neg_offset/test4.s xa-2.3.11/tests/neg_offset/test4.s --- xa-2.3.8/tests/neg_offset/test4.s 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.11/tests/neg_offset/test4.s 2019-11-09 01:21:08.000000000 +0100 @@ -0,0 +1,6 @@ + + .text + + jsr LIB6502+256 + + diff -Nru xa-2.3.8/tests/neg_offset/test5.s xa-2.3.11/tests/neg_offset/test5.s --- xa-2.3.8/tests/neg_offset/test5.s 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.11/tests/neg_offset/test5.s 2019-11-09 01:21:09.000000000 +0100 @@ -0,0 +1,6 @@ + + .text + + jsr LIB6502-256 + + diff -Nru xa-2.3.8/tests/neg_offset/test6.s xa-2.3.11/tests/neg_offset/test6.s --- xa-2.3.8/tests/neg_offset/test6.s 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.11/tests/neg_offset/test6.s 2019-11-09 01:21:09.000000000 +0100 @@ -0,0 +1,6 @@ + + .text + + jsr LIB6502-65537 + + diff -Nru xa-2.3.8/tests/neg_offset/test7.s xa-2.3.11/tests/neg_offset/test7.s --- xa-2.3.8/tests/neg_offset/test7.s 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.11/tests/neg_offset/test7.s 2019-11-09 01:21:09.000000000 +0100 @@ -0,0 +1,6 @@ + + .text + + jsr 65536 + + diff -Nru xa-2.3.8/tests/neg_offset/test8.s xa-2.3.11/tests/neg_offset/test8.s --- xa-2.3.8/tests/neg_offset/test8.s 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.11/tests/neg_offset/test8.s 2019-11-09 01:21:09.000000000 +0100 @@ -0,0 +1,6 @@ + + .text + + jsr LIB6502+65536 + + Binary files /tmp/user/1000/KWOtsOxNdc/xa-2.3.8/tests/ppstrings/ok and /tmp/user/1000/OSWa8ZGOHD/xa-2.3.11/tests/ppstrings/ok differ diff -Nru xa-2.3.8/tests/ppstrings/test.s xa-2.3.11/tests/ppstrings/test.s --- xa-2.3.8/tests/ppstrings/test.s 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.11/tests/ppstrings/test.s 2019-11-09 01:48:54.000000000 +0100 @@ -0,0 +1,15 @@ + +#define DUP 123 + + .asc "DUP^@" + + .asc '0DUP^@' + + .asc "D","UP^@" + + .asc "DUP + + .asc "DU0 + + .asc "DU + diff -Nru xa-2.3.8/tests/README xa-2.3.11/tests/README --- xa-2.3.8/tests/README 2017-06-30 06:54:20.000000000 +0200 +++ xa-2.3.11/tests/README 2020-05-03 23:04:15.000000000 +0200 @@ -16,6 +16,8 @@ prefixes) nonl/ Patryk's no-new-line-on-last-line cases ;) fordef/ Optimizer warnings for forward defined labels +relocmode/ Tests to prevent use of irrational segments if relocating + mde isn't on relocundef/ Tests for the detection of undefined references during a reloc65 export ldoreloc/ Test case for the relocation table reading of ldo when undef'd @@ -27,6 +29,8 @@ incerr/ 1) .xl/.al should error without -w 2) error should be in the correct file ('816) binclude/ Binary include code with some weird casing +ppstrings/ Don't substitute inside strings (unless -S) +neg_offset/ Test negative offsets/values with/without relocation chppch/ Changing preprocessor characters (-p) charset/ Tests of when charsets should be honoured and when not mvnmvp/ Test MVN MVP unusual addressing mode ('816) @@ -36,6 +40,9 @@ 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 +csapiec/ Test on pointer arithmetic in relocating mode +math/ Math tests (currently divide by zero, thanks Frederic Cambus) Cameron Kaiser, André Fachat diff -Nru xa-2.3.8/tests/relocmode/Makefile xa-2.3.11/tests/relocmode/Makefile --- xa-2.3.8/tests/relocmode/Makefile 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.11/tests/relocmode/Makefile 2019-11-09 02:00:27.000000000 +0100 @@ -0,0 +1,10 @@ +default: test1 + +test1: + # this should fail in non-relocating mode + ../../xa test1.s -o test1.o || exit 0 && exit 1 + ../../xa -R test1.s -o test1.o + ../hextool -cmp=ok < test1.o + +clean: + rm -f *.o Binary files /tmp/user/1000/KWOtsOxNdc/xa-2.3.8/tests/relocmode/ok and /tmp/user/1000/OSWa8ZGOHD/xa-2.3.11/tests/relocmode/ok differ diff -Nru xa-2.3.8/tests/relocmode/test1.s xa-2.3.11/tests/relocmode/test1.s --- xa-2.3.8/tests/relocmode/test1.s 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.11/tests/relocmode/test1.s 2019-11-09 02:00:05.000000000 +0100 @@ -0,0 +1,7 @@ + + lda foo + + .data + +foo .byt $aa + diff -Nru xa-2.3.8/tests/reset_segment/Makefile xa-2.3.11/tests/reset_segment/Makefile --- xa-2.3.8/tests/reset_segment/Makefile 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.11/tests/reset_segment/Makefile 2019-11-09 02:03:41.000000000 +0100 @@ -0,0 +1,10 @@ +default: test1 + +test1: + ../../xa -R -LLIB6502 test1.s -o test1.o + ../hextool -cmp=ok1 < test1.o + ../../xa -R test2.s -o test2.o + ../hextool -cmp=ok2 < test2.o + +clean: + rm -f *.o Binary files /tmp/user/1000/KWOtsOxNdc/xa-2.3.8/tests/reset_segment/ok1 and /tmp/user/1000/OSWa8ZGOHD/xa-2.3.11/tests/reset_segment/ok1 differ Binary files /tmp/user/1000/KWOtsOxNdc/xa-2.3.8/tests/reset_segment/ok2 and /tmp/user/1000/OSWa8ZGOHD/xa-2.3.11/tests/reset_segment/ok2 differ diff -Nru xa-2.3.8/tests/reset_segment/test1.s xa-2.3.11/tests/reset_segment/test1.s --- xa-2.3.8/tests/reset_segment/test1.s 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.11/tests/reset_segment/test1.s 2019-11-09 02:03:47.000000000 +0100 @@ -0,0 +1,12 @@ + + ; forward reference + ; results in illegal ptr arithmetic when segment + ; is not reset between pass1 and pass2 + + bne foo +foo + + .data + + + diff -Nru xa-2.3.8/tests/reset_segment/test2.s xa-2.3.11/tests/reset_segment/test2.s --- xa-2.3.8/tests/reset_segment/test2.s 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.11/tests/reset_segment/test2.s 2019-11-09 02:03:44.000000000 +0100 @@ -0,0 +1,23 @@ + + ; test absolute code embedded into relocatable mode + + .text + + lda foo + lda bar + + ; go into absolute mode + *=$1234 + +foo .asc "absolute",0 + + lda foo + lda bar + + ; go back into relocatble mode + *= + +bar .asc "reloc",0 + + +
signature.asc
Description: PGP signature

