Fix compile crash on unknown assembly instruction
Make the assembler fail with a fatal error 104 "invalid assembler instruction" if met an unknown instruction. It won't tell a correct line number though.
This commit is contained in:
parent
6b0809a99e
commit
80eceb586d
@ -649,8 +649,10 @@ int pc_compile(int argc, char *argv[])
|
|||||||
error(13); /* no entry point (no public functions) */
|
error(13); /* no entry point (no public functions) */
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (inpf!=NULL) /* main source file is not closed, do it now */
|
if (inpf!=NULL) { /* main source file is not closed, do it now */
|
||||||
pc_closesrc(inpf);
|
pc_closesrc(inpf);
|
||||||
|
inpf=NULL;
|
||||||
|
}
|
||||||
/* write the binary file (the file is already open) */
|
/* write the binary file (the file is already open) */
|
||||||
if (!(sc_asmfile || sc_listing) && errnum==0 && jmpcode==0) {
|
if (!(sc_asmfile || sc_listing) && errnum==0 && jmpcode==0) {
|
||||||
assert(binf!=NULL);
|
assert(binf!=NULL);
|
||||||
|
@ -211,6 +211,21 @@ static char *stripcomment(char *str)
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *stripwhitespace(char *str)
|
||||||
|
{
|
||||||
|
if (*str!='\0') {
|
||||||
|
size_t len = strlen(str);
|
||||||
|
size_t i;
|
||||||
|
for (i=len-1; i>=0; i--) {
|
||||||
|
if (!isspace(str[i])) {
|
||||||
|
str[i+1]='\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
static void write_encoded(FILE *fbin,ucell *c,int num)
|
static void write_encoded(FILE *fbin,ucell *c,int num)
|
||||||
{
|
{
|
||||||
#if PAWN_CELL_SIZE == 16
|
#if PAWN_CELL_SIZE == 16
|
||||||
@ -1016,7 +1031,8 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
|
|||||||
/* nothing */;
|
/* nothing */;
|
||||||
assert(params>instr);
|
assert(params>instr);
|
||||||
i=findopcode(instr,(int)(params-instr));
|
i=findopcode(instr,(int)(params-instr));
|
||||||
assert(opcodelist[i].name!=NULL);
|
if (opcodelist[i].name==NULL)
|
||||||
|
error(104, stripwhitespace(instr)); /* invalid assembler instruction */
|
||||||
if (opcodelist[i].segment==pass)
|
if (opcodelist[i].segment==pass)
|
||||||
opcodelist[i].func(fout,skipwhitespace(params),opcodelist[i].opcode);
|
opcodelist[i].func(fout,skipwhitespace(params),opcodelist[i].opcode);
|
||||||
} /* while */
|
} /* while */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user