Fixed issue with invalid hexadecimal values

This commit is contained in:
Devine Lu Linvega 2024-05-30 18:37:05 -07:00
parent 4f846beb26
commit f44c43b801
1 changed files with 8 additions and 7 deletions

View File

@ -266,11 +266,12 @@ writehex(char *w, Context *ctx)
{ {
if(*w == '#') if(*w == '#')
writebyte(findopcode("LIT") | !!(++w)[2] << 5, ctx); writebyte(findopcode("LIT") | !!(++w)[2] << 5, ctx);
if(ishex(w)) {
if(w[1] && !w[2]) if(w[1] && !w[2])
return writebyte(shex(w), ctx); return writebyte(shex(w), ctx);
else if(w[3] && !w[4]) else if(w[3] && !w[4])
return writeshort(shex(w)); return writeshort(shex(w));
else }
return error_asm("Hexadecimal invalid"); return error_asm("Hexadecimal invalid");
} }
@ -409,7 +410,7 @@ main(int argc, char *argv[])
{ {
ptr = PAGE; ptr = PAGE;
copy("on-reset", scope, 0); copy("on-reset", scope, 0);
if(argc == 2 && scmp(argv[1], "-v", 2)) return !printf("Uxnasm - Uxntal Assembler, 10 May 2024.\n"); if(argc == 2 && scmp(argv[1], "-v", 2)) return !printf("Uxnasm - Uxntal Assembler, 30 May 2024.\n");
if(argc != 3) return error_top("usage", "uxnasm [-v] input.tal output.rom"); if(argc != 3) return error_top("usage", "uxnasm [-v] input.tal output.rom");
if(!assemble(argv[1])) return 1; if(!assemble(argv[1])) return 1;
if(!resolve(argv[2])) return 1; if(!resolve(argv[2])) return 1;