commit 0df50c4

Devine Lu Linvega  ·  2024-04-04 02:37:06 +0000 UTC
parent 8e8b179
(uxnasm) Report unknown mode
1 files changed,  +9, -8
+9, -8
 1@@ -45,7 +45,7 @@ static char *save(char *s, char c) { char *o = dictnext; while((*dictnext++ = *s
 2 static char *join(char *a, char j, char *b) { char *res = dictnext; save(a, j), save(b, 0); return res; } /* join two str */
 3 
 4 #define ishex(x) (shex(x) >= 0)
 5-#define isopc(x) (findopcode(x) || scmp(x, "BRK", 4))
 6+#define isopc(x) (findopcode(x, ctx) || scmp(x, "BRK", 4))
 7 #define isinvalid(x) (!x[0] || ishex(x) || isopc(x) || find(runes, x[0]) >= 0)
 8 #define writeshort(x) (writebyte(x >> 8, ctx) && writebyte(x & 0xff, ctx))
 9 #define findlabel(x) finditem(x, labels, labels_len)
10@@ -82,7 +82,7 @@ finditem(char *name, Item *list, int len)
11 }
12 
13 static Uint8
14-findopcode(char *s)
15+findopcode(char *s, Context *ctx)
16 {
17 	int i;
18 	for(i = 0; i < 0x20; i++) {
19@@ -97,7 +97,7 @@ findopcode(char *s)
20 			else if(s[m] == 'k')
21 				i |= (1 << 7);
22 			else
23-				return 0;
24+				return error_asm("Opcode mode unknown");
25 			m++;
26 		}
27 		return i;
28@@ -261,7 +261,7 @@ static int
29 writehex(char *w, Context *ctx)
30 {
31 	if(*w == '#')
32-		writebyte(findopcode("LIT") | !!(++w)[2] << 5, ctx);
33+		writebyte(findopcode("LIT", ctx) | !!(++w)[2] << 5, ctx);
34 	if(w[1] && !w[2])
35 		return writebyte(shex(w), ctx);
36 	else if(w[3] && !w[4])
37@@ -299,6 +299,7 @@ parse(char *w, FILE *f, Context *ctx)
38 {
39 	Item *m;
40 	switch(w[0]) {
41+	case 0x0: return 1;
42 	case '(': return walkcomment(f, ctx);
43 	case '%': return makemacro(w + 1, f, ctx);
44 	case '@': return makelabel(w + 1, 1, ctx);
45@@ -306,12 +307,12 @@ parse(char *w, FILE *f, Context *ctx)
46 	case '}': return makelabel(makelambda(lambda_stack[--lambda_ptr]), 0, ctx);
47 	case '#': return writehex(w, ctx);
48 	case '_': return makeref(w + 1, w[0], ptr) && writebyte(0xff, ctx);
49-	case ',': return makeref(w + 1, w[0], ptr + 1) && writebyte(findopcode("LIT"), ctx) && writebyte(0xff, ctx);
50+	case ',': return makeref(w + 1, w[0], ptr + 1) && writebyte(findopcode("LIT", ctx), ctx) && writebyte(0xff, ctx);
51 	case '-': return makeref(w + 1, w[0], ptr) && writebyte(0xff, ctx);
52-	case '.': return makeref(w + 1, w[0], ptr + 1) && writebyte(findopcode("LIT"), ctx) && writebyte(0xff, ctx);
53+	case '.': return makeref(w + 1, w[0], ptr + 1) && writebyte(findopcode("LIT", ctx), ctx) && writebyte(0xff, ctx);
54 	case ':': printf("Deprecated rune %s, use =%s\n", w, w + 1); /* fall-through */
55 	case '=': return makeref(w + 1, w[0], ptr) && writeshort(0xffff);
56-	case ';': return makeref(w + 1, w[0], ptr + 1) && writebyte(findopcode("LIT2"), ctx) && writeshort(0xffff);
57+	case ';': return makeref(w + 1, w[0], ptr + 1) && writebyte(findopcode("LIT2", ctx), ctx) && writeshort(0xffff);
58 	case '?': return makeref(w + 1, w[0], ptr + 1) && writebyte(0x20, ctx) && writeshort(0xffff);
59 	case '!': return makeref(w + 1, w[0], ptr + 1) && writebyte(0x40, ctx) && writeshort(0xffff);
60 	case '"': return writestring(w + 1, ctx);
61@@ -322,7 +323,7 @@ parse(char *w, FILE *f, Context *ctx)
62 	case ']': return 1;
63 	}
64 	if(ishex(w)) return writehex(w, ctx);
65-	if(isopc(w)) return writebyte(findopcode(w), ctx);
66+	if(isopc(w)) return writebyte(findopcode(w, ctx), ctx);
67 	if((m = findmacro(w))) return walkmacro(m, ctx);
68 	return makeref(w, ' ', ptr + 1) && writebyte(0x60, ctx) && writeshort(0xffff);
69 }