...
|
...
|
@@ -48,7 +48,7 @@ char ops[][4] = {
|
48
|
48
|
|
49
|
49
|
int scin(char *s, char c) { int i = 0; while(s[i]) if(s[i++] == c) return i - 1; return -1; } /* string char index */
|
50
|
50
|
int scmp(char *a, char *b, int len) { int i = 0; while(a[i] == b[i] && i < len) if(!a[i++]) return 1; return 0; } /* string compare */
|
51
|
|
-int sihx(char *s) { int i = 0; char c; while((c = s[i++])) if(!(c >= '0' && c <= '9') && !(c >= 'a' && c <= 'f')) return 0; return 1; } /* string is hexadecimal */
|
|
51
|
+int sihx(char *s) { int i = 0; char c; while((c = s[i++])) if(!(c >= '0' && c <= '9') && !(c >= 'a' && c <= 'f')) return 0; return i > 1; } /* string is hexadecimal */
|
52
|
52
|
int ssin(char *s, char *ss) { int a = 0, b = 0; while(s[a]) { if(s[a] == ss[b]) { if(!ss[b + 1]) return a - b; b++; } else b = 0; a++; } return -1; } /* string substring index */
|
53
|
53
|
int shex(char *s) { int n = 0, i = 0; char c; while((c = s[i++])) if(c >= '0' && c <= '9') n = n * 16 + (c - '0'); else if(c >= 'a' && c <= 'f') n = n * 16 + 10 + (c - 'a'); return n; } /* string to num */
|
54
|
54
|
int slen(char *s) { int i = 0; while(s[i] && s[++i]) ; return i; } /* string length */
|
...
|
...
|
@@ -154,7 +154,7 @@ makemacro(char *name, FILE *f)
|
154
|
154
|
return error("Macro duplicate", name);
|
155
|
155
|
if(sihx(name) && slen(name) % 2 == 0)
|
156
|
156
|
return error("Macro name is hex number", name);
|
157
|
|
- if(findopcode(name))
|
|
157
|
+ if(findopcode(name) || !slen(name))
|
158
|
158
|
return error("Macro name is invalid", name);
|
159
|
159
|
m = &p.macros[p.mlen++];
|
160
|
160
|
scpy(name, m->name, 64);
|
...
|
...
|
@@ -179,7 +179,7 @@ makelabel(char *name, Uint16 addr)
|
179
|
179
|
return error("Label duplicate", name);
|
180
|
180
|
if(sihx(name) && slen(name) % 2 == 0)
|
181
|
181
|
return error("Label name is hex number", name);
|
182
|
|
- if(findopcode(name))
|
|
182
|
+ if(findopcode(name) || !slen(name))
|
183
|
183
|
return error("Label name is invalid", name);
|
184
|
184
|
l = &p.labels[p.llen++];
|
185
|
185
|
l->addr = addr;
|