-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassembler.h
57 lines (46 loc) · 1.55 KB
/
assembler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef _ASSEMBLER_H
#define _ASSEMBLER_H
#include <ctype.h>
#include <stdlib.h>
#include "emulator.h"
#define LINELEN 100
#define SKIPSPACES(t) while (isspace(*((t)++))); (t)--
// Stores information about a future reference or a literal constant
// to be filled in later.
typedef struct {
int addr;
bool resolved;
bool which; // False for sym, true for literal.
char sym[11];
word literal;
} futureref;
#define MAXSYMS 1000
typedef struct {
int star;
int numsyms, numfuturerefs;
char syms[MAXSYMS][11];
word symvals[MAXSYMS];
futureref futurerefs[MAXSYMS];
int localsymcounts[10]; // The current number of instances of each local symbol <n>H.
} parsestate;
// Returned by reference in parseline() for mmm to use.
typedef struct {
bool setdebugline;
bool isend;
} extraparseinfo;
void initparsestate(parsestate *ps);
bool lookupsym(char *sym, word *val, parsestate *ps);
bool parsesym(char **s, char *sym);
bool parseOP(char **s, char *op, int *opidx);
bool parsenum(char **s, int *val);
// parseatomic() and the rest all write into a word instead of an int,
// because words and ints are NOT equivalent.
// Specifically, +0 != -0.
bool parseatomic(char **s, word *val, parsestate *ps);
bool parseexpr(char **s, word *val, parsestate *ps);
bool parseA(char **s, word *val, parsestate *ps);
bool parseI(char **s, word *val, parsestate *ps);
bool parseF(char **s, word *val, parsestate *ps);
bool parseW(char **s, word *val, parsestate *ps);
bool parseline(char *line, parsestate *ps, mix *mix, extraparseinfo *extraparseinfo);
#endif