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

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [sw/] [zasm/] [zopcodes.cpp] - Blame information for rev 70

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    zopcodes.cpp
4
//
5
// Project:     Zip CPU -- a small, lightweight, RISC CPU core
6
//
7 13 dgisselq
// Purpose:     A simple program to handle the disassembly and definition
8
//              of the various Zip Assembly opcodes.  The primary function
9
//              of this file is the zipi_to_string, or Zip Instruction to
10
//              string (disassemble) conversion.
11 2 dgisselq
//
12
// Creator:     Dan Gisselquist, Ph.D.
13 69 dgisselq
//              Gisselquist Technology, LLC
14 2 dgisselq
//
15
////////////////////////////////////////////////////////////////////////////////
16
//
17
// Copyright (C) 2015, Gisselquist Technology, LLC
18
//
19
// This program is free software (firmware): you can redistribute it and/or
20
// modify it under the terms of  the GNU General Public License as published
21
// by the Free Software Foundation, either version 3 of the License, or (at
22
// your option) any later version.
23
//
24
// This program is distributed in the hope that it will be useful, but WITHOUT
25
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
26
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
27
// for more details.
28
//
29
// You should have received a copy of the GNU General Public License along
30
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
31
// target there if the PDF file isn't present.)  If not, see
32
// <http://www.gnu.org/licenses/> for a copy.
33
//
34
// License:     GPL, v3, as defined and found on www.gnu.org,
35
//              http://www.gnu.org/licenses/gpl.html
36
//
37
//
38
////////////////////////////////////////////////////////////////////////////////
39
 
40
#include <stdio.h>
41
#include <strings.h>
42
#include <string.h>
43
#include <assert.h>
44
 
45
#include "twoc.h"
46
#include "zopcodes.h"
47
 
48
const   char    *zop_regstr[] = {
49
        "R0", "R1", "R2", "R3",
50
        "R4", "R5", "R6", "R7",
51
        "R8", "R9", "R10","R11",
52
        "R12","SP", "CC", "PC",
53
        "uR0", "uR1", "uR2", "uR3",
54
        "uR4", "uR5", "uR6", "uR7",
55
        "uR8", "uR9", "uR10", "uR11",
56
        "uR12", "uSP", "uCC", "uPC",
57
        "sR0", "sR1", "sR2", "sR3",
58
        "sR4", "sR5", "sR6", "sR7",
59
        "sR8", "sR9", "sR10","sR11",
60
        "sR12","sSP", "sCC", "sPC"
61
};
62
 
63
const   char    *zop_ccstr[] = {
64 69 dgisselq
        "", ".LT", ".Z", ".NZ", ".GT", ".GE", ".C", ".V"
65 2 dgisselq
};
66
 
67
const ZOPCODE   zoplist[] = {
68
        // Special case instructions.  These are general instructions, but with
69
        // special opcodes
70
        // Conditional branches
71 69 dgisselq
        //      0.1111.0111.ccc.0.111.10iiiii--
72
        //      0111 1011 11cc c011 110i iiii iiii iiii
73
        "BUSY", 0xffc7ffff, 0x7bc3dfff, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
74
        "BRA",  0xffffe000, 0x7bc3c000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
75
        "BLT",  0xffffe000, 0x7bcbc000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
76
        "BRZ",  0xffffe000, 0x7bd3c000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
77
        "BNZ",  0xffffe000, 0x7bdbc000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
78
        "BGE",  0xffffe000, 0x7be3c000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
79
        "BGT",  0xffffe000, 0x7bebc000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
80
        "BRC",  0xffffe000, 0x7bf3c000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
81
        "BRV",  0xffffe000, 0x7bfbc000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
82
        // CLRF ... an XOR w/ self instruction
83
        //      0.rrrr.00100.ccc.1.rrrr.iiiii---
84
        //      0rrr r001 00cc c1rr rr00 0000 0000 0000
85
        "CLRF", 0xffc7cfff, 0x01040000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
86
        "CLRF", 0xffc7cfff, 0x09044000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
87
        "CLRF", 0xffc7cfff, 0x11048000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
88
        "CLRF", 0xffc7cfff, 0x1904c000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
89
        "CLRF", 0xffc7cfff, 0x21050000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
90
        "CLRF", 0xffc7cfff, 0x29054000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
91
        "CLRF", 0xffc7cfff, 0x31058000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
92
        "CLRF", 0xffc7cfff, 0x3905c000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
93
        "CLRF", 0xffc7cfff, 0x41060000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
94
        "CLRF", 0xffc7cfff, 0x49064000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
95
        "CLRF", 0xffc7cfff, 0x51068000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
96
        "CLRF", 0xffc7cfff, 0x5906c000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
97
        "CLRF", 0xffc7cfff, 0x61070000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
98
        "CLRF", 0xffc7cfff, 0x69074000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
99
        "CLRF", 0xffc7cfff, 0x71078000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
100
        "CLRF", 0xffc7cfff, 0x7907c000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
101
        // CLR -- a LDI of zero
102
        //      0.rrrr.1011.iiiiiii--
103
        //      0rrr r101 1...
104
        "CLR",  0x878fffff, 0x05800000, REGFIELD(27),OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED,
105
        // HALT
106
        //      0.1110.00011.ccc.0.0000000000010
107
        //      0111.0000.11cc.c000.0000.0000.0000.0010
108
        "HALT", 0xffc7ffff, 0x70c00010, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
109 2 dgisselq
        // The "wait" instruction is identical, with the only difference being
110 69 dgisselq
        // the interrrupt context of the processor.  Well, almost.  To
111
        // facilitate waits from supervisor mode, the wait instruction
112
        // explicitly forces the CPU into user mode.
113
        "WAIT", 0xffc7ffff, 0x70c00030, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
114 2 dgisselq
        //
115 69 dgisselq
        // "INT",       0xff10007f, 0x9e00005f, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
116 2 dgisselq
        // Return to user space
117 69 dgisselq
        "RTU",  0xffc7ffff, 0x70c00020, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
118 2 dgisselq
        // JMP (possibly a conditional jump, if not covered by branches above)
119 69 dgisselq
        // 0.1111.01111.ccc.a.rrrr.biiiiiiiiiiiiiiii
120
        // 0111.1011.11cc.c0rr.rrbi.iiii.iiii.iiii
121
        "JMP",  0xffc42000, 0x7bc00000, OPUNUSED,OPUNUSED, REGFIELD(14), IMMFIELD(13,0), BITFIELD(3,19),
122
        "JMP",  0xffc42000, 0x7bc02000, OPUNUSED,OPUNUSED, URGFIELD(14), IMMFIELD(13,0), BITFIELD(3,19),
123
        // 0.1111.1001.ii.iiii.iiii.iiii.iiii.iiii.iiii
124
        // 0111.1100.1iii.iiii.iiii.iiii.iiii.iiii
125
        "JMP",  0xff800000, 0x7c800000, REGFIELD(27),OPUNUSED, OPUNUSED, IMMFIELD(23,0), OPUNUSED,
126
        // 0.1111.00010.ccc0.iiiii.iiii.iiii.iiii.iiii
127
        // 0111.1000.10cc.c0ii.iiii.iiii.iiii.iiii
128
        "LJMP", 0xffc40000, 0x78800000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
129
        // 0.1111.10010.000.1.1111.000000000000000
130
        // 0111.1100.10cc.c111.11ii.iiii.iiii.iiii
131
        "FJMP", 0xffc7ffff, 0x7c87c000, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
132
        // NOT : XOR w/ -1
133
        //      0.rrrr.00100.ccc.0111.11111111111
134
        //      0rrr.r001.00cc.c011.f.f.f.f
135
        "NOT",  0x87c7ffff, 0x0103ffff, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
136 2 dgisselq
        // General instructions
137 69 dgisselq
        // 0rrr.rooo.oocc.cxrr.rrii.iiii.iiii.iiii
138
        "SUB",  0x87c40000, 0x00000000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
139
        "SUB",  0x87c40000, 0x00040000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
140
        //
141
        "AND",  0x87c40000, 0x00400000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
142
        "AND",  0x87c40000, 0x00440000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
143
        //
144
        "ADD",  0x87c40000, 0x00800000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
145
        "ADD",  0x87c40000, 0x00840000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
146
        //
147
        "OR",   0x87c40000, 0x00c00000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
148
        "OR",   0x87c40000, 0x00c40000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
149
        //
150
        "XOR",  0x87c40000, 0x01000000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
151
        "XOR",  0x87c40000, 0x01040000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
152
        //
153
        "LSR",  0x87c40000, 0x01400000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
154
        "LSR",  0x87c40000, 0x01440000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
155
        //
156
        "LSL",  0x87c40000, 0x01800000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
157
        "LSL",  0x87c40000, 0x01840000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
158
        //
159
        "ASR",  0x87c40000, 0x01c00000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
160
        "ASR",  0x87c40000, 0x01c40000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
161
        //
162
        "LDIHI",0x87c40000, 0x02000000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
163
        "LDIHI",0x87c40000, 0x02040000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
164
        //
165
        "LDILO",0x87c40000, 0x02400000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
166
        "LDILO",0x87c40000, 0x02440000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
167
        //
168
        "MPYU", 0x87c40000, 0x02800000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
169
        "MPYU", 0x87c40000, 0x02840000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
170
        //
171
        "MPYS", 0x87c40000, 0x02c00000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
172
        "MPYS", 0x87c40000, 0x02c40000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
173
        //
174
        "BREV", 0x87c40000, 0x03000000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
175
        "BREV", 0x87c40000, 0x03040000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
176
        //
177
        "POPC", 0x87c40000, 0x03400000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
178
        "POPC", 0x87c40000, 0x03440000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
179
        //
180
        "ROL",  0x87c40000, 0x03800000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
181
        "ROL",  0x87c40000, 0x03840000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
182
        //
183 2 dgisselq
        // map bit = 1 (interrupts enabled) specifies user reg
184 69 dgisselq
        // 0rrr.rooo.oocc.cxrr.rrxi.iiii.iiii.iiii
185
        "MOV",  0x87c42000, 0x03c00000, REGFIELD(27),OPUNUSED, REGFIELD(14), IMMFIELD(13,0), BITFIELD(3,19),
186
        "MOV",  0x87c42000, 0x03c40000, URGFIELD(27),OPUNUSED, REGFIELD(14), IMMFIELD(13,0), BITFIELD(3,19),
187
        "MOV",  0x87c42000, 0x03c02000, REGFIELD(27),OPUNUSED, URGFIELD(14), IMMFIELD(13,0), BITFIELD(3,19),
188
        "MOV",  0x87c42000, 0x03c42000, URGFIELD(27),OPUNUSED, URGFIELD(14), IMMFIELD(13,0), BITFIELD(3,19),
189 2 dgisselq
        //
190 69 dgisselq
        "CMP",  0x87c40000, 0x04000000, OPUNUSED, REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
191
        "CMP",  0x87c40000, 0x04040000, OPUNUSED, REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
192
        "TST",  0x87c40000, 0x04400000, OPUNUSED, REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
193
        "TST",  0x87c40000, 0x04440000, OPUNUSED, REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
194
        // 0rrr.r101.1
195
        "LDI",  0x87800000, 0x05800000, REGFIELD(27),OPUNUSED, OPUNUSED, IMMFIELD(23,0), OPUNUSED,
196 2 dgisselq
        //
197 69 dgisselq
        "NOOP",  0xffffffff, 0x76000000, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED,
198
        "BRK",   0xffffffff, 0x76400000, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED,
199
        "LOCK",  0xffffffff, 0x76800000, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED,
200 2 dgisselq
        //
201
        //
202 69 dgisselq
        // LOD: 0rrr.r100.10cc.cxrr.rrii.iiii.iiii.iiii
203
        "LOD",  0x87c40000, 0x04800000, REGFIELD(27), OPUNUSED, OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
204
        "LOD",  0x87c40000, 0x04840000, REGFIELD(27), OPUNUSED, REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
205 8 dgisselq
        //
206 69 dgisselq
        "STO",  0x87c40000, 0x04c00000, OPUNUSED, REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
207
        "STO",  0x87c40000, 0x04c40000, OPUNUSED, REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
208 8 dgisselq
        //
209 69 dgisselq
        // 0rrr.r101.1dcc.cxrr.rrii.iiii.iiii.iiii
210
        "DIVU", 0x87c40000, 0x05000000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
211
        "DIVU", 0x87c40000, 0x05040000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
212
        "DIVS", 0x87c40000, 0x05400000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
213
        "DIVS", 0x87c40000, 0x05440000, REGFIELD(27), REGFIELD(27), REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
214 2 dgisselq
        //
215 69 dgisselq
        // 0rrr.r11f.ffcc.cxrr.rrii.iiii.iiii.iiii
216
        "FPADD",0x87c43fff, 0x06040000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(3,19),
217
        "FPSUB",0x87c43fff, 0x06440000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(3,19),
218
        "FPMPY",0x87c43fff, 0x06840000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(3,19),
219
        "FPDIV",0x87c43fff, 0x06c40000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(3,19),
220
        "FPCVT",0x87c40000, 0x07000000, REGFIELD(27), OPUNUSED, OPUNUSED, IMMFIELD(18,0), BITFIELD(3,19),
221
        "FPCVT",0x87c40000, 0x07040000, REGFIELD(27), OPUNUSED, REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
222
        "FPINT",0x87c40000, 0x07440000, REGFIELD(27), OPUNUSED, REGFIELD(14), IMMFIELD(14,0), BITFIELD(3,19),
223 2 dgisselq
        //
224
        //
225
        //
226
        //
227
        //
228 69 dgisselq
        //      16-bit instructions, high side
229 2 dgisselq
        //
230 69 dgisselq
        // LDI  1.rrrr.1001x.ccc.iiiii  -> 1rrr r100 1xcc ciii ii
231
        "CLR",  0x87c7c000, 0x84800000, REGFIELD(27),OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED,
232
        // JMP  1.1111.01111.ccc.1rrrr  -> 1111 1011 11cc c1rr rr
233
        "JMP",  0xffc40000, 0xfbc40000, REGFIELD(27),OPUNUSED, REGFIELD(14), OPUNUSED, BITFIELD(2,19),
234
        // XOR  1.rrrr.00100.ccc.01111  -> 1rrr r001 00cc c011 11
235
        "NOT",  0x87c7c000, 0x8103c000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(2,19),
236
        // General instructions, top half
237
        // 1rrr.rooo.oocc.cxrr.rr
238
        "SUB",  0x87c40000, 0x80000000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
239
        "SUB",  0x87c40000, 0x80040000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
240 2 dgisselq
        //
241 69 dgisselq
        "AND",  0x87c40000, 0x80400000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
242
        "AND",  0x87c40000, 0x80440000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
243 2 dgisselq
        //
244 69 dgisselq
        "ADD",  0x87c40000, 0x80800000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
245
        "ADD",  0x87c40000, 0x80840000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
246
        //
247
        "OR",   0x87c40000, 0x80c00000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
248
        "OR",   0x87c40000, 0x80c40000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
249
        //
250
        "XOR",  0x87c40000, 0x81000000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
251
        "XOR",  0x87c40000, 0x81040000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
252
        //
253
        "LSR",  0x87c40000, 0x81400000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
254
        "LSR",  0x87c40000, 0x81440000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
255
        //
256
        "LSL",  0x87c40000, 0x81800000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
257
        "LSL",  0x87c40000, 0x81840000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
258
        //
259
        "ASR",  0x87c40000, 0x81c00000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
260
        "ASR",  0x87c40000, 0x81c40000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
261
        //
262
        "LDIHI",0x87c40000, 0x82000000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(5,14), BITFIELD(2,19),
263
        "LDILO",0x87c40000, 0x82400000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(5,14), BITFIELD(2,19),
264
        //
265
        "MPYU", 0x87c40000, 0x82800000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
266
        "MPYU", 0x87c40000, 0x82840000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
267
        //
268
        "MPYS", 0x87c40000, 0x82c00000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
269
        "MPYS", 0x87c40000, 0x82c40000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
270
        //
271
        "BREV", 0x87c40000, 0x83000000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
272
        "BREV", 0x87c40000, 0x83040000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
273
        //
274
        "POPC", 0x87c40000, 0x83400000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
275
        "POPC", 0x87c40000, 0x83440000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
276
        //
277
        "ROL",  0x87c40000, 0x83800000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
278
        "ROL",  0x87c40000, 0x83840000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
279
        //
280
        "MOV",  0x87c40000, 0x83c40000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
281
        //
282
        "CMP",  0x87c40000, 0x84000000, OPUNUSED, REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
283
        "CMP",  0x87c40000, 0x84040000, OPUNUSED, REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
284
        //
285
        "TST",  0x87c40000, 0x84400000, OPUNUSED, REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
286
        "TST",  0x87c40000, 0x84440000, OPUNUSED, REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
287
        //
288
        "LOD",  0x87c40000, 0x84840000, REGFIELD(27), OPUNUSED, REGFIELD(14), OPUNUSED, BITFIELD(2,19),
289
        //
290
        "STO",  0x87c40000, 0x84c40000, REGFIELD(27), OPUNUSED, REGFIELD(14), OPUNUSED, BITFIELD(2,19),
291
        //
292
        "DIVU", 0x87c40000, 0x85000000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
293
        "DIVU", 0x87c40000, 0x85040000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
294
        //
295
        "DIVS", 0x87c40000, 0x85400000, REGFIELD(27), REGFIELD(27), OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
296
        "DIVS", 0x87c40000, 0x85440000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
297
        //
298
        "LDI",  0x87c40000, 0x85800000, REGFIELD(27), OPUNUSED, OPUNUSED, IMMFIELD(5,14), BITFIELD(2,19),
299
        //
300
        "NOOP", 0xf7c00000, 0xf6000000, REGFIELD(27), OPUNUSED, OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
301
        //
302
        "BRK",  0xf7c00000, 0xf6400000, REGFIELD(27), OPUNUSED, OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
303
        //
304
        "LOCK", 0xf7c00000, 0xf6800000, REGFIELD(27), OPUNUSED, OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
305
        //
306
        //
307
        "FPADD",0x87c40000, 0x86040000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
308
        //
309
        "FPSUB",0x87c40000, 0x86440000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
310
        //
311
        "FPMUL",0x87c40000, 0x86840000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
312
        //
313
        "FPDIV",0x87c40000, 0x86c40000, REGFIELD(27), REGFIELD(27), REGFIELD(14), OPUNUSED, BITFIELD(2,19),
314
        //
315
        "FPCVT",0x87c40000, 0x87000000, REGFIELD(27), OPUNUSED, OPUNUSED, IMMFIELD(4,14), BITFIELD(2,19),
316
        "FPCVT",0x87c40000, 0x87040000, REGFIELD(27), OPUNUSED, REGFIELD(14), OPUNUSED, BITFIELD(2,19),
317
        //
318
        "FPINT",0x87c40000, 0x87440000, REGFIELD(27), OPUNUSED, REGFIELD(14), OPUNUSED, BITFIELD(2,19),
319
        //
320
        //
321 2 dgisselq
        // Illegal instruction !!
322
        "ILL",  0x00000000, 0x00000000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(32,0), OPUNUSED
323
};
324
 
325 69 dgisselq
const ZOPCODE   zbottomlist[] = {
326
        //
327
        //
328
        //
329
        //      16-bit instructions, low side ... treat these as special
330
        //
331
        //
332
        // Special case instructions.  These are general instructions, but with
333
        // special opcodes
334
        // Conditional branches
335
        //      0.1111.0111.ccc.0.111.10iiiii--
336
        //      0111 1011 11cc c011 110i iiii iiii iiii
337
        // "BRA",  0xffffe000, 0x7bc3c000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
338
        // "BLT",  0xffffe000, 0x7bcbc000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
339
        // "BRZ",  0xffffe000, 0x7bd3c000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
340
        // "BNZ",  0xffffe000, 0x7bdbc000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
341
        // "BGE",  0xffffe000, 0x7be3c000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
342
        // "BGT",  0xffffe000, 0x7bebc000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
343
        // "BRC",  0xffffe000, 0x7bf3c000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
344
        // "BRV",  0xffffe000, 0x7bfbc000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(13,0), OPUNUSED,
345
        //
346
        //
347
        // CLRF ... an XOR w/ self instruction
348
        //      0.rrrr.00100.ccc.1.rrrr.iiiii---
349
        //      0rrr r001 00cc c1rr rr00 0000 0000 0000
350
        // "CLRF",      0xffc7cfff, 0x7907c000, REGFIELD(27), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(3,19),
351
        // CLR -- a LDI of zero
352
        // LDI  1xxx.xxxx.xxxx.xxxx.xxrr.rroo.ooo.iiiii -> 1rrr r100 1xcc ciii ii
353
        "CLR",  0x800003ff, 0x80000000, REGFIELD(12),OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED,
354
        // JMP  1xxx -- xx11.1101.1111.rrrr
355
        "JMP",  0x80203ff0, 0x80003df0, REGFIELD(12),OPUNUSED, REGFIELD(0), OPUNUSED, OPUNUSED,
356
        "JMP",  0x80203ff0, 0x80203df0, REGFIELD(12),OPUNUSED, REGFIELD(0), OPUNUSED, BITFIELD(2,19),
357
        //
358
        // XOR  1xxx -- xx00.1000.1111  -> 1rrr r001 00cc c011 11
359
        "NOT",  0x802003ff, 0x80000080, REGFIELD(12), OPUNUSED, OPUNUSED, OPUNUSED, OPUNUSED,
360
        "NOT",  0x802003ff, 0x80200080, REGFIELD(12), OPUNUSED, OPUNUSED, OPUNUSED, BITFIELD(2,19),
361
        // General instructions, bottom half
362
        // 1xxx -- xxrr.rroo.ooox.rrrr
363
        "SUB",  0x800003f0, 0x80000000, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
364
        "SUB",  0x802003f0, 0x80200000, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
365
        "SUB",  0x800003f0, 0x80000010, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
366
        "SUB",  0x802003f0, 0x80200010, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
367
        //
368
        "AND",  0x800003f0, 0x80000020, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
369
        "AND",  0x802003f0, 0x80200020, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
370
        "AND",  0x800003f0, 0x80000030, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
371
        "AND",  0x802003f0, 0x80200030, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
372
        //
373
        "ADD",  0x800003f0, 0x80000040, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
374
        "ADD",  0x802003f0, 0x80200040, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
375
        "ADD",  0x800003f0, 0x80000050, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
376
        "ADD",  0x802003f0, 0x80200050, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
377
        //
378
        "OR",   0x800003f0, 0x80000060, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
379
        "OR",   0x802003f0, 0x80200060, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
380
        "OR",   0x800003f0, 0x80000070, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
381
        "OR",   0x802003f0, 0x80200070, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
382
        //
383
        "XOR",  0x800003f0, 0x80000080, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
384
        "XOR",  0x802003f0, 0x80200080, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
385
        "XOR",  0x800003f0, 0x80000090, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
386
        "XOR",  0x802003f0, 0x80200090, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
387
        //
388
        "LSR",  0x800003f0, 0x800000a0, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
389
        "LSR",  0x802003f0, 0x802000a0, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
390
        "LSR",  0x800003f0, 0x800000b0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
391
        "LSR",  0x802003f0, 0x802000b0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
392
        //
393
        "LSL",  0x800003f0, 0x800000c0, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
394
        "LSL",  0x802003f0, 0x802000c0, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
395
        "LSL",  0x800003f0, 0x800000d0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
396
        "LSL",  0x802003f0, 0x802000d0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
397
        //
398
        "ASR",  0x800003f0, 0x800000e0, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
399
        "ASR",  0x802003f0, 0x802000e0, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
400
        "ASR",  0x800003f0, 0x800000f0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
401
        "ASR",  0x802003f0, 0x802000f0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
402
        //
403
        "LDIHI",0x800003e0, 0x80000100, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(5,0), BITFIELD(2,19),
404
        "LDIHI",0x802003e0, 0x80200100, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(5,0), OPUNUSED,
405
        //
406
        "LDILO",0x800003e0, 0x80000120, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(5,0), BITFIELD(2,19),
407
        "LDILO",0x802003e0, 0x80200120, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(5,0), OPUNUSED,
408
        //
409
        //
410
        "MPYU", 0x800003f0, 0x80000140, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
411
        "MPYU", 0x802003f0, 0x80200140, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
412
        "MPYU", 0x800003f0, 0x80000150, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
413
        "MPYU", 0x802003f0, 0x80200150, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
414
        //
415
        "MPYS", 0x800003f0, 0x80000160, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
416
        "MPYS", 0x802003f0, 0x80200160, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
417
        "MPYS", 0x800003f0, 0x80000170, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
418
        "MPYS", 0x802003f0, 0x80200170, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
419
        //
420
        "BREV", 0x800003f0, 0x80000180, REGFIELD(12), OPUNUSED, OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
421
        "BREV", 0x802003f0, 0x80200180, REGFIELD(12), OPUNUSED, OPUNUSED, IMMFIELD(4,0), OPUNUSED,
422
        "BREV", 0x800003f0, 0x80000190, REGFIELD(12), OPUNUSED, REGFIELD(0), OPUNUSED, BITFIELD(2,19),
423
        "BREV", 0x802003f0, 0x80200190, REGFIELD(12), OPUNUSED, REGFIELD(0), OPUNUSED, OPUNUSED,
424
        //
425
        "POPC", 0x800003f0, 0x800001a0, REGFIELD(12), OPUNUSED, OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
426
        "POPC", 0x802003f0, 0x802001a0, REGFIELD(12), OPUNUSED, OPUNUSED, IMMFIELD(4,0), OPUNUSED,
427
        "POPC", 0x800003f0, 0x800001b0, REGFIELD(12), OPUNUSED, REGFIELD(0), OPUNUSED, BITFIELD(2,19),
428
        "POPC", 0x802003f0, 0x802001b0, REGFIELD(12), OPUNUSED, REGFIELD(0), OPUNUSED, OPUNUSED,
429
        //
430
        "ROL",  0x800003f0, 0x800001c0, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
431
        "ROL",  0x802003f0, 0x802001c0, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
432
        "ROL",  0x800003f0, 0x800001d0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
433
        "ROL",  0x802003f0, 0x802001d0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
434
        //
435
        "MOV",  0x800003f0, 0x800001f0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
436
        "MOV",  0x802003f0, 0x802001f0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
437
        //
438
        "CMP",  0x800003f0, 0x80000200, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
439
        "CMP",  0x802003f0, 0x80200200, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
440
        "CMP",  0x800003f0, 0x80000210, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
441
        "CMP",  0x802003f0, 0x80200210, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
442
        //
443
        "TST",  0x800003f0, 0x80000220, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
444
        "TST",  0x802003f0, 0x80200220, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
445
        "TST",  0x800003f0, 0x80000230, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
446
        "TST",  0x802003f0, 0x80200230, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
447
        //
448
        "LOD",  0x800003f0, 0x80000250, REGFIELD(12), OPUNUSED, REGFIELD(0), OPUNUSED, BITFIELD(2,19),
449
        "LOD",  0x802003f0, 0x80200250, REGFIELD(12), OPUNUSED, REGFIELD(0), OPUNUSED, OPUNUSED,
450
        //
451
        "STO",  0x800003f0, 0x80000270, OPUNUSED, REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
452
        "STO",  0x802003f0, 0x80200270, OPUNUSED, REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
453
        //
454
        "DIVU", 0x800003f0, 0x80000280, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
455
        "DIVU", 0x802003f0, 0x80200280, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
456
        "DIVU", 0x800003f0, 0x80000290, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
457
        "DIVU", 0x802003f0, 0x80200290, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
458
        //
459
        "DIVS", 0x800003f0, 0x800002a0, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
460
        "DIVS", 0x802003f0, 0x802002a0, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
461
        "DIVS", 0x800003f0, 0x800002b0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
462
        "DIVS", 0x802003f0, 0x802002b0, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
463
        //
464
        "LDI",  0x802003d0, 0x800002c0, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
465
        //
466
        "NOOP", 0x80003bf0, 0x80003b00, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
467
        //
468
        "BRK",  0x80003bf0, 0x80003b20, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
469
        //
470
        "LOCK", 0x80003bf0, 0x80003b40, REGFIELD(12), REGFIELD(12), OPUNUSED, IMMFIELD(4,0), OPUNUSED,
471
        //
472
        // FPU instructions
473
        //
474
        "FPADD",0x802003f0, 0x80000310, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
475
        "FPADD",0x802003f0, 0x80200310, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
476
        //
477
        "FPSUB",0x802003f0, 0x80000330, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
478
        "FPSUB",0x802003f0, 0x80200330, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
479
        //
480
        "FPMUL",0x802003f0, 0x80000350, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
481
        "FPMUL",0x802003f0, 0x80200350, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
482
        //
483
        "FPDIV",0x802003f0, 0x80000370, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, OPUNUSED,
484
        "FPDIV",0x802003f0, 0x80200370, REGFIELD(12), REGFIELD(12), REGFIELD(0), OPUNUSED, BITFIELD(2,19),
485
        // Convert to floating point
486
        "FPCVT",0x802003f0, 0x80000380, REGFIELD(12), OPUNUSED, OPUNUSED, IMMFIELD(4,0), OPUNUSED,
487
        "FPCVT",0x802003f0, 0x80200380, REGFIELD(12), OPUNUSED, OPUNUSED, IMMFIELD(4,0), BITFIELD(2,19),
488
        "FPCVT",0x802003f0, 0x80000390, REGFIELD(12), OPUNUSED, REGFIELD(0), OPUNUSED, OPUNUSED,
489
        "FPCVT",0x802003f0, 0x80200390, REGFIELD(12), OPUNUSED, REGFIELD(0), OPUNUSED, BITFIELD(2,19),
490
        // Convert to integer
491
        "FPINT",0x802003f0, 0x800003b0, REGFIELD(12), OPUNUSED, REGFIELD(0), OPUNUSED, OPUNUSED,
492
        "FPINT",0x802003f0, 0x802003b0, REGFIELD(12), OPUNUSED, REGFIELD(0), OPUNUSED, BITFIELD(2,19),
493
        //
494
        //
495
        // Illegal instruction !!
496
        "ILL",  0x00000000, 0x00000000, OPUNUSED, OPUNUSED, OPUNUSED, IMMFIELD(32,0), OPUNUSED
497
};
498
 
499
 
500 2 dgisselq
const int       nzoplist = (sizeof(zoplist)/sizeof(ZOPCODE));
501 69 dgisselq
const int       nzopbottom = (sizeof(zbottomlist)/sizeof(ZOPCODE));
502 2 dgisselq
 
503
static  int     getbits(const ZIPI ins, const int which) {
504
        if (which & 0x40000000) {
505
                // printf("SBITS: %08x, %08x = %08lx\n", ins, which,
506
                        // sbits(ins>>(which & 0x03f), (which>>8)&0x03f));
507
                return sbits(ins>>(which & 0x03f), (which>>8)&0x03f);
508 70 dgisselq
        } else { // if (which &0x03f)
509 2 dgisselq
                return ubits(ins>>(which & 0x03f), (which>>8)&0x03f)
510
                        + ((which>>16)&0x0ff);
511 70 dgisselq
        // } else {
512
                // fprintf(stderr, "Returning an uncoded %08x\n", which);
513
                // return which;
514
        }
515 2 dgisselq
}
516
 
517 70 dgisselq
static  void static_zipi_to_string(const ZIPI ins, char *line, const ZOPCODE *listp) {
518 2 dgisselq
        for(int i=0; i<nzoplist; i++) {
519 69 dgisselq
                if (((~zoplist[i].s_mask)&zoplist[i].s_val)!=0) {
520
                        printf("Instruction %d, %s, fails consistency check\n",
521
                                i, zoplist[i].s_opstr);
522
                        assert(((~zoplist[i].s_mask)&zoplist[i].s_val)==0);
523
                }
524 70 dgisselq
        } line[0] = '\0';
525
        for(int i=0; (listp[i].s_mask != 0); i++) {
526 2 dgisselq
                // printf("%2d: %6s %08x & %08x == %08x\n",
527
                        // i, zoplist[i].s_opstr, ins,
528
                        // zoplist[i].s_mask, zoplist[i].s_val);
529 70 dgisselq
                if ((ins & listp[i].s_mask) == listp[i].s_val) {
530
                        sprintf(line, "%s", listp[i].s_opstr);
531
                        if (listp[i].s_cf != OPUNUSED) {
532
                                int bv = getbits(ins, listp[i].s_cf);
533 2 dgisselq
                                strcat(line, zop_ccstr[bv]);
534 70 dgisselq
                        } sprintf(line, "%-11s", line);
535 2 dgisselq
 
536
                        // Treat stores special
537 70 dgisselq
                        if (strncasecmp("STO",listp[i].s_opstr, 3)==0) {
538
                                int ra = getbits(ins, listp[i].s_ra);
539 2 dgisselq
                                strcat(line, zop_regstr[ra]);
540
                                strcat(line, ",");
541
 
542 70 dgisselq
                                if (listp[i].s_i != OPUNUSED) {
543 2 dgisselq
                                        int     imv = 0;
544 70 dgisselq
                                        imv = getbits(ins, listp[i].s_i);
545
                                        if ((imv != 0)&&(listp[i].s_rb != OPUNUSED))
546 2 dgisselq
                                                sprintf(&line[strlen(line)],
547
                                                        "$%d", imv);
548
                                        else if (imv != 0)
549
                                                sprintf(&line[strlen(line)],
550
                                                        "($%d)", imv);
551 70 dgisselq
                                } if (listp[i].s_rb != OPUNUSED) {
552
                                        int rb = getbits(ins, listp[i].s_rb);
553 2 dgisselq
                                        sprintf(&line[strlen(line)],
554
                                                "(%s)", zop_regstr[rb]);
555
                                }
556
 
557
                        } else {
558
                                bool memop = (strncasecmp("LOD",
559 70 dgisselq
                                                listp[i].s_opstr, 3)==0);
560
                                if (listp[i].s_i != OPUNUSED) {
561 2 dgisselq
                                        int     imv = 0;
562 70 dgisselq
 
563
                                        imv = getbits(ins, listp[i].s_i);
564
                                        if ((imv != 0)||(listp[i].s_rb == OPUNUSED))
565 2 dgisselq
                                                sprintf(&line[strlen(line)],
566
                                                        "$%d%s", imv,
567 70 dgisselq
                                                        ((!memop)&&(listp[i].s_rb!=OPUNUSED))?"+":"");
568
                                } if (listp[i].s_rb != OPUNUSED) {
569
                                        int rb = getbits(ins, listp[i].s_rb);
570 2 dgisselq
                                        if (memop)
571
                                                sprintf(&line[strlen(line)],
572
                                                        "(%s)", zop_regstr[rb]);
573
                                        else
574
                                                strcat(line, zop_regstr[rb]);
575 70 dgisselq
                                } if(((listp[i].s_i != OPUNUSED)||(listp[i].s_rb != OPUNUSED))
576
                                        &&((listp[i].s_ra != OPUNUSED)||(listp[i].s_result != OPUNUSED)))
577 2 dgisselq
                                        strcat(line, ",");
578
 
579 70 dgisselq
                                if (listp[i].s_ra != OPUNUSED) {
580
                                        int ra = getbits(ins, listp[i].s_ra);
581 2 dgisselq
                                        strcat(line, zop_regstr[ra]);
582 70 dgisselq
                                } else if (listp[i].s_result != OPUNUSED) {
583
                                        int ra = getbits(ins, listp[i].s_result);
584 2 dgisselq
                                        strcat(line, zop_regstr[ra]);
585
                                }
586
 
587
                        }
588
                        break;
589
                }
590 70 dgisselq
        } if (line[0] == '\0') {
591
                sprintf(line, "ILL %08x", ins);
592 2 dgisselq
        }
593
}
594
 
595 70 dgisselq
void    zipi_to_string(const ZIPI ins, char *la, char *lb) {
596
        static_zipi_to_string(ins, la, zoplist);
597
        if (lb) {
598
                if (ins & 0x80000000) {
599
                        static_zipi_to_string(ins, lb, zbottomlist);
600
                } else lb[0] = '\0';
601
        }
602
}
603
 
604
unsigned int    zop_early_branch(const unsigned int pc, const ZIPI ins) {
605
        if ((ins & 0xf8000000) != 0x78000000)
606
                return pc+1;
607
        if ((ins & 0x07c00000) == 0x05800000) // LDI, high bit clear
608
                return (ins & 0x003fffff);
609
        if ((ins & 0x07c00000) == 0x05c00000) // LDI, high bit set
610
                return (ins & 0x007fffff)|0xffc00000;
611
        if ((ins & 0xffffe000) == 0x7bc3c000) // MOV
612
                return ((ins & 0x001fff)|((ins&0x01000)?0xffffe000:0))+pc+1;
613
        if ((ins & 0x07fc0000) == 0x00800000) // ADD, unconditional
614
                return ((ins & 0x03ffff)|((ins&0x020000)?0xfffc0000:0))+pc+1;
615
        return pc+1;
616
}
617
 
618
 

powered by: WebSVN 2.1.0

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