1
0
mirror of https://github.com/fachat/xa65.git synced 2024-06-18 11:29:34 +00:00

added 0xHEX and 0OCTAL parsing with -XC compatibility parameter

This commit is contained in:
fachat 2012-08-15 03:06:45 +02:00 committed by Andre Fachat
parent eff641bcff
commit e8a6ba088e
5 changed files with 73 additions and 16 deletions

View File

@ -65,6 +65,9 @@ not affect colon interpretation elsewhere.
.B \-R
Start assembler in relocating mode.
.TP
.B \-N
Allow C-style numerals (starting with digit '0')
.TP
.B \-Llabel
Defines
.B label

View File

@ -61,8 +61,12 @@
/* exported globals */
int ncmos, cmosfl, w65816, n65816;
/* compatibility flags */
int masm = 0;
int ppinstr = 0;
int ctypes = 0; /* C compatibility, like "0xab" types */
int nolink = 0;
int romable = 0;
int romaddr = 0;
@ -234,6 +238,9 @@ int main(int argc,char *argv[])
if(argv[i][2]==0) romaddr = atoi(argv[++i]);
else romaddr = atoi(argv[i]+2);
break;
case 'N': /* C style numerals */
ctypes = 1;
break;
case 'G':
noglob = 1;
break;
@ -860,6 +867,8 @@ static void usage(int default816, FILE *fp)
" starts at addr, relocation is not necessary. Overrides -bt\n"
" Other segments must be specified with `-b?'\n"
" -G suppress list of exported globals\n");
fprintf(fp,
" -N Allow C-style numerals (starting with '0' digit)\n");
fprintf(fp,
" -p? set preprocessor character to ?, default is #\n"
" -DDEF=TEXT defines a preprocessor replacement\n"
@ -1141,3 +1150,33 @@ void logout(char *s)
fprintf(fperr,"%s",s);
}
#if 0
/*****************************************************************/
typedef struct {
char *name;
int *flag;
} compat_set;
static compat_set compat_sets[] = {
{ "MASM", &masm },
{ "CA65", &ca65 },
{ "C", &ctypes },
{ NULL, NULL }
};
int set_compat(char *compat_name) {
int i = 0;
while (compat_sets[i].name != NULL) {
if (strcmp(compat_sets[i].name, compat_name) == 0) {
/* set appropriate compatibility flag */
(*compat_sets[i].flag) = 1;
return 0;
}
i++;
}
return -1;
}
#endif

View File

@ -27,6 +27,7 @@ extern int noglob;
extern int showblk;
extern int relmode;
extern int crossref;
extern int ctypes;
extern char altppchar;
extern int tlen, tbase;

View File

@ -71,20 +71,20 @@ typedef struct {
#define BUFSIZE 4096 /* File-Puffegroesse (wg Festplatte) */
#define E_OK 0 /* Fehlernummern */
#define E_SYNTAX -1 /* Syntax Fehler */
#define E_LABDEF -2 /* Label definiert */
#define E_NODEF -3 /* Label nicht definiert */
#define E_LABFULL -4 /* Labeltabelle voll */
#define E_LABEXP -5 /* Label erwartet */
#define E_NOMEM -6 /* kein Speicher mehr */
#define E_ILLCODE -7 /* Illegaler Opcode */
#define E_ADRESS -8 /* Illegale Adressierung */
#define E_OK 0 /* No error */
#define E_SYNTAX -1 /* Syntax error */
#define E_LABDEF -2 /* Label already defined (duplicate label definition) */
#define E_NODEF -3 /* Label not defined */
#define E_LABFULL -4 /* Label table full */
#define E_LABEXP -5 /* Label expected but not found */
#define E_NOMEM -6 /* out of memory */
#define E_ILLCODE -7 /* Illegal Opcode */
#define E_ADRESS -8 /* Illegal Addressing mode */
#define E_RANGE -9 /* Branch out of range */
#define E_OVERFLOW -10 /* Ueberlauf */
#define E_DIV -11 /* Division durch Null */
#define E_PSOEXP -12 /* Pseudo-Opcode erwartet */
#define E_BLKOVR -13 /* Block-Stack Uebergelaufen */
#define E_OVERFLOW -10 /* overflow */
#define E_DIV -11 /* Division by zero */
#define E_PSOEXP -12 /* Pseudo-Opcode expected but not found */
#define E_BLKOVR -13 /* Block-Stack overflow */
#define E_FNF -14 /* File not found (pp) */
#define E_EOF -15 /* End of File */
#define E_BLOCK -16 /* Block inkonsistent */

View File

@ -1826,16 +1826,30 @@ fprintf(stderr, "could not find %s\n", (char *)s+p);
p+=ll;
}
else
if(s[p]<='9' && s[p]>='0')
if(s[p]<='9' && (s[p]>'0' || (s[p] == '0' && !ctypes)))
{
tg_dez(s+p,&ll,&v);
p+=ll;
wval(q,v);
}
else
/* handle encodings: hex, binary, octal, quoted strings */
/* handle encodings: hex, binary, octal, quoted strings */
switch(s[p]) {
case '0':
// only gets here when "ctypes" is set, and starts with 0
// we here check for the C stype "0xHEX" and "0OCTAL" encodings
if ('x' == tolower(s[p+1])) {
// c-style hex
tg_hex(s+p+2, &ll, &v);
p+=2+ll;
wval(q, v, '$');
} else {
// c-style octal
tg_oct(s+p+1,&ll,&v);
p+=1+ll;
wval(q,v, '&');
}
break;
case '$':
tg_hex(s+p+1,&ll,&v);
p+=1+ll;