Changeset 609 for branches/GNU/src/binutils/opcodes/arc-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/arc-dis.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* Instruction printing code for the ARC. 2 Copyright 1994, 1995, 1997, 1998, 2000, 2001 2 Copyright 1994, 1995, 1997, 1998, 2000, 2001, 2002 3 3 Free Software Foundation, Inc. 4 4 Contributed by Doug Evans (dje@cygnus.com). … … 18 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 19 19 20 #include <ansidecl.h>21 #include <libiberty.h>20 #include "ansidecl.h" 21 #include "libiberty.h" 22 22 #include "dis-asm.h" 23 23 #include "opcode/arc.h" … … 27 27 #include "opintl.h" 28 28 29 #include <ctype.h>30 29 #include <stdarg.h> 31 30 #include "arc-dis.h" … … 36 35 #endif 37 36 38 #define BIT(word,n) 39 #define BITS(word,s,e) (((word) << (31 - e)) >> (s + (31 - e))) 40 #define OPCODE(word) 41 #define FIELDA(word) 42 #define FIELDB(word) 43 #define FIELDC(word) 37 #define BIT(word,n) ((word) & (1 << n)) 38 #define BITS(word,s,e) (((word) << (31 - e)) >> (s + (31 - e))) 39 #define OPCODE(word) (BITS ((word), 27, 31)) 40 #define FIELDA(word) (BITS ((word), 21, 26)) 41 #define FIELDB(word) (BITS ((word), 15, 20)) 42 #define FIELDC(word) (BITS ((word), 9, 14)) 44 43 45 44 /* FIELD D is signed in all of its uses, so we make sure argument is 46 45 treated as signed for bit shifting purposes: */ 47 #define FIELDD(word) 48 49 #define PUT_NEXT_WORD_IN(a) 50 do 51 { 52 if (is_limm == 1 && !NEXT_WORD (1)) 53 mwerror (state, _("Illegal limm reference in last instruction!\n")); 54 a = state->words[1];\55 } 46 #define FIELDD(word) (BITS (((signed int)word), 0, 8)) 47 48 #define PUT_NEXT_WORD_IN(a) \ 49 do \ 50 { \ 51 if (is_limm == 1 && !NEXT_WORD (1)) \ 52 mwerror (state, _("Illegal limm reference in last instruction!\n")); \ 53 a = state->words[1]; \ 54 } \ 56 55 while (0) 57 56 … … 99 98 do \ 100 99 { \ 101 fieldA = FIELDA (state->words[0]);\100 fieldA = FIELDA (state->words[0]); \ 102 101 if (fieldA > 60) \ 103 102 { \ … … 137 136 usesAuxReg ? cb"%a"ca : \ 138 137 IS_SMALL (x) ? cb"%d"ca : cb"%h"ca)) 139 #define WRITE_FORMAT_RB() 138 #define WRITE_FORMAT_RB() strcat (formatString, "]") 140 139 #define WRITE_COMMENT(str) (state->comm[state->commNum++] = (str)) 141 #define WRITE_NOP_COMMENT() 142 143 #define NEXT_WORD(x) 144 145 #define add_target(x) 140 #define WRITE_NOP_COMMENT() if (!fieldAisReg && !flag) WRITE_COMMENT ("nop"); 141 142 #define NEXT_WORD(x) (offset += 4, state->words[x]) 143 144 #define add_target(x) (state->targets[state->tcnt++] = (x)) 146 145 147 146 static char comment_prefix[] = "\t; "; 147 148 static const char *core_reg_name PARAMS ((struct arcDisState *, int)); 149 static const char *aux_reg_name PARAMS ((struct arcDisState *, int)); 150 static const char *cond_code_name PARAMS ((struct arcDisState *, int)); 151 static const char *instruction_name 152 PARAMS ((struct arcDisState *, int, int, int *)); 153 static void mwerror PARAMS ((struct arcDisState *, const char *)); 154 static const char *post_address PARAMS ((struct arcDisState *, int)); 155 static void write_comments_ 156 PARAMS ((struct arcDisState *, int, int, long int)); 157 static void write_instr_name_ 158 PARAMS ((struct arcDisState *, const char *, int, int, int, int, int, int)); 159 static int dsmOneArcInst PARAMS ((bfd_vma, struct arcDisState *)); 160 static const char *_coreRegName PARAMS ((void *, int)); 161 static int decodeInstr PARAMS ((bfd_vma, disassemble_info *)); 148 162 149 163 static const char * 150 164 core_reg_name (state, val) 151 165 struct arcDisState * state; 152 int val; 166 int val; 153 167 { 154 168 if (state->coreRegName) … … 160 174 aux_reg_name (state, val) 161 175 struct arcDisState * state; 162 int val; 176 int val; 163 177 { 164 178 if (state->auxRegName) … … 170 184 cond_code_name (state, val) 171 185 struct arcDisState * state; 172 int val; 186 int val; 173 187 { 174 188 if (state->condCodeName) … … 182 196 int op1; 183 197 int op2; 184 int * flags; 198 int * flags; 185 199 { 186 200 if (state->instName) … … 192 206 mwerror (state, msg) 193 207 struct arcDisState * state; 194 const char * msg; 208 const char * msg; 195 209 { 196 210 if (state->err != 0) … … 201 215 post_address (state, addr) 202 216 struct arcDisState * state; 203 int addr; 217 int addr; 204 218 { 205 219 static char id[3 * ARRAY_SIZE (state->addresses)]; … … 214 228 id[j+1] = '0'+i; 215 229 id[j+2] = 0; 216 230 217 231 return id + j; 218 232 } … … 220 234 } 221 235 222 static void 223 my_sprintf ( 224 struct arcDisState * state, 225 char * buf, 226 const char *format,227 ...)228 { 229 char *bp; 236 static void my_sprintf PARAMS ((struct arcDisState *, char *, const char *, 237 ...)); 238 239 static void 240 my_sprintf VPARAMS ((struct arcDisState *state, char *buf, const char *format, 241 ...)) 242 { 243 char *bp; 230 244 const char *p; 231 245 int size, leading_zero, regMap[2]; 232 246 long auxNum; 233 va_list ap; 234 235 va_start (ap, format); 236 237 bp = buf; 247 248 VA_OPEN (ap, format); 249 VA_FIXEDARG (ap, struct arcDisState *, state); 250 VA_FIXEDARG (ap, char *, buf); 251 VA_FIXEDARG (ap, const char *, format); 252 253 bp = buf; 238 254 *bp = 0; 239 255 p = format; … … 241 257 regMap[0] = 0; 242 258 regMap[1] = 0; 243 244 while (1) 259 260 while (1) 245 261 switch (*p++) 246 262 { 247 case 0:248 249 default: 250 *bp++ = p[-1]; 263 case 0: 264 goto DOCOMM; /* (return) */ 265 default: 266 *bp++ = p[-1]; 251 267 break; 252 268 case '%': … … 254 270 leading_zero = 0; 255 271 RETRY: ; 256 switch (*p++) 272 switch (*p++) 257 273 { 258 274 case '0': … … 280 296 #define inc_bp() bp = bp + strlen (bp) 281 297 282 case 'h': 298 case 'h': 283 299 { 284 300 unsigned u = va_arg (ap, int); … … 287 303 one place, here, if we wish. 288 304 We add underscores for easy reading. */ 289 if (u > 65536) 305 if (u > 65536) 290 306 sprintf (bp, "0x%x_%04x", u >> 16, u & 0xffff); 291 else 307 else 292 308 sprintf (bp, "0x%x", u); 293 309 inc_bp (); 294 } 310 } 295 311 break; 296 case 'X': case 'x': 312 case 'X': case 'x': 297 313 { 298 314 int val = va_arg (ap, int); 299 315 300 if (size != 0) 316 if (size != 0) 301 317 if (leading_zero) 302 318 sprintf (bp, "%0*x", size, val); … … 308 324 } 309 325 break; 310 case 'd': 326 case 'd': 311 327 { 312 328 int val = va_arg (ap, int); 313 329 314 330 if (size != 0) 315 331 sprintf (bp, "%*d", size, val); … … 319 335 } 320 336 break; 321 case 'r': 337 case 'r': 322 338 { 323 339 /* Register. */ 324 340 int val = va_arg (ap, int); 325 341 326 342 #define REG2NAME(num, name) case num: sprintf (bp, ""name); \ 327 343 regMap[(num < 32) ? 0 : 1] |= 1 << (num - ((num < 32) ? 0 : 32)); break; 328 329 switch (val) 344 345 switch (val) 330 346 { 331 347 REG2NAME (26, "gp"); … … 350 366 inc_bp (); 351 367 } break; 352 353 case 'a': 368 369 case 'a': 354 370 { 355 371 /* Aux Register. */ … … 358 374 #define AUXREG2NAME(num, name) case num: sprintf (bp,name); break; 359 375 360 switch (val) 376 switch (val) 361 377 { 362 378 AUXREG2NAME (0x0, "status"); … … 381 397 } 382 398 break; 383 384 case 's': 399 400 case 's': 385 401 { 386 402 sprintf (bp, "%s", va_arg (ap, char *)); … … 388 404 } 389 405 break; 390 406 391 407 default: 392 408 fprintf (stderr, "?? format %c\n", p[-1]); … … 396 412 397 413 DOCOMM: *bp = 0; 398 } 399 400 static void 414 VA_CLOSE (ap); 415 } 416 417 static void 401 418 write_comments_(state, shimm, is_limm, limm_value) 402 419 struct arcDisState * state; … … 405 422 long limm_value; 406 423 { 407 if (state->commentBuffer != 0) 424 if (state->commentBuffer != 0) 408 425 { 409 426 int i; 410 427 411 if (is_limm) 428 if (is_limm) 412 429 { 413 430 const char *name = post_address (state, limm_value + shimm); … … 416 433 WRITE_COMMENT (name); 417 434 } 418 for (i = 0; i < state->commNum; i++) 435 for (i = 0; i < state->commNum; i++) 419 436 { 420 437 if (i == 0) 421 438 strcpy (state->commentBuffer, comment_prefix); 422 439 else 423 strcat (state->commentBuffer, ", "); 424 strncat (state->commentBuffer, state->comm[i], sizeof (state->commentBuffer)); 440 strcat (state->commentBuffer, ", "); 441 strncat (state->commentBuffer, state->comm[i], 442 sizeof (state->commentBuffer)); 425 443 } 426 444 } … … 432 450 static const char *condName[] = { 433 451 /* 0..15. */ 434 "" , "z" , "nz" , "p" , "n" , "c" , "nc" , "v" , 452 "" , "z" , "nz" , "p" , "n" , "c" , "nc" , "v" , 435 453 "nv" , "gt" , "ge" , "lt" , "le" , "hi" , "ls" , "pnz" 436 454 }; 437 455 438 static void 456 static void 439 457 write_instr_name_(state, instrName, cond, condCodeIsPartOfName, flag, signExtend, addrWriteBack, directMem) 440 458 struct arcDisState * state; … … 449 467 strcpy (state->instrBuffer, instrName); 450 468 451 if (cond > 0) 469 if (cond > 0) 452 470 { 453 471 const char *cc = 0; … … 470 488 strcat (state->instrBuffer, ".f"); 471 489 472 switch (state->nullifyMode) 490 switch (state->nullifyMode) 473 491 { 474 492 case BR_exec_always: … … 499 517 while (0) 500 518 501 enum { 502 op_LD0 = 0, op_LD1 = 1, op_ST = 2, op_3 = 3, 519 enum { 520 op_LD0 = 0, op_LD1 = 1, op_ST = 2, op_3 = 3, 503 521 op_BC = 4, op_BLC = 5, op_LPC = 6, op_JC = 7, 504 op_ADD = 8, op_ADC = 9, op_SUB = 10, op_SBC = 11, 522 op_ADD = 8, op_ADC = 9, op_SUB = 10, op_SBC = 11, 505 523 op_AND = 12, op_OR = 13, op_BIC = 14, op_XOR = 15 506 524 }; … … 508 526 extern disassemble_info tm_print_insn_info; 509 527 510 static int 528 static int 511 529 dsmOneArcInst (addr, state) 512 530 bfd_vma addr; … … 537 555 int ignoreFirstOpd; 538 556 char formatString[60]; 539 557 540 558 state->instructionLen = 4; 541 559 state->nullifyMode = BR_exec_when_no_jump; 542 560 state->opWidth = 12; 543 561 state->isBranch = 0; 544 562 545 563 state->_mem_load = 0; 546 564 state->_ea_present = 0; … … 549 567 state->ea_reg2 = no_reg; 550 568 state->_offset = 0; 551 569 552 570 if (! NEXT_WORD (0)) 553 571 return 0; 554 572 555 573 state->_opcode = OPCODE (state->words[0]); 556 574 instrName = 0; … … 567 585 state->commentBuffer[0] = '\0'; 568 586 569 switch (state->_opcode) 587 switch (state->_opcode) 570 588 { 571 case op_LD0: 572 switch (BITS (state->words[0],1,2)) 589 case op_LD0: 590 switch (BITS (state->words[0],1,2)) 573 591 { 574 592 case 0: … … 585 603 break; 586 604 default: 587 instrName = "??? (0[3])"; 605 instrName = "??? (0[3])"; 588 606 state->flow = invalid_instr; 589 607 break; 590 608 } 591 decodingClass = 5; 592 break; 593 594 case op_LD1: 595 if (BIT (state->words[0],13)) 596 { 597 instrName = "lr"; 609 decodingClass = 5; 610 break; 611 612 case op_LD1: 613 if (BIT (state->words[0],13)) 614 { 615 instrName = "lr"; 598 616 decodingClass = 10; 599 617 } 600 else 601 { 602 switch (BITS (state->words[0],10,11)) 618 else 619 { 620 switch (BITS (state->words[0],10,11)) 603 621 { 604 622 case 0: … … 615 633 break; 616 634 default: 617 instrName = "??? (1[3])"; 635 instrName = "??? (1[3])"; 618 636 state->flow = invalid_instr; 619 637 break; … … 622 640 } 623 641 break; 624 642 625 643 case op_ST: 626 if (BIT (state->words[0],25)) 644 if (BIT (state->words[0],25)) 627 645 { 628 646 instrName = "sr"; 629 647 decodingClass = 8; 630 648 } 631 else 632 { 633 switch (BITS (state->words[0],22,23)) 649 else 650 { 651 switch (BITS (state->words[0],22,23)) 634 652 { 635 653 case 0: … … 643 661 break; 644 662 default: 645 instrName = "??? (2[3])"; 663 instrName = "??? (2[3])"; 646 664 state->flow = invalid_instr; 647 665 break; … … 650 668 } 651 669 break; 652 670 653 671 case op_3: 654 672 decodingClass = 1; /* default for opcode 3... */ 655 switch (FIELDC (state->words[0])) 673 switch (FIELDC (state->words[0])) 656 674 { 657 675 case 0: 658 instrName = "flag"; 676 instrName = "flag"; 659 677 decodingClass = 2; 660 678 break; … … 683 701 instrName = "extw"; 684 702 break; 685 case 0x3f: 703 case 0x3f: 686 704 { 687 705 decodingClass = 9; 688 switch( FIELDD (state->words[0]) ) 706 switch( FIELDD (state->words[0]) ) 689 707 { 690 708 case 0: … … 704 722 } 705 723 break; 706 724 707 725 /* ARC Extension Library Instructions 708 726 NOTE: We assume that extension codes are these instrs. */ … … 711 729 state->_opcode, 712 730 FIELDC (state->words[0]), 713 & 731 &flags); 714 732 if (!instrName) 715 733 { … … 724 742 725 743 case op_BC: 726 instrName = "b"; 744 instrName = "b"; 727 745 case op_BLC: 728 746 if (!instrName) 729 instrName = "bl"; 747 instrName = "bl"; 730 748 case op_LPC: 731 749 if (!instrName) 732 instrName = "lp"; 750 instrName = "lp"; 733 751 case op_JC: 734 752 if (!instrName) 735 753 { 736 if (BITS (state->words[0],9,9)) 737 { 738 instrName = "jl"; 754 if (BITS (state->words[0],9,9)) 755 { 756 instrName = "jl"; 739 757 is_linked = 1; 740 758 } 741 else 742 { 743 instrName = "j"; 759 else 760 { 761 instrName = "j"; 744 762 is_linked = 0; 745 763 } … … 749 767 state->isBranch = 1; 750 768 break; 751 769 752 770 case op_ADD: 753 771 case op_ADC: … … 756 774 decodingClass = 0; 757 775 758 switch (state->_opcode) 776 switch (state->_opcode) 759 777 { 760 778 case op_ADD: … … 769 787 } 770 788 break; 771 789 772 790 case op_SUB: instrName = "sub"; 773 791 break; … … 786 804 decodingClass = 9; 787 805 } 788 else 806 else 789 807 instrName = "xor"; 790 808 break; 791 809 792 810 default: 793 811 instrName = instruction_name (state,state->_opcode,0,&flags); … … 802 820 break; 803 821 } 804 822 805 823 fieldAisReg = fieldBisReg = fieldCisReg = 1; /* Assume regs for now. */ 806 824 flag = cond = is_shimm = is_limm = 0; … … 808 826 signExtend = addrWriteBack = directMem = 0; 809 827 usesAuxReg = 0; 810 811 switch (decodingClass) 828 829 switch (decodingClass) 812 830 { 813 831 case 0: … … 817 835 CHECK_FIELD_C (); 818 836 CHECK_FLAG_COND_NULLIFY (); 819 837 820 838 write_instr_name (); 821 if (!ignoreFirstOpd) 839 if (!ignoreFirstOpd) 822 840 { 823 841 WRITE_FORMAT_x (A); … … 826 844 WRITE_FORMAT_COMMA_x (C); 827 845 WRITE_NOP_COMMENT (); 828 my_sprintf (state, state->operandBuffer, formatString, fieldA, fieldB, fieldC); 829 } 830 else 846 my_sprintf (state, state->operandBuffer, formatString, 847 fieldA, fieldB, fieldC); 848 } 849 else 831 850 { 832 851 WRITE_FORMAT_x (B); 833 852 if (!repeatsOp) 834 853 WRITE_FORMAT_COMMA_x (C); 835 my_sprintf (state, state->operandBuffer, formatString, fieldB, fieldC); 854 my_sprintf (state, state->operandBuffer, formatString, 855 fieldB, fieldC); 836 856 } 837 857 write_comments (); 838 858 break; 839 859 840 860 case 1: 841 861 CHECK_FIELD_A (); 842 862 CHECK_FIELD_B (); 843 863 CHECK_FLAG_COND_NULLIFY (); 844 864 845 865 write_instr_name (); 846 if (!ignoreFirstOpd) 866 if (!ignoreFirstOpd) 847 867 { 848 868 WRITE_FORMAT_x (A); 849 869 WRITE_FORMAT_COMMA_x (B); 850 870 WRITE_NOP_COMMENT (); 851 my_sprintf (state, state->operandBuffer, formatString, fieldA, fieldB); 852 } 853 else 871 my_sprintf (state, state->operandBuffer, formatString, 872 fieldA, fieldB); 873 } 874 else 854 875 { 855 876 WRITE_FORMAT_x (B); 856 my_sprintf (state, state->operandBuffer, formatString, fieldB); 877 my_sprintf (state, state->operandBuffer, formatString, fieldB); 857 878 } 858 879 write_comments (); 859 880 break; 860 881 861 882 case 2: 862 883 CHECK_FIELD_B (); 863 884 CHECK_FLAG_COND_NULLIFY (); 864 885 flag = 0; /* this is the FLAG instruction -- it's redundant */ 865 886 866 887 write_instr_name (); 867 888 WRITE_FORMAT_x (B); … … 869 890 write_comments (); 870 891 break; 871 892 872 893 case 3: 873 894 fieldA = BITS (state->words[0],7,26) << 2; … … 876 897 CHECK_FLAG_COND_NULLIFY (); 877 898 flag = 0; 878 899 879 900 write_instr_name (); 880 901 /* This address could be a label we know. Convert it. */ 881 if (state->_opcode != op_LPC /* LP */) 882 { 883 add_target (fieldA); /* For debugger. */884 state->flow = state->_opcode == op_BLC /* BL */885 ? direct_call886 : direct_jump;887 /* indirect calls are achieved by "lr blink,[status];888 lr dest<- func addr; j [dest]" */889 } 890 902 if (state->_opcode != op_LPC /* LP */) 903 { 904 add_target (fieldA); /* For debugger. */ 905 state->flow = state->_opcode == op_BLC /* BL */ 906 ? direct_call 907 : direct_jump; 908 /* indirect calls are achieved by "lr blink,[status]; 909 lr dest<- func addr; j [dest]" */ 910 } 911 891 912 strcat (formatString, "%s"); /* address/label name */ 892 my_sprintf (state, state->operandBuffer, formatString, post_address (state, fieldA)); 913 my_sprintf (state, state->operandBuffer, formatString, 914 post_address (state, fieldA)); 893 915 write_comments (); 894 916 break; 895 917 896 918 case 4: 897 919 /* For op_JC -- jump to address specified. … … 901 923 CHECK_FIELD_B (); 902 924 CHECK_FLAG_COND_NULLIFY (); 903 904 if (!fieldBisReg) 925 926 if (!fieldBisReg) 905 927 { 906 928 fieldAisReg = 0; … … 914 936 state->nullifyMode = BR_exec_when_no_jump; 915 937 } 916 else 938 else 917 939 { 918 940 state->flow = is_linked ? indirect_call : indirect_jump; … … 923 945 state->register_for_indirect_jump = fieldB; 924 946 } 925 947 926 948 write_instr_name (); 927 strcat (formatString, 949 strcat (formatString, 928 950 IS_REG (B) ? "[%r]" : "%s"); /* address/label name */ 929 if (fieldA != 0) 951 if (fieldA != 0) 930 952 { 931 953 fieldAisReg = 0; … … 935 957 my_sprintf (state, state->operandBuffer, formatString, fieldB, fieldA); 936 958 else 937 my_sprintf (state, state->operandBuffer, formatString, 959 my_sprintf (state, state->operandBuffer, formatString, 938 960 post_address (state, fieldB), fieldA); 939 961 write_comments (); 940 962 break; 941 963 942 964 case 5: 943 965 /* LD instruction. … … 960 982 state->_offset += fieldC; 961 983 state->_mem_load = 1; 962 984 963 985 directMem = BIT (state->words[0],5); 964 986 addrWriteBack = BIT (state->words[0],3); 965 987 signExtend = BIT (state->words[0],0); 966 988 967 989 write_instr_name (); 968 990 WRITE_FORMAT_x_COMMA_LB(A); … … 971 993 else 972 994 fieldB = fieldC; 973 995 974 996 WRITE_FORMAT_x_RB (C); 975 my_sprintf (state, state->operandBuffer, formatString, fieldA, fieldB, fieldC); 997 my_sprintf (state, state->operandBuffer, formatString, 998 fieldA, fieldB, fieldC); 976 999 write_comments (); 977 1000 break; 978 1001 979 1002 case 6: 980 1003 /* LD instruction. */ … … 982 1005 CHECK_FIELD_A (); 983 1006 fieldC = FIELDD (state->words[0]); 984 1007 985 1008 if (dbg) 986 1009 printf ("6:b reg %d %d c 0x%x \n", … … 995 1018 else 996 1019 state->_offset += fieldB, state->_ea_present = 0; 997 1020 998 1021 directMem = BIT (state->words[0],14); 999 1022 addrWriteBack = BIT (state->words[0],12); 1000 1023 signExtend = BIT (state->words[0],9); 1001 1024 1002 1025 write_instr_name (); 1003 1026 WRITE_FORMAT_x_COMMA_LB (A); 1004 if (!fieldBisReg) 1027 if (!fieldBisReg) 1005 1028 { 1006 1029 fieldB = state->_offset; 1007 1030 WRITE_FORMAT_x_RB (B); 1008 1031 } 1009 else 1032 else 1010 1033 { 1011 1034 WRITE_FORMAT_x (B); 1012 if (fieldC != 0 && !BIT (state->words[0],13)) 1035 if (fieldC != 0 && !BIT (state->words[0],13)) 1013 1036 { 1014 1037 fieldCisReg = 0; … … 1018 1041 WRITE_FORMAT_RB (); 1019 1042 } 1020 my_sprintf (state, state->operandBuffer, formatString, fieldA, fieldB, fieldC); 1043 my_sprintf (state, state->operandBuffer, formatString, 1044 fieldA, fieldB, fieldC); 1021 1045 write_comments (); 1022 1046 break; 1023 1047 1024 1048 case 7: 1025 1049 /* ST instruction. */ … … 1027 1051 CHECK_FIELD_C(); 1028 1052 fieldA = FIELDD(state->words[0]); /* shimm */ 1029 1053 1030 1054 /* [B,A offset] */ 1031 1055 if (dbg) printf("7:b reg %d %x off %x\n", 1032 1056 fieldBisReg,fieldB,fieldA); 1033 1057 state->_ea_present = 1; 1034 1058 state->_offset = fieldA; 1035 1059 if (fieldBisReg) 1036 1060 state->ea_reg1 = fieldB; 1037 /* field B is either a shimm (same as fieldA) or limm (different!) 1061 /* field B is either a shimm (same as fieldA) or limm (different!) 1038 1062 Say ea is not present, so only one of us will do the name lookup. 1039 1063 (for is_limm we do the name translation here). */ 1040 else 1064 else 1041 1065 state->_offset += fieldB, state->_ea_present = 0; 1042 1066 1043 1067 directMem = BIT(state->words[0],26); 1044 1068 addrWriteBack = BIT(state->words[0],24); 1045 1069 1046 1070 write_instr_name(); 1047 1071 WRITE_FORMAT_x_COMMA_LB(C); 1048 1049 if (!fieldBisReg) 1072 1073 if (!fieldBisReg) 1050 1074 { 1051 1075 fieldB = state->_offset; 1052 1076 WRITE_FORMAT_x_RB(B); 1053 1077 } 1054 else 1078 else 1055 1079 { 1056 1080 WRITE_FORMAT_x(B); 1057 if (fieldBisReg && fieldA != 0) 1081 if (fieldBisReg && fieldA != 0) 1058 1082 { 1059 1083 fieldAisReg = 0; … … 1063 1087 WRITE_FORMAT_RB(); 1064 1088 } 1065 my_sprintf (state, state->operandBuffer, formatString, fieldC, fieldB, fieldA); 1089 my_sprintf (state, state->operandBuffer, formatString, 1090 fieldC, fieldB, fieldA); 1066 1091 write_comments2(fieldA); 1067 1092 break; … … 1070 1095 CHECK_FIELD_B(); 1071 1096 CHECK_FIELD_C(); 1072 1097 1073 1098 write_instr_name(); 1074 1099 WRITE_FORMAT_x_COMMA_LB(C); … … 1080 1105 write_comments(); 1081 1106 break; 1082 1107 1083 1108 case 9: 1084 1109 write_instr_name(); 1085 1110 state->operandBuffer[0] = '\0'; 1086 1111 break; 1087 1112 1088 1113 case 10: 1089 1114 /* LR instruction */ 1090 1115 CHECK_FIELD_A(); 1091 1116 CHECK_FIELD_B(); 1092 1117 1093 1118 write_instr_name(); 1094 1119 WRITE_FORMAT_x_COMMA_LB(A); … … 1100 1125 write_comments(); 1101 1126 break; 1102 1127 1103 1128 case 11: 1104 1129 CHECK_COND(); … … 1106 1131 state->operandBuffer[0] = '\0'; 1107 1132 break; 1108 1133 1109 1134 default: 1110 1135 mwerror (state, "Bad decoding class in ARC disassembler"); 1111 1136 break; 1112 1137 } 1113 1138 1114 1139 state->_cond = cond; 1115 1140 return state->instructionLen = offset; … … 1130 1155 _auxRegName(void *_this ATTRIBUTE_UNUSED, int regval) 1131 1156 { 1132 1157 return arcExtMap_auxRegName(regval); 1133 1158 } 1134 1159 … … 1138 1163 _condCodeName(void *_this ATTRIBUTE_UNUSED, int regval) 1139 1164 { 1140 1165 return arcExtMap_condCodeName(regval); 1141 1166 } 1142 1167 … … 1145 1170 _instName (void *_this ATTRIBUTE_UNUSED, int majop, int minop, int *flags) 1146 1171 { 1147 1172 return arcExtMap_instName(majop, minop, flags); 1148 1173 } 1149 1174 … … 1159 1184 struct arcDisState s; /* ARC Disassembler state */ 1160 1185 void *stream = info->stream; /* output stream */ 1161 fprintf_ftype func = info->fprintf_func; 1186 fprintf_ftype func = info->fprintf_func; 1162 1187 int bytes; 1163 1188 1164 1189 memset (&s, 0, sizeof(struct arcDisState)); 1165 1190 1166 1191 /* read first instruction */ 1167 1192 status = (*info->read_memory_func) (address, buffer, 4, info); … … 1196 1221 (*func) (stream, "%08x ", s.words[0]); 1197 1222 (*func) (stream, " "); 1198 1223 1199 1224 (*func) (stream, "%-10s ", s.instrBuffer); 1200 1225 1201 1226 if (__TRANSLATION_REQUIRED(s)) 1202 1227 { -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.