| ... | ... |
@@ -15,6 +15,7 @@ WITH REGARD TO THIS SOFTWARE. |
| 15 | 15 |
#define LENGTH 0x10000 |
| 16 | 16 |
|
| 17 | 17 |
#define LABELS 512 |
| 18 |
+#define MACROS 256 |
|
| 18 | 19 |
|
| 19 | 20 |
typedef unsigned char Uint8; |
| 20 | 21 |
typedef signed char Sint8; |
| ... | ... |
@@ -31,10 +32,10 @@ typedef struct {
|
| 31 | 32 |
} Label; |
| 32 | 33 |
|
| 33 | 34 |
typedef struct {
|
| 34 |
- Uint8 data[LENGTH], mlen; |
|
| 35 |
- Uint16 ptr, length, llen; |
|
| 35 |
+ Uint8 data[LENGTH]; |
|
| 36 |
+ Uint16 ptr, length, llen, mlen; |
|
| 36 | 37 |
Label labels[LABELS]; |
| 37 |
- Macro macros[256]; |
|
| 38 |
+ Macro macros[MACROS]; |
|
| 38 | 39 |
} Program; |
| 39 | 40 |
|
| 40 | 41 |
Program p; |
| ... | ... |
@@ -158,6 +159,8 @@ makemacro(char *name, FILE *f) |
| 158 | 159 |
return error("Macro name is hex number", name);
|
| 159 | 160 |
if(findopcode(name) || scmp(name, "BRK", 4) || !slen(name) || scmp(name, "include", 8)) |
| 160 | 161 |
return error("Macro name is invalid", name);
|
| 162 |
+ if(p.mlen == MACROS) |
|
| 163 |
+ return error("Too many macros", name);
|
|
| 161 | 164 |
m = &p.macros[p.mlen++]; |
| 162 | 165 |
scpy(name, m->name, 64); |
| 163 | 166 |
while(fscanf(f, "%63s", word) == 1) {
|