-
Notifications
You must be signed in to change notification settings - Fork 5
/
as6-8070.c
194 lines (171 loc) · 4.41 KB
/
as6-8070.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*
* INS 8070
* Basic symbol tables.
* Contain all of the instructions
* and register names.
*/
#include "as.h"
/*
* This array of symbol nodes
* make up the basic symbol table.
* The "syminit" routine links these
* nodes into the builtin symbol hash
* table at start-up time.
*/
SYM sym[] = {
{ 0, "pc", TWR, P0 },
{ 0, "sp", TWR, P1 },
{ 0, "p0", TWR, P0 },
{ 0, "p1", TWR, P1 },
{ 0, "p2", TWR, P2 },
{ 0, "p3", TWR, P3 },
{ 0, "a", TBR, A },
{ 0, "ea", TWR, EA },
{ 0, "e", TBR, E },
{ 0, "s", TBR, S },
{ 0, "t", TWR, T },
{ 0, "defb", TDEFB, XXXX },
{ 0, "defw", TDEFW, XXXX },
{ 0, "defs", TDEFS, XXXX },
{ 0, "defm", TDEFM, XXXX },
{ 0, "org", TORG, XXXX },
{ 0, "equ", TEQU, XXXX },
{ 0, "export", TEXPORT, XXXX },
{ 0, ".byte", TDEFB, XXXX },
{ 0, ".word", TDEFW, XXXX },
{ 0, ".dbyte", TDEFW, XXXX },
{ 0, ".blkb", TDEFS, XXXX },
{ 0, ".ascii", TDEFM, XXXX },
{ 0, ".org", TORG, XXXX },
{ 0, ".equ", TEQU, XXXX },
{ 0, ".export", TEXPORT, XXXX },
{ 0, "cond", TCOND, XXXX },
{ 0, "endc", TENDC, XXXX },
{ 0, "code", TSEGMENT, CODE },
{ 0, "data", TSEGMENT, DATA },
{ 0, "bss", TSEGMENT, BSS },
{ 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, ".discard", TSEGMENT, DISCARD },
{ 0, ".common", TSEGMENT, COMMON },
{ 0, ".literal", TSEGMENT, LITERAL },
{ 0, ".commondata", TSEGMENT, COMMONDATA },
{ 0, ".buffers", TSEGMENT, BUFFERS },
/* Implicit */
{ 0, "nop", TIMPL, 0x00 },
{ 0, "ret", TIMPL, 0x5C },
/* SSM (P2/P3 only) */
{ 0, "ssm", TP2P3, 0x2C },
/* 16bit const - really JSR is PLI 0 and jmp is LD PC,=addr */
{ 0, "jsr", TIMM16, 0x20 },
{ 0, "jmp", TIMM16, 0x24 },
/* PLI (p, imm16) */
{ 0, "pli", TPIMM16, 0x20 },
/* logic 8 */
{ 0, "and", TLOGIC, 0x39D0 },
{ 0, "or", TLOGIC, 0x3BD8 },
{ 0, "xor", TLOGIC, 0x00E0 },
/* logic16 */
{ 0, "add", TLOGIC16, 0xF0B0 },
{ 0, "sub", TLOGIC16, 0xF8B8 },
/* mem8 */
{ 0, "dld", TMEM8, 0x98 },
{ 0, "ild", TMEM8, 0x90 },
/* branches */
{ 0, "bnd", TBRA, 0x2D },
{ 0, "bp", TBRA, 0x64 },
{ 0, "bz", TBRA, 0x6C },
{ 0, "bra", TBRA16, 0x74 },
{ 0, "bnz", TBRA, 0x8C },
/* exchange */
{ 0, "xch", TXCH, 0x44 },
/* call */
{ 0, "call", TCALL, 0x10 },
/* eat/t */
{ 0, "div", TEAT, 0x0D },
{ 0, "mpy", TEAT, 0x2C },
/* Load and store */
{ 0, "ld", TLOAD, 0x00 },
{ 0, "st", TSTORE, 0x00 },
/* A only */
{ 0, "rr", TAONLY, 0x3E },
{ 0, "rrl", TAONLY, 0x3F },
{ 0, "srl", TAONLY, 0x3D },
/* A or EA */
{ 0, "sl", TAEA, 0x0E0F },
{ 0, "sr", TAEA, 0x3C0C },
/* Stack */
{ 0, "push", TSTACK, 0x0854 },
{ 0, "pop", TSTACK, 0x385C },
/* Helper ops */
{ 0, "jz", TBRA16, 0x6C },
{ 0, "jnz", TBRA16, 0x7C },
/* Funny one for addresses where the value - 1 is used */
{ 0, ".addr", TADDR, XXXX }
};
/*
* 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", /* 10 */
"phase error", /* 11 */
"multiple definitions", /* 12 */
"syntax error", /* 13 */
"must be absolute", /* 14 */
"missing delimiter", /* 15 */
"invalid constant", /* 16 */
"address required", /* 17 */
"invalid id", /* 18 */
"bad mode", /* 19 */
"constant out of range",/* 20 */
"data in BSS", /* 21 */
"segment overflow", /* 22 */
"segment conflict", /* 23 */
"divide by zero", /* 24 */
"autoindexing not permitted", /* 25 */
"branch out of range", /* 26 */
"out of range", /* 27 */
"invalid addressing mode", /* 28 */
"pointer required", /* 29 */
"invalid register", /* 30 */
"too many jz/jnz", /* 31 */
"A register only", /* 32 */
"A or EA required", /* 33 */
};
/*
* 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);
}