diff -Nru xa-2.3.3/ChangeLog xa-2.3.5/ChangeLog --- xa-2.3.3/ChangeLog 2007-05-16 05:19:17.000000000 +0100 +++ xa-2.3.5/ChangeLog 2009-02-08 06:56:01.000000000 +0000 @@ -274,3 +274,24 @@ Fabian Nunez and Mikkel Holm Olsen). -- Cameron Kaiser 15 May, 2007 + +xa-2.3.4 + + * -p to define alternate synonym for # for preprocessor to avoid cpp/xa + preprocessor clashes and messes. + * Direct linking into output stream of binary files (.bin). + * Minor overhaul of error system to facilitate future expansion. + * Documentation updated. + + -- Cameron Kaiser 1 July, 2008 + +xa-2.3.5 + + Most of this was suggested by Martin Wendt. + * Fixed bug where .bin was affected by the current character set. + * Added PETSCREEN and HIGH character sets. + * Added .aasc. + * Some more legibility work. + * Documentation updated. + + -- Cameron Kaiser 7 February, 2009 diff -Nru /tmp/i8VLdkb5vH/xa-2.3.3/debian/changelog /tmp/BeHKTGR5sN/xa-2.3.5/debian/changelog --- xa-2.3.3/debian/changelog 2009-11-06 13:24:52.000000000 +0000 +++ xa-2.3.5/debian/changelog 2009-11-06 13:24:52.000000000 +0000 @@ -1,3 +1,11 @@ +xa (2.3.5-1) unstable; urgency=low + + * New upstream release + * Added link to upstream web site + * Bump Standards-Version to 3.8.2 + + -- David Weinehall Sun, 12 Jul 2009 22:56:19 +0300 + xa (2.3.3-1) unstable; urgency=low * New upstream release diff -Nru /tmp/i8VLdkb5vH/xa-2.3.3/debian/control /tmp/BeHKTGR5sN/xa-2.3.5/debian/control --- xa-2.3.3/debian/control 2009-11-06 13:24:52.000000000 +0000 +++ xa-2.3.5/debian/control 2009-11-06 13:24:52.000000000 +0000 @@ -3,7 +3,8 @@ Priority: optional Maintainer: David Weinehall Build-Depends: debhelper (>> 5.0.22) -Standards-Version: 3.7.3 +Standards-Version: 3.8.2 +Homepage: http://www.floodgap.com/retrotech/xa/ Package: xa65 Architecture: any diff -Nru /tmp/i8VLdkb5vH/xa-2.3.3/Makefile /tmp/BeHKTGR5sN/xa-2.3.5/Makefile --- xa-2.3.3/Makefile 2007-05-16 05:14:33.000000000 +0100 +++ xa-2.3.5/Makefile 2009-02-08 06:49:30.000000000 +0000 @@ -58,4 +58,5 @@ #$(MKDIR) $(DOCDIR)/xa65 dist: clean - cd .. ; tar cvf xa-2.3.3.tar xa-2.3.3 ; gzip xa-2.3.3.tar + #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 diff -Nru /tmp/i8VLdkb5vH/xa-2.3.3/man/xa.1 /tmp/BeHKTGR5sN/xa-2.3.5/man/xa.1 --- xa-2.3.3/man/xa.1 2007-01-31 16:31:33.000000000 +0000 +++ xa-2.3.5/man/xa.1 2009-02-08 06:41:00.000000000 +0000 @@ -1,4 +1,4 @@ -.TH XA "1" "31 January 2007" +.TH XA "1" "7 February 2009" .SH NAME xa \- 6502/R65C02/65816 cross-assembler @@ -104,7 +104,7 @@ Define a preprocessor macro on the command line (see .BR PREPROCESSOR ). .TP -.B \-Idir +.B \-I dir Add directory .B dir to the include path (before @@ -113,8 +113,21 @@ .BR ENVIRONMENT ). .TP .B \-O charset -Define the output charset for values in quotes. Currently supported are ASCII -(default) and PETSCII. +Define the output charset for character strings. Currently supported are ASCII +(default), PETSCII (Commodore ASCII), +PETSCREEN (Commodore screen codes) and HIGH (set high bit on all +characters). +.TP +.B \-p? +Set the alternative preprocessor character to +.BR ? . +This is useful when you wish to use +.BR cpp (1) +and the built-in preprocessor at the same time (see +.BR PREPROCESSOR ). +Characters may need to be quoted for your shell (example: +.B \-p'~' +). .TP .B \-\-help Show summary of options. @@ -169,9 +182,9 @@ The ASCII value of any quoted character is inserted directly into the program text (example: .B """A""" -inserts the byte "A" into the output stream). See also the +inserts the byte "A" into the output stream); see also the .B PSEUDO-OPS -section. +section. This is affected by the currently selected character set, if any. .LP .B Labels define locations within the program text, just as in other multi-pass @@ -407,25 +420,36 @@ .TP .B .asc """text1""","text2",... Specifies a character string which will be inserted into the assembled -object. The characters are understood according to the currently specified +object. Strings are understood according to the currently specified character set; for example, if ASCII is specified, they will be rendered as ASCII, and if PETSCII is specified, they will be translated into the equivalent Commodore ASCII equivalent. Other non-standard ASCIIs such as ATASCII for -Atari computers should be specified explicitly using their ASCII equivalents or +Atari computers should use the ASCII equivalent characters; graphic and +control characters should be specified explicitly using .B .byt -for other characters, such as control and graphics sequences. Note that +for the precise character you want. Note that when specifying the argument of an opcode, .B .asc is not necessary; the quoted character can simply be inserted (e.g., .B lda #"A" -). Any number of character strings can be specified. +), and is also affected by the current character set. +Any number of character strings can be specified. .LP .B .byt and .B .asc are synonymous, so you can mix things such as .B .byt $43, 22, """a character string""" -and get the expected result. +and get the expected result. The string is subject to the current character +set, but the remaining bytes are inserted wtihout modification. +.TP +.B .aasc """text1""","text2",... +Specifies a character string that is +.B always +rendered in true ASCII regardless of the current character set. Like +.BR .asc , +it is synonymous with +.BR .byt . .TP .B .word value1,value2,value3... Specifies a string of 16-bit words to be placed into the assembled object in @@ -442,6 +466,21 @@ will insert five bytes, each being 16 decimal, into the object. The arguments may be expressions. .TP +.B .bin offset,length,"filename" +Inlines a binary file without further interpretation specified by +.B filename +from offset +.B offset +to length +.BR length . +This allows you to insert data such as a previously assembled object file +or an image or other binary data structure, inlined directly into this +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. +.TP .B \&.( Opens a new block for scoping. Within a block, all labels defined are local to that block and any sub-blocks, and go out of scope as soon as the enclosing @@ -552,11 +591,7 @@ .B xa will treat them as .B cc -would, except that flags are ignored. Note that passing your file through -.BR cpp (1) -will not allow you to use -.BR xa 's -non-standard directives, so you may need to add them manually to the output. +would, except that flags are ignored. .B xa does not accept files on standard input for parsing reasons, so you should dump your @@ -573,6 +608,36 @@ .BR cpp (1) output is detected automatically. .LP +Note that passing your file through +.BR cpp (1) +may interfere with +.BR xa 's +own preprocessor directives. In this case, to mask directives from +.BR cpp (1), +use the +.B \-p +option to specify an alternative character instead of +.BR # , +such as the tilde (e.g., +.B \-p'~' +). With this option and argument specified, then instead of +.BR #include , +for example, you can also use +.BR ~include , +in addition to +.B #include +(which will also still be accepted by the +.B xa +preprocessor, assuming any survive +.BR cpp (1)). +Any character can be used, although frankly pathologic choices may lead +to amusing and frustrating glitches during parsing. +You can also use this option to defer preprocessor directives that +.BR cpp (1) +may interpret too early until the file actually gets to +.B xa +itself for processing. +.LP The following preprocessor directives are supported. .TP @@ -765,7 +830,7 @@ Andre Fachat and Cameron Kaiser . Original xa package (C)1989-1997 Andre Fachat. Additional changes -(C)1989-2007 Andre Fachat, Jolse Maginnis, David Weinehall, +(C)1989-2009 Andre Fachat, Jolse Maginnis, David Weinehall, Cameron Kaiser. The official maintainer is Cameron Kaiser. .SH WEBSITE diff -Nru /tmp/i8VLdkb5vH/xa-2.3.3/README.1st /tmp/BeHKTGR5sN/xa-2.3.5/README.1st --- xa-2.3.3/README.1st 2007-06-02 06:35:16.000000000 +0100 +++ xa-2.3.5/README.1st 2008-07-02 06:59:36.000000000 +0100 @@ -3,12 +3,11 @@ 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. +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 +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 diff -Nru /tmp/i8VLdkb5vH/xa-2.3.3/src/xa.c /tmp/BeHKTGR5sN/xa-2.3.5/src/xa.c --- xa-2.3.3/src/xa.c 2007-06-02 22:57:10.000000000 +0100 +++ xa-2.3.5/src/xa.c 2009-01-21 16:57:32.000000000 +0000 @@ -48,16 +48,16 @@ #include "version.h" -/* ANZERR: total number in ertxt[] - ANZERR-ANZWARN-1: first index to non-fatal warnings */ +/* ANZERR: total number of errors */ +/* ANZWARN: total number of warnings */ -#define ANZERR 35 -#define ANZWARN 8 +#define ANZERR 64 +#define ANZWARN 13 #define programname "xa" -#define progversion "v2.3.3" +#define progversion "v2.3.5" #define authors "Written by Andre Fachat, Jolse Maginnis, David Weinehall and Cameron Kaiser" -#define copyright "Copyright (C) 1989-2007 Andre Fachat, Jolse Maginnis, David Weinehall\nand Cameron Kaiser." +#define copyright "Copyright (C) 1989-2009 Andre Fachat, Jolse Maginnis, David Weinehall\nand Cameron Kaiser." /* exported globals */ int ncmos, cmosfl, w65816, n65816; @@ -68,6 +68,7 @@ int noglob = 0; int showblk = 0; int crossref = 0; +char altppchar; /* local variables */ static char out[MAXLINE]; @@ -132,6 +133,8 @@ cmosfl=1; w65816=0; /* default: 6502 only */ + altppchar = '#' ; /* i.e., NO alternate char */ + if((tmpp = strrchr(argv[0],'/'))) { tmpp++; } else { @@ -188,6 +191,22 @@ while(imn.tmp+afile->mn.tmpe,&ll,1,&al); - + if(er==E_NOLINE) { } else @@ -653,8 +672,69 @@ memset(datap, c, ll); datap+=ll; } - } else - { + } else if (er == E_BIN) { + int i; + int j; + int flen; + int offset; + int fstart; + FILE *foo; + char binfnam[256]; + + i = afile->mn.tmpe; +/* + fprintf(stderr, "ok, ready to insert\n"); + for (i=0; imn.tmp[afile->mn.tmpe+i]); + } +*/ + + offset = afile->mn.tmp[i] + + (afile->mn.tmp[i+1] << 8) + + (afile->mn.tmp[i+2] << 16); + fstart = afile->mn.tmp[i+3] + 1 + + (afile->mn.tmp[i+4] << 8); + /* usually redundant but here for single-char names + that get interpreted as chars */ + flen = afile->mn.tmp[i+5]; + if (flen > 1) fstart++; + /* now fstart points either to string past quote and + length mark, OR, single char byte */ +/* +fprintf(stderr, "offset = %i length = %i fstart = %i flen = %i charo = %c\n", + offset, ll, fstart, flen, afile->mn.tmp[afile->mn.tmpe+fstart]); +*/ + /* there is a race condition here where altering the + file between validation in t_p2 (xat.c) and + here will cause problems. I'm not going to + worry about this right now. */ + + for(j=0; jmn.tmp[i+fstart+j]; + } + binfnam[flen] = '\0'; +/* + fprintf(stderr, "fnam = %s\n", binfnam); +*/ + /* primitive insurance */ + if (!(foo = fopen(binfnam, "r"))) { + errout(E_FNF); + ner++; + } else { + fseek(foo, offset, SEEK_SET); + for(j=0; j-1) { if(er>=-(ANZERR+ANZWARN) && er < -ANZERR) { sprintf(out,"%s:line %d: %04x: Warning - %s\n", - filep->fname, filep->fline, pc[segment], ertxt[-er-1]); + filep->fname, filep->fline, pc[segment], ertxt[(-er)-1]); } else { /* sprintf(out,"%s:Zeile %d: %04x:Unbekannter Fehler Nr.: %d\n",*/ sprintf(out,"%s:line %d: %04x: Unknown error # %d\n", @@ -969,7 +1108,7 @@ filep->fname,filep->fline,pc[segment],lz); else sprintf(out,"%s:line %d: %04x:%s error\n", - filep->fname,filep->fline,pc[segment],ertxt[-er-1]); + filep->fname,filep->fline,pc[segment],ertxt[(-er)-1]); ner++; } diff -Nru /tmp/i8VLdkb5vH/xa-2.3.3/src/xacharset.c /tmp/BeHKTGR5sN/xa-2.3.5/src/xacharset.c --- xa-2.3.3/src/xacharset.c 2007-01-11 04:13:20.000000000 +0000 +++ xa-2.3.5/src/xacharset.c 2009-02-07 16:02:46.000000000 +0000 @@ -3,7 +3,7 @@ * Copyright (C) 1989-1997 Andre Fachat (a.fachat@physik.tu-chemnitz.de) * Maintained by Cameron Kaiser * - * PETSCII conversion module + * Charset conversion module * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -50,6 +50,49 @@ return c; } +/* + * Built upon Steve Judd's suggested PETSCII -> screen code algorithm + * This could probably be written a lot better, but it works. + * http://www.floodgap.com/retrobits/ckb/display.cgi?572 + */ +static signed char convert_char_petscreen(signed char c) { + int i; + + i = (int)convert_char_petscii(c); +#ifdef SIGH +fprintf(stderr, "input: %i output: %i\n", c, i); +#endif + if (i< 0) + i += 0x80; + i ^= 0xe0; +#ifdef SIGH +fprintf(stderr, "(1)input: %i output: %i\n", c, i); +#endif + i += 0x20; + i &= 0xff; +#ifdef SIGH +fprintf(stderr, "(2)input: %i output: %i\n", c, i); +#endif + if (i < 0x80) + return (signed char)i; + i += 0x40; + i &= 0xff; +#ifdef SIGH +fprintf(stderr, "(3)input: %i output: %i\n", c, i); +#endif + if (i < 0x80) + return (signed char)i; + i ^= 0xa0; +#ifdef SIGH +fprintf(stderr, "(4)input: %i output: %i\n", c, i); +#endif + return (signed char)i; +} + +static signed char convert_char_high(signed char c) { + return (c | 0x80); +} + typedef struct { char *name; signed char (*func)(signed char); @@ -58,6 +101,8 @@ static charset charsets[] = { { "ASCII", convert_char_ascii }, { "PETSCII", convert_char_petscii }, + { "PETSCREEN", convert_char_petscreen }, + { "HIGH", convert_char_high }, { NULL, NULL } }; diff -Nru /tmp/i8VLdkb5vH/xa-2.3.3/src/xa.h /tmp/BeHKTGR5sN/xa-2.3.5/src/xa.h --- xa-2.3.3/src/xa.h 2003-01-28 04:46:09.000000000 +0000 +++ xa-2.3.5/src/xa.h 2008-07-02 06:04:25.000000000 +0100 @@ -27,6 +27,7 @@ extern int showblk; extern int relmode; extern int crossref; +extern char altppchar; extern int tlen, tbase; extern int blen, bbase; diff -Nru /tmp/i8VLdkb5vH/xa-2.3.3/src/xah.h /tmp/BeHKTGR5sN/xa-2.3.5/src/xah.h --- xa-2.3.3/src/xah.h 2007-01-13 06:16:36.000000000 +0000 +++ xa-2.3.5/src/xah.h 2008-06-04 18:27:23.000000000 +0100 @@ -109,15 +109,22 @@ #define E_ORECMAC -32 /* exceeded recursion limit for label eval */ #define E_OPENPP -33 /* open preprocessor directive */ - -#define W_ADRRELOC -34 /* word relocation in byte value */ -#define W_BYTRELOC -35 /* byte relocation in word value */ -#define E_WPOINTER -36 /* illegal pointer arithmetic! */ -#define W_ADDRACC -37 /* addr access to low or high byte pointer */ -#define W_HIGHACC -38 /* high byte access to low byte pointer */ -#define W_LOWACC -39 /* low byte access to high byte pointer */ -#define W_FORLAB -40 /* no zp-optimization for a forward label */ -#define W_OPENPP -41 /* warning about open preprocessor directive */ +#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 */ + +#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 T_VALUE -1 #define T_LABEL -2 diff -Nru /tmp/i8VLdkb5vH/xa-2.3.3/src/xap.c /tmp/BeHKTGR5sN/xa-2.3.5/src/xap.c --- xa-2.3.3/src/xap.c 2007-05-16 05:17:57.000000000 +0100 +++ xa-2.3.5/src/xap.c 2008-07-02 06:10:11.000000000 +0100 @@ -861,7 +861,7 @@ c=fgetline(in_line + tlen-1, MAXLINE-tlen, &rlen, flist[fsp].filep); tlen += rlen-1; } - if(in_line[0]=='#') + if(in_line[0]=='#' || in_line[0] == altppchar) { if (in_line[1]==' ') { /* cpp comment -- pp_comand doesn't handle this right */ diff -Nru /tmp/i8VLdkb5vH/xa-2.3.3/src/xat.c /tmp/BeHKTGR5sN/xa-2.3.5/src/xat.c --- xa-2.3.3/src/xat.c 2007-01-31 16:27:52.000000000 +0000 +++ xa-2.3.5/src/xat.c 2009-01-21 19:08:49.000000000 +0000 @@ -21,7 +21,7 @@ */ /* enable this to turn on (copious) optimization output */ -/* #define DEBUG_AM */ +/* #define DEBUG_AM */ #include #include @@ -43,7 +43,7 @@ static int t_conv(signed char*,signed char*,int*,int,int*,int*,int*,int,int*); static int t_keyword(signed char*,int*,int*); -static int tg_asc(signed char*,signed char*,int*,int*,int*,int*); +static int tg_asc(signed char*,signed char*,int*,int*,int*,int*,int); static void tg_dez(signed char*,int*,int*); static void tg_hex(signed char*,int*,int*); static void tg_oct(signed char*,int*,int*); @@ -71,11 +71,11 @@ "sei","smb","sta","stx","sty","stz","sep","stp","tax","tay", "trb","tsb","tsx","txa","txs","tya","txy","tyx","tcd","tdc", - "tcs","tsc","wai","wdb","xba","xce", /* 96 */ + "tcs","tsc","wai","wdb","xba","xce", ".byt",".word",".asc",".dsb", ".(", ".)", "*=", ".text",".data",".bss", ".zero",".fopt", ".byte", ".end", ".list", ".xlist", ".dupb", ".blkb", ".db", ".dw", - ".align",".block", ".bend",".al",".as",".xl",".xs" /* 96 + 27 = 123 */ + ".align",".block", ".bend",".al",".as",".xl",".xs", ".bin", ".aasc" }; @@ -85,7 +85,7 @@ /* last valid mnemonic */ #define Lastbef 93 /* last valid token+1 */ -#define Anzkey 121 +#define Anzkey 123 #define Kbyt Lastbef+1 #define Kword Lastbef+2 @@ -116,9 +116,14 @@ #define Kxlong Lastbef+26 #define Kxshort Lastbef+27 +#define Kbin Lastbef+28 +#define Kaasc Lastbef+29 + #define Kreloc Anzkey /* *= (relocation mode) */ #define Ksegment Anzkey+1 +/* array used for hashing tokens (26 entries, a-z) */ + static int ktp[]={ 0,3,17,25,28,29,29,29,29,32,34,34,38,40,41,42,58, 58,65,76,90,90,90,92,94,94,94,Anzkey }; @@ -512,6 +517,113 @@ er=E_ILLSEGMENT; } */ } else + if (n==Kbin) { + int j; + int l; + + /* this first pass just calculates a prospective length + for pass 2. */ + char binfnam[255]; + int offset; + int length; + int fstart; + + i = 1; + j = 0; + + /* get offset */ + if(!(er=a_term(t+i,&offset,&l,pc[segment],&afl,&label,1))) { + i += l; + } + if (offset < 0) + er = E_ILLQUANT; + if(t[i] == ',') { /* skip comma */ + i++; + } else { + er = E_SYNTAX; + } + + /* get length */ + if (!er && + !(er=a_term(t+i,&length,&l,pc[segment],&afl,&label,1))) + { + i += l; + } + if (length < 0) + er = E_ILLQUANT; + if(t[i] == ',') { /* skip comma */ + i++; + } else { + er = E_SYNTAX; + } + + /* get filename. + the tokenizer can either see it as a multichar string ... */ + if (!er) { + int k; + + fstart = i; + if(t[i]=='\"') { + i++; + k=t[i]+i+1; + i++; + while(i 255) + er = E_NOMEM; /* buffer overflow */ + } + binfnam[j] = '\0'; + /* or as a 'char' if it's a single character ("word" would + have been caught by the above) */ + } else + if(!(er=a_term(t+i,&v,&l,pc[segment],&afl,&label,1))) { + binfnam[0] = v; + binfnam[1] = '\0'; + i += l; + } + } + + /* three arguments only please */ + if (!er && t[i] != T_END) { + er = E_SYNTAX; + } + + if (!er) { + FILE *foo; + +#ifdef DEBUG_AM + fprintf(stderr, +"binclude1 offset = %i len = %i filename = %s endchar = %i\n", + offset, length, binfnam, i); +#endif + if (!(foo = fopen(binfnam, "r"))) { + er = E_FNF; + } else { + fseek(foo, 0, SEEK_END); + if ((length+offset) > ftell(foo)) { + er = E_OUTOFDATA; + } else { + length = (length) ? length : + (ftell(foo)-offset); + } + fclose(foo); + } + if (!er) { + if (length > 65535 && !w65816) { + errout(W_OVER64K); + } else if (length > 16777215) { + errout(W_OVER16M); + } + /* pass parameters back to xa.c */ + *ll=i+1; +/* + bl=length+2; +*/ + bl=length; + er = E_OKDEF; /* defer to pass 2 */ + } + } + } else if(n==Kalign) { int tmp; if(segment!=SEG_ABS) { @@ -559,6 +671,9 @@ * */ +#ifdef DEBUG_AM +fprintf(stderr, "E_NODEF pass1 xat.c\n"); +#endif er = E_OK; /* stuff error */ n=t[0]; /* look at first token */ @@ -659,8 +774,11 @@ /* .byt, .asc, .word, .dsb, .fopt pseudo-op dispatch */ } else - if(n==Kbyt || n==Kasc) + if(n==Kbyt || n==Kasc || n==Kaasc) { +#ifdef DEBUG_AM +fprintf(stderr, "byt pass 1 %i\n", nk+1-na1+na2); +#endif bl=nk+1-na1+na2; } else if(n==Kword) @@ -813,9 +931,125 @@ } *ll=j; bl=j; - } else - if(n==Kasc || n==Kbyt) - { + } else if (n == Kbin) { + int j; + int l; + + /* figure out our parameters again. repeat most of + the error checking since we might not be over + the total number of bogosities */ + char binfnam[255]; + int offset; + int length; + int fstart; + int flen; + + i = 1; + j = 0; + flen = 0; + + /* get offset */ + if(!(er=a_term(t+i,&offset,&l,pc[segment],&afl,&label,1))) { + i += l; + } + if (offset < 0) + er = E_ILLQUANT; + if(t[i] == ',') { /* skip comma */ + i++; + } else { + er = E_SYNTAX; + } + + /* get length */ + if (!er && + !(er=a_term(t+i,&length,&l,pc[segment],&afl,&label,1))) + { + i += l; + } + if (length < 0) + er = E_ILLQUANT; + if(t[i] == ',') { /* skip comma */ + i++; + } else { + er = E_SYNTAX; + } + + /* get filename. + the tokenizer can either see it as a multichar string ... */ + if (!er) { + int k; + + fstart = i; + if(t[i]=='\"') { + i++; + k=t[i]+i+1; + i++; + while(i 255) + er = E_NOMEM; /* buffer overflow */ + } + binfnam[j] = '\0'; + flen = j; + /* or as a 'char' if it's a single character ("word" would + have been caught by the above) */ + } else + if(!(er=a_term(t+i,&v,&l,pc[segment],&afl,&label,1))) { + binfnam[0] = v; + binfnam[1] = '\0'; + i += l; + flen = 1; + } + } + + /* three arguments only please */ + if (!er && t[i] != T_END) { + er = E_SYNTAX; + } + + if (!er) { + FILE *foo; + +#ifdef DEBUG_AM + fprintf(stderr, +"binclude2 offset = %i len = %i filename = %s endchar = %i\n", + offset, length, binfnam, i); +#endif + if (!(foo = fopen(binfnam, "r"))) { + er = E_FNF; + } else { + fseek(foo, 0, SEEK_END); + if ((length+offset) > ftell(foo)) { + er = E_OUTOFDATA; + } else { + length = (length) ? length : + (ftell(foo)-offset); + } + fclose(foo); + } + if (!er) { + if (length > 65535 && !w65816) { + errout(W_OVER64K); + } else if (length > 16777215) { + errout(W_OVER16M); + } + /* pass parameters back to xa.c */ + *ll=length; +/* + bl=length+2; +*/ + bl=length; + t[0] = offset & 255; + t[1] = (offset >> 8) & 255; + t[2] = (offset >> 16) & 255; + /* God help us if the index is > 65535 */ + t[3] = fstart & 255; + t[4] = (fstart >> 8) & 255; + t[5] = flen; /* to massage 'char' types */ + er = E_BIN; + } + } + } else if(n==Kasc || n==Kbyt || n==Kaasc) { i=1; j=0; while(!er && t[i]!=T_END) @@ -927,6 +1161,9 @@ { *ll=j; bl=j; +#ifdef DEBUG_AM +fprintf(stderr, "Kdsb E_DSB %i\n", j); +#endif er=E_DSB; } } @@ -1268,6 +1505,9 @@ } else er=E_SYNTAX; } +#ifdef DEBUG_AM +fprintf(stderr, "-- endof P2\n"); +#endif pc[segment]+=bl; if(segment==SEG_TEXT) pc[SEG_ABS]+=bl; if(segment==SEG_ABS) pc[SEG_TEXT]+=bl; @@ -1523,7 +1763,7 @@ break; case '\'': case '\"': - er=tg_asc(s+p,t+q,&q,&p,na1,na2); + er=tg_asc(s+p,t+q,&q,&p,na1,na2,n); break; case ',': if(mk) @@ -1779,19 +2019,26 @@ /* * tokenize a string - handle two delimiter types, ' and " */ -static int tg_asc(signed char *s, signed char *t, int *q, int *p, int *na1, int *na2) +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; signed char delimiter = s[i++]; +#ifdef DEBUG_AM +fprintf(stderr, "tg_asc token = %i\n", n); +#endif + t[j++]='"'; /* pass2 token for string */ j++; /* skip place for length */ while(s[i]!='\0' && s[i]!=delimiter) { - if(s[i]!='^') { /* no escape code "^" */ + /* do NOT convert for Kbin or Kaasc, or for initial parse */ + if (!n || n == Kbin || n == Kaasc) { + t[j++]=s[i]; + } else if(s[i]!='^') { /* no escape code "^" */ t[j++]=convert_char(s[i]); } else { /* escape code */ signed char payload = s[i+1]; diff -Nru /tmp/i8VLdkb5vH/xa-2.3.3/tests/binclude/README.1st /tmp/BeHKTGR5sN/xa-2.3.5/tests/binclude/README.1st --- xa-2.3.3/tests/binclude/README.1st 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.5/tests/binclude/README.1st 2008-07-02 05:59:04.000000000 +0100 @@ -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 -Nru /tmp/i8VLdkb5vH/xa-2.3.3/tests/binclude/test2.asm /tmp/BeHKTGR5sN/xa-2.3.5/tests/binclude/test2.asm --- xa-2.3.3/tests/binclude/test2.asm 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.5/tests/binclude/test2.asm 2008-07-23 00:26:22.000000000 +0100 @@ -0,0 +1,18 @@ + .word $9000 + * = $9000 + + w = 10 + +glorb + +.dsb 9,10 +.byt 6, 6, 6, "devil", 'Q' +.bin 0,109,'README.1st' +.bin w,w+119,'README.1st' + +gleeb + + jmp glorb + jmp gleeb + bne * + diff -Nru /tmp/i8VLdkb5vH/xa-2.3.3/tests/binclude/test.asm /tmp/BeHKTGR5sN/xa-2.3.5/tests/binclude/test.asm --- xa-2.3.3/tests/binclude/test.asm 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.5/tests/binclude/test.asm 2008-07-23 00:37:16.000000000 +0100 @@ -0,0 +1,19 @@ + .word $9000 + * = $9000 + + w = 10 + +glorb + +.dsb 9,10 ; +9 +.byt 6, 6, 6, "devil", 'Q' ; +9 => 18 +.bin 0,5,'README.1st' ; +5 => 23 +.bin w,w+256,'README.1st' ; +266 => 289 ($0121) + +gleeb + ; $0123 + jmp glorb + ; should be $9121 (remember the SA) + jmp gleeb + bne * + Binary files /tmp/i8VLdkb5vH/xa-2.3.3/tests/charset/a.o65 and /tmp/BeHKTGR5sN/xa-2.3.5/tests/charset/a.o65 differ diff -Nru /tmp/i8VLdkb5vH/xa-2.3.3/tests/charset/README.1st /tmp/BeHKTGR5sN/xa-2.3.5/tests/charset/README.1st --- xa-2.3.3/tests/charset/README.1st 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.5/tests/charset/README.1st 2009-01-21 17:48:43.000000000 +0000 @@ -0,0 +1,116 @@ +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.4, which implements multiple 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 -Nru /tmp/i8VLdkb5vH/xa-2.3.3/tests/charset/test2.s /tmp/BeHKTGR5sN/xa-2.3.5/tests/charset/test2.s --- xa-2.3.3/tests/charset/test2.s 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.5/tests/charset/test2.s 2009-02-08 06:42:56.000000000 +0000 @@ -0,0 +1 @@ +.aasc "test2" diff -Nru /tmp/i8VLdkb5vH/xa-2.3.3/tests/charset/test.asm /tmp/BeHKTGR5sN/xa-2.3.5/tests/charset/test.asm --- xa-2.3.3/tests/charset/test.asm 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.5/tests/charset/test.asm 2009-02-08 06:43:07.000000000 +0000 @@ -0,0 +1,16 @@ + .word $9000 + * = $9000 + + w = 10 +.bin 0,10+w,"README.1st" +.bin 0,10,"README.1st" +#include "test2.s" +.byt "FooBar" +.aasc "FooBar" +.asc "FooBar",65,97,10 +.aasc "FooBar" +.bin 0,10,"README.1st" +.aasc "Barfoo",65,97,10 + +lda #'A' +lda #"A" diff -Nru /tmp/i8VLdkb5vH/xa-2.3.3/tests/chppch/a.o65 /tmp/BeHKTGR5sN/xa-2.3.5/tests/chppch/a.o65 --- xa-2.3.3/tests/chppch/a.o65 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.5/tests/chppch/a.o65 2008-07-02 06:33:26.000000000 +0100 @@ -0,0 +1 @@ +` \ No newline at end of file diff -Nru /tmp/i8VLdkb5vH/xa-2.3.3/tests/chppch/qwerty.h /tmp/BeHKTGR5sN/xa-2.3.5/tests/chppch/qwerty.h --- xa-2.3.3/tests/chppch/qwerty.h 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.5/tests/chppch/qwerty.h 2008-07-02 06:30:44.000000000 +0100 @@ -0,0 +1,4 @@ + rts + +#print 12+12 +~print 10+10 diff -Nru /tmp/i8VLdkb5vH/xa-2.3.3/tests/chppch/test.c /tmp/BeHKTGR5sN/xa-2.3.5/tests/chppch/test.c --- xa-2.3.3/tests/chppch/test.c 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.5/tests/chppch/test.c 2008-07-02 06:27:33.000000000 +0100 @@ -0,0 +1,3 @@ +#include "qwerty.h" + +~print 5+5 diff -Nru /tmp/i8VLdkb5vH/xa-2.3.3/tests/chppch/test.out /tmp/BeHKTGR5sN/xa-2.3.5/tests/chppch/test.out --- xa-2.3.3/tests/chppch/test.out 1970-01-01 01:00:00.000000000 +0100 +++ xa-2.3.5/tests/chppch/test.out 2008-07-02 06:30:47.000000000 +0100 @@ -0,0 +1,10 @@ +# 1 "test.c" +# 1 "qwerty.h" 1 + rts + +#print 12+12 +~print 10+10 +# 1 "test.c" 2 + + +~print 5+5 diff -Nru /tmp/i8VLdkb5vH/xa-2.3.3/tests/cpp/over.asm /tmp/BeHKTGR5sN/xa-2.3.5/tests/cpp/over.asm --- xa-2.3.3/tests/cpp/over.asm 2007-01-13 19:14:21.000000000 +0000 +++ xa-2.3.5/tests/cpp/over.asm 2009-01-21 17:16:05.000000000 +0000 @@ -29,4 +29,4 @@ # 17 "over.c" 2 -# bull + diff -Nru /tmp/i8VLdkb5vH/xa-2.3.3/tests/README /tmp/BeHKTGR5sN/xa-2.3.5/tests/README --- xa-2.3.3/tests/README 2007-01-31 16:30:47.000000000 +0000 +++ xa-2.3.5/tests/README 2009-01-21 17:17:45.000000000 +0000 @@ -13,8 +13,12 @@ comcom/ Comments-with-comments-with-commands-etc. for testing -M 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 +binclude/ Binary include code with some weird casing +chppch/ Changing preprocessor characters (-p) +charset/ Tests of when charsets should be honoured and when not Cameron Kaiser, André Fachat