-
Notifications
You must be signed in to change notification settings - Fork 5
/
as6-nova.c
168 lines (151 loc) · 3.9 KB
/
as6-nova.c
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
* DG Nova assembler.
*
* Tables
*/
#include "as.h"
SYM sym[] = {
{ 0, "skp", TCC, 1 },
{ 0, "szc", TCC, 2 },
{ 0, "snc", TCC, 3 },
{ 0, "szr", TCC, 4 },
{ 0, "snr", TCC, 5 },
{ 0, "sez", TCC, 6 },
{ 0, "sbn", TCC, 7 },
{ 0, "defw", TDEFW, XXXX },
{ 0, "defs", TDEFS, XXXX },
{ 0, "defm", TDEFM, XXXX },
{ 0, "org", TORG, XXXX },
{ 0, ".org", TORG, XXXX },
{ 0, "equ", TEQU, XXXX },
{ 0, "export", TEXPORT, XXXX },
{ 0, ".byte", TDEFB, XXXX },
{ 0, ".word", TDEFW, XXXX },
{ 0, ".blkw", TDEFS, XXXX },
{ 0, ".ds", TDEFS, XXXX },
{ 0, ".ascii", TDEFM, XXXX },
{ 0, ".org", TORG, XXXX },
{ 0, ".equ", TEQU, XXXX },
{ 0, ".export", TEXPORT, XXXX },
{ 0, "code", TSEGMENT, CODE },
{ 0, "data", TSEGMENT, DATA },
{ 0, "bss", TSEGMENT, BSS },
{ 0, "zp", TSEGMENT, ZP },
{ 0, "discard", TSEGMENT, DISCARD },
{ 0, "common", TSEGMENT, COMMON },
{ 0, "literal", TSEGMENT, LITERAL },
{ 0, "commondata", TSEGMENT, COMMONDATA },
{ 0, "buffers", TSEGMENT, BUFFERS },
{ 0, ".code", TSEGMENT, CODE },
{ 0, ".data", TSEGMENT, DATA },
{ 0, ".bss", TSEGMENT, BSS },
{ 0, ".zp", TSEGMENT, ZP },
{ 0, ".abs", TSEGMENT, ABSOLUTE },
{ 0, ".discard", TSEGMENT, DISCARD },
{ 0, ".common", TSEGMENT, COMMON },
{ 0, ".literal", TSEGMENT, LITERAL },
{ 0, ".commondata", TSEGMENT, COMMONDATA },
{ 0, ".buffers", TSEGMENT, BUFFERS },
{ 0, ".byteptr", TBPTR, 0 },
{ 0, "jmp", TMEMNA, 0x0000 },
{ 0, "jsr", TMEMNA, 0x0800 },
{ 0, "isz", TMEMNA, 0x1000 },
{ 0, "dsz", TMEMNA, 0x1800 },
{ 0, "lda", TMEMORY, 0x2000 },
{ 0, "sta", TMEMORY, 0x4000 },
{ 0, "com", TALU, 0x8000 },
{ 0, "neg", TALU, 0x8100 },
{ 0, "mov", TALU, 0x8200 },
{ 0, "adc", TALU, 0x8400 },
{ 0, "sub", TALU, 0x8500 },
{ 0, "add", TALU, 0x8600 },
{ 0, "and", TALU, 0x8700 },
{ 0, "inc", TALU, 0x8300 },
{ 0, "nio", TNIO, 0x6000 },
{ 0, "dia", TIO, 0x6100 },
{ 0, "doa", TIO, 0x6200 },
{ 0, "dib", TIO, 0x6300 },
{ 0, "dob", TIO, 0x6400 },
{ 0, "dic", TIO, 0x6500 },
{ 0, "doc", TIO, 0x6600 },
{ 0, "skpbn", TDEV, 0x6700 },
{ 0, "skpbz", TDEV, 0x6740 },
{ 0, "skpdn", TDEV, 0x6780 },
{ 0, "skpdz", TDEV, 0x67C0 },
/* Then the post NOVA 1 operations that are less elegant being
device ops */
{ 0, "mtfp", TAC, 0x6001 },
{ 0, "mffp", TAC, 0x6081 },
{ 0, "mtsp", TAC, 0x6201 },
{ 0, "mfsp", TAC, 0x6281 },
{ 0, "psha", TAC, 0x6301 },
{ 0, "popa", TAC, 0x6381 },
{ 0, "sav", TIMPL, 0x6501 },
{ 0, "ret", TIMPL, 0x6581 },
/* Undocumented SAV n ? */
{ 0, "trap", TTRAP, 0x8008 },
{ 0, "ldb", TBYTE, 0x6101 },
{ 0, "stb", TBYTE, 0x6401 },
{ 0, "div", TIMPL, 0x7641 },
{ 0, "mul", TIMPL, 0x76C1 },
{ 0, "divs", TIMPL, 0x7E01 },
{ 0, "muls", TIMPL, 0x7E81 },
};
/*
* Set up the symbol table.
* Sweep through the initializations
* of the "phash", and link them into the
* buckets. Because it is here, a
* "sizeof" works.
*/
void syminit(void)
{
SYM *sp;
int hash;
sp = &sym[0];
while (sp < &sym[sizeof(sym)/sizeof(SYM)]) {
hash = symhash(sp->s_id);
sp->s_fp = phash[hash];
phash[hash] = sp;
++sp;
}
}
char *etext[] = {
"unexpected character",
"phase error",
"multiple definitions",
"syntax error",
"must be absolute",
"missing delimiter",
"invalid constant",
"relative out of range",
"skip condition required",
"invalid register for operation",
"address required",
"invalid id",
"bad addressing mode",
"divide by 0",
"constant out of range",
"data in BSS",
"segment overflow",
"data in zero page",
"bad accumulator",
"must be zero page or absolute",
"bad device",
"segment conflict"
};
/*
* Make sure that the
* mode and register fields of
* the type of the "ADDR" pointed to
* by "ap" can participate in an addition
* or a subtraction.
*/
void isokaors(ADDR *ap, int paren)
{
int mode;
mode = ap->a_type&TMMODE;
if (mode == TUSER)
return;
aerr(ADDR_REQUIRED);
}