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

Subversion Repositories scarm

[/] [scarm/] [trunk/] [src/] [Instructions/] [scARMInstruction.cpp] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 zhong
// scARMInstruction.cpp: implementation of the scARMInstruction class.
2
//
3
//////////////////////////////////////////////////////////////////////
4
 
5
#include "scARMInstruction.h"
6
#include "scException.h"
7
#include <stdio.h>
8
 
9
//////////////////////////////////////////////////////////////////////
10
// Construction/Destruction
11
//////////////////////////////////////////////////////////////////////
12
 
13
scARMInstruction::scARMInstruction()
14
{
15
 
16
}
17
 
18
scARMInstruction::~scARMInstruction()
19
{
20
 
21
}
22
 
23
 
24
 
25
scARMInstruction* scARMInstruction::Create(uint32_t nI)
26
{
27
    scARMInstruction* pI=NULL;
28
 
29
  /*
30
 
31
 
32
  if ((nI & BRANCH_MASK) == BRANCH_SIG)
33
    {
34
 
35
//      pI=scARM_Branch(nI);
36
          printf("create str\n");
37
    }
38
 
39
  else if ((i & SWI_MASK) == SWI_SIG)
40
    {
41
      decode_swi(i, str);
42
    }
43
  else if ((i & MULT_MASK) == MULT_SIG)
44
    {
45
      decode_mult(i, str);
46
    }
47
  else if ((i & DPI_MASK) == DPI_SIG)
48
    {
49
      decode_dpi(i, str);
50
    }
51
  else if ((i & SWT_MASK) == SWT_SIG)
52
    {
53
      decode_swt(i, str);
54
    }
55
#if 0
56
  else if ((i & HWT_MASK) == HWT_SIG)
57
    {
58
      decode_hwt(i, str);
59
    }
60
#endif
61
  else if ((i & MRT_MASK) == MRT_SIG)
62
    {
63
      decode_mrt(i, str);
64
    }
65
  return;
66
#if 0
67
 
68
  else if ((i & SWP_MASK) == SWP_SIG)
69
    {
70
      decode_swp(i, str);
71
    }
72
  else if ((i & MRS_MASK) == MRS_SIG)
73
    {
74
      decode_sgr(i, str);
75
    }
76
  else if ((i & MSR_MASK) == MSR_SIG)
77
    {
78
      decode_gsr(i, str);
79
    }
80
  else if ((i & CDO_MASK) == CDO_SIG)
81
    {
82
      decode_cdo(i, str);
83
    }
84
  else if ((i & CDT_MASK) == CDT_SIG)
85
    {
86
      decode_cdt(i, str);
87
    }
88
  else if ((i & CRT_MASK) == CRT_SIG)
89
    {
90
      decode_crt(i, str);
91
    }
92
  else if ((i & UAI_MASK) == UAI_SIG)
93
    {
94
      sprintf(str, "Unused arithmetic op\n");
95
    }
96
  else if ((i & UCI1_MASK) == UCI1_SIG)
97
    {
98
      sprintf(str, "Unused control 1\n");
99
    }
100
  else if ((i & UCI2_MASK) == UCI2_SIG)
101
    {
102
      sprintf(str, "Unused control 2\n");
103
    }
104
  else if ((i & UCI3_MASK) == UCI3_SIG)
105
    {
106
      sprintf(str, "Unused control 3\n");
107
    }
108
  else if ((i & ULSI_MASK) == ULSI_SIG)
109
    {
110
      sprintf(str, "Unused load/store\n");
111
    }
112
  else if ((i & UCPI_MASK) == UCPI_SIG)
113
    {
114
      sprintf(str, "Unused CoPro\n");
115
    }
116
  else if ((i & UNDEF_MASK) == UNDEF_SIG)
117
    {
118
      sprintf(str, "Undefined\n");
119
    }
120
  else
121
    {
122
      sprintf(str, "Rubbish");
123
    }
124
#endif
125
        */
126
     return pI;
127
}
128
 
129
void scARMInstruction::Decode(uint32_t inst)
130
{
131
  uint32_t i = inst;
132
/*
133
  if (str == NULL)
134
    {
135
      throw scException();
136
    }
137
 
138
  if ((i & BRANCH_MASK) == BRANCH_SIG)
139
    {
140
      decode_branch(i, str);
141
    }
142
  else if ((i & SWI_MASK) == SWI_SIG)
143
    {
144
      decode_swi(i, str);
145
    }
146
  else if ((i & MULT_MASK) == MULT_SIG)
147
    {
148
      decode_mult(i, str);
149
    }
150
  else if ((i & DPI_MASK) == DPI_SIG)
151
    {
152
      decode_dpi(i, str);
153
    }
154
  else if ((i & SWT_MASK) == SWT_SIG)
155
    {
156
      decode_swt(i, str);
157
    }
158
#if 0
159
  else if ((i & HWT_MASK) == HWT_SIG)
160
    {
161
      decode_hwt(i, str);
162
    }
163
#endif
164
  else if ((i & MRT_MASK) == MRT_SIG)
165
    {
166
      decode_mrt(i, str);
167
    }
168
  return;
169
#if 0
170
 
171
  else if ((i & SWP_MASK) == SWP_SIG)
172
    {
173
      decode_swp(i, str);
174
    }
175
  else if ((i & MRS_MASK) == MRS_SIG)
176
    {
177
      decode_sgr(i, str);
178
    }
179
  else if ((i & MSR_MASK) == MSR_SIG)
180
    {
181
      decode_gsr(i, str);
182
    }
183
  else if ((i & CDO_MASK) == CDO_SIG)
184
    {
185
      decode_cdo(i, str);
186
    }
187
  else if ((i & CDT_MASK) == CDT_SIG)
188
    {
189
      decode_cdt(i, str);
190
    }
191
  else if ((i & CRT_MASK) == CRT_SIG)
192
    {
193
      decode_crt(i, str);
194
    }
195
  else if ((i & UAI_MASK) == UAI_SIG)
196
    {
197
      sprintf(str, "Unused arithmetic op\n");
198
    }
199
  else if ((i & UCI1_MASK) == UCI1_SIG)
200
    {
201
      sprintf(str, "Unused control 1\n");
202
    }
203
  else if ((i & UCI2_MASK) == UCI2_SIG)
204
    {
205
      sprintf(str, "Unused control 2\n");
206
    }
207
  else if ((i & UCI3_MASK) == UCI3_SIG)
208
    {
209
      sprintf(str, "Unused control 3\n");
210
    }
211
  else if ((i & ULSI_MASK) == ULSI_SIG)
212
    {
213
      sprintf(str, "Unused load/store\n");
214
    }
215
  else if ((i & UCPI_MASK) == UCPI_SIG)
216
    {
217
      sprintf(str, "Unused CoPro\n");
218
    }
219
  else if ((i & UNDEF_MASK) == UNDEF_SIG)
220
    {
221
      sprintf(str, "Undefined\n");
222
    }
223
  else
224
    {
225
      sprintf(str, "Rubbish");
226
    }
227
#endif
228
        */
229
}
230
/*
231
enum COND {C_EQ = 0x0, C_NE = 0x1, C_CS = 0x2, C_CC = 0x3,
232
           C_MI = 0x4, C_PL = 0x5, C_VS = 0x6, C_VC = 0x7,
233
           C_HI = 0x8, C_LS = 0x9, C_GE = 0xA, C_LT = 0xB,
234
           C_GT = 0xC, C_LE = 0xD, C_AL = 0xE, C_NV = 0xF};
235
*/
236
COND scARMInstruction::get_cond(uint32_t nI)
237
{
238
        uint32_t nCOND=nI>>27;
239
        COND c;
240
        switch(nCOND)
241
    {
242
        case 0x00: { c=C_EQ; break;}
243
        case 0x01: { c=C_NE; break;}
244
        case 0x02: { c=C_CS; break;}
245
        case 0x03: { c=C_CC; break;}
246
        case 0x04: { c=C_MI; break;}
247
        case 0x05: { c=C_PL; break;}
248
        case 0x06: { c=C_VS; break;}
249
        case 0x07: { c=C_VC; break;}
250
        case 0x08: { c=C_HI; break;}
251
        case 0x09: { c=C_LS; break;}
252
        case 0x0a: { c=C_GE; break;}
253
        case 0x0b: { c=C_LT; break;}
254
        case 0x0c: { c=C_GT; break;}
255
        case 0x0d: { c=C_LE; break;}
256
        case 0x0e: { c=C_AL; break;}
257
        case 0x0f: { c=C_NV; break;}
258
        }
259
 
260
        return c;
261
}

powered by: WebSVN 2.1.0

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