mirror of
https://github.com/fachat/xa65.git
synced 2024-11-15 23:05:30 +00:00
add another off-by-one
This commit is contained in:
parent
b0ef07addc
commit
1cbb0a34f0
@ -88,7 +88,7 @@ int a_term(signed char *s, int *v, int *l, int xpc, int *pfl, int *label, int f)
|
|||||||
}
|
}
|
||||||
|
|
||||||
*l=pp;
|
*l=pp;
|
||||||
/* printf("a_term: afl->%04x *pfl=%04x, (pc=%04x)\n",afl,*pfl, xpc); */
|
//fprintf(stderr, "a_term: nolink=%d, noundef=%d ->er=%d; l=%d, pp=%d, afl->%04x *pfl=%04x, (pc=%04x)\n",nolink, noundef ,er, *l, pp, afl,*pfl, xpc);
|
||||||
return(er);
|
return(er);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,9 +98,8 @@ static int ag_term(signed char *s, int p, int *v, int *nafl, int *label)
|
|||||||
|
|
||||||
afl = 0;
|
afl = 0;
|
||||||
|
|
||||||
/*
|
//fprintf(stderr, "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]=='-')
|
while(s[pp]=='-')
|
||||||
{
|
{
|
||||||
pp++;
|
pp++;
|
||||||
@ -174,6 +173,7 @@ printf("pointer: v=%04x, afl=%04x\n",*v,afl);
|
|||||||
|
|
||||||
while(!er && s[pp]!=')' && s[pp]!=']' && s[pp]!=',' && s[pp]!=T_END && s[pp]!=T_COMMENT)
|
while(!er && s[pp]!=')' && s[pp]!=']' && s[pp]!=',' && s[pp]!=T_END && s[pp]!=T_COMMENT)
|
||||||
{
|
{
|
||||||
|
fprintf(stderr, "ag_term while: s[pp=%d]=%02x\n", pp, s[pp]);
|
||||||
er=get_op(s,&o);
|
er=get_op(s,&o);
|
||||||
|
|
||||||
if(!er && pr[o]>p)
|
if(!er && pr[o]>p)
|
||||||
|
@ -1019,8 +1019,9 @@ int pgetline(char *t)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
er=1;
|
er=1;
|
||||||
|
}
|
||||||
|
|
||||||
if(c==EOF) {
|
if(c==EOF) {
|
||||||
if (loopfl && fsp) {
|
if (loopfl && fsp) {
|
||||||
|
40
xa/src/xat.c
40
xa/src/xat.c
@ -432,18 +432,23 @@ fprintf(stderr, "- p1 %d starting -\n", pc[segment]);
|
|||||||
* using memcpy is fine here
|
* using memcpy is fine here
|
||||||
*/
|
*/
|
||||||
inp = 0;
|
inp = 0;
|
||||||
/* discard label definitions before copying the buffer */
|
/* discard label definitions before copying the buffer, so we don't get
|
||||||
|
* label defined errors */
|
||||||
while (inp<l && t[6+inp]==T_DEFINE) {
|
while (inp<l && t[6+inp]==T_DEFINE) {
|
||||||
inp+=3;
|
inp+=3;
|
||||||
}
|
}
|
||||||
/* copy the buffer */
|
/* copy the buffer;
|
||||||
|
* t+tlen is directly after the T_LISTING buffer
|
||||||
|
* t+6+inp is the start of the T_LISTING buffer, after label defines
|
||||||
|
* l-inp is the length of the T_LISTING buffer, without label defines
|
||||||
|
*/
|
||||||
memcpy(t+tlen, t+6+inp, l-inp);
|
memcpy(t+tlen, t+6+inp, l-inp);
|
||||||
|
|
||||||
#ifdef DEBUG_CONV
|
#ifdef DEBUG_CONV
|
||||||
printf("t_conv s:%s\n",s);
|
printf("t_conv s:%s\n",s);
|
||||||
printf("t_conv (er=%d, t=%p, tlen=%d, inp=%d):",er, t, tlen, inp);
|
printf("t_conv (er=%d, t=%p, l=%d, tlen=%d, inp=%d):",er, t, l, tlen, inp);
|
||||||
for(i=0;i<l+6;i++)
|
for(i=0;i<l;i++)
|
||||||
printf("%02x,",t[i] & 0xff);
|
printf("%02x,",t[i+6] & 0xff);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -551,7 +556,7 @@ printf(" wrote %02x %02x %02x %02x %02x %02x, %02x, %02x\n",
|
|||||||
i=1;
|
i=1;
|
||||||
wval(i,pc[SEG_TEXT], 0);
|
wval(i,pc[SEG_TEXT], 0);
|
||||||
t[i++]=T_END;
|
t[i++]=T_END;
|
||||||
*ll=6;
|
*ll=7;
|
||||||
er=E_OKDEF;
|
er=E_OKDEF;
|
||||||
r_mode(RMODE_RELOC);
|
r_mode(RMODE_RELOC);
|
||||||
/*printf(" : newseg=%d, pc[newseg]=%04x, pc[abs]=%04x, pc[text]=%04x\n",
|
/*printf(" : newseg=%d, pc[newseg]=%04x, pc[abs]=%04x, pc[text]=%04x\n",
|
||||||
@ -2016,6 +2021,7 @@ static int t_conv(signed char *s, signed char *t, int *l, int pc, int *nk,
|
|||||||
fl=0; /* 1 = pass text thru */
|
fl=0; /* 1 = pass text thru */
|
||||||
afl=0; /* pointer flag for label */
|
afl=0; /* pointer flag for label */
|
||||||
|
|
||||||
|
// skip leading whitespace
|
||||||
while(isspace(s[p])) p++;
|
while(isspace(s[p])) p++;
|
||||||
|
|
||||||
n=T_END;
|
n=T_END;
|
||||||
@ -2116,8 +2122,9 @@ static int t_conv(signed char *s, signed char *t, int *l, int pc, int *nk,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(n != Kmvn && n != Kmvp && ((n & 0xff) <=Lastbef))
|
if(n != Kmvn && n != Kmvp && ((n & 0xff) <=Lastbef)) {
|
||||||
mk=1; /* 1= nur 1 Komma erlaubt *//* = only 1 comma ok */
|
mk=1; /* = only 1 comma ok for normal opcodes */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(s[p]=='\0' || s[p]==';')
|
if(s[p]=='\0' || s[p]==';')
|
||||||
@ -2140,13 +2147,20 @@ static int t_conv(signed char *s, signed char *t, int *l, int pc, int *nk,
|
|||||||
|
|
||||||
operand=1;
|
operand=1;
|
||||||
|
|
||||||
while(s[p]==' ') p++;
|
// skip whitespace
|
||||||
|
while(isspace(s[p])) {
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
if(s[p]=='#')
|
if(s[p]=='#')
|
||||||
{
|
{
|
||||||
mk=0;
|
mk=0;
|
||||||
t[q++]=s[p++];
|
t[q++]=s[p++];
|
||||||
while(s[p]==' ') p++;
|
|
||||||
|
// skip following whitespace
|
||||||
|
while(isspace(s[p])) {
|
||||||
|
p++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2167,7 +2181,9 @@ static int t_conv(signed char *s, signed char *t, int *l, int pc, int *nk,
|
|||||||
{
|
{
|
||||||
if(fl)
|
if(fl)
|
||||||
{
|
{
|
||||||
|
// pass through text (e.g. for ",y")
|
||||||
t[q++]=s[p++];
|
t[q++]=s[p++];
|
||||||
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
if(operand)
|
if(operand)
|
||||||
@ -2342,8 +2358,10 @@ fprintf(stderr, "could not find %s\n", (char *)s+p);
|
|||||||
if(s[p]==',')
|
if(s[p]==',')
|
||||||
{
|
{
|
||||||
t[q++]=s[p++];
|
t[q++]=s[p++];
|
||||||
if(mk)
|
if(mk) {
|
||||||
|
// if only one comma, pass through all following text - esp. ",y" or ",x" etc
|
||||||
fl++;
|
fl++;
|
||||||
|
}
|
||||||
*nk+=1;
|
*nk+=1;
|
||||||
} else
|
} else
|
||||||
switch(s[p]) {
|
switch(s[p]) {
|
||||||
|
Loading…
Reference in New Issue
Block a user