-
Notifications
You must be signed in to change notification settings - Fork 0
/
op_halfwords.c
220 lines (201 loc) · 3.51 KB
/
op_halfwords.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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#include "op.h"
INITBOP(0500,0577,op_halfword,0)
_SUB int op_halfword(PCTX *ctx)
{
register short iop;
#define from_L1 0
#define from_R1 1
#define from_R2 2
#define from_L2 3
#define to_L 0
#define to_R 1
#define mod_none 0
#define mod_Z 1
#define mod_O 2
#define mod_E 3
#define mem_mem 0
#define mem_I 1
#define mem_M 2
#define mem_S 3
int lw,rw;
char put_left,set_accum,set_effw;
BIGV t,u;
iop = ctx->OP;
#define DO_tfrom (iop&040)>>4 |(iop&004)>>2
#define DO_tto (iop&040)>>5
#define DO_tmod (iop&030)>>3
#define DO_tmem (iop&003)
lw = rw = 0;
put_left = 1;
set_accum = 0;
set_effw = 0;
switch (DO_tfrom) {
case from_R1:
case from_R2:
switch (DO_tmem) {
case mem_mem:
rw = RH(READMEM(jctx,ctx->E));
CHKERROR(jctx);
lw = 0;
put_left = 0;
break;
case mem_I:
rw = RH(cE);
lw = 0;
put_left = 1;
break;
case mem_M:
rw = RH(READMEM(jctx,ctx->AC));
CHKERROR(jctx);
lw = 0;
set_effw = 1;
put_left = 1;
break;
case mem_S:
rw = RH(READMEM(jctx,ctx->E));
CHKERROR(jctx);
lw = 0;
set_effw = 1;
set_accum = 1;
put_left = 1;
break;
}
break;
case from_L1:
case from_L2:
switch (DO_tmem) {
case mem_mem:
rw = LH(READMEM(jctx, ctx->E));
CHKERROR(jctx);
lw = 0;
put_left = 0;
break;
case mem_I:
rw = 0;
lw = 0;
put_left = 1;
break;
case mem_M:
rw = LH(READMEM(jctx,ctx->AC));
CHKERROR(jctx);
lw = 0;
set_effw = 1;
put_left = 1;
break;
case mem_S:
rw = LH(READMEM(jctx, ctx->E));
CHKERROR(jctx);
lw = 0;
set_accum = 1;
set_effw = 1;
put_left = 1;
break;
}
break;
}
switch (DO_tmod) {
case mod_none:
put_left = 0;
break;
case mod_Z:
put_left = 1;
break;
case mod_O:
put_left = 1;
lw = 0777777;
break;
case mod_E:
put_left = 1;
if (rw & 0400000)
lw = 0777777;
break;
}
/* printf("lw=%o rw=%o left=%d effw=%d accum=%d\n",lw,rw,put_left,set_effw,set_accum);*/
switch (DO_tto) {
case to_L:
if (set_effw) {
if (put_left) {
t = rw;
t <<= 18;
t |= lw;
WRITEMEM(jctx, ctx->E, t);
CHKERROR(jctx);
}
else {
t = READMEM(jctx, ctx->E) & RWM;
CHKERROR(jctx);
u = rw;
u <<= 18;
u |= t;
WRITEMEM(jctx, ctx->E, u);
CHKERROR(jctx);
}
if (set_accum && cAC) {
t = READMEM(jctx, ctx->E);
CHKERROR(jctx);
WRITEMEM(jctx, ctx->AC, t);
CHKERROR(jctx);
}
} else {
if (put_left) {
t = rw;
t <<= 18;
t |= lw;
WRITEMEM(jctx, ctx->AC, t);
CHKERROR(jctx);
}
else {
t = READMEM(jctx,ctx->AC) & RWM;
CHKERROR(jctx);
u = rw;
u <<= 18;
u |= t;
WRITEMEM(jctx, ctx->AC, u);
CHKERROR(jctx);
}
}
break;
case to_R:
if (set_effw) {
if (put_left) {
t = lw;
t <<= 18;
t |= rw;
WRITEMEM(jctx, ctx->E, t);
CHKERROR(jctx);
}
else {
t = READMEM(jctx, ctx->E) & LWM;
CHKERROR(jctx);
u = t;
u |= rw;
WRITEMEM(jctx, ctx->E, u);
CHKERROR(jctx);
}
if (set_accum && cAC) {
t = READMEM(jctx, ctx->E);
CHKERROR(jctx);
WRITEMEM(jctx, ctx->AC, t);
CHKERROR(jctx);
}
} else {
if (put_left) {
t = lw;
t <<= 18;
t |= rw;
WRITEMEM(jctx, ctx->AC, t);
CHKERROR(jctx);
}
else {
t = READMEM(jctx,ctx->AC) & LWM;
CHKERROR(jctx);
u = rw;
u |= t;
WRITEMEM(jctx, ctx->AC, u);
CHKERROR(jctx);
}
}
break;
}
return(OK_EXIT);
}