OpenCores
URL https://opencores.org/ocsvn/zipcpu/zipcpu/trunk

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [sw/] [zasm/] [zparser.cpp] - Blame information for rev 143

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    zparser.cpp
4
//
5
// Project:     Zip CPU -- a small, lightweight, RISC CPU core
6
//
7 13 dgisselq
// Purpose:     This file is really mis-named.  At one time it was going to
8
//              be the parser for the Zip Assembler, zasm.  Since then, I
9
//              discovered Flex and Bison and have written a parser using
10
//              those tools.  The true parser may therefore be found in zasm.y.
11
//              This file, however, still contains some very valuable tools.
12
//              In particular, all of the routines used to build instructions
13
//              from the appropriate fields are kept in this file.  For example,
14
//              op_noop() returns the instruction code for a NOOP  instruction.
15 2 dgisselq
//
16
// Creator:     Dan Gisselquist, Ph.D.
17 69 dgisselq
//              Gisselquist Technology, LLC
18 2 dgisselq
//
19
////////////////////////////////////////////////////////////////////////////////
20
//
21
// Copyright (C) 2015, Gisselquist Technology, LLC
22
//
23
// This program is free software (firmware): you can redistribute it and/or
24
// modify it under the terms of  the GNU General Public License as published
25
// by the Free Software Foundation, either version 3 of the License, or (at
26
// your option) any later version.
27
//
28
// This program is distributed in the hope that it will be useful, but WITHOUT
29
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
30
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
31
// for more details.
32
//
33
// You should have received a copy of the GNU General Public License along
34
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
35
// target there if the PDF file isn't present.)  If not, see
36
// <http://www.gnu.org/licenses/> for a copy.
37
//
38
// License:     GPL, v3, as defined and found on www.gnu.org,
39
//              http://www.gnu.org/licenses/gpl.html
40
//
41
//
42
////////////////////////////////////////////////////////////////////////////////
43
 
44
#include <stdio.h>
45
#include <stdlib.h>
46
#include <string.h>
47
#include <ctype.h>
48
#include <strings.h>
49 69 dgisselq
#include <assert.h>
50 2 dgisselq
 
51
#include "zparser.h"
52
#include "zopcodes.h"
53
 
54 69 dgisselq
#define IMMOP(OP,CND,IMM,A) (((OP&0x01f)<<22)|((A&0x0f)<<27)|((CND&0x07)<<19) \
55
                        | (IMM & 0x03ffff))
56 2 dgisselq
 
57 69 dgisselq
#define DBLREGOP(OP,CND,IMM,B,A) (((OP&0x01f)<<22)|((A&0x0f)<<27)       \
58
                        |((CND&0x07)<<19)|(1<<18)|((B&0x0f)<<14)         \
59
                        | (IMM & 0x03fff))
60 2 dgisselq
 
61 126 dgisselq
#define LONG_MPY
62
 
63
ZPARSER::ZIPIMM ZPARSER::brev(ZIPIMM v) const {
64
        unsigned r=0, b;
65
 
66
        for(b=0; b<32; b++, v>>=1)
67
                r = (r<<1)|(v&1);
68
 
69
        return r;
70
}
71
 
72 2 dgisselq
ZIPI    ZPARSER::op_cmp(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const {
73 69 dgisselq
        return DBLREGOP(ZIPO_CMP, cnd, imm, b, a);
74 2 dgisselq
}
75
 
76
ZIPI    ZPARSER::op_cmp(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
77 69 dgisselq
        return IMMOP(ZIPO_CMP, cnd, imm, a);
78 2 dgisselq
}
79
 
80
 
81
ZIPI    ZPARSER::op_tst(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const {
82 69 dgisselq
        return DBLREGOP(ZIPO_TST, cnd, imm, b, a);
83 2 dgisselq
} ZIPI  ZPARSER::op_tst(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
84 69 dgisselq
        return IMMOP(ZIPO_TST, cnd, imm, a);
85 2 dgisselq
}
86
 
87
ZIPI    ZPARSER::op_mov(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const {
88
        ZIPI    in;
89 69 dgisselq
 
90
        in = (ZIPO_MOV)<<22;
91
        in |= ((a  &0x0f)<<27);
92
        in |= ((cnd&0x07)<<19);
93
        in |= ((b  &0x0f)<<14);
94
        in |= ( imm&0x01fff);
95
 
96
 
97
        if (b & 0x10)
98
                in |= (1<<13);
99
        if (a & 0x10)
100
                in |= (1<<18);
101 2 dgisselq
        return in;
102
}
103
 
104
 
105
ZIPI    ZPARSER::op_ldi(ZIPIMM imm, ZIPREG a) const {
106
        ZIPI    in;
107 69 dgisselq
        in = ((a&0x0f)<<27) | (ZIPO_LDI << 22) | (imm & ((1<<23)-1));
108 2 dgisselq
        return in;
109
}
110
 
111
ZIPI    ZPARSER::op_trap(ZIPCOND cnd, ZIPIMM imm) const {
112
        ZIPI    in;
113 13 dgisselq
        if (cnd != ZIPC_ALWAYS)
114
                return op_ldilo(cnd, imm, ZIP_CC);
115
        else
116
                return op_ldi(imm, ZIP_CC);
117
        // in  = ((0x4f)<<24)|((cnd&0x07)<<21)|(1<<20)|((0x0e)<<16);
118
        // in |= (imm & 0x0ffff);
119 2 dgisselq
        return in;
120
}
121
 
122
ZIPI    ZPARSER::op_noop(void) const {
123 69 dgisselq
        return 0x76000000;
124
} ZIPI  ZPARSER::op_break(void) const {
125
        return 0x76400000;
126
} ZIPI  ZPARSER::op_lock(void) const {
127
        return 0x76800000;
128 2 dgisselq
}
129
 
130 126 dgisselq
#ifdef  LONG_MPY
131
ZIPI    ZPARSER::op_mpy(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const {
132
        return DBLREGOP(ZIPO_MPY, cnd, imm, b, a);
133
} ZIPI  ZPARSER::op_mpy(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
134
        return IMMOP(ZIPO_MPY, cnd, imm, a);
135
}
136
#else
137 2 dgisselq
ZIPI    ZPARSER::op_ldihi(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
138 69 dgisselq
        ZIPI    in = IMMOP(ZIPO_LDIHI, cnd, (imm & 0x0ffff), a);
139 2 dgisselq
        return in;
140 126 dgisselq
}
141
#endif
142
ZIPI    ZPARSER::op_ldilo(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
143 69 dgisselq
        ZIPI    in = IMMOP(ZIPO_LDILO, cnd, (imm & 0x0ffff), a);
144 2 dgisselq
        return in;
145
}
146
 
147 143 dgisselq
#ifdef  LONG_MPY
148
ZIPI    ZPARSER::op_mpyuhi(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const {
149
        return DBLREGOP(ZIPO_MPYUHI, cnd, imm, b, a);
150
} ZIPI  ZPARSER::op_mpyuhi(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
151
        return IMMOP(ZIPO_MPYUHI, cnd, imm & 0x0ffff, a);
152
}
153
 
154
ZIPI    ZPARSER::op_mpyshi(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const {
155
        return DBLREGOP(ZIPO_MPYSHI, cnd, imm, b, a);
156
} ZIPI  ZPARSER::op_mpyshi(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
157
        return IMMOP(ZIPO_MPYSHI, cnd, imm & 0x0ffff, a);
158
}
159
#else
160 26 dgisselq
ZIPI    ZPARSER::op_mpyu(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const {
161 69 dgisselq
        return DBLREGOP(ZIPO_MPYU, cnd, imm, b, a);
162 26 dgisselq
} ZIPI  ZPARSER::op_mpyu(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
163 69 dgisselq
        return IMMOP(ZIPO_MPYU, cnd, imm & 0x0ffff, a);
164 8 dgisselq
}
165
 
166 26 dgisselq
ZIPI    ZPARSER::op_mpys(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const {
167 69 dgisselq
        return DBLREGOP(ZIPO_MPYS, cnd, imm, b, a);
168 26 dgisselq
} ZIPI  ZPARSER::op_mpys(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
169 69 dgisselq
        return IMMOP(ZIPO_MPYS, cnd, imm & 0x0ffff, a);
170 26 dgisselq
}
171 143 dgisselq
#endif
172 26 dgisselq
 
173 8 dgisselq
ZIPI    ZPARSER::op_rol(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const {
174 69 dgisselq
        return DBLREGOP(ZIPO_ROL, cnd, imm, b, a);
175 8 dgisselq
} ZIPI  ZPARSER::op_rol(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
176 69 dgisselq
        return IMMOP(ZIPO_ROL, cnd, imm, a);
177 8 dgisselq
}
178
 
179 69 dgisselq
ZIPI    ZPARSER::op_popc(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const {
180
        return DBLREGOP(ZIPO_POPC, cnd, imm, b, a);
181
} ZIPI  ZPARSER::op_popc(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
182
        return IMMOP(ZIPO_POPC, cnd, imm, a);
183
}
184
 
185
ZIPI    ZPARSER::op_brev(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const {
186
        return DBLREGOP(ZIPO_BREV, cnd, imm, b, a);
187
} ZIPI  ZPARSER::op_brev(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
188
        return IMMOP(ZIPO_BREV, cnd, imm, a);
189
}
190
 
191 2 dgisselq
ZIPI    ZPARSER::op_lod(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const {
192 69 dgisselq
        return DBLREGOP(ZIPO_LOD, cnd, imm, b, a);
193 8 dgisselq
} ZIPI  ZPARSER::op_lod(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
194 69 dgisselq
        return IMMOP(ZIPO_LOD, cnd, imm, a);
195 2 dgisselq
}
196
 
197
 
198
ZIPI    ZPARSER::op_sto(ZIPCOND cnd, ZIPREG v, ZIPIMM imm, ZIPREG b) const {
199 69 dgisselq
        return DBLREGOP(ZIPO_STO, cnd, imm, b, v);
200 2 dgisselq
} ZIPI  ZPARSER::op_sto(ZIPCOND cnd, ZIPREG v, ZIPIMM imm) const {
201 69 dgisselq
        return IMMOP(ZIPO_STO, cnd, imm, v);
202 2 dgisselq
}
203
 
204
 
205
ZIPI    ZPARSER::op_sub(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const {
206 69 dgisselq
        return DBLREGOP(ZIPO_SUB, cnd, imm, b, a);
207 2 dgisselq
} ZIPI  ZPARSER::op_sub(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
208 26 dgisselq
        // While it seems like we might do well replacing a subtract immediate
209
        // with an add of the negative same, the conditions aren't the same
210
        // when doing so.  Hence this is an invalid substitution.
211
        // return IMMOP(0xa, cnd, -imm, a); // Do an add of the negative of imm
212 69 dgisselq
        return IMMOP(ZIPO_SUB, cnd, imm, a);
213 2 dgisselq
}
214
 
215
 
216
ZIPI    ZPARSER::op_and(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const {
217 69 dgisselq
        return DBLREGOP(ZIPO_AND, cnd, imm, b, a);
218 2 dgisselq
} ZIPI  ZPARSER::op_and(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
219 69 dgisselq
        return IMMOP(ZIPO_AND, cnd, imm, a);
220 2 dgisselq
}
221
 
222
 
223
ZIPI    ZPARSER::op_add(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const {
224 69 dgisselq
        return DBLREGOP(ZIPO_ADD, cnd, imm, b, a);
225 2 dgisselq
} ZIPI  ZPARSER::op_add(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
226 69 dgisselq
        return IMMOP(ZIPO_ADD, cnd, imm, a);
227 2 dgisselq
}
228
 
229
 
230
ZIPI    ZPARSER::op_or(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const {
231 69 dgisselq
        return DBLREGOP(ZIPO_OR, cnd, imm, b, a);
232 2 dgisselq
} ZIPI  ZPARSER::op_or(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
233 69 dgisselq
        return IMMOP(ZIPO_OR, cnd, imm, a);
234 2 dgisselq
}
235
 
236
ZIPI    ZPARSER::op_xor(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const {
237 69 dgisselq
        return DBLREGOP(ZIPO_XOR, cnd, imm, b, a);
238 2 dgisselq
} ZIPI  ZPARSER::op_xor(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
239 69 dgisselq
        return IMMOP(ZIPO_XOR, cnd, imm, a);
240 2 dgisselq
}
241
 
242
ZIPI    ZPARSER::op_lsl(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const {
243 69 dgisselq
        return DBLREGOP(ZIPO_LSL, cnd, imm, b, a);
244 2 dgisselq
} ZIPI  ZPARSER::op_lsl(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
245 69 dgisselq
        return IMMOP(ZIPO_LSL, cnd, imm, a);
246 2 dgisselq
}
247
 
248
ZIPI    ZPARSER::op_asr(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const {
249 69 dgisselq
        return DBLREGOP(ZIPO_ASR, cnd, imm, b, a);
250 2 dgisselq
} ZIPI  ZPARSER::op_asr(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
251 69 dgisselq
        return IMMOP(ZIPO_ASR, cnd, imm, a);
252 2 dgisselq
}
253
 
254
ZIPI    ZPARSER::op_lsr(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const {
255 69 dgisselq
        return DBLREGOP(ZIPO_LSR, cnd, imm, b, a);
256 2 dgisselq
} ZIPI  ZPARSER::op_lsr(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
257 69 dgisselq
        return IMMOP(ZIPO_LSR, cnd, imm, a);
258 2 dgisselq
}
259
 
260 69 dgisselq
ZIPI    ZPARSER::op_divu(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const {
261
        return DBLREGOP(ZIPO_DIVU, cnd, imm, b, a);
262
} ZIPI  ZPARSER::op_divu(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
263
        return IMMOP(ZIPO_DIVU, cnd, imm, a);
264
}
265
 
266
ZIPI    ZPARSER::op_divs(ZIPCOND cnd, ZIPIMM imm, ZIPREG b, ZIPREG a) const {
267
        return DBLREGOP(ZIPO_DIVS, cnd, imm, b, a);
268
} ZIPI  ZPARSER::op_divs(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
269
        return IMMOP(ZIPO_DIVS, cnd, imm, a);
270
}
271
 
272
ZPARSER::ZIPIMM ZPARSER::immediate(const ZIPI a) {
273 89 dgisselq
        ZIPOP   op((ZIPOP)((a>>22)&0x01f));
274 69 dgisselq
        ZIPIMM  imm;
275
 
276
        switch(op) {
277
                case ZIPO_MOV:
278
                        imm = (a & 0x0fff); if (a&0x1fff) imm |= -0x1000; break;
279
                case ZIPO_LDI:
280
                        imm = (a & 0x03fffff); break;
281
                case ZIPO_LDIn:
282
                        imm = (a & 0x03fffff); imm |= -0x200000; break;
283 143 dgisselq
                case ZIPO_LDILO:
284
#ifndef LONG_MPY
285
                case ZIPO_LDIHI:
286
#endif
287 69 dgisselq
                        imm = (a & 0x0ffff);   break;
288
                default:
289
                        if (a & 0x040000) {
290
                                imm = (a&0x3fff);
291
                                if (a&0x2000) imm |= -0x02000;
292
                        } else {
293
                                imm = (a&0x3ffff);
294
                                if (a&0x20000)
295
                                        imm |= -0x20000;
296
                        }
297
        }
298
 
299
        return imm;
300
}
301
 
302
bool    ZPARSER::can_merge(const ZIPI a, const ZIPI b) {
303
        // 1. Can't merge anything that's already merged
304
        if ((a|b) & 0x80000000)
305
                return false;
306
 
307 89 dgisselq
        ZIPOP   opa((ZIPOP)((a>>22)&0x01f)), opb((ZIPOP)((b>>22)&0x01f));
308 69 dgisselq
        // 2. Conditions
309
        {
310
                ZIPCOND ca((ZIPCOND)((a>>19)&0x07)),cb((ZIPCOND)((b>>19)&0x07));
311
 
312
                if ((opa == ZIPO_LDI)||(opa == ZIPO_LDIn))
313
                        ca = ZIPC_ALWAYS;
314
                if ((opb == ZIPO_LDI)||(opb == ZIPO_LDIn))
315
                        cb = ZIPC_ALWAYS;
316
 
317
                if ((ca == ZIPC_ALWAYS)&&(cb != ZIPC_ALWAYS))
318
                        return false;
319
                if ((ca|cb) &0x04)
320
                        return false;
321
                if ((ca != ZIPC_ALWAYS)&&((cb != ca)&&(cb != ZIPC_ALWAYS)))
322
                        return false;
323
                // if ((ca != ZIPC_ALWAYS)||(cb != ZIPC_ALWAYS))
324
                        // return false;
325
        }
326
 
327
        // 3. Moves ... only move if the move doesn't address user registers
328
 
329
        if ((opa == ZIPO_MOV)&&(a & ((1<<18)|(1<<13))))
330
                return false;
331
        if ((opb == ZIPO_MOV)&&(b & ((1<<18)|(1<<13))))
332
                return false;
333
 
334
        // 4. Immediates.  If Register + Immediate, the answer is No.
335
        ZIPIMM imma, immb;
336
        switch(opa) {
337
                case ZIPO_MOV:
338 89 dgisselq
                        imma = (a & 0x03fff); if (a) return false; break;
339 69 dgisselq
                case ZIPO_LDI: case ZIPO_LDIn:
340 143 dgisselq
                case ZIPO_LDILO:
341
#ifndef LONG_MPY
342
                case ZIPO_LDIHI:
343
#endif
344 69 dgisselq
                        imma = immediate(a);   break;
345
                default:
346
                        if (a & 0x040000) {
347
                                imma = (a&0x3ffff);
348
                                // if (a&0x20000) a |= -0x20000;
349
                                if (imma != 0)
350
                                        return false;
351
                        } else {
352
                                imma = (a&0x3fff);
353
                                if (a&0x2000) // Sign extension?
354
                                        imma |= -0x02000;
355
                        }
356
        } switch(opb) {
357
                case ZIPO_MOV:
358
                        immb = (b & 0x0fff); if (b) return false; break;
359
                case ZIPO_LDI: case ZIPO_LDIn:
360 143 dgisselq
                case ZIPO_LDILO:
361
#ifndef LONG_MPY
362
                case ZIPO_LDIHI:
363
#endif
364 69 dgisselq
                        immb = immediate(b);   break;
365
                default:
366
                        if (b & 0x040000) {
367
                                immb = (b&0x3fff);
368
                                // if (b&0x2000) b |= -0x02000;
369
                                if (immb != 0)
370
                                        return false;
371
                        } else {
372
                                immb = (b&0x3ffff);
373
                                if (b&0x20000)
374
                                        immb |= -0x20000;
375
                        }
376
        }
377
 
378 143 dgisselq
        if ((opa == ZIPO_LDI)||(opa == ZIPO_LDIn)
379
#ifndef LONG_MPY
380
                ||(opa == ZIPO_LDIHI)
381
#endif
382
                ||(opa == ZIPO_LDILO)) {
383 69 dgisselq
                if ((imma > 15)||(imma < -16))
384
                        return false;
385
        } else if ((imma > 7)||(imma < -8))
386
                        return false;
387 143 dgisselq
        if ((opb == ZIPO_LDI)||(opb == ZIPO_LDIn)
388
#ifndef LONG_MPY
389
                ||(opb == ZIPO_LDIHI)
390
#endif
391
                ||(opb == ZIPO_LDILO)) {
392 69 dgisselq
                if ((immb > 15)||(immb < -16))
393
                        return false;
394
        } else if ((immb > 7)||(immb < -8))
395
                        return false;
396
 
397
        return true;
398
}
399
 
400
ZIPI    ZPARSER::merge(const ZIPI a, const ZIPI b) {
401
        assert(can_merge(a, b));
402
        ZIPI    ni;
403
 
404
        ZIPCOND ca( (ZIPCOND)((a>>19)&0x007)), cb( (ZIPCOND)((b>>19)&0x007));
405
        ZIPOP   opa((ZIPOP)((a>>25)&0x012)), opb((ZIPOP)((b>>22)&0x01f));
406
 
407
        if ((opa == ZIPO_LDI)||(opa == ZIPO_LDIn))
408
                ca = ZIPC_ALWAYS;
409
        if ((opb == ZIPO_LDI)||(opb == ZIPO_LDIn))
410
                cb = ZIPC_ALWAYS;
411
 
412
        ZIPIMM imma, immb;
413
        imma = immediate(a);
414
        immb = immediate(b);
415
 
416
        ni = (opa << 26)|(opb<<9)|0x80000000;
417
        if (ca != ZIPC_ALWAYS) {
418
                ni |= (ca << 19);
419
                if (cb == ca)
420
                        ni |= (1<<21);
421
        }
422
 
423
        // The result register(s)
424
        ni |= (a & 0x78000000);
425
        ni |= ((b>>27)&0x0f)<<5;
426
 
427
        // Are we using the register form of opB?
428
        switch(opa) {
429
                case ZIPO_MOV: ni |= (a&0x078000); break; // Always a register
430
                case ZIPO_LDI: case ZIPO_LDIn:
431 143 dgisselq
                case ZIPO_LDILO:
432
#ifndef LONG_MPY
433
                case ZIPO_LDIHI:
434
#endif
435 69 dgisselq
                        ni |= (imma & 0x01f)<<14;
436
                        break;
437
                default:
438
                        if (a & 0x040000) {
439
                                ni |= (a&0x078000);
440
                        } else
441
                                ni |= (imma & 0x0f)<<14;
442
        }
443
 
444
        switch(opb) {
445
                case ZIPO_MOV:
446
                        ni |= ((b>>14)&0x0f)|0x10; break;
447
                case ZIPO_LDI: case ZIPO_LDIn:
448 143 dgisselq
                case ZIPO_LDILO:
449
#ifndef LONG_MPY
450
                case ZIPO_LDIHI:
451
#endif
452 69 dgisselq
                        ni |= (immb & 0x01f);
453
                        break;
454
                default:
455
                        if (b & 0x040000) {
456
                                ni |= ((b>>14)&0x0f)|0x10;
457
                        } else
458
                                ni |= (immb & 0x0f);
459
        }
460
 
461
        return ni;
462
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.