Changeset 609 for branches/GNU/src/binutils/opcodes/d10v-dis.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/opcodes/d10v-dis.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* Disassemble D10V instructions. 2 Copyright 1996, 1997, 1998, 2000 Free Software Foundation, Inc.2 Copyright 1996, 1997, 1998, 2000, 2001 Free Software Foundation, Inc. 3 3 4 4 This program is free software; you can redistribute it and/or modify … … 16 16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 17 18 19 18 #include <stdio.h> 20 19 21 20 #include "sysdep.h" 22 #include "opcode/d10v.h" 21 #include "opcode/d10v.h" 23 22 #include "dis-asm.h" 24 23 25 /* the PC wraps at 18 bits, except for the segment number */26 /* so use this mask to keep the parts we want*/24 /* The PC wraps at 18 bits, except for the segment number, 25 so use this mask to keep the parts we want. */ 27 26 #define PC_MASK 0x0303FFFF 28 27 29 static void dis_2_short PARAMS ((unsigned long insn, bfd_vma memaddr, 28 static void dis_2_short PARAMS ((unsigned long insn, bfd_vma memaddr, 30 29 struct disassemble_info *info, int order)); 31 static void dis_long PARAMS ((unsigned long insn, bfd_vma memaddr, 30 static void dis_long PARAMS ((unsigned long insn, bfd_vma memaddr, 32 31 struct disassemble_info *info)); 33 34 int 32 static void print_operand 33 PARAMS ((struct d10v_operand *, long unsigned int, struct d10v_opcode *, 34 bfd_vma, struct disassemble_info *)); 35 36 int 35 37 print_insn_d10v (memaddr, info) 36 38 bfd_vma memaddr; … … 50 52 51 53 status = insn & FM11; 52 switch (status) { 53 case 0: 54 dis_2_short (insn, memaddr, info, 2); 55 break; 56 case FM01: 57 dis_2_short (insn, memaddr, info, 0); 58 break; 59 case FM10: 60 dis_2_short (insn, memaddr, info, 1); 61 break; 62 case FM11: 63 dis_long (insn, memaddr, info); 64 break; 65 } 54 switch (status) 55 { 56 case 0: 57 dis_2_short (insn, memaddr, info, 2); 58 break; 59 case FM01: 60 dis_2_short (insn, memaddr, info, 0); 61 break; 62 case FM10: 63 dis_2_short (insn, memaddr, info, 1); 64 break; 65 case FM11: 66 dis_long (insn, memaddr, info); 67 break; 68 } 66 69 return 4; 67 70 } … … 79 82 if (oper->flags == OPERAND_ATMINUS) 80 83 { 81 (*info->fprintf_func) (info->stream, "@-"); 84 (*info->fprintf_func) (info->stream, "@-"); 82 85 return; 83 86 } 84 87 if (oper->flags == OPERAND_MINUS) 85 88 { 86 (*info->fprintf_func) (info->stream, "-"); 89 (*info->fprintf_func) (info->stream, "-"); 87 90 return; 88 91 } 89 92 if (oper->flags == OPERAND_PLUS) 90 93 { 91 (*info->fprintf_func) (info->stream, "+"); 94 (*info->fprintf_func) (info->stream, "+"); 92 95 return; 93 96 } 94 97 if (oper->flags == OPERAND_ATSIGN) 95 98 { 96 (*info->fprintf_func) (info->stream, "@"); 99 (*info->fprintf_func) (info->stream, "@"); 97 100 return; 98 101 } 99 102 if (oper->flags == OPERAND_ATPAR) 100 103 { 101 (*info->fprintf_func) (info->stream, "@("); 104 (*info->fprintf_func) (info->stream, "@("); 102 105 return; 103 106 } … … 105 108 shift = oper->shift; 106 109 107 /* the LONG_L format shifts registers over by 15*/110 /* The LONG_L format shifts registers over by 15. */ 108 111 if (op->format == LONG_L && (oper->flags & OPERAND_REG)) 109 112 shift += 15; … … 114 117 { 115 118 int i; 116 int match =0;119 int match = 0; 117 120 num += (oper->flags 118 & (OPERAND_GPR |OPERAND_FFLAG|OPERAND_CFLAG|OPERAND_CONTROL));119 if (oper->flags & (OPERAND_ACC0 |OPERAND_ACC1))121 & (OPERAND_GPR | OPERAND_FFLAG | OPERAND_CFLAG | OPERAND_CONTROL)); 122 if (oper->flags & (OPERAND_ACC0 | OPERAND_ACC1)) 120 123 num += num ? OPERAND_ACC1 : OPERAND_ACC0; 121 for (i = 0; i < d10v_reg_name_cnt (); i++)122 { 123 if (num == d10v_predefined_registers[i].value)124 for (i = 0; i < d10v_reg_name_cnt (); i++) 125 { 126 if (num == (d10v_predefined_registers[i].value & ~ OPERAND_SP)) 124 127 { 125 128 if (d10v_predefined_registers[i].pname) 126 (*info->fprintf_func) (info->stream, "%s",d10v_predefined_registers[i].pname); 129 (*info->fprintf_func) (info->stream, "%s", 130 d10v_predefined_registers[i].pname); 127 131 else 128 (*info->fprintf_func) (info->stream, "%s",d10v_predefined_registers[i].name); 129 match=1; 132 (*info->fprintf_func) (info->stream, "%s", 133 d10v_predefined_registers[i].name); 134 match = 1; 130 135 break; 131 136 } … … 133 138 if (match == 0) 134 139 { 135 /* this would only get executed if a register was not in the136 register table */137 if (oper->flags & (OPERAND_ACC0 |OPERAND_ACC1))140 /* This would only get executed if a register was not in the 141 register table. */ 142 if (oper->flags & (OPERAND_ACC0 | OPERAND_ACC1)) 138 143 (*info->fprintf_func) (info->stream, "a"); 139 144 else if (oper->flags & OPERAND_CONTROL) 140 145 (*info->fprintf_func) (info->stream, "cr"); 141 else if (oper->flags & OPERAND_REG)146 else if (oper->flags & OPERAND_REG) 142 147 (*info->fprintf_func) (info->stream, "r"); 143 (*info->fprintf_func) (info->stream, "%d", num);148 (*info->fprintf_func) (info->stream, "%d", num & REGISTER_MASK); 144 149 } 145 150 } 146 151 else 147 152 { 148 /* addresses are right-shifted by 2*/153 /* Addresses are right-shifted by 2. */ 149 154 if (oper->flags & OPERAND_ADDR) 150 155 { 151 156 long max; 152 int neg =0;157 int neg = 0; 153 158 max = (1 << (oper->bits - 1)); 154 159 if (num & max) 155 160 { 156 num = -num & ((1 << oper->bits) -1);161 num = -num & ((1 << oper->bits) - 1); 157 162 neg = 1; 158 163 } 159 num = num <<2;164 num = num << 2; 160 165 if (info->flags & INSN_HAS_RELOC) 161 166 (*info->print_address_func) (num & PC_MASK, info); … … 175 180 if (num & max) 176 181 { 177 num = -num & ((1 << oper->bits) -1);182 num = -num & ((1 << oper->bits) - 1); 178 183 (*info->fprintf_func) (info->stream, "-"); 179 184 } 180 185 } 181 (*info->fprintf_func) (info->stream, "0x%x", num);186 (*info->fprintf_func) (info->stream, "0x%x", num); 182 187 } 183 188 } 184 189 } 185 186 190 187 191 static void … … 192 196 { 193 197 int i; 194 char buf[32]; 195 struct d10v_opcode *op = (struct d10v_opcode *)d10v_opcodes; 198 struct d10v_opcode *op = (struct d10v_opcode *) d10v_opcodes; 196 199 struct d10v_operand *oper; 197 200 int need_paren = 0; … … 200 203 while (op->name) 201 204 { 202 if ((op->format & LONG_OPCODE) && ((op->mask & insn) == op->opcode))205 if ((op->format & LONG_OPCODE) && ((op->mask & insn) == (unsigned long) op->opcode)) 203 206 { 204 207 match = 1; 205 (*info->fprintf_func) (info->stream, "%s\t", op->name); 206 for ( i=0; op->operands[i]; i++)207 { 208 oper = (struct d10v_operand *) &d10v_operands[op->operands[i]];208 (*info->fprintf_func) (info->stream, "%s\t", op->name); 209 for (i = 0; op->operands[i]; i++) 210 { 211 oper = (struct d10v_operand *) &d10v_operands[op->operands[i]]; 209 212 if (oper->flags == OPERAND_ATPAR) 210 213 need_paren = 1; 211 214 print_operand (oper, insn, op, memaddr, info); 212 if (op->operands[i +1] && oper->bits &&213 d10v_operands[op->operands[i+1]].flags != OPERAND_PLUS &&214 d10v_operands[op->operands[i+1]].flags != OPERAND_MINUS)215 (*info->fprintf_func) (info->stream, ", "); 215 if (op->operands[i + 1] && oper->bits 216 && d10v_operands[op->operands[i + 1]].flags != OPERAND_PLUS 217 && d10v_operands[op->operands[i + 1]].flags != OPERAND_MINUS) 218 (*info->fprintf_func) (info->stream, ", "); 216 219 } 217 220 break; … … 221 224 222 225 if (!match) 223 (*info->fprintf_func) (info->stream, ".long\t0x%08x", insn);226 (*info->fprintf_func) (info->stream, ".long\t0x%08x", insn); 224 227 225 228 if (need_paren) 226 (*info->fprintf_func) (info->stream, ")"); 229 (*info->fprintf_func) (info->stream, ")"); 227 230 } 228 231 … … 234 237 int order; 235 238 { 236 int i,j; 237 char astr[2][32]; 239 int i, j; 238 240 unsigned int ins[2]; 239 241 struct d10v_opcode *op; 240 char buf[32]; 241 int match, num_match=0; 242 int match, num_match = 0; 242 243 struct d10v_operand *oper; 243 244 int need_paren = 0; … … 246 247 ins[1] = insn & 0x00007FFF; 247 248 248 for (j=0;j<2;j++)249 { 250 op = (struct d10v_opcode *) d10v_opcodes;251 match =0;249 for (j = 0; j < 2; j++) 250 { 251 op = (struct d10v_opcode *) d10v_opcodes; 252 match = 0; 252 253 while (op->name) 253 254 { 254 if ((op->format & SHORT_OPCODE) && ((op->mask & ins[j]) == op->opcode)) 255 { 256 (*info->fprintf_func) (info->stream, "%s\t",op->name); 257 for (i=0; op->operands[i]; i++) 255 if ((op->format & SHORT_OPCODE) 256 && ((op->mask & ins[j]) == (unsigned long) op->opcode)) 257 { 258 (*info->fprintf_func) (info->stream, "%s\t", op->name); 259 for (i = 0; op->operands[i]; i++) 258 260 { 259 oper = (struct d10v_operand *) &d10v_operands[op->operands[i]];261 oper = (struct d10v_operand *) &d10v_operands[op->operands[i]]; 260 262 if (oper->flags == OPERAND_ATPAR) 261 263 need_paren = 1; 262 264 print_operand (oper, ins[j], op, memaddr, info); 263 if (op->operands[i +1] && oper->bits &&264 d10v_operands[op->operands[i+1]].flags != OPERAND_PLUS &&265 d10v_operands[op->operands[i+1]].flags != OPERAND_MINUS)266 (*info->fprintf_func) (info->stream, ", "); 265 if (op->operands[i + 1] && oper->bits 266 && d10v_operands[op->operands[i + 1]].flags != OPERAND_PLUS 267 && d10v_operands[op->operands[i + 1]].flags != OPERAND_MINUS) 268 (*info->fprintf_func) (info->stream, ", "); 267 269 } 268 270 match = 1; … … 273 275 } 274 276 if (!match) 275 (*info->fprintf_func) (info->stream, "unknown"); 277 (*info->fprintf_func) (info->stream, "unknown"); 276 278 277 279 switch (order) 278 280 { 279 281 case 0: 280 (*info->fprintf_func) (info->stream, "\t->\t"); 282 (*info->fprintf_func) (info->stream, "\t->\t"); 281 283 order = -1; 282 284 break; 283 285 case 1: 284 (*info->fprintf_func) (info->stream, "\t<-\t"); 286 (*info->fprintf_func) (info->stream, "\t<-\t"); 285 287 order = -1; 286 288 break; 287 289 case 2: 288 (*info->fprintf_func) (info->stream, "\t||\t"); 290 (*info->fprintf_func) (info->stream, "\t||\t"); 289 291 order = -1; 290 292 break; … … 295 297 296 298 if (num_match == 0) 297 (*info->fprintf_func) (info->stream, ".long\t0x%08x", insn);299 (*info->fprintf_func) (info->stream, ".long\t0x%08x", insn); 298 300 299 301 if (need_paren) 300 (*info->fprintf_func) (info->stream, ")"); 302 (*info->fprintf_func) (info->stream, ")"); 301 303 } -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.