Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(804)

Side by Side Diff: opcodes/xgate-dis.c

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « opcodes/v850-opc.c ('k') | opcodes/xgate-opc.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* xgate-dis.c -- Freescale XGATE disassembly 1 /* xgate-dis.c -- Freescale XGATE disassembly
2 Copyright 2009, 2010, 2011, 2012 2 Copyright 2009, 2010, 2011, 2012
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 Written by Sean Keys (skeys@ipdatasys.com) 4 Written by Sean Keys (skeys@ipdatasys.com)
5 5
6 This file is part of the GNU opcodes library. 6 This file is part of the GNU opcodes library.
7 7
8 This library is free software; you can redistribute it and/or modify 8 This library is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option) 10 the Free Software Foundation; either version 3, or (at your option)
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 raw_code <<= 8; 117 raw_code <<= 8;
118 raw_code += buffer[1]; 118 raw_code += buffer[1];
119 119
120 decodePTR = find_match (raw_code); 120 decodePTR = find_match (raw_code);
121 if (decodePTR) 121 if (decodePTR)
122 { 122 {
123 operMaskReg = decodePTR->operMasksRegisterBits; 123 operMaskReg = decodePTR->operMasksRegisterBits;
124 (*info->fprintf_func)(info->stream, "%s", decodePTR->opcodePTR->name); 124 (*info->fprintf_func)(info->stream, "%s", decodePTR->opcodePTR->name);
125 125
126 /* First we compare the shorthand format of the constraints. If we 126 /* First we compare the shorthand format of the constraints. If we
127 » still are unable to pinpoint the operands 127 » still are unable to pinpoint the operands
128 » we analyze the opcodes constraint string. */ 128 » we analyze the opcodes constraint string. */
129 switch (decodePTR->opcodePTR->sh_format) 129 if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_MON_R_C))
130 { 130 » {
131 case XG_R_C: 131 » (*info->fprintf_func)(info->stream, " R%x, CCR",
132 (*info->fprintf_func)(info->stream, " R%x, CCR", 132 » » (raw_code >> 8) & 0x7);
133 (raw_code >> 8) & 0x7); 133 » }
134 break; 134 else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_MON_C_R) )
135 case XG_C_R: 135 {
136 (*info->fprintf_func)(info->stream, " CCR, R%x", 136 » (*info->fprintf_func)(info->stream, " CCR, R%x",
137 (raw_code >> 8) & 0x7); 137 » (raw_code >> 8) & 0x7);
138 break; 138 }
139 case XG_R_P: 139 else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_MON_R_P) )
140 (*info->fprintf_func)(info->stream, " R%x, PC", 140 {
141 (raw_code >> 8) & 0x7); 141 » (*info->fprintf_func)(info->stream, " R%x, PC",
142 break; 142 » (raw_code >> 8) & 0x7);
143 case XG_INH: 143 }
144 break; 144 else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_TRI))
145 case XG_R_R_R: 145 {
146 if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_TRI)) 146 (*info->fprintf_func)(info->stream, " R%x, R%x, R%x",
147 { 147 (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7,
148 (*info->fprintf_func)(info->stream, " R%x, R%x, R%x", 148 (raw_code >> 2) & 0x7);
149 (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7, 149 }
150 (raw_code >> 2) & 0x7); 150 else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IDR))
151 } 151 {
152 else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IDR)) 152 if (raw_code & 0x01)
153 { 153 {
154 if (raw_code & 0x01) 154 (*info->fprintf_func)(info->stream, " R%x, (R%x, R%x+)",
155 { 155 (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7,
156 (*info->fprintf_func)(info->stream, " R%x, (R%x, R%x+)", 156 (raw_code >> 2) & 0x7);
157 (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7, 157 }
158 (raw_code >> 2) & 0x7); 158 else if (raw_code & 0x02)
159 } 159 {
160 else if (raw_code & 0x02) 160 (*info->fprintf_func)(info->stream, " R%x, (R%x, -R% x)",
161 { 161 (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7,
162 (*info->fprintf_func)(info->stream, " R%x, (R%x, -R%x)", 162 (raw_code >> 2) & 0x7);
163 (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7, 163 }
164 (raw_code >> 2) & 0x7); 164 else
165 } 165 {
166 else 166 (*info->fprintf_func)(info->stream, " R%x, (R%x, R%x)",
167 { 167 (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7,
168 (*info->fprintf_func)(info->stream, " R%x, (R%x, R%x)", 168 (raw_code >> 2) & 0x7);
169 (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7, 169 }
170 (raw_code >> 2) & 0x7); 170 }
171 } 171 else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_DYA))
172 } 172 {
173 else 173 » operandOne = ripBits (&operMaskReg, 3, opcodePTR, raw_code);
174 { 174 » operandTwo = ripBits (&operMaskReg, 3, opcodePTR, raw_code);
175 (*info->fprintf_func)(info->stream, " unhandled mode %s", 175 » ( *info->fprintf_func)(info->stream, " R%x, R%x", operandOne,
176 decodePTR->opcodePTR->constraints); 176 » operandTwo);
177 } 177 }
178 break; 178 else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IDO5))
179 case XG_R_R: 179 {
180 if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_DYA)) 180 » (*info->fprintf_func)(info->stream, " R%x, (R%x, #0x%x)",
181 { 181 » (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7, raw_code & 0 x1f);
182 operandOne = ripBits (&operMaskReg, 3, opcodePTR, raw_code); 182 }
183 operandTwo = ripBits (&operMaskReg, 3, opcodePTR, raw_code); 183 else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_MON))
184 (*info->fprintf_func)(info->stream, " R%x, R%x", operandOne, 184 {
185 operandTwo); 185 » operandOne = ripBits (&operMaskReg, 3, decodePTR->opcodePTR,
186 } 186 » raw_code);
187 else 187 » (*info->fprintf_func)(info->stream, " R%x", operandOne);
188 { 188 }
189 (*info->fprintf_func)(info->stream, " unhandled mode %s", 189 else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_REL9))
190 opcodePTR->constraints);
191 }
192 break;
193 case XG_R_R_I:
194 (*info->fprintf_func)(info->stream, " R%x, (R%x, #0x%x)",
195 (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7, raw_code & 0x1f);
196 break;
197 case XG_R:
198 operandOne = ripBits (&operMaskReg, 3, decodePTR->opcodePTR,
199 raw_code);
200 (*info->fprintf_func)(info->stream, " R%x", operandOne);
201 break;
202 case XG_I | XG_PCREL:
203 if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_REL9))
204 { 190 {
205 /* If address is negative handle it accordingly. */ 191 /* If address is negative handle it accordingly. */
206 if (raw_code & XGATE_NINE_SIGNBIT) 192 if (raw_code & XGATE_NINE_SIGNBIT)
207 { 193 {
208 relAddr = XGATE_NINE_BITS >> 1; /* Clip sign bit. */ 194 relAddr = XGATE_NINE_BITS >> 1; /* Clip sign bit. */
209 relAddr = ~relAddr; /* Make signed. */ 195 relAddr = ~relAddr; /* Make signed. */
210 relAddr |= (raw_code & 0xFF) + 1; /* Apply our value. */ 196 relAddr |= (raw_code & 0xFF) + 1; /* Apply our value. */
211 relAddr <<= 1; /* Multiply by two as per processor docs. */ 197 relAddr <<= 1; /* Multiply by two as per processor docs. */
212 } 198 }
213 else 199 else
214 { 200 {
215 relAddr = raw_code & 0xff; 201 relAddr = raw_code & 0xff;
216 relAddr = (relAddr << 1) + 2; 202 relAddr = (relAddr << 1) + 2;
217 } 203 }
218 (*info->fprintf_func)(info->stream, " *%d", relAddr); 204 (*info->fprintf_func)(info->stream, " *%d", relAddr);
219 (*info->fprintf_func)(info->stream, " Abs* 0x"); 205 (*info->fprintf_func)(info->stream, " Abs* 0x");
220 (*info->print_address_func)(memaddr + relAddr, info); 206 (*info->print_address_func)(memaddr + relAddr, info);
221 } 207 }
222 else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_REL10)) 208 else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_REL10))
223 { 209 {
224 /* If address is negative handle it accordingly. */ 210 /* If address is negative handle it accordingly. */
225 if (raw_code & XGATE_TEN_SIGNBIT) 211 if (raw_code & XGATE_TEN_SIGNBIT)
226 { 212 {
227 relAddr = XGATE_TEN_BITS >> 1; /* Clip sign bit. */ 213 relAddr = XGATE_TEN_BITS >> 1; /* Clip sign bit. */
228 relAddr = ~relAddr; /* Make signed. */ 214 relAddr = ~relAddr; /* Make signed. */
229 relAddr |= (raw_code & 0x1FF) + 1; /* Apply our value. */ 215 relAddr |= (raw_code & 0x1FF) + 1; /* Apply our value. */
230 relAddr <<= 1; /* Multiply by two as per processor docs. */ 216 relAddr <<= 1; /* Multiply by two as per processor docs. */
231 } 217 }
232 else 218 else
233 { 219 {
234 relAddr = raw_code & 0x1FF; 220 relAddr = raw_code & 0x1FF;
235 relAddr = (relAddr << 1) + 2; 221 relAddr = (relAddr << 1) + 2;
236 } 222 }
237 (*info->fprintf_func)(info->stream, " *%d", relAddr); 223 (*info->fprintf_func)(info->stream, " *%d", relAddr);
238 (*info->fprintf_func)(info->stream, " Abs* 0x"); 224 (*info->fprintf_func)(info->stream, " Abs* 0x");
239 (*info->print_address_func)(memaddr + relAddr, info); 225 (*info->print_address_func)(memaddr + relAddr, info);
240 } 226 }
227 else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IMM4))
228 {
229 (*info->fprintf_func)(info->stream, " R%x, #0x%02x",
230 (raw_code >> 8) & 0x7, (raw_code >> 4) & 0xF);
231 }
232 else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IMM8))
233 {
234 if (macro_search (decodePTR->opcodePTR->name, previousOpName) &&
235 previousOpName[0])
236 {
237 absAddress = (0xFF & raw_code) << 8;
238 absAddress |= perviousBin & 0xFF;
239 (*info->fprintf_func)(info->stream, " R%x, #0x%02x Abs* 0x",
240 (raw_code >> 8) & 0x7, raw_code & 0xff);
241 (*info->print_address_func)(absAddress, info);
242 previousOpName[0] = 0;
243 }
244 else
245 {
246 strcpy (previousOpName, decodePTR->opcodePTR->name);
247 (*info->fprintf_func)(info->stream, " R%x, #0x%02x",
248 (raw_code >> 8) & 0x7, raw_code & 0xff);
249 }
250 }
251 else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IMM3))
252 {
253 (*info->fprintf_func)(info->stream, " #0x%x",
254 (raw_code >> 8) & 0x7);
255 }
256 else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_INH))
257 {
258 //
259 }
241 else 260 else
242 { 261 {
243 (*info->fprintf_func)(info->stream, 262 (*info->fprintf_func)(info->stream, " unhandled mode %s",
244 " Can't disassemble for mode) %s", 263 opcodePTR->constraints);
245 decodePTR->opcodePTR->constraints);
246 } 264 }
247 break;
248 case XG_R_I:
249 if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IMM4))
250 {
251 (*info->fprintf_func)(info->stream, " R%x, #0x%02x",
252 (raw_code >> 8) & 0x7, (raw_code >> 4) & 0xF);
253 }
254 else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IMM8))
255 {
256 if (macro_search (decodePTR->opcodePTR->name, previousOpName) &&
257 previousOpName[0])
258 {
259 absAddress = (0xFF & raw_code) << 8;
260 absAddress |= perviousBin & 0xFF;
261 (*info->fprintf_func)(info->stream, " R%x, #0x%02x Abs* 0x",
262 (raw_code >> 8) & 0x7, raw_code & 0xff);
263 (*info->print_address_func)(absAddress, info);
264 previousOpName[0] = 0;
265 }
266 else
267 {
268 strcpy (previousOpName, decodePTR->opcodePTR->name);
269 (*info->fprintf_func)(info->stream, " R%x, #0x%02x",
270 (raw_code >> 8) & 0x7, raw_code & 0xff);
271 }
272 }
273 else
274 {
275 (*info->fprintf_func)(info->stream,
276 " Can't disassemble for mode %s",
277 decodePTR->opcodePTR->constraints);
278 }
279 break;
280 case XG_I:
281 (*info->fprintf_func)(info->stream, " #0x%x",
282 (raw_code >> 8) & 0x7);
283 break;
284 default:
285 (*info->fprintf_func)(info->stream, "address mode not found\t %x",
286 opcodePTR->bin_opcode);
287 break;
288 }
289 perviousBin = raw_code; 265 perviousBin = raw_code;
290 } 266 }
291 else 267 else
292 { 268 {
293 (*info->fprintf_func)(info->stream, 269 (*info->fprintf_func)(info->stream,
294 " unable to find opcode match #0%x", raw_code); 270 " unable to find opcode match #0%x", raw_code);
295 } 271 }
296 } 272 }
297 return bytesRead; 273 return bytesRead;
298 } 274 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 { 363 {
388 return decodeTablePTR; 364 return decodeTablePTR;
389 break; 365 break;
390 } 366 }
391 else 367 else
392 continue; 368 continue;
393 } 369 }
394 } 370 }
395 return 0; 371 return 0;
396 } 372 }
OLDNEW
« no previous file with comments | « opcodes/v850-opc.c ('k') | opcodes/xgate-opc.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698