emit: Allow the use of labels in arguments of type 'any'
This commit is contained in:
parent
bc76324d03
commit
a19b740a28
@ -478,6 +478,7 @@ typedef enum s_optmark {
|
|||||||
|
|
||||||
#define eotNUMBER 0
|
#define eotNUMBER 0
|
||||||
#define eotFUNCTION 1
|
#define eotFUNCTION 1
|
||||||
|
#define eotLABEL 2
|
||||||
typedef struct s_emit_outval {
|
typedef struct s_emit_outval {
|
||||||
int type;
|
int type;
|
||||||
union {
|
union {
|
||||||
|
@ -5981,10 +5981,12 @@ fetchtok:
|
|||||||
break;
|
break;
|
||||||
} /* if */
|
} /* if */
|
||||||
if (sym->ident==iLABEL) {
|
if (sym->ident==iLABEL) {
|
||||||
tok=tLABEL;
|
if (neg!=FALSE)
|
||||||
goto invalid_token;
|
goto invalid_token_neg;
|
||||||
} /* if */
|
sym->usage|=uREAD;
|
||||||
if (sym->ident==iFUNCTN || sym->ident==iREFFUNC) {
|
p->type=eotLABEL;
|
||||||
|
p->value.ucell=(ucell)sym->addr;
|
||||||
|
} else if (sym->ident==iFUNCTN || sym->ident==iREFFUNC) {
|
||||||
if (neg!=FALSE)
|
if (neg!=FALSE)
|
||||||
goto invalid_token_neg;
|
goto invalid_token_neg;
|
||||||
if ((sym->usage & uNATIVE)!=0 && (sym->usage & uREAD)==0 && sym->addr>=0)
|
if ((sym->usage & uNATIVE)!=0 && (sym->usage & uREAD)==0 && sym->addr>=0)
|
||||||
@ -6024,7 +6026,6 @@ fetchtok:
|
|||||||
break;
|
break;
|
||||||
} /* if */
|
} /* if */
|
||||||
default:
|
default:
|
||||||
invalid_token:
|
|
||||||
emit_invalid_token(teNUMERIC,tok);
|
emit_invalid_token(teNUMERIC,tok);
|
||||||
} /* switch */
|
} /* switch */
|
||||||
}
|
}
|
||||||
|
@ -1390,6 +1390,9 @@ SC_FUNC void outinstr(const char *name, emit_outval params[],int numparams)
|
|||||||
stgwrite(" ");
|
stgwrite(" ");
|
||||||
switch (params[i].type)
|
switch (params[i].type)
|
||||||
{
|
{
|
||||||
|
case eotLABEL:
|
||||||
|
stgwrite("l.");
|
||||||
|
/* fallthrough */
|
||||||
case eotNUMBER:
|
case eotNUMBER:
|
||||||
stgwrite(itoh(params[i].value.ucell));
|
stgwrite(itoh(params[i].value.ucell));
|
||||||
break;
|
break;
|
||||||
|
@ -102,7 +102,7 @@ static ucell getparam(const char *s,char **n)
|
|||||||
char name[sNAMEMAX+1];
|
char name[sNAMEMAX+1];
|
||||||
symbol *sym;
|
symbol *sym;
|
||||||
|
|
||||||
if (*s=='.') {
|
if (s[0]=='.') {
|
||||||
/* this is a function, find it in the global symbol table */
|
/* this is a function, find it in the global symbol table */
|
||||||
for (i=0; !isspace(*(++s)); i++) {
|
for (i=0; !isspace(*(++s)); i++) {
|
||||||
assert(*s!='\0');
|
assert(*s!='\0');
|
||||||
@ -115,6 +115,12 @@ static ucell getparam(const char *s,char **n)
|
|||||||
assert(sym->ident==iFUNCTN || sym->ident==iREFFUNC);
|
assert(sym->ident==iFUNCTN || sym->ident==iREFFUNC);
|
||||||
assert(sym->vclass==sGLOBAL);
|
assert(sym->vclass==sGLOBAL);
|
||||||
result=sym->addr;
|
result=sym->addr;
|
||||||
|
} else if (s[0]=='l' && s[1]=='.') {
|
||||||
|
/* this is a label */
|
||||||
|
i=(int)hex2long(s+2,NULL);
|
||||||
|
assert(i>=0 && i<sc_labnum);
|
||||||
|
assert(lbltab!=NULL);
|
||||||
|
result=lbltab[i];
|
||||||
} else {
|
} else {
|
||||||
for ( ;; ) {
|
for ( ;; ) {
|
||||||
result+=hex2long(s,(char**)&s);
|
result+=hex2long(s,(char**)&s);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user