1
0
mirror of https://github.com/fachat/xa65.git synced 2026-04-19 19:16:25 +00:00

merged xa-2.3.13 into listing

This commit is contained in:
Andre Fachat
2022-03-28 10:20:00 +02:00
24 changed files with 288 additions and 45 deletions
+21
View File
@@ -363,8 +363,29 @@ xa-2.3.11
-- Cameron Kaiser <ckaiser@floodgap.com> 4 May 2020
xa-2.3.12
* Regression fix for address size validation in 65816 mode (thanks Sam
Falvo; we had a pending fix for this but I like his test case).
* Testsuite expanded.
-- Cameron Kaiser <ckaiser@floodgap.com> 26 November 2021
xa-2.3.13
* Fix // and /* */ in quoted strings. Incredible no one ever hit this
before (thanks ZornsLemma).
* Segfault fixes for file65, reloc65 and xa. Remember, kids, if you ever
run xa as root all kittens will die. Please save the kittens (thanks
Stephen Kitt).
* Just compare to null in the preprocessor (thanks Bas Wassink).
* Testsuite expanded.
-- Cameron Kaiser <ckaiser@floodgap.com> 25 March 2022
xa-2.x.x
* Listing feature
* Add -E commandline option to not stop after 20 errors, but show all
of them
* Introduce -X compatibility set commandline option, to distinguish
+2 -2
View File
@@ -53,7 +53,7 @@ clean:
(cd src && ${MAKE} clean)
(cd loader && ${MAKE} clean)
(cd misc && ${MAKE} mrproper)
rm -f xa *.exe *.o65
rm -f xa *.exe *.o65 *.s
install: xa uncpk
$(MKDIR) $(BINDIR)
@@ -63,7 +63,7 @@ install: xa uncpk
#$(MKDIR) $(DOCDIR)/xa65
dist: clean
cd .. ; tar cvf xa-2.3.11.tar xa-2.3.11 ; gzip xa-2.3.11.tar
cd .. ; tar cvf xa-2.3.13.tar xa-2.3.13 ; gzip xa-2.3.13.tar
test: xa uncpk
cd tests && ./harness -make="$(MAKE)" -cc="$(CC)" -cflags="$(CFLAGS)"
+3 -3
View File
@@ -1,4 +1,4 @@
.TH XA "1" "9 November 2019"
.TH XA "1" "24 November 2021"
.SH NAME
xa \- 6502/R65C02/65816 cross-assembler
@@ -325,7 +325,7 @@ shift right (8)
.B >= =>
greater than or equal to (7)
.TP
.B <
.B >
greater than (7)
.TP
.B <= =<
@@ -1041,7 +1041,7 @@ 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-2019 Andre Fachat, Jolse Maginnis, David Weinehall,
(C)1989-2021 Andre Fachat, Jolse Maginnis, David Weinehall,
Cameron Kaiser. The official maintainer is Cameron Kaiser.
.SH 30 YEARS OF XA
+3 -2
View File
@@ -101,13 +101,14 @@ int main(int argc, char *argv[]) {
rompar = 1;
if(argv[i][1]=='A') rompar++;
if(argv[i][2]) romoff = atoi(argv[i]+2);
else romoff = atoi(argv[++i]);
else if(i + 1 < argc) romoff = atoi(argv[++i]);
else fprintf(stderr,"%s: missing offset\n",programname);
break;
case 'P':
xapar = 1;
break;
default:
fprintf(stderr,"file65: %s unknown option\n",argv[i]);
fprintf(stderr,"%s: %s unknown option\n",programname,argv[i]);
break;
}
} else {
+14 -10
View File
@@ -85,6 +85,7 @@ int main(int argc, char *argv[]) {
FILE *fp;
int tflag = 0, dflag = 0, bflag = 0, zflag = 0;
int tbase = 0, dbase = 0, bbase = 0, zbase = 0;
int *base;
char *outfile = "a.o65";
int extract = 0;
int verbose = 0;
@@ -113,37 +114,40 @@ int main(int argc, char *argv[]) {
break;
case 'o':
if(argv[i][2]) outfile=argv[i]+2;
else outfile=argv[++i];
else if(i + 1 < argc) outfile=argv[++i];
else fprintf(stderr,"%s: missing output file\n",programname);
break;
case 'X':
extract=3;
break;
case 'b':
base=NULL;
switch(argv[i][2]) {
case 't':
tflag= 1;
if(argv[i][3]) tbase = atoi(argv[i]+3);
else tbase = atoi(argv[++i]);
base=&tbase;
break;
case 'd':
dflag= 1;
if(argv[i][3]) dbase = atoi(argv[i]+3);
else dbase = atoi(argv[++i]);
base=&dbase;
break;
case 'b':
bflag= 1;
if(argv[i][3]) bbase = atoi(argv[i]+3);
else bbase = atoi(argv[++i]);
base=&bbase;
break;
case 'z':
zflag= 1;
if(argv[i][3]) zbase = atoi(argv[i]+3);
else zbase = atoi(argv[++i]);
base=&zbase;
break;
default:
printf("Unknown segment type '%c' - ignored!\n", argv[i][2]);
break;
}
if (base != NULL) {
if(argv[i][3]) *base = atoi(argv[i]+3);
else if(i + 1 < argc) *base = atoi(argv[++i]);
else fprintf(stderr,"%s: missing address\n",programname);
}
break;
case 'x': /* extract segment */
switch(argv[i][2]) {
@@ -163,7 +167,7 @@ int main(int argc, char *argv[]) {
}
break;
default:
fprintf(stderr,"reloc65: %s unknown option, use '-?' for help\n",argv[i]);
fprintf(stderr,"%s: %s unknown option, use '-?' for help\n",programname,argv[i]);
break;
}
} else {
+35 -9
View File
@@ -56,9 +56,9 @@
#define ANZWARN 13
#define programname "xa"
#define progversion "v2.3.11+af"
#define progversion "v2.3.13+af"
#define authors "Written by Andre Fachat, Jolse Maginnis, David Weinehall and Cameron Kaiser"
#define copyright "Copyright (C) 1989-2020 Andre Fachat, Jolse Maginnis, David Weinehall\nand Cameron Kaiser."
#define copyright "Copyright (C) 1989-2022 Andre Fachat, Jolse Maginnis, David Weinehall\nand Cameron Kaiser."
/* exported globals */
int ncmos, cmosfl, w65816, n65816;
@@ -247,8 +247,12 @@ int main(int argc,char *argv[])
case 'O': /* output charset */
{
char *name = NULL;
if (argv[i][2] == 0) {
name = argv[++i];
if (argv[i][2] == 0) {
if (i + 1 < argc) name = argv[++i];
else {
fprintf(stderr, "-O requires an argument\n");
exit(1);
}
} else {
name = argv[i]+2;
}
@@ -260,7 +264,13 @@ int main(int argc,char *argv[])
case 'A': /* make text segment start so that text relocation
is not necessary when _file_ starts at adr */
romable = 2;
if(argv[i][2]==0) romaddr = atoi(argv[++i]);
if(argv[i][2]==0) {
if (i + 1 < argc) romaddr = atoi(argv[++i]);
else {
fprintf(stderr, "-A requires an argument\n");
exit(1);
}
}
else romaddr = atoi(argv[i]+2);
break;
case 'G':
@@ -308,7 +318,11 @@ int main(int argc,char *argv[])
break;
case 'I':
if(argv[i][2]==0) {
reg_include(argv[++i]);
if (i + 1 < argc) reg_include(argv[++i]);
else {
fprintf(stderr, "-I requires an argument\n");
exit(1);
}
} else {
reg_include(argv[i]+2);
}
@@ -329,21 +343,33 @@ int main(int argc,char *argv[])
break;
case 'o':
if(argv[i][2]==0) {
ofile=argv[++i];
if (i + 1 < argc) ofile=argv[++i];
else {
fprintf(stderr, "-o requires an argument\n");
exit(1);
}
} else {
ofile=argv[i]+2;
}
break;
case 'l':
if(argv[i][2]==0) {
lfile=argv[++i];
if (i + 1 < argc) lfile=argv[++i];
else {
fprintf(stderr, "-l requires an argument\n");
exit(1);
}
} else {
lfile=argv[i]+2;
}
break;
case 'e':
if(argv[i][2]==0) {
efile=argv[++i];
if (i + 1 < argc) efile=argv[++i];
else {
fprintf(stderr, "-e requires an argument\n");
exit(1);
}
} else {
efile=argv[i]+2;
}
+51 -5
View File
@@ -62,6 +62,8 @@ static int pp_undef(char*);
#define VALBEF 6
static int ungeteof = 0;
static int quotebs = 0;
static int inquote = 0;
static char *cmd[]={ "echo","include","define","undef","printdef","print",
"ifdef","ifndef","else","endif",
@@ -886,7 +888,7 @@ int pp_open(char *name)
flist[0].filep=fp;
flist[0].flinep=NULL;
return(((long)fp)==0l);
return (fp == NULL);
}
void pp_close(void)
@@ -1017,6 +1019,7 @@ int pgetline(char *t)
int c,er=E_OK;
int rlen, tlen;
char *p = 0;
char *q = 0;
loopfl =0; /* set if additional fetch needed */
@@ -1075,6 +1078,40 @@ int pgetline(char *t)
errout(E_OPENPP);
}
/* handle the double-slash comment (like in C++) */
/* get p past any quoted strings */
p = strchr(in_line, '/');
if (p != NULL) {
q = strchr(in_line, '"');
for(;;) {
/* no more quotes to skip, or slashes before quotes */
if (q == NULL || (p < q)) {
if (p[1] == '/') {
/* truncate line, done with loop */
*p = 0;
break;
} else {
/* wasn't //, but could be later */
p++;
}
} else {
/* quote before slash, so skip string */
q++;
while (*q != 0 && *q != '"') {
if (*q == '\\') q++;
if (*q != 0) q++;
}
if (*q == 0) break; /* oops */
q++;
p = q;
}
p = strchr(p, '/');
if (p == NULL) break; /* never mind */
if (q != NULL) q = strchr(q, '"');
}
}
if(!er || loopfl) {
in_line[0]='\0';
}
@@ -1138,15 +1175,22 @@ int egetc(FILE *fp) {
/* smart getc that can skip C comment blocks */
int rgetc(FILE *fp)
{
static int c,d,fl;
static int c,cc,d,fl;
cc=0;
fl=0;
do
{
while((c=egetc(fp))==13); /* remove ^M for unices */
if(fl && (c=='*'))
/* flag if we're in a quoted string */
if(c=='"' && !quotebs) inquote ^= 1;
#if(0)
/* implement backslashed quotes for 2.4 */
if(c=='\\') quotebs=1; else quotebs=0;
#endif
if(!inquote && fl && (c=='*'))
{
if((d=egetc(fp))!='/')
ungetc(d,fp);
@@ -1156,12 +1200,14 @@ int rgetc(FILE *fp)
while((c=egetc(fp))==13);
}
}
/* in comment block */
if(c=='\n')
{
flist[fsp].fline++;
nlf=1;
} else
if(c=='/')
if(!inquote && c=='/')
{
if((d=egetc(fp))!='*')
ungetc(d,fp);
+21 -14
View File
@@ -194,8 +194,8 @@ static int ktp[]={ 0,3,17,25,28,29,29,29,29,32,34,34,38,40,41,42,58,
* opcodes for each addressing mode
* high byte: supported architecture (no bits = original NMOS 6502)
* bit 1: R65C02
* bit 2: 65816
* bit 3: 65816 and allows 16-bit quantity (immediate only)
* bit 2: 65816 and allows 16-bit quantity (accum only)
* bit 3: 65816 and allows 16-bit quantity (index only)
* low byte: opcode itself
*
* each opcode is indexed in this order: *=65816, ^=R65C02
@@ -1767,8 +1767,8 @@ fprintf(stderr, "Kdsb E_DSB %i\n", j);
{
#ifdef DEBUG_AM
fprintf(stderr,
"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);
"b4: pc= %d, am = %d and vv[0] = %d, optimize = %d, bitmask = %u, er=%d, bl=%d\n",
pc[segment], am, vv[0], fl, (vv[0]&0xffff00), er, bl);
#endif
/* terrible KLUDGE!!!! OH NOES!!!1!
@@ -1784,8 +1784,8 @@ fprintf(stderr,
am=opt[am];
#ifdef DEBUG_AM
fprintf(stderr,
"aftaa1: pc= %d, am = %d and vv[0] = %d, optimize = %d, bitmask = %d\n",
pc[segment], am, vv[0], fl, (vv[0]&0xffff00));
"aftaa1: pc= %d, am = %d and vv[0] = %d, optimize = %d, bitmask = %d, bl = %d\n",
pc[segment], am, vv[0], fl, (vv[0]&0xffff00), bl);
#endif
if(cast!='!') {
if(bl && !er && !(vv[0]&0xffff00) && opt[am]>=0) {
@@ -1800,8 +1800,8 @@ fprintf(stderr,
}
#ifdef DEBUG_AM
fprintf(stderr,
"aftaa2: pc=%d, am=%d and vv[0]=%d, optimize=%d, bitmask=%d, op=%d\n",
pc[segment], am, vv[0], fl, (vv[0]&0xffff00), ct[n][opt[am]]);
"aftaa2: pc=%d, am=%d and vv[0]=%d, optimize=%d, bitmask=%d, op=%d, bl=%d\n",
pc[segment], am, vv[0], fl, (vv[0]&0xffff00), ct[n][opt[am]], bl);
#endif
}
@@ -1810,17 +1810,16 @@ fprintf(stderr,
else
{
bl=le[am];
if( ((ct[n][am]&0x400) && memode) || ((ct[n][am]&0x800) && xmode)) {
bl++;
}
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
@@ -2607,7 +2606,7 @@ static void tg_hex(signed char *s, int *l, int *v)
static int tg_asc(signed char *s, signed char *t, int *q, int *p, int *na1, int *na2,int n)
{
int er=E_OK,i=0,j=0;
int er=E_OK,i=0,j=0,bs=0;
signed char delimiter = s[i++];
@@ -2618,8 +2617,16 @@ fprintf(stderr, "tg_asc token = %i\n", n);
t[j++]='"'; /* pass2 token for string */
j++; /* skip place for length */
while(s[i]!='\0' && s[i]!=delimiter)
while(s[i]!='\0' && (bs || s[i]!=delimiter))
{
#if(0)
/* implement backslashed quotes for 2.4 */
if(n != Kbin && s[i] == '\\' && !bs) {
fprintf(stderr, "B"); bs=1; i++; continue;
} else bs=0;
#endif
/* do NOT convert for Kbin or Kaasc, or for initial parse */
if (!n || n == Kbin || n == Kaasc) {
t[j++]=s[i];
+1
View File
@@ -45,6 +45,7 @@ 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)
alxl/ Various '816 width tests (includes Samuel Falvo's test)
Cameron Kaiser, André Fachat
+24
View File
@@ -0,0 +1,24 @@
default:
# xa should not allow this to happen. if it does, this test is no good.
../../xa alxl.s || exit 0 && exit 1
../../xa alxlo1.s || exit 0 && exit 1
../../xa alxlo2.s || exit 0 && exit 1
../../xa alxlx1.s || exit 0 && exit 1
../../xa alxlx2.s || exit 0 && exit 1
../../xa alxlx3.s || exit 0 && exit 1
../../xa sizes.s || exit 0 && exit 1
../../xa -w alxlx1.s || exit 0 && exit 1
../../xa -w alxlx2.s || exit 0 && exit 1
../../xa -w alxlx3.s || exit 0 && exit 1
# expected-to-fail tests did fail. should be no more errors now.
../../xa -w alxl.s -o alxl.o
../hextool -cmp=alxl.ok < alxl.o
../../xa -w alxlo1.s -o alxlo1.o
../hextool -cmp=alxlo1.ok < alxlo1.o
../../xa -w alxlo2.s -o alxlo2.o
../hextool -cmp=alxlo2.ok < alxlo2.o
../../xa -w sizes.s -o sizes.o
../hextool -cmp=sizes.ok < sizes.o
clean:
rm -f *.o
+1
View File
@@ -0,0 +1 @@
444
+13
View File
@@ -0,0 +1,13 @@
; test for the xa .xl opcode that should set the XR handling to 16 bit
*=$f000
; set X/Y registers to 16 bit ...
rep #%00010000
; ... and tell the assembler about it
.xl
ldx #$1234
ldy #$1234
.al
lda #$1234
+1
View File
@@ -0,0 +1 @@
4
+10
View File
@@ -0,0 +1,10 @@
; test for the xa .xl opcode that should set the XR handling to 16 bit
*=$f000
; set X/Y registers to 16 bit ...
rep #%00010000
; ... and tell the assembler about it
.al
lda #$1234
+1
View File
@@ -0,0 +1 @@
44
+10
View File
@@ -0,0 +1,10 @@
; test for the xa .xl opcode that should set the XR handling to 16 bit
*=$f000
; set X/Y registers to 16 bit ...
rep #%00010000
; ... and tell the assembler about it
.xl
ldx #$1234
ldy #$1234
+12
View File
@@ -0,0 +1,12 @@
; test for the xa .xl opcode that should set the XR handling to 16 bit
*=$f000
; set X/Y registers to 16 bit ...
rep #%00010000
; ... and tell the assembler about it
.al
ldx #$1234
ldy #$1234
lda #$1234
+11
View File
@@ -0,0 +1,11 @@
; test for the xa .xl opcode that should set the XR handling to 16 bit
*=$f000
; set X/Y registers to 16 bit ...
rep #%00010000
; ... and tell the assembler about it
.xl
ldx #$1234
ldy #$1234
lda #$1234
+10
View File
@@ -0,0 +1,10 @@
; test for the xa .xl opcode that should set the XR handling to 16 bit
*=$f000
; set X/Y registers to 16 bit ...
rep #%00010000
; ... and tell the assembler about it
ldx #$1234
ldy #$1234
lda #$1234
Binary file not shown.
+22
View File
@@ -0,0 +1,22 @@
#define HI(z) (((z) >> 16) & $FFFF)
#define LO(z) ((z) & $FFFF)
.al
.xl
*=$112233
SYM:
rts
jmp SYM
jmp $112233
lda $112233
lda @$2233
lda $2233
lda $33
#print HI(SYM)
lda #HI(SYM)
pha
#print LO(SYM)
lda #LO(SYM)
pha
+1
View File
@@ -55,6 +55,7 @@ W: while($x = readdir(D)) {
chdir("..");
}
closedir(D);
print STDOUT "=" x 79, "\n";
print STDOUT "\n## ALL TESTS PASS ##\n";
exit 0;
Binary file not shown.
+21
View File
@@ -0,0 +1,21 @@
* = $e00
.byt 10/2 // watchs // phlegm
/* .word 10/2 */ .word 65536/2
// .byt 9/9 // yo mama
// .asc "FAIL"
.asc "SIEx256SN" // foo
.asc "SIE/256SN" // bar
.asc "SIE//256SN" // bar
.asc "SIEy256SN" // baz
.asc "PASS/*PASS*///PASS//PASS"
#if(0)
/* enable when backslashed quotes are supported in 2.4 */
.asc "PASS\"\\PASS/*PASS*///PASS//\"\\PASS"
#endif
.asc "SIE/*256*/N"
/* .asc "SIE/*256*/N"
.asc "FAIL"
*/ .asc "PASS" // .asc "FAIL" /* .asc "FAIL*/" */