cris-dis.c 80 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895
  1. /* Disassembler code for CRIS.
  2. Copyright 2000, 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
  3. Contributed by Axis Communications AB, Lund, Sweden.
  4. Written by Hans-Peter Nilsson.
  5. This file is part of the GNU binutils and GDB, the GNU debugger.
  6. This program is free software; you can redistribute it and/or modify it
  7. under the terms of the GNU General Public License as published by the
  8. Free Software Foundation; either version 2, or (at your option) any later
  9. version.
  10. This program is distributed in the hope that it will be useful, but WITHOUT
  11. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  17. MA 02110-1301, USA. */
  18. #include "dis-asm.h"
  19. //#include "sysdep.h"
  20. #include "target-cris/opcode-cris.h"
  21. //#include "libiberty.h"
  22. void *qemu_malloc(size_t len); /* can't include qemu-common.h here */
  23. #define FALSE 0
  24. #define TRUE 1
  25. #define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0)
  26. /* cris-opc.c -- Table of opcodes for the CRIS processor.
  27. Copyright 2000, 2001, 2004 Free Software Foundation, Inc.
  28. Contributed by Axis Communications AB, Lund, Sweden.
  29. Originally written for GAS 1.38.1 by Mikael Asker.
  30. Reorganized by Hans-Peter Nilsson.
  31. This file is part of GAS, GDB and the GNU binutils.
  32. GAS, GDB, and GNU binutils is free software; you can redistribute it
  33. and/or modify it under the terms of the GNU General Public License as
  34. published by the Free Software Foundation; either version 2, or (at your
  35. option) any later version.
  36. GAS, GDB, and GNU binutils are distributed in the hope that they will be
  37. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  38. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  39. GNU General Public License for more details.
  40. You should have received a copy of the GNU General Public License
  41. along with this program; if not, write to the Free Software
  42. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
  43. #ifndef NULL
  44. #define NULL (0)
  45. #endif
  46. /* This table isn't used for CRISv32 and the size of immediate operands. */
  47. const struct cris_spec_reg
  48. cris_spec_regs[] =
  49. {
  50. {"bz", 0, 1, cris_ver_v32p, NULL},
  51. {"p0", 0, 1, 0, NULL},
  52. {"vr", 1, 1, 0, NULL},
  53. {"p1", 1, 1, 0, NULL},
  54. {"pid", 2, 1, cris_ver_v32p, NULL},
  55. {"p2", 2, 1, cris_ver_v32p, NULL},
  56. {"p2", 2, 1, cris_ver_warning, NULL},
  57. {"srs", 3, 1, cris_ver_v32p, NULL},
  58. {"p3", 3, 1, cris_ver_v32p, NULL},
  59. {"p3", 3, 1, cris_ver_warning, NULL},
  60. {"wz", 4, 2, cris_ver_v32p, NULL},
  61. {"p4", 4, 2, 0, NULL},
  62. {"ccr", 5, 2, cris_ver_v0_10, NULL},
  63. {"exs", 5, 4, cris_ver_v32p, NULL},
  64. {"p5", 5, 2, cris_ver_v0_10, NULL},
  65. {"p5", 5, 4, cris_ver_v32p, NULL},
  66. {"dcr0",6, 2, cris_ver_v0_3, NULL},
  67. {"eda", 6, 4, cris_ver_v32p, NULL},
  68. {"p6", 6, 2, cris_ver_v0_3, NULL},
  69. {"p6", 6, 4, cris_ver_v32p, NULL},
  70. {"dcr1/mof", 7, 4, cris_ver_v10p,
  71. "Register `dcr1/mof' with ambiguous size specified. Guessing 4 bytes"},
  72. {"dcr1/mof", 7, 2, cris_ver_v0_3,
  73. "Register `dcr1/mof' with ambiguous size specified. Guessing 2 bytes"},
  74. {"mof", 7, 4, cris_ver_v10p, NULL},
  75. {"dcr1",7, 2, cris_ver_v0_3, NULL},
  76. {"p7", 7, 4, cris_ver_v10p, NULL},
  77. {"p7", 7, 2, cris_ver_v0_3, NULL},
  78. {"dz", 8, 4, cris_ver_v32p, NULL},
  79. {"p8", 8, 4, 0, NULL},
  80. {"ibr", 9, 4, cris_ver_v0_10, NULL},
  81. {"ebp", 9, 4, cris_ver_v32p, NULL},
  82. {"p9", 9, 4, 0, NULL},
  83. {"irp", 10, 4, cris_ver_v0_10, NULL},
  84. {"erp", 10, 4, cris_ver_v32p, NULL},
  85. {"p10", 10, 4, 0, NULL},
  86. {"srp", 11, 4, 0, NULL},
  87. {"p11", 11, 4, 0, NULL},
  88. /* For disassembly use only. Accept at assembly with a warning. */
  89. {"bar/dtp0", 12, 4, cris_ver_warning,
  90. "Ambiguous register `bar/dtp0' specified"},
  91. {"nrp", 12, 4, cris_ver_v32p, NULL},
  92. {"bar", 12, 4, cris_ver_v8_10, NULL},
  93. {"dtp0",12, 4, cris_ver_v0_3, NULL},
  94. {"p12", 12, 4, 0, NULL},
  95. /* For disassembly use only. Accept at assembly with a warning. */
  96. {"dccr/dtp1",13, 4, cris_ver_warning,
  97. "Ambiguous register `dccr/dtp1' specified"},
  98. {"ccs", 13, 4, cris_ver_v32p, NULL},
  99. {"dccr",13, 4, cris_ver_v8_10, NULL},
  100. {"dtp1",13, 4, cris_ver_v0_3, NULL},
  101. {"p13", 13, 4, 0, NULL},
  102. {"brp", 14, 4, cris_ver_v3_10, NULL},
  103. {"usp", 14, 4, cris_ver_v32p, NULL},
  104. {"p14", 14, 4, cris_ver_v3p, NULL},
  105. {"usp", 15, 4, cris_ver_v10, NULL},
  106. {"spc", 15, 4, cris_ver_v32p, NULL},
  107. {"p15", 15, 4, cris_ver_v10p, NULL},
  108. {NULL, 0, 0, cris_ver_version_all, NULL}
  109. };
  110. /* Add version specifiers to this table when necessary.
  111. The (now) regular coding of register names suggests a simpler
  112. implementation. */
  113. const struct cris_support_reg cris_support_regs[] =
  114. {
  115. {"s0", 0},
  116. {"s1", 1},
  117. {"s2", 2},
  118. {"s3", 3},
  119. {"s4", 4},
  120. {"s5", 5},
  121. {"s6", 6},
  122. {"s7", 7},
  123. {"s8", 8},
  124. {"s9", 9},
  125. {"s10", 10},
  126. {"s11", 11},
  127. {"s12", 12},
  128. {"s13", 13},
  129. {"s14", 14},
  130. {"s15", 15},
  131. {NULL, 0}
  132. };
  133. /* All CRIS opcodes are 16 bits.
  134. - The match component is a mask saying which bits must match a
  135. particular opcode in order for an instruction to be an instance
  136. of that opcode.
  137. - The args component is a string containing characters symbolically
  138. matching the operands of an instruction. Used for both assembly
  139. and disassembly.
  140. Operand-matching characters:
  141. [ ] , space
  142. Verbatim.
  143. A The string "ACR" (case-insensitive).
  144. B Not really an operand. It causes a "BDAP -size,SP" prefix to be
  145. output for the PUSH alias-instructions and recognizes a push-
  146. prefix at disassembly. This letter isn't recognized for v32.
  147. Must be followed by a R or P letter.
  148. ! Non-match pattern, will not match if there's a prefix insn.
  149. b Non-matching operand, used for branches with 16-bit
  150. displacement. Only recognized by the disassembler.
  151. c 5-bit unsigned immediate in bits <4:0>.
  152. C 4-bit unsigned immediate in bits <3:0>.
  153. d At assembly, optionally (as in put other cases before this one)
  154. ".d" or ".D" at the start of the operands, followed by one space
  155. character. At disassembly, nothing.
  156. D General register in bits <15:12> and <3:0>.
  157. f List of flags in bits <15:12> and <3:0>.
  158. i 6-bit signed immediate in bits <5:0>.
  159. I 6-bit unsigned immediate in bits <5:0>.
  160. M Size modifier (B, W or D) for CLEAR instructions.
  161. m Size modifier (B, W or D) in bits <5:4>
  162. N A 32-bit dword, like in the difference between s and y.
  163. This has no effect on bits in the opcode. Can also be expressed
  164. as "[pc+]" in input.
  165. n As N, but PC-relative (to the start of the instruction).
  166. o [-128..127] word offset in bits <7:1> and <0>. Used by 8-bit
  167. branch instructions.
  168. O [-128..127] offset in bits <7:0>. Also matches a comma and a
  169. general register after the expression, in bits <15:12>. Used
  170. only for the BDAP prefix insn (in v32 the ADDOQ insn; same opcode).
  171. P Special register in bits <15:12>.
  172. p Indicates that the insn is a prefix insn. Must be first
  173. character.
  174. Q As O, but don't relax; force an 8-bit offset.
  175. R General register in bits <15:12>.
  176. r General register in bits <3:0>.
  177. S Source operand in bit <10> and a prefix; a 3-operand prefix
  178. without side-effect.
  179. s Source operand in bits <10> and <3:0>, optionally with a
  180. side-effect prefix, except [pc] (the name, not R15 as in ACR)
  181. isn't allowed for v32 and higher.
  182. T Support register in bits <15:12>.
  183. u 4-bit (PC-relative) unsigned immediate word offset in bits <3:0>.
  184. U Relaxes to either u or n, instruction is assumed LAPCQ or LAPC.
  185. Not recognized at disassembly.
  186. x Register-dot-modifier, for example "r5.w" in bits <15:12> and <5:4>.
  187. y Like 's' but do not allow an integer at assembly.
  188. Y The difference s-y; only an integer is allowed.
  189. z Size modifier (B or W) in bit <4>. */
  190. /* Please note the order of the opcodes in this table is significant.
  191. The assembler requires that all instances of the same mnemonic must
  192. be consecutive. If they aren't, the assembler might not recognize
  193. them, or may indicate an internal error.
  194. The disassembler should not normally care about the order of the
  195. opcodes, but will prefer an earlier alternative if the "match-score"
  196. (see cris-dis.c) is computed as equal.
  197. It should not be significant for proper execution that this table is
  198. in alphabetical order, but please follow that convention for an easy
  199. overview. */
  200. const struct cris_opcode
  201. cris_opcodes[] =
  202. {
  203. {"abs", 0x06B0, 0x0940, "r,R", 0, SIZE_NONE, 0,
  204. cris_abs_op},
  205. {"add", 0x0600, 0x09c0, "m r,R", 0, SIZE_NONE, 0,
  206. cris_reg_mode_add_sub_cmp_and_or_move_op},
  207. {"add", 0x0A00, 0x01c0, "m s,R", 0, SIZE_FIELD, 0,
  208. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  209. {"add", 0x0A00, 0x01c0, "m S,D", 0, SIZE_NONE,
  210. cris_ver_v0_10,
  211. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  212. {"add", 0x0a00, 0x05c0, "m S,R,r", 0, SIZE_NONE,
  213. cris_ver_v0_10,
  214. cris_three_operand_add_sub_cmp_and_or_op},
  215. {"add", 0x0A00, 0x01c0, "m s,R", 0, SIZE_FIELD,
  216. cris_ver_v32p,
  217. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  218. {"addc", 0x0570, 0x0A80, "r,R", 0, SIZE_FIX_32,
  219. cris_ver_v32p,
  220. cris_not_implemented_op},
  221. {"addc", 0x09A0, 0x0250, "s,R", 0, SIZE_FIX_32,
  222. cris_ver_v32p,
  223. cris_not_implemented_op},
  224. {"addi", 0x0540, 0x0A80, "x,r,A", 0, SIZE_NONE,
  225. cris_ver_v32p,
  226. cris_addi_op},
  227. {"addi", 0x0500, 0x0Ac0, "x,r", 0, SIZE_NONE, 0,
  228. cris_addi_op},
  229. /* This collates after "addo", but we want to disassemble as "addoq",
  230. not "addo". */
  231. {"addoq", 0x0100, 0x0E00, "Q,A", 0, SIZE_NONE,
  232. cris_ver_v32p,
  233. cris_not_implemented_op},
  234. {"addo", 0x0940, 0x0280, "m s,R,A", 0, SIZE_FIELD_SIGNED,
  235. cris_ver_v32p,
  236. cris_not_implemented_op},
  237. /* This must be located after the insn above, lest we misinterpret
  238. "addo.b -1,r0,acr" as "addo .b-1,r0,acr". FIXME: Sounds like a
  239. parser bug. */
  240. {"addo", 0x0100, 0x0E00, "O,A", 0, SIZE_NONE,
  241. cris_ver_v32p,
  242. cris_not_implemented_op},
  243. {"addq", 0x0200, 0x0Dc0, "I,R", 0, SIZE_NONE, 0,
  244. cris_quick_mode_add_sub_op},
  245. {"adds", 0x0420, 0x0Bc0, "z r,R", 0, SIZE_NONE, 0,
  246. cris_reg_mode_add_sub_cmp_and_or_move_op},
  247. /* FIXME: SIZE_FIELD_SIGNED and all necessary changes. */
  248. {"adds", 0x0820, 0x03c0, "z s,R", 0, SIZE_FIELD, 0,
  249. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  250. {"adds", 0x0820, 0x03c0, "z S,D", 0, SIZE_NONE,
  251. cris_ver_v0_10,
  252. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  253. {"adds", 0x0820, 0x07c0, "z S,R,r", 0, SIZE_NONE,
  254. cris_ver_v0_10,
  255. cris_three_operand_add_sub_cmp_and_or_op},
  256. {"addu", 0x0400, 0x0be0, "z r,R", 0, SIZE_NONE, 0,
  257. cris_reg_mode_add_sub_cmp_and_or_move_op},
  258. /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
  259. {"addu", 0x0800, 0x03e0, "z s,R", 0, SIZE_FIELD, 0,
  260. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  261. {"addu", 0x0800, 0x03e0, "z S,D", 0, SIZE_NONE,
  262. cris_ver_v0_10,
  263. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  264. {"addu", 0x0800, 0x07e0, "z S,R,r", 0, SIZE_NONE,
  265. cris_ver_v0_10,
  266. cris_three_operand_add_sub_cmp_and_or_op},
  267. {"and", 0x0700, 0x08C0, "m r,R", 0, SIZE_NONE, 0,
  268. cris_reg_mode_add_sub_cmp_and_or_move_op},
  269. {"and", 0x0B00, 0x00C0, "m s,R", 0, SIZE_FIELD, 0,
  270. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  271. {"and", 0x0B00, 0x00C0, "m S,D", 0, SIZE_NONE,
  272. cris_ver_v0_10,
  273. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  274. {"and", 0x0B00, 0x04C0, "m S,R,r", 0, SIZE_NONE,
  275. cris_ver_v0_10,
  276. cris_three_operand_add_sub_cmp_and_or_op},
  277. {"andq", 0x0300, 0x0CC0, "i,R", 0, SIZE_NONE, 0,
  278. cris_quick_mode_and_cmp_move_or_op},
  279. {"asr", 0x0780, 0x0840, "m r,R", 0, SIZE_NONE, 0,
  280. cris_asr_op},
  281. {"asrq", 0x03a0, 0x0c40, "c,R", 0, SIZE_NONE, 0,
  282. cris_asrq_op},
  283. {"ax", 0x15B0, 0xEA4F, "", 0, SIZE_NONE, 0,
  284. cris_ax_ei_setf_op},
  285. /* FIXME: Should use branch #defines. */
  286. {"b", 0x0dff, 0x0200, "b", 1, SIZE_NONE, 0,
  287. cris_sixteen_bit_offset_branch_op},
  288. {"ba",
  289. BA_QUICK_OPCODE,
  290. 0x0F00+(0xF-CC_A)*0x1000, "o", 1, SIZE_NONE, 0,
  291. cris_eight_bit_offset_branch_op},
  292. /* Needs to come after the usual "ba o", which might be relaxed to
  293. this one. */
  294. {"ba", BA_DWORD_OPCODE,
  295. 0xffff & (~BA_DWORD_OPCODE), "n", 0, SIZE_FIX_32,
  296. cris_ver_v32p,
  297. cris_none_reg_mode_jump_op},
  298. {"bas", 0x0EBF, 0x0140, "n,P", 0, SIZE_FIX_32,
  299. cris_ver_v32p,
  300. cris_none_reg_mode_jump_op},
  301. {"basc", 0x0EFF, 0x0100, "n,P", 0, SIZE_FIX_32,
  302. cris_ver_v32p,
  303. cris_none_reg_mode_jump_op},
  304. {"bcc",
  305. BRANCH_QUICK_OPCODE+CC_CC*0x1000,
  306. 0x0f00+(0xF-CC_CC)*0x1000, "o", 1, SIZE_NONE, 0,
  307. cris_eight_bit_offset_branch_op},
  308. {"bcs",
  309. BRANCH_QUICK_OPCODE+CC_CS*0x1000,
  310. 0x0f00+(0xF-CC_CS)*0x1000, "o", 1, SIZE_NONE, 0,
  311. cris_eight_bit_offset_branch_op},
  312. {"bdap",
  313. BDAP_INDIR_OPCODE, BDAP_INDIR_Z_BITS, "pm s,R", 0, SIZE_FIELD_SIGNED,
  314. cris_ver_v0_10,
  315. cris_bdap_prefix},
  316. {"bdap",
  317. BDAP_QUICK_OPCODE, BDAP_QUICK_Z_BITS, "pO", 0, SIZE_NONE,
  318. cris_ver_v0_10,
  319. cris_quick_mode_bdap_prefix},
  320. {"beq",
  321. BRANCH_QUICK_OPCODE+CC_EQ*0x1000,
  322. 0x0f00+(0xF-CC_EQ)*0x1000, "o", 1, SIZE_NONE, 0,
  323. cris_eight_bit_offset_branch_op},
  324. /* This is deliberately put before "bext" to trump it, even though not
  325. in alphabetical order, since we don't do excluding version checks
  326. for v0..v10. */
  327. {"bwf",
  328. BRANCH_QUICK_OPCODE+CC_EXT*0x1000,
  329. 0x0f00+(0xF-CC_EXT)*0x1000, "o", 1, SIZE_NONE,
  330. cris_ver_v10,
  331. cris_eight_bit_offset_branch_op},
  332. {"bext",
  333. BRANCH_QUICK_OPCODE+CC_EXT*0x1000,
  334. 0x0f00+(0xF-CC_EXT)*0x1000, "o", 1, SIZE_NONE,
  335. cris_ver_v0_3,
  336. cris_eight_bit_offset_branch_op},
  337. {"bge",
  338. BRANCH_QUICK_OPCODE+CC_GE*0x1000,
  339. 0x0f00+(0xF-CC_GE)*0x1000, "o", 1, SIZE_NONE, 0,
  340. cris_eight_bit_offset_branch_op},
  341. {"bgt",
  342. BRANCH_QUICK_OPCODE+CC_GT*0x1000,
  343. 0x0f00+(0xF-CC_GT)*0x1000, "o", 1, SIZE_NONE, 0,
  344. cris_eight_bit_offset_branch_op},
  345. {"bhi",
  346. BRANCH_QUICK_OPCODE+CC_HI*0x1000,
  347. 0x0f00+(0xF-CC_HI)*0x1000, "o", 1, SIZE_NONE, 0,
  348. cris_eight_bit_offset_branch_op},
  349. {"bhs",
  350. BRANCH_QUICK_OPCODE+CC_HS*0x1000,
  351. 0x0f00+(0xF-CC_HS)*0x1000, "o", 1, SIZE_NONE, 0,
  352. cris_eight_bit_offset_branch_op},
  353. {"biap", BIAP_OPCODE, BIAP_Z_BITS, "pm r,R", 0, SIZE_NONE,
  354. cris_ver_v0_10,
  355. cris_biap_prefix},
  356. {"ble",
  357. BRANCH_QUICK_OPCODE+CC_LE*0x1000,
  358. 0x0f00+(0xF-CC_LE)*0x1000, "o", 1, SIZE_NONE, 0,
  359. cris_eight_bit_offset_branch_op},
  360. {"blo",
  361. BRANCH_QUICK_OPCODE+CC_LO*0x1000,
  362. 0x0f00+(0xF-CC_LO)*0x1000, "o", 1, SIZE_NONE, 0,
  363. cris_eight_bit_offset_branch_op},
  364. {"bls",
  365. BRANCH_QUICK_OPCODE+CC_LS*0x1000,
  366. 0x0f00+(0xF-CC_LS)*0x1000, "o", 1, SIZE_NONE, 0,
  367. cris_eight_bit_offset_branch_op},
  368. {"blt",
  369. BRANCH_QUICK_OPCODE+CC_LT*0x1000,
  370. 0x0f00+(0xF-CC_LT)*0x1000, "o", 1, SIZE_NONE, 0,
  371. cris_eight_bit_offset_branch_op},
  372. {"bmi",
  373. BRANCH_QUICK_OPCODE+CC_MI*0x1000,
  374. 0x0f00+(0xF-CC_MI)*0x1000, "o", 1, SIZE_NONE, 0,
  375. cris_eight_bit_offset_branch_op},
  376. {"bmod", 0x0ab0, 0x0140, "s,R", 0, SIZE_FIX_32,
  377. cris_ver_sim_v0_10,
  378. cris_not_implemented_op},
  379. {"bmod", 0x0ab0, 0x0140, "S,D", 0, SIZE_NONE,
  380. cris_ver_sim_v0_10,
  381. cris_not_implemented_op},
  382. {"bmod", 0x0ab0, 0x0540, "S,R,r", 0, SIZE_NONE,
  383. cris_ver_sim_v0_10,
  384. cris_not_implemented_op},
  385. {"bne",
  386. BRANCH_QUICK_OPCODE+CC_NE*0x1000,
  387. 0x0f00+(0xF-CC_NE)*0x1000, "o", 1, SIZE_NONE, 0,
  388. cris_eight_bit_offset_branch_op},
  389. {"bound", 0x05c0, 0x0A00, "m r,R", 0, SIZE_NONE, 0,
  390. cris_two_operand_bound_op},
  391. /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
  392. {"bound", 0x09c0, 0x0200, "m s,R", 0, SIZE_FIELD,
  393. cris_ver_v0_10,
  394. cris_two_operand_bound_op},
  395. /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
  396. {"bound", 0x0dcf, 0x0200, "m Y,R", 0, SIZE_FIELD, 0,
  397. cris_two_operand_bound_op},
  398. {"bound", 0x09c0, 0x0200, "m S,D", 0, SIZE_NONE,
  399. cris_ver_v0_10,
  400. cris_two_operand_bound_op},
  401. {"bound", 0x09c0, 0x0600, "m S,R,r", 0, SIZE_NONE,
  402. cris_ver_v0_10,
  403. cris_three_operand_bound_op},
  404. {"bpl",
  405. BRANCH_QUICK_OPCODE+CC_PL*0x1000,
  406. 0x0f00+(0xF-CC_PL)*0x1000, "o", 1, SIZE_NONE, 0,
  407. cris_eight_bit_offset_branch_op},
  408. {"break", 0xe930, 0x16c0, "C", 0, SIZE_NONE,
  409. cris_ver_v3p,
  410. cris_break_op},
  411. {"bsb",
  412. BRANCH_QUICK_OPCODE+CC_EXT*0x1000,
  413. 0x0f00+(0xF-CC_EXT)*0x1000, "o", 1, SIZE_NONE,
  414. cris_ver_v32p,
  415. cris_eight_bit_offset_branch_op},
  416. {"bsr", 0xBEBF, 0x4140, "n", 0, SIZE_FIX_32,
  417. cris_ver_v32p,
  418. cris_none_reg_mode_jump_op},
  419. {"bsrc", 0xBEFF, 0x4100, "n", 0, SIZE_FIX_32,
  420. cris_ver_v32p,
  421. cris_none_reg_mode_jump_op},
  422. {"bstore", 0x0af0, 0x0100, "s,R", 0, SIZE_FIX_32,
  423. cris_ver_warning,
  424. cris_not_implemented_op},
  425. {"bstore", 0x0af0, 0x0100, "S,D", 0, SIZE_NONE,
  426. cris_ver_warning,
  427. cris_not_implemented_op},
  428. {"bstore", 0x0af0, 0x0500, "S,R,r", 0, SIZE_NONE,
  429. cris_ver_warning,
  430. cris_not_implemented_op},
  431. {"btst", 0x04F0, 0x0B00, "r,R", 0, SIZE_NONE, 0,
  432. cris_btst_nop_op},
  433. {"btstq", 0x0380, 0x0C60, "c,R", 0, SIZE_NONE, 0,
  434. cris_btst_nop_op},
  435. {"bvc",
  436. BRANCH_QUICK_OPCODE+CC_VC*0x1000,
  437. 0x0f00+(0xF-CC_VC)*0x1000, "o", 1, SIZE_NONE, 0,
  438. cris_eight_bit_offset_branch_op},
  439. {"bvs",
  440. BRANCH_QUICK_OPCODE+CC_VS*0x1000,
  441. 0x0f00+(0xF-CC_VS)*0x1000, "o", 1, SIZE_NONE, 0,
  442. cris_eight_bit_offset_branch_op},
  443. {"clear", 0x0670, 0x3980, "M r", 0, SIZE_NONE, 0,
  444. cris_reg_mode_clear_op},
  445. {"clear", 0x0A70, 0x3180, "M y", 0, SIZE_NONE, 0,
  446. cris_none_reg_mode_clear_test_op},
  447. {"clear", 0x0A70, 0x3180, "M S", 0, SIZE_NONE,
  448. cris_ver_v0_10,
  449. cris_none_reg_mode_clear_test_op},
  450. {"clearf", 0x05F0, 0x0A00, "f", 0, SIZE_NONE, 0,
  451. cris_clearf_di_op},
  452. {"cmp", 0x06C0, 0x0900, "m r,R", 0, SIZE_NONE, 0,
  453. cris_reg_mode_add_sub_cmp_and_or_move_op},
  454. {"cmp", 0x0Ac0, 0x0100, "m s,R", 0, SIZE_FIELD, 0,
  455. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  456. {"cmp", 0x0Ac0, 0x0100, "m S,D", 0, SIZE_NONE,
  457. cris_ver_v0_10,
  458. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  459. {"cmpq", 0x02C0, 0x0D00, "i,R", 0, SIZE_NONE, 0,
  460. cris_quick_mode_and_cmp_move_or_op},
  461. /* FIXME: SIZE_FIELD_SIGNED and all necessary changes. */
  462. {"cmps", 0x08e0, 0x0300, "z s,R", 0, SIZE_FIELD, 0,
  463. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  464. {"cmps", 0x08e0, 0x0300, "z S,D", 0, SIZE_NONE,
  465. cris_ver_v0_10,
  466. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  467. /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
  468. {"cmpu", 0x08c0, 0x0320, "z s,R" , 0, SIZE_FIELD, 0,
  469. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  470. {"cmpu", 0x08c0, 0x0320, "z S,D", 0, SIZE_NONE,
  471. cris_ver_v0_10,
  472. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  473. {"di", 0x25F0, 0xDA0F, "", 0, SIZE_NONE, 0,
  474. cris_clearf_di_op},
  475. {"dip", DIP_OPCODE, DIP_Z_BITS, "ps", 0, SIZE_FIX_32,
  476. cris_ver_v0_10,
  477. cris_dip_prefix},
  478. {"div", 0x0980, 0x0640, "m R,r", 0, SIZE_FIELD, 0,
  479. cris_not_implemented_op},
  480. {"dstep", 0x06f0, 0x0900, "r,R", 0, SIZE_NONE, 0,
  481. cris_dstep_logshift_mstep_neg_not_op},
  482. {"ei", 0x25B0, 0xDA4F, "", 0, SIZE_NONE, 0,
  483. cris_ax_ei_setf_op},
  484. {"fidxd", 0x0ab0, 0xf540, "[r]", 0, SIZE_NONE,
  485. cris_ver_v32p,
  486. cris_not_implemented_op},
  487. {"fidxi", 0x0d30, 0xF2C0, "[r]", 0, SIZE_NONE,
  488. cris_ver_v32p,
  489. cris_not_implemented_op},
  490. {"ftagd", 0x1AB0, 0xE540, "[r]", 0, SIZE_NONE,
  491. cris_ver_v32p,
  492. cris_not_implemented_op},
  493. {"ftagi", 0x1D30, 0xE2C0, "[r]", 0, SIZE_NONE,
  494. cris_ver_v32p,
  495. cris_not_implemented_op},
  496. {"halt", 0xF930, 0x06CF, "", 0, SIZE_NONE,
  497. cris_ver_v32p,
  498. cris_not_implemented_op},
  499. {"jas", 0x09B0, 0x0640, "r,P", 0, SIZE_NONE,
  500. cris_ver_v32p,
  501. cris_reg_mode_jump_op},
  502. {"jas", 0x0DBF, 0x0240, "N,P", 0, SIZE_FIX_32,
  503. cris_ver_v32p,
  504. cris_reg_mode_jump_op},
  505. {"jasc", 0x0B30, 0x04C0, "r,P", 0, SIZE_NONE,
  506. cris_ver_v32p,
  507. cris_reg_mode_jump_op},
  508. {"jasc", 0x0F3F, 0x00C0, "N,P", 0, SIZE_FIX_32,
  509. cris_ver_v32p,
  510. cris_reg_mode_jump_op},
  511. {"jbrc", 0x69b0, 0x9640, "r", 0, SIZE_NONE,
  512. cris_ver_v8_10,
  513. cris_reg_mode_jump_op},
  514. {"jbrc", 0x6930, 0x92c0, "s", 0, SIZE_FIX_32,
  515. cris_ver_v8_10,
  516. cris_none_reg_mode_jump_op},
  517. {"jbrc", 0x6930, 0x92c0, "S", 0, SIZE_NONE,
  518. cris_ver_v8_10,
  519. cris_none_reg_mode_jump_op},
  520. {"jir", 0xA9b0, 0x5640, "r", 0, SIZE_NONE,
  521. cris_ver_v8_10,
  522. cris_reg_mode_jump_op},
  523. {"jir", 0xA930, 0x52c0, "s", 0, SIZE_FIX_32,
  524. cris_ver_v8_10,
  525. cris_none_reg_mode_jump_op},
  526. {"jir", 0xA930, 0x52c0, "S", 0, SIZE_NONE,
  527. cris_ver_v8_10,
  528. cris_none_reg_mode_jump_op},
  529. {"jirc", 0x29b0, 0xd640, "r", 0, SIZE_NONE,
  530. cris_ver_v8_10,
  531. cris_reg_mode_jump_op},
  532. {"jirc", 0x2930, 0xd2c0, "s", 0, SIZE_FIX_32,
  533. cris_ver_v8_10,
  534. cris_none_reg_mode_jump_op},
  535. {"jirc", 0x2930, 0xd2c0, "S", 0, SIZE_NONE,
  536. cris_ver_v8_10,
  537. cris_none_reg_mode_jump_op},
  538. {"jsr", 0xB9b0, 0x4640, "r", 0, SIZE_NONE, 0,
  539. cris_reg_mode_jump_op},
  540. {"jsr", 0xB930, 0x42c0, "s", 0, SIZE_FIX_32,
  541. cris_ver_v0_10,
  542. cris_none_reg_mode_jump_op},
  543. {"jsr", 0xBDBF, 0x4240, "N", 0, SIZE_FIX_32,
  544. cris_ver_v32p,
  545. cris_none_reg_mode_jump_op},
  546. {"jsr", 0xB930, 0x42c0, "S", 0, SIZE_NONE,
  547. cris_ver_v0_10,
  548. cris_none_reg_mode_jump_op},
  549. {"jsrc", 0x39b0, 0xc640, "r", 0, SIZE_NONE,
  550. cris_ver_v8_10,
  551. cris_reg_mode_jump_op},
  552. {"jsrc", 0x3930, 0xc2c0, "s", 0, SIZE_FIX_32,
  553. cris_ver_v8_10,
  554. cris_none_reg_mode_jump_op},
  555. {"jsrc", 0x3930, 0xc2c0, "S", 0, SIZE_NONE,
  556. cris_ver_v8_10,
  557. cris_none_reg_mode_jump_op},
  558. {"jsrc", 0xBB30, 0x44C0, "r", 0, SIZE_NONE,
  559. cris_ver_v32p,
  560. cris_reg_mode_jump_op},
  561. {"jsrc", 0xBF3F, 0x40C0, "N", 0, SIZE_FIX_32,
  562. cris_ver_v32p,
  563. cris_reg_mode_jump_op},
  564. {"jump", 0x09b0, 0xF640, "r", 0, SIZE_NONE, 0,
  565. cris_reg_mode_jump_op},
  566. {"jump",
  567. JUMP_INDIR_OPCODE, JUMP_INDIR_Z_BITS, "s", 0, SIZE_FIX_32,
  568. cris_ver_v0_10,
  569. cris_none_reg_mode_jump_op},
  570. {"jump",
  571. JUMP_INDIR_OPCODE, JUMP_INDIR_Z_BITS, "S", 0, SIZE_NONE,
  572. cris_ver_v0_10,
  573. cris_none_reg_mode_jump_op},
  574. {"jump", 0x09F0, 0x060F, "P", 0, SIZE_NONE,
  575. cris_ver_v32p,
  576. cris_none_reg_mode_jump_op},
  577. {"jump",
  578. JUMP_PC_INCR_OPCODE_V32,
  579. (0xffff & ~JUMP_PC_INCR_OPCODE_V32), "N", 0, SIZE_FIX_32,
  580. cris_ver_v32p,
  581. cris_none_reg_mode_jump_op},
  582. {"jmpu", 0x8930, 0x72c0, "s", 0, SIZE_FIX_32,
  583. cris_ver_v10,
  584. cris_none_reg_mode_jump_op},
  585. {"jmpu", 0x8930, 0x72c0, "S", 0, SIZE_NONE,
  586. cris_ver_v10,
  587. cris_none_reg_mode_jump_op},
  588. {"lapc", 0x0970, 0x0680, "U,R", 0, SIZE_NONE,
  589. cris_ver_v32p,
  590. cris_not_implemented_op},
  591. {"lapc", 0x0D7F, 0x0280, "dn,R", 0, SIZE_FIX_32,
  592. cris_ver_v32p,
  593. cris_not_implemented_op},
  594. {"lapcq", 0x0970, 0x0680, "u,R", 0, SIZE_NONE,
  595. cris_ver_v32p,
  596. cris_addi_op},
  597. {"lsl", 0x04C0, 0x0B00, "m r,R", 0, SIZE_NONE, 0,
  598. cris_dstep_logshift_mstep_neg_not_op},
  599. {"lslq", 0x03c0, 0x0C20, "c,R", 0, SIZE_NONE, 0,
  600. cris_dstep_logshift_mstep_neg_not_op},
  601. {"lsr", 0x07C0, 0x0800, "m r,R", 0, SIZE_NONE, 0,
  602. cris_dstep_logshift_mstep_neg_not_op},
  603. {"lsrq", 0x03e0, 0x0C00, "c,R", 0, SIZE_NONE, 0,
  604. cris_dstep_logshift_mstep_neg_not_op},
  605. {"lz", 0x0730, 0x08C0, "r,R", 0, SIZE_NONE,
  606. cris_ver_v3p,
  607. cris_not_implemented_op},
  608. {"mcp", 0x07f0, 0x0800, "P,r", 0, SIZE_NONE,
  609. cris_ver_v32p,
  610. cris_not_implemented_op},
  611. {"move", 0x0640, 0x0980, "m r,R", 0, SIZE_NONE, 0,
  612. cris_reg_mode_add_sub_cmp_and_or_move_op},
  613. {"move", 0x0A40, 0x0180, "m s,R", 0, SIZE_FIELD, 0,
  614. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  615. {"move", 0x0A40, 0x0180, "m S,D", 0, SIZE_NONE,
  616. cris_ver_v0_10,
  617. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  618. {"move", 0x0630, 0x09c0, "r,P", 0, SIZE_NONE, 0,
  619. cris_move_to_preg_op},
  620. {"move", 0x0670, 0x0980, "P,r", 0, SIZE_NONE, 0,
  621. cris_reg_mode_move_from_preg_op},
  622. {"move", 0x0BC0, 0x0000, "m R,y", 0, SIZE_FIELD, 0,
  623. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  624. {"move", 0x0BC0, 0x0000, "m D,S", 0, SIZE_NONE,
  625. cris_ver_v0_10,
  626. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  627. {"move",
  628. MOVE_M_TO_PREG_OPCODE, MOVE_M_TO_PREG_ZBITS,
  629. "s,P", 0, SIZE_SPEC_REG, 0,
  630. cris_move_to_preg_op},
  631. {"move", 0x0A30, 0x01c0, "S,P", 0, SIZE_NONE,
  632. cris_ver_v0_10,
  633. cris_move_to_preg_op},
  634. {"move", 0x0A70, 0x0180, "P,y", 0, SIZE_SPEC_REG, 0,
  635. cris_none_reg_mode_move_from_preg_op},
  636. {"move", 0x0A70, 0x0180, "P,S", 0, SIZE_NONE,
  637. cris_ver_v0_10,
  638. cris_none_reg_mode_move_from_preg_op},
  639. {"move", 0x0B70, 0x0480, "r,T", 0, SIZE_NONE,
  640. cris_ver_v32p,
  641. cris_not_implemented_op},
  642. {"move", 0x0F70, 0x0080, "T,r", 0, SIZE_NONE,
  643. cris_ver_v32p,
  644. cris_not_implemented_op},
  645. {"movem", 0x0BF0, 0x0000, "R,y", 0, SIZE_FIX_32, 0,
  646. cris_move_reg_to_mem_movem_op},
  647. {"movem", 0x0BF0, 0x0000, "D,S", 0, SIZE_NONE,
  648. cris_ver_v0_10,
  649. cris_move_reg_to_mem_movem_op},
  650. {"movem", 0x0BB0, 0x0040, "s,R", 0, SIZE_FIX_32, 0,
  651. cris_move_mem_to_reg_movem_op},
  652. {"movem", 0x0BB0, 0x0040, "S,D", 0, SIZE_NONE,
  653. cris_ver_v0_10,
  654. cris_move_mem_to_reg_movem_op},
  655. {"moveq", 0x0240, 0x0D80, "i,R", 0, SIZE_NONE, 0,
  656. cris_quick_mode_and_cmp_move_or_op},
  657. {"movs", 0x0460, 0x0B80, "z r,R", 0, SIZE_NONE, 0,
  658. cris_reg_mode_add_sub_cmp_and_or_move_op},
  659. /* FIXME: SIZE_FIELD_SIGNED and all necessary changes. */
  660. {"movs", 0x0860, 0x0380, "z s,R", 0, SIZE_FIELD, 0,
  661. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  662. {"movs", 0x0860, 0x0380, "z S,D", 0, SIZE_NONE,
  663. cris_ver_v0_10,
  664. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  665. {"movu", 0x0440, 0x0Ba0, "z r,R", 0, SIZE_NONE, 0,
  666. cris_reg_mode_add_sub_cmp_and_or_move_op},
  667. /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
  668. {"movu", 0x0840, 0x03a0, "z s,R", 0, SIZE_FIELD, 0,
  669. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  670. {"movu", 0x0840, 0x03a0, "z S,D", 0, SIZE_NONE,
  671. cris_ver_v0_10,
  672. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  673. {"mstep", 0x07f0, 0x0800, "r,R", 0, SIZE_NONE,
  674. cris_ver_v0_10,
  675. cris_dstep_logshift_mstep_neg_not_op},
  676. {"muls", 0x0d00, 0x02c0, "m r,R", 0, SIZE_NONE,
  677. cris_ver_v10p,
  678. cris_muls_op},
  679. {"mulu", 0x0900, 0x06c0, "m r,R", 0, SIZE_NONE,
  680. cris_ver_v10p,
  681. cris_mulu_op},
  682. {"neg", 0x0580, 0x0A40, "m r,R", 0, SIZE_NONE, 0,
  683. cris_dstep_logshift_mstep_neg_not_op},
  684. {"nop", NOP_OPCODE, NOP_Z_BITS, "", 0, SIZE_NONE,
  685. cris_ver_v0_10,
  686. cris_btst_nop_op},
  687. {"nop", NOP_OPCODE_V32, NOP_Z_BITS_V32, "", 0, SIZE_NONE,
  688. cris_ver_v32p,
  689. cris_btst_nop_op},
  690. {"not", 0x8770, 0x7880, "r", 0, SIZE_NONE, 0,
  691. cris_dstep_logshift_mstep_neg_not_op},
  692. {"or", 0x0740, 0x0880, "m r,R", 0, SIZE_NONE, 0,
  693. cris_reg_mode_add_sub_cmp_and_or_move_op},
  694. {"or", 0x0B40, 0x0080, "m s,R", 0, SIZE_FIELD, 0,
  695. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  696. {"or", 0x0B40, 0x0080, "m S,D", 0, SIZE_NONE,
  697. cris_ver_v0_10,
  698. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  699. {"or", 0x0B40, 0x0480, "m S,R,r", 0, SIZE_NONE,
  700. cris_ver_v0_10,
  701. cris_three_operand_add_sub_cmp_and_or_op},
  702. {"orq", 0x0340, 0x0C80, "i,R", 0, SIZE_NONE, 0,
  703. cris_quick_mode_and_cmp_move_or_op},
  704. {"pop", 0x0E6E, 0x0191, "!R", 0, SIZE_NONE,
  705. cris_ver_v0_10,
  706. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  707. {"pop", 0x0e3e, 0x01c1, "!P", 0, SIZE_NONE,
  708. cris_ver_v0_10,
  709. cris_none_reg_mode_move_from_preg_op},
  710. {"push", 0x0FEE, 0x0011, "BR", 0, SIZE_NONE,
  711. cris_ver_v0_10,
  712. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  713. {"push", 0x0E7E, 0x0181, "BP", 0, SIZE_NONE,
  714. cris_ver_v0_10,
  715. cris_move_to_preg_op},
  716. {"rbf", 0x3b30, 0xc0c0, "y", 0, SIZE_NONE,
  717. cris_ver_v10,
  718. cris_not_implemented_op},
  719. {"rbf", 0x3b30, 0xc0c0, "S", 0, SIZE_NONE,
  720. cris_ver_v10,
  721. cris_not_implemented_op},
  722. {"rfe", 0x2930, 0xD6CF, "", 0, SIZE_NONE,
  723. cris_ver_v32p,
  724. cris_not_implemented_op},
  725. {"rfg", 0x4930, 0xB6CF, "", 0, SIZE_NONE,
  726. cris_ver_v32p,
  727. cris_not_implemented_op},
  728. {"rfn", 0x5930, 0xA6CF, "", 0, SIZE_NONE,
  729. cris_ver_v32p,
  730. cris_not_implemented_op},
  731. {"ret", 0xB67F, 0x4980, "", 1, SIZE_NONE,
  732. cris_ver_v0_10,
  733. cris_reg_mode_move_from_preg_op},
  734. {"ret", 0xB9F0, 0x460F, "", 1, SIZE_NONE,
  735. cris_ver_v32p,
  736. cris_reg_mode_move_from_preg_op},
  737. {"retb", 0xe67f, 0x1980, "", 1, SIZE_NONE,
  738. cris_ver_v0_10,
  739. cris_reg_mode_move_from_preg_op},
  740. {"rete", 0xA9F0, 0x560F, "", 1, SIZE_NONE,
  741. cris_ver_v32p,
  742. cris_reg_mode_move_from_preg_op},
  743. {"reti", 0xA67F, 0x5980, "", 1, SIZE_NONE,
  744. cris_ver_v0_10,
  745. cris_reg_mode_move_from_preg_op},
  746. {"retn", 0xC9F0, 0x360F, "", 1, SIZE_NONE,
  747. cris_ver_v32p,
  748. cris_reg_mode_move_from_preg_op},
  749. {"sbfs", 0x3b70, 0xc080, "y", 0, SIZE_NONE,
  750. cris_ver_v10,
  751. cris_not_implemented_op},
  752. {"sbfs", 0x3b70, 0xc080, "S", 0, SIZE_NONE,
  753. cris_ver_v10,
  754. cris_not_implemented_op},
  755. {"sa",
  756. 0x0530+CC_A*0x1000,
  757. 0x0AC0+(0xf-CC_A)*0x1000, "r", 0, SIZE_NONE, 0,
  758. cris_scc_op},
  759. {"ssb",
  760. 0x0530+CC_EXT*0x1000,
  761. 0x0AC0+(0xf-CC_EXT)*0x1000, "r", 0, SIZE_NONE,
  762. cris_ver_v32p,
  763. cris_scc_op},
  764. {"scc",
  765. 0x0530+CC_CC*0x1000,
  766. 0x0AC0+(0xf-CC_CC)*0x1000, "r", 0, SIZE_NONE, 0,
  767. cris_scc_op},
  768. {"scs",
  769. 0x0530+CC_CS*0x1000,
  770. 0x0AC0+(0xf-CC_CS)*0x1000, "r", 0, SIZE_NONE, 0,
  771. cris_scc_op},
  772. {"seq",
  773. 0x0530+CC_EQ*0x1000,
  774. 0x0AC0+(0xf-CC_EQ)*0x1000, "r", 0, SIZE_NONE, 0,
  775. cris_scc_op},
  776. {"setf", 0x05b0, 0x0A40, "f", 0, SIZE_NONE, 0,
  777. cris_ax_ei_setf_op},
  778. {"sfe", 0x3930, 0xC6CF, "", 0, SIZE_NONE,
  779. cris_ver_v32p,
  780. cris_not_implemented_op},
  781. /* Need to have "swf" in front of "sext" so it is the one displayed in
  782. disassembly. */
  783. {"swf",
  784. 0x0530+CC_EXT*0x1000,
  785. 0x0AC0+(0xf-CC_EXT)*0x1000, "r", 0, SIZE_NONE,
  786. cris_ver_v10,
  787. cris_scc_op},
  788. {"sext",
  789. 0x0530+CC_EXT*0x1000,
  790. 0x0AC0+(0xf-CC_EXT)*0x1000, "r", 0, SIZE_NONE,
  791. cris_ver_v0_3,
  792. cris_scc_op},
  793. {"sge",
  794. 0x0530+CC_GE*0x1000,
  795. 0x0AC0+(0xf-CC_GE)*0x1000, "r", 0, SIZE_NONE, 0,
  796. cris_scc_op},
  797. {"sgt",
  798. 0x0530+CC_GT*0x1000,
  799. 0x0AC0+(0xf-CC_GT)*0x1000, "r", 0, SIZE_NONE, 0,
  800. cris_scc_op},
  801. {"shi",
  802. 0x0530+CC_HI*0x1000,
  803. 0x0AC0+(0xf-CC_HI)*0x1000, "r", 0, SIZE_NONE, 0,
  804. cris_scc_op},
  805. {"shs",
  806. 0x0530+CC_HS*0x1000,
  807. 0x0AC0+(0xf-CC_HS)*0x1000, "r", 0, SIZE_NONE, 0,
  808. cris_scc_op},
  809. {"sle",
  810. 0x0530+CC_LE*0x1000,
  811. 0x0AC0+(0xf-CC_LE)*0x1000, "r", 0, SIZE_NONE, 0,
  812. cris_scc_op},
  813. {"slo",
  814. 0x0530+CC_LO*0x1000,
  815. 0x0AC0+(0xf-CC_LO)*0x1000, "r", 0, SIZE_NONE, 0,
  816. cris_scc_op},
  817. {"sls",
  818. 0x0530+CC_LS*0x1000,
  819. 0x0AC0+(0xf-CC_LS)*0x1000, "r", 0, SIZE_NONE, 0,
  820. cris_scc_op},
  821. {"slt",
  822. 0x0530+CC_LT*0x1000,
  823. 0x0AC0+(0xf-CC_LT)*0x1000, "r", 0, SIZE_NONE, 0,
  824. cris_scc_op},
  825. {"smi",
  826. 0x0530+CC_MI*0x1000,
  827. 0x0AC0+(0xf-CC_MI)*0x1000, "r", 0, SIZE_NONE, 0,
  828. cris_scc_op},
  829. {"sne",
  830. 0x0530+CC_NE*0x1000,
  831. 0x0AC0+(0xf-CC_NE)*0x1000, "r", 0, SIZE_NONE, 0,
  832. cris_scc_op},
  833. {"spl",
  834. 0x0530+CC_PL*0x1000,
  835. 0x0AC0+(0xf-CC_PL)*0x1000, "r", 0, SIZE_NONE, 0,
  836. cris_scc_op},
  837. {"sub", 0x0680, 0x0940, "m r,R", 0, SIZE_NONE, 0,
  838. cris_reg_mode_add_sub_cmp_and_or_move_op},
  839. {"sub", 0x0a80, 0x0140, "m s,R", 0, SIZE_FIELD, 0,
  840. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  841. {"sub", 0x0a80, 0x0140, "m S,D", 0, SIZE_NONE,
  842. cris_ver_v0_10,
  843. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  844. {"sub", 0x0a80, 0x0540, "m S,R,r", 0, SIZE_NONE,
  845. cris_ver_v0_10,
  846. cris_three_operand_add_sub_cmp_and_or_op},
  847. {"subq", 0x0280, 0x0d40, "I,R", 0, SIZE_NONE, 0,
  848. cris_quick_mode_add_sub_op},
  849. {"subs", 0x04a0, 0x0b40, "z r,R", 0, SIZE_NONE, 0,
  850. cris_reg_mode_add_sub_cmp_and_or_move_op},
  851. /* FIXME: SIZE_FIELD_SIGNED and all necessary changes. */
  852. {"subs", 0x08a0, 0x0340, "z s,R", 0, SIZE_FIELD, 0,
  853. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  854. {"subs", 0x08a0, 0x0340, "z S,D", 0, SIZE_NONE,
  855. cris_ver_v0_10,
  856. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  857. {"subs", 0x08a0, 0x0740, "z S,R,r", 0, SIZE_NONE,
  858. cris_ver_v0_10,
  859. cris_three_operand_add_sub_cmp_and_or_op},
  860. {"subu", 0x0480, 0x0b60, "z r,R", 0, SIZE_NONE, 0,
  861. cris_reg_mode_add_sub_cmp_and_or_move_op},
  862. /* FIXME: SIZE_FIELD_UNSIGNED and all necessary changes. */
  863. {"subu", 0x0880, 0x0360, "z s,R", 0, SIZE_FIELD, 0,
  864. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  865. {"subu", 0x0880, 0x0360, "z S,D", 0, SIZE_NONE,
  866. cris_ver_v0_10,
  867. cris_none_reg_mode_add_sub_cmp_and_or_move_op},
  868. {"subu", 0x0880, 0x0760, "z S,R,r", 0, SIZE_NONE,
  869. cris_ver_v0_10,
  870. cris_three_operand_add_sub_cmp_and_or_op},
  871. {"svc",
  872. 0x0530+CC_VC*0x1000,
  873. 0x0AC0+(0xf-CC_VC)*0x1000, "r", 0, SIZE_NONE, 0,
  874. cris_scc_op},
  875. {"svs",
  876. 0x0530+CC_VS*0x1000,
  877. 0x0AC0+(0xf-CC_VS)*0x1000, "r", 0, SIZE_NONE, 0,
  878. cris_scc_op},
  879. /* The insn "swapn" is the same as "not" and will be disassembled as
  880. such, but the swap* family of mnmonics are generally v8-and-higher
  881. only, so count it in. */
  882. {"swapn", 0x8770, 0x7880, "r", 0, SIZE_NONE,
  883. cris_ver_v8p,
  884. cris_not_implemented_op},
  885. {"swapw", 0x4770, 0xb880, "r", 0, SIZE_NONE,
  886. cris_ver_v8p,
  887. cris_not_implemented_op},
  888. {"swapnw", 0xc770, 0x3880, "r", 0, SIZE_NONE,
  889. cris_ver_v8p,
  890. cris_not_implemented_op},
  891. {"swapb", 0x2770, 0xd880, "r", 0, SIZE_NONE,
  892. cris_ver_v8p,
  893. cris_not_implemented_op},
  894. {"swapnb", 0xA770, 0x5880, "r", 0, SIZE_NONE,
  895. cris_ver_v8p,
  896. cris_not_implemented_op},
  897. {"swapwb", 0x6770, 0x9880, "r", 0, SIZE_NONE,
  898. cris_ver_v8p,
  899. cris_not_implemented_op},
  900. {"swapnwb", 0xE770, 0x1880, "r", 0, SIZE_NONE,
  901. cris_ver_v8p,
  902. cris_not_implemented_op},
  903. {"swapr", 0x1770, 0xe880, "r", 0, SIZE_NONE,
  904. cris_ver_v8p,
  905. cris_not_implemented_op},
  906. {"swapnr", 0x9770, 0x6880, "r", 0, SIZE_NONE,
  907. cris_ver_v8p,
  908. cris_not_implemented_op},
  909. {"swapwr", 0x5770, 0xa880, "r", 0, SIZE_NONE,
  910. cris_ver_v8p,
  911. cris_not_implemented_op},
  912. {"swapnwr", 0xd770, 0x2880, "r", 0, SIZE_NONE,
  913. cris_ver_v8p,
  914. cris_not_implemented_op},
  915. {"swapbr", 0x3770, 0xc880, "r", 0, SIZE_NONE,
  916. cris_ver_v8p,
  917. cris_not_implemented_op},
  918. {"swapnbr", 0xb770, 0x4880, "r", 0, SIZE_NONE,
  919. cris_ver_v8p,
  920. cris_not_implemented_op},
  921. {"swapwbr", 0x7770, 0x8880, "r", 0, SIZE_NONE,
  922. cris_ver_v8p,
  923. cris_not_implemented_op},
  924. {"swapnwbr", 0xf770, 0x0880, "r", 0, SIZE_NONE,
  925. cris_ver_v8p,
  926. cris_not_implemented_op},
  927. {"test", 0x0640, 0x0980, "m D", 0, SIZE_NONE,
  928. cris_ver_v0_10,
  929. cris_reg_mode_test_op},
  930. {"test", 0x0b80, 0xf040, "m y", 0, SIZE_FIELD, 0,
  931. cris_none_reg_mode_clear_test_op},
  932. {"test", 0x0b80, 0xf040, "m S", 0, SIZE_NONE,
  933. cris_ver_v0_10,
  934. cris_none_reg_mode_clear_test_op},
  935. {"xor", 0x07B0, 0x0840, "r,R", 0, SIZE_NONE, 0,
  936. cris_xor_op},
  937. {NULL, 0, 0, NULL, 0, 0, 0, cris_not_implemented_op}
  938. };
  939. /* Condition-names, indexed by the CC_* numbers as found in cris.h. */
  940. const char * const
  941. cris_cc_strings[] =
  942. {
  943. "hs",
  944. "lo",
  945. "ne",
  946. "eq",
  947. "vc",
  948. "vs",
  949. "pl",
  950. "mi",
  951. "ls",
  952. "hi",
  953. "ge",
  954. "lt",
  955. "gt",
  956. "le",
  957. "a",
  958. /* This is a placeholder. In v0, this would be "ext". In v32, this
  959. is "sb". See cris_conds15. */
  960. "wf"
  961. };
  962. /* Different names and semantics for condition 1111 (0xf). */
  963. const struct cris_cond15 cris_cond15s[] =
  964. {
  965. /* FIXME: In what version did condition "ext" disappear? */
  966. {"ext", cris_ver_v0_3},
  967. {"wf", cris_ver_v10},
  968. {"sb", cris_ver_v32p},
  969. {NULL, 0}
  970. };
  971. /*
  972. * Local variables:
  973. * eval: (c-set-style "gnu")
  974. * indent-tabs-mode: t
  975. * End:
  976. */
  977. /* No instruction will be disassembled longer than this. In theory, and
  978. in silicon, address prefixes can be cascaded. In practice, cascading
  979. is not used by GCC, and not supported by the assembler. */
  980. #ifndef MAX_BYTES_PER_CRIS_INSN
  981. #define MAX_BYTES_PER_CRIS_INSN 8
  982. #endif
  983. /* Whether or not to decode prefixes, folding it into the following
  984. instruction. FIXME: Make this optional later. */
  985. #ifndef PARSE_PREFIX
  986. #define PARSE_PREFIX 1
  987. #endif
  988. /* Sometimes we prefix all registers with this character. */
  989. #define REGISTER_PREFIX_CHAR '$'
  990. /* Whether or not to trace the following sequence:
  991. sub* X,r%d
  992. bound* Y,r%d
  993. adds.w [pc+r%d.w],pc
  994. This is the assembly form of a switch-statement in C.
  995. The "sub is optional. If there is none, then X will be zero.
  996. X is the value of the first case,
  997. Y is the number of cases (including default).
  998. This results in case offsets printed on the form:
  999. case N: -> case_address
  1000. where N is an estimation on the corresponding 'case' operand in C,
  1001. and case_address is where execution of that case continues after the
  1002. sequence presented above.
  1003. The old style of output was to print the offsets as instructions,
  1004. which made it hard to follow "case"-constructs in the disassembly,
  1005. and caused a lot of annoying warnings about undefined instructions.
  1006. FIXME: Make this optional later. */
  1007. #ifndef TRACE_CASE
  1008. #define TRACE_CASE (disdata->trace_case)
  1009. #endif
  1010. enum cris_disass_family
  1011. { cris_dis_v0_v10, cris_dis_common_v10_v32, cris_dis_v32 };
  1012. /* Stored in the disasm_info->private_data member. */
  1013. struct cris_disasm_data
  1014. {
  1015. /* Whether to print something less confusing if we find something
  1016. matching a switch-construct. */
  1017. bfd_boolean trace_case;
  1018. /* Whether this code is flagged as crisv32. FIXME: Should be an enum
  1019. that includes "compatible". */
  1020. enum cris_disass_family distype;
  1021. };
  1022. /* Value of first element in switch. */
  1023. static long case_offset = 0;
  1024. /* How many more case-offsets to print. */
  1025. static long case_offset_counter = 0;
  1026. /* Number of case offsets. */
  1027. static long no_of_case_offsets = 0;
  1028. /* Candidate for next case_offset. */
  1029. static long last_immediate = 0;
  1030. static int cris_constraint
  1031. (const char *, unsigned, unsigned, struct cris_disasm_data *);
  1032. /* Parse disassembler options and store state in info. FIXME: For the
  1033. time being, we abuse static variables. */
  1034. static bfd_boolean
  1035. cris_parse_disassembler_options (disassemble_info *info,
  1036. enum cris_disass_family distype)
  1037. {
  1038. struct cris_disasm_data *disdata;
  1039. info->private_data = calloc (1, sizeof (struct cris_disasm_data));
  1040. disdata = (struct cris_disasm_data *) info->private_data;
  1041. if (disdata == NULL)
  1042. return FALSE;
  1043. /* Default true. */
  1044. disdata->trace_case
  1045. = (info->disassembler_options == NULL
  1046. || (strcmp (info->disassembler_options, "nocase") != 0));
  1047. disdata->distype = distype;
  1048. return TRUE;
  1049. }
  1050. static const struct cris_spec_reg *
  1051. spec_reg_info (unsigned int sreg, enum cris_disass_family distype)
  1052. {
  1053. int i;
  1054. for (i = 0; cris_spec_regs[i].name != NULL; i++)
  1055. {
  1056. if (cris_spec_regs[i].number == sreg)
  1057. {
  1058. if (distype == cris_dis_v32)
  1059. switch (cris_spec_regs[i].applicable_version)
  1060. {
  1061. case cris_ver_warning:
  1062. case cris_ver_version_all:
  1063. case cris_ver_v3p:
  1064. case cris_ver_v8p:
  1065. case cris_ver_v10p:
  1066. case cris_ver_v32p:
  1067. /* No ambiguous sizes or register names with CRISv32. */
  1068. if (cris_spec_regs[i].warning == NULL)
  1069. return &cris_spec_regs[i];
  1070. default:
  1071. ;
  1072. }
  1073. else if (cris_spec_regs[i].applicable_version != cris_ver_v32p)
  1074. return &cris_spec_regs[i];
  1075. }
  1076. }
  1077. return NULL;
  1078. }
  1079. /* Return the number of bits in the argument. */
  1080. static int
  1081. number_of_bits (unsigned int val)
  1082. {
  1083. int bits;
  1084. for (bits = 0; val != 0; val &= val - 1)
  1085. bits++;
  1086. return bits;
  1087. }
  1088. /* Get an entry in the opcode-table. */
  1089. static const struct cris_opcode *
  1090. get_opcode_entry (unsigned int insn,
  1091. unsigned int prefix_insn,
  1092. struct cris_disasm_data *disdata)
  1093. {
  1094. /* For non-prefixed insns, we keep a table of pointers, indexed by the
  1095. insn code. Each entry is initialized when found to be NULL. */
  1096. static const struct cris_opcode **opc_table = NULL;
  1097. const struct cris_opcode *max_matchedp = NULL;
  1098. const struct cris_opcode **prefix_opc_table = NULL;
  1099. /* We hold a table for each prefix that need to be handled differently. */
  1100. static const struct cris_opcode **dip_prefixes = NULL;
  1101. static const struct cris_opcode **bdapq_m1_prefixes = NULL;
  1102. static const struct cris_opcode **bdapq_m2_prefixes = NULL;
  1103. static const struct cris_opcode **bdapq_m4_prefixes = NULL;
  1104. static const struct cris_opcode **rest_prefixes = NULL;
  1105. /* Allocate and clear the opcode-table. */
  1106. if (opc_table == NULL)
  1107. {
  1108. opc_table = qemu_malloc (65536 * sizeof (opc_table[0]));
  1109. memset (opc_table, 0, 65536 * sizeof (const struct cris_opcode *));
  1110. dip_prefixes
  1111. = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
  1112. memset (dip_prefixes, 0, 65536 * sizeof (dip_prefixes[0]));
  1113. bdapq_m1_prefixes
  1114. = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
  1115. memset (bdapq_m1_prefixes, 0, 65536 * sizeof (bdapq_m1_prefixes[0]));
  1116. bdapq_m2_prefixes
  1117. = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
  1118. memset (bdapq_m2_prefixes, 0, 65536 * sizeof (bdapq_m2_prefixes[0]));
  1119. bdapq_m4_prefixes
  1120. = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
  1121. memset (bdapq_m4_prefixes, 0, 65536 * sizeof (bdapq_m4_prefixes[0]));
  1122. rest_prefixes
  1123. = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
  1124. memset (rest_prefixes, 0, 65536 * sizeof (rest_prefixes[0]));
  1125. }
  1126. /* Get the right table if this is a prefix.
  1127. This code is connected to cris_constraints in that it knows what
  1128. prefixes play a role in recognition of patterns; the necessary
  1129. state is reflected by which table is used. If constraints
  1130. involving match or non-match of prefix insns are changed, then this
  1131. probably needs changing too. */
  1132. if (prefix_insn != NO_CRIS_PREFIX)
  1133. {
  1134. const struct cris_opcode *popcodep
  1135. = (opc_table[prefix_insn] != NULL
  1136. ? opc_table[prefix_insn]
  1137. : get_opcode_entry (prefix_insn, NO_CRIS_PREFIX, disdata));
  1138. if (popcodep == NULL)
  1139. return NULL;
  1140. if (popcodep->match == BDAP_QUICK_OPCODE)
  1141. {
  1142. /* Since some offsets are recognized with "push" macros, we
  1143. have to have different tables for them. */
  1144. int offset = (prefix_insn & 255);
  1145. if (offset > 127)
  1146. offset -= 256;
  1147. switch (offset)
  1148. {
  1149. case -4:
  1150. prefix_opc_table = bdapq_m4_prefixes;
  1151. break;
  1152. case -2:
  1153. prefix_opc_table = bdapq_m2_prefixes;
  1154. break;
  1155. case -1:
  1156. prefix_opc_table = bdapq_m1_prefixes;
  1157. break;
  1158. default:
  1159. prefix_opc_table = rest_prefixes;
  1160. break;
  1161. }
  1162. }
  1163. else if (popcodep->match == DIP_OPCODE)
  1164. /* We don't allow postincrement when the prefix is DIP, so use a
  1165. different table for DIP. */
  1166. prefix_opc_table = dip_prefixes;
  1167. else
  1168. prefix_opc_table = rest_prefixes;
  1169. }
  1170. if (prefix_insn != NO_CRIS_PREFIX
  1171. && prefix_opc_table[insn] != NULL)
  1172. max_matchedp = prefix_opc_table[insn];
  1173. else if (prefix_insn == NO_CRIS_PREFIX && opc_table[insn] != NULL)
  1174. max_matchedp = opc_table[insn];
  1175. else
  1176. {
  1177. const struct cris_opcode *opcodep;
  1178. int max_level_of_match = -1;
  1179. for (opcodep = cris_opcodes;
  1180. opcodep->name != NULL;
  1181. opcodep++)
  1182. {
  1183. int level_of_match;
  1184. if (disdata->distype == cris_dis_v32)
  1185. {
  1186. switch (opcodep->applicable_version)
  1187. {
  1188. case cris_ver_version_all:
  1189. break;
  1190. case cris_ver_v0_3:
  1191. case cris_ver_v0_10:
  1192. case cris_ver_v3_10:
  1193. case cris_ver_sim_v0_10:
  1194. case cris_ver_v8_10:
  1195. case cris_ver_v10:
  1196. case cris_ver_warning:
  1197. continue;
  1198. case cris_ver_v3p:
  1199. case cris_ver_v8p:
  1200. case cris_ver_v10p:
  1201. case cris_ver_v32p:
  1202. break;
  1203. case cris_ver_v8:
  1204. abort ();
  1205. default:
  1206. abort ();
  1207. }
  1208. }
  1209. else
  1210. {
  1211. switch (opcodep->applicable_version)
  1212. {
  1213. case cris_ver_version_all:
  1214. case cris_ver_v0_3:
  1215. case cris_ver_v3p:
  1216. case cris_ver_v0_10:
  1217. case cris_ver_v8p:
  1218. case cris_ver_v8_10:
  1219. case cris_ver_v10:
  1220. case cris_ver_sim_v0_10:
  1221. case cris_ver_v10p:
  1222. case cris_ver_warning:
  1223. break;
  1224. case cris_ver_v32p:
  1225. continue;
  1226. case cris_ver_v8:
  1227. abort ();
  1228. default:
  1229. abort ();
  1230. }
  1231. }
  1232. /* We give a double lead for bits matching the template in
  1233. cris_opcodes. Not even, because then "move p8,r10" would
  1234. be given 2 bits lead over "clear.d r10". When there's a
  1235. tie, the first entry in the table wins. This is
  1236. deliberate, to avoid a more complicated recognition
  1237. formula. */
  1238. if ((opcodep->match & insn) == opcodep->match
  1239. && (opcodep->lose & insn) == 0
  1240. && ((level_of_match
  1241. = cris_constraint (opcodep->args,
  1242. insn,
  1243. prefix_insn,
  1244. disdata))
  1245. >= 0)
  1246. && ((level_of_match
  1247. += 2 * number_of_bits (opcodep->match
  1248. | opcodep->lose))
  1249. > max_level_of_match))
  1250. {
  1251. max_matchedp = opcodep;
  1252. max_level_of_match = level_of_match;
  1253. /* If there was a full match, never mind looking
  1254. further. */
  1255. if (level_of_match >= 2 * 16)
  1256. break;
  1257. }
  1258. }
  1259. /* Fill in the new entry.
  1260. If there are changes to the opcode-table involving prefixes, and
  1261. disassembly then does not work correctly, try removing the
  1262. else-clause below that fills in the prefix-table. If that
  1263. helps, you need to change the prefix_opc_table setting above, or
  1264. something related. */
  1265. if (prefix_insn == NO_CRIS_PREFIX)
  1266. opc_table[insn] = max_matchedp;
  1267. else
  1268. prefix_opc_table[insn] = max_matchedp;
  1269. }
  1270. return max_matchedp;
  1271. }
  1272. /* Return -1 if the constraints of a bitwise-matched instruction say
  1273. that there is no match. Otherwise return a nonnegative number
  1274. indicating the confidence in the match (higher is better). */
  1275. static int
  1276. cris_constraint (const char *cs,
  1277. unsigned int insn,
  1278. unsigned int prefix_insn,
  1279. struct cris_disasm_data *disdata)
  1280. {
  1281. int retval = 0;
  1282. int tmp;
  1283. int prefix_ok = 0;
  1284. const char *s;
  1285. for (s = cs; *s; s++)
  1286. switch (*s)
  1287. {
  1288. case '!':
  1289. /* Do not recognize "pop" if there's a prefix and then only for
  1290. v0..v10. */
  1291. if (prefix_insn != NO_CRIS_PREFIX
  1292. || disdata->distype != cris_dis_v0_v10)
  1293. return -1;
  1294. break;
  1295. case 'U':
  1296. /* Not recognized at disassembly. */
  1297. return -1;
  1298. case 'M':
  1299. /* Size modifier for "clear", i.e. special register 0, 4 or 8.
  1300. Check that it is one of them. Only special register 12 could
  1301. be mismatched, but checking for matches is more logical than
  1302. checking for mismatches when there are only a few cases. */
  1303. tmp = ((insn >> 12) & 0xf);
  1304. if (tmp != 0 && tmp != 4 && tmp != 8)
  1305. return -1;
  1306. break;
  1307. case 'm':
  1308. if ((insn & 0x30) == 0x30)
  1309. return -1;
  1310. break;
  1311. case 'S':
  1312. /* A prefix operand without side-effect. */
  1313. if (prefix_insn != NO_CRIS_PREFIX && (insn & 0x400) == 0)
  1314. {
  1315. prefix_ok = 1;
  1316. break;
  1317. }
  1318. else
  1319. return -1;
  1320. case 's':
  1321. case 'y':
  1322. case 'Y':
  1323. /* If this is a prefixed insn with postincrement (side-effect),
  1324. the prefix must not be DIP. */
  1325. if (prefix_insn != NO_CRIS_PREFIX)
  1326. {
  1327. if (insn & 0x400)
  1328. {
  1329. const struct cris_opcode *prefix_opcodep
  1330. = get_opcode_entry (prefix_insn, NO_CRIS_PREFIX, disdata);
  1331. if (prefix_opcodep->match == DIP_OPCODE)
  1332. return -1;
  1333. }
  1334. prefix_ok = 1;
  1335. }
  1336. break;
  1337. case 'B':
  1338. /* If we don't fall through, then the prefix is ok. */
  1339. prefix_ok = 1;
  1340. /* A "push" prefix. Check for valid "push" size.
  1341. In case of special register, it may be != 4. */
  1342. if (prefix_insn != NO_CRIS_PREFIX)
  1343. {
  1344. /* Match the prefix insn to BDAPQ. */
  1345. const struct cris_opcode *prefix_opcodep
  1346. = get_opcode_entry (prefix_insn, NO_CRIS_PREFIX, disdata);
  1347. if (prefix_opcodep->match == BDAP_QUICK_OPCODE)
  1348. {
  1349. int pushsize = (prefix_insn & 255);
  1350. if (pushsize > 127)
  1351. pushsize -= 256;
  1352. if (s[1] == 'P')
  1353. {
  1354. unsigned int spec_reg = (insn >> 12) & 15;
  1355. const struct cris_spec_reg *sregp
  1356. = spec_reg_info (spec_reg, disdata->distype);
  1357. /* For a special-register, the "prefix size" must
  1358. match the size of the register. */
  1359. if (sregp && sregp->reg_size == (unsigned int) -pushsize)
  1360. break;
  1361. }
  1362. else if (s[1] == 'R')
  1363. {
  1364. if ((insn & 0x30) == 0x20 && pushsize == -4)
  1365. break;
  1366. }
  1367. /* FIXME: Should abort here; next constraint letter
  1368. *must* be 'P' or 'R'. */
  1369. }
  1370. }
  1371. return -1;
  1372. case 'D':
  1373. retval = (((insn >> 12) & 15) == (insn & 15));
  1374. if (!retval)
  1375. return -1;
  1376. else
  1377. retval += 4;
  1378. break;
  1379. case 'P':
  1380. {
  1381. const struct cris_spec_reg *sregp
  1382. = spec_reg_info ((insn >> 12) & 15, disdata->distype);
  1383. /* Since we match four bits, we will give a value of 4-1 = 3
  1384. in a match. If there is a corresponding exact match of a
  1385. special register in another pattern, it will get a value of
  1386. 4, which will be higher. This should be correct in that an
  1387. exact pattern would match better than a general pattern.
  1388. Note that there is a reason for not returning zero; the
  1389. pattern for "clear" is partly matched in the bit-pattern
  1390. (the two lower bits must be zero), while the bit-pattern
  1391. for a move from a special register is matched in the
  1392. register constraint. */
  1393. if (sregp != NULL)
  1394. {
  1395. retval += 3;
  1396. break;
  1397. }
  1398. else
  1399. return -1;
  1400. }
  1401. }
  1402. if (prefix_insn != NO_CRIS_PREFIX && ! prefix_ok)
  1403. return -1;
  1404. return retval;
  1405. }
  1406. /* Format number as hex with a leading "0x" into outbuffer. */
  1407. static char *
  1408. format_hex (unsigned long number,
  1409. char *outbuffer,
  1410. struct cris_disasm_data *disdata)
  1411. {
  1412. /* Truncate negative numbers on >32-bit hosts. */
  1413. number &= 0xffffffff;
  1414. sprintf (outbuffer, "0x%lx", number);
  1415. /* Save this value for the "case" support. */
  1416. if (TRACE_CASE)
  1417. last_immediate = number;
  1418. return outbuffer + strlen (outbuffer);
  1419. }
  1420. /* Format number as decimal into outbuffer. Parameter signedp says
  1421. whether the number should be formatted as signed (!= 0) or
  1422. unsigned (== 0). */
  1423. static char *
  1424. format_dec (long number, char *outbuffer, int signedp)
  1425. {
  1426. last_immediate = number;
  1427. sprintf (outbuffer, signedp ? "%ld" : "%lu", number);
  1428. return outbuffer + strlen (outbuffer);
  1429. }
  1430. /* Format the name of the general register regno into outbuffer. */
  1431. static char *
  1432. format_reg (struct cris_disasm_data *disdata,
  1433. int regno,
  1434. char *outbuffer_start,
  1435. bfd_boolean with_reg_prefix)
  1436. {
  1437. char *outbuffer = outbuffer_start;
  1438. if (with_reg_prefix)
  1439. *outbuffer++ = REGISTER_PREFIX_CHAR;
  1440. switch (regno)
  1441. {
  1442. case 15:
  1443. /* For v32, there is no context in which we output PC. */
  1444. if (disdata->distype == cris_dis_v32)
  1445. strcpy (outbuffer, "acr");
  1446. else
  1447. strcpy (outbuffer, "pc");
  1448. break;
  1449. case 14:
  1450. strcpy (outbuffer, "sp");
  1451. break;
  1452. default:
  1453. sprintf (outbuffer, "r%d", regno);
  1454. break;
  1455. }
  1456. return outbuffer_start + strlen (outbuffer_start);
  1457. }
  1458. /* Format the name of a support register into outbuffer. */
  1459. static char *
  1460. format_sup_reg (unsigned int regno,
  1461. char *outbuffer_start,
  1462. bfd_boolean with_reg_prefix)
  1463. {
  1464. char *outbuffer = outbuffer_start;
  1465. int i;
  1466. if (with_reg_prefix)
  1467. *outbuffer++ = REGISTER_PREFIX_CHAR;
  1468. for (i = 0; cris_support_regs[i].name != NULL; i++)
  1469. if (cris_support_regs[i].number == regno)
  1470. {
  1471. sprintf (outbuffer, "%s", cris_support_regs[i].name);
  1472. return outbuffer_start + strlen (outbuffer_start);
  1473. }
  1474. /* There's supposed to be register names covering all numbers, though
  1475. some may be generic names. */
  1476. sprintf (outbuffer, "format_sup_reg-BUG");
  1477. return outbuffer_start + strlen (outbuffer_start);
  1478. }
  1479. /* Return the length of an instruction. */
  1480. static unsigned
  1481. bytes_to_skip (unsigned int insn,
  1482. const struct cris_opcode *matchedp,
  1483. enum cris_disass_family distype,
  1484. const struct cris_opcode *prefix_matchedp)
  1485. {
  1486. /* Each insn is a word plus "immediate" operands. */
  1487. unsigned to_skip = 2;
  1488. const char *template = matchedp->args;
  1489. const char *s;
  1490. for (s = template; *s; s++)
  1491. if ((*s == 's' || *s == 'N' || *s == 'Y')
  1492. && (insn & 0x400) && (insn & 15) == 15
  1493. && prefix_matchedp == NULL)
  1494. {
  1495. /* Immediate via [pc+], so we have to check the size of the
  1496. operand. */
  1497. int mode_size = 1 << ((insn >> 4) & (*template == 'z' ? 1 : 3));
  1498. if (matchedp->imm_oprnd_size == SIZE_FIX_32)
  1499. to_skip += 4;
  1500. else if (matchedp->imm_oprnd_size == SIZE_SPEC_REG)
  1501. {
  1502. const struct cris_spec_reg *sregp
  1503. = spec_reg_info ((insn >> 12) & 15, distype);
  1504. /* FIXME: Improve error handling; should have been caught
  1505. earlier. */
  1506. if (sregp == NULL)
  1507. return 2;
  1508. /* PC is incremented by two, not one, for a byte. Except on
  1509. CRISv32, where constants are always DWORD-size for
  1510. special registers. */
  1511. to_skip +=
  1512. distype == cris_dis_v32 ? 4 : (sregp->reg_size + 1) & ~1;
  1513. }
  1514. else
  1515. to_skip += (mode_size + 1) & ~1;
  1516. }
  1517. else if (*s == 'n')
  1518. to_skip += 4;
  1519. else if (*s == 'b')
  1520. to_skip += 2;
  1521. return to_skip;
  1522. }
  1523. /* Print condition code flags. */
  1524. static char *
  1525. print_flags (struct cris_disasm_data *disdata, unsigned int insn, char *cp)
  1526. {
  1527. /* Use the v8 (Etrax 100) flag definitions for disassembly.
  1528. The differences with v0 (Etrax 1..4) vs. Svinto are:
  1529. v0 'd' <=> v8 'm'
  1530. v0 'e' <=> v8 'b'.
  1531. FIXME: Emit v0..v3 flag names somehow. */
  1532. static const char v8_fnames[] = "cvznxibm";
  1533. static const char v32_fnames[] = "cvznxiup";
  1534. const char *fnames
  1535. = disdata->distype == cris_dis_v32 ? v32_fnames : v8_fnames;
  1536. unsigned char flagbits = (((insn >> 8) & 0xf0) | (insn & 15));
  1537. int i;
  1538. for (i = 0; i < 8; i++)
  1539. if (flagbits & (1 << i))
  1540. *cp++ = fnames[i];
  1541. return cp;
  1542. }
  1543. /* Print out an insn with its operands, and update the info->insn_type
  1544. fields. The prefix_opcodep and the rest hold a prefix insn that is
  1545. supposed to be output as an address mode. */
  1546. static void
  1547. print_with_operands (const struct cris_opcode *opcodep,
  1548. unsigned int insn,
  1549. unsigned char *buffer,
  1550. bfd_vma addr,
  1551. disassemble_info *info,
  1552. /* If a prefix insn was before this insn (and is supposed
  1553. to be output as an address), here is a description of
  1554. it. */
  1555. const struct cris_opcode *prefix_opcodep,
  1556. unsigned int prefix_insn,
  1557. unsigned char *prefix_buffer,
  1558. bfd_boolean with_reg_prefix)
  1559. {
  1560. /* Get a buffer of somewhat reasonable size where we store
  1561. intermediate parts of the insn. */
  1562. char temp[sizeof (".d [$r13=$r12-2147483648],$r10") * 2];
  1563. char *tp = temp;
  1564. static const char mode_char[] = "bwd?";
  1565. const char *s;
  1566. const char *cs;
  1567. struct cris_disasm_data *disdata
  1568. = (struct cris_disasm_data *) info->private_data;
  1569. /* Print out the name first thing we do. */
  1570. (*info->fprintf_func) (info->stream, "%s", opcodep->name);
  1571. cs = opcodep->args;
  1572. s = cs;
  1573. /* Ignore any prefix indicator. */
  1574. if (*s == 'p')
  1575. s++;
  1576. if (*s == 'm' || *s == 'M' || *s == 'z')
  1577. {
  1578. *tp++ = '.';
  1579. /* Get the size-letter. */
  1580. *tp++ = *s == 'M'
  1581. ? (insn & 0x8000 ? 'd'
  1582. : insn & 0x4000 ? 'w' : 'b')
  1583. : mode_char[(insn >> 4) & (*s == 'z' ? 1 : 3)];
  1584. /* Ignore the size and the space character that follows. */
  1585. s += 2;
  1586. }
  1587. /* Add a space if this isn't a long-branch, because for those will add
  1588. the condition part of the name later. */
  1589. if (opcodep->match != (BRANCH_PC_LOW + BRANCH_INCR_HIGH * 256))
  1590. *tp++ = ' ';
  1591. /* Fill in the insn-type if deducible from the name (and there's no
  1592. better way). */
  1593. if (opcodep->name[0] == 'j')
  1594. {
  1595. if (CONST_STRNEQ (opcodep->name, "jsr"))
  1596. /* It's "jsr" or "jsrc". */
  1597. info->insn_type = dis_jsr;
  1598. else
  1599. /* Any other jump-type insn is considered a branch. */
  1600. info->insn_type = dis_branch;
  1601. }
  1602. /* We might know some more fields right now. */
  1603. info->branch_delay_insns = opcodep->delayed;
  1604. /* Handle operands. */
  1605. for (; *s; s++)
  1606. {
  1607. switch (*s)
  1608. {
  1609. case 'T':
  1610. tp = format_sup_reg ((insn >> 12) & 15, tp, with_reg_prefix);
  1611. break;
  1612. case 'A':
  1613. if (with_reg_prefix)
  1614. *tp++ = REGISTER_PREFIX_CHAR;
  1615. *tp++ = 'a';
  1616. *tp++ = 'c';
  1617. *tp++ = 'r';
  1618. break;
  1619. case '[':
  1620. case ']':
  1621. case ',':
  1622. *tp++ = *s;
  1623. break;
  1624. case '!':
  1625. /* Ignore at this point; used at earlier stages to avoid
  1626. recognition if there's a prefix at something that in other
  1627. ways looks like a "pop". */
  1628. break;
  1629. case 'd':
  1630. /* Ignore. This is an optional ".d " on the large one of
  1631. relaxable insns. */
  1632. break;
  1633. case 'B':
  1634. /* This was the prefix that made this a "push". We've already
  1635. handled it by recognizing it, so signal that the prefix is
  1636. handled by setting it to NULL. */
  1637. prefix_opcodep = NULL;
  1638. break;
  1639. case 'D':
  1640. case 'r':
  1641. tp = format_reg (disdata, insn & 15, tp, with_reg_prefix);
  1642. break;
  1643. case 'R':
  1644. tp = format_reg (disdata, (insn >> 12) & 15, tp, with_reg_prefix);
  1645. break;
  1646. case 'n':
  1647. {
  1648. /* Like N but pc-relative to the start of the insn. */
  1649. unsigned long number
  1650. = (buffer[2] + buffer[3] * 256 + buffer[4] * 65536
  1651. + buffer[5] * 0x1000000 + addr);
  1652. /* Finish off and output previous formatted bytes. */
  1653. *tp = 0;
  1654. if (temp[0])
  1655. (*info->fprintf_func) (info->stream, "%s", temp);
  1656. tp = temp;
  1657. (*info->print_address_func) ((bfd_vma) number, info);
  1658. }
  1659. break;
  1660. case 'u':
  1661. {
  1662. /* Like n but the offset is bits <3:0> in the instruction. */
  1663. unsigned long number = (buffer[0] & 0xf) * 2 + addr;
  1664. /* Finish off and output previous formatted bytes. */
  1665. *tp = 0;
  1666. if (temp[0])
  1667. (*info->fprintf_func) (info->stream, "%s", temp);
  1668. tp = temp;
  1669. (*info->print_address_func) ((bfd_vma) number, info);
  1670. }
  1671. break;
  1672. case 'N':
  1673. case 'y':
  1674. case 'Y':
  1675. case 'S':
  1676. case 's':
  1677. /* Any "normal" memory operand. */
  1678. if ((insn & 0x400) && (insn & 15) == 15 && prefix_opcodep == NULL)
  1679. {
  1680. /* We're looking at [pc+], i.e. we need to output an immediate
  1681. number, where the size can depend on different things. */
  1682. long number;
  1683. int signedp
  1684. = ((*cs == 'z' && (insn & 0x20))
  1685. || opcodep->match == BDAP_QUICK_OPCODE);
  1686. int nbytes;
  1687. if (opcodep->imm_oprnd_size == SIZE_FIX_32)
  1688. nbytes = 4;
  1689. else if (opcodep->imm_oprnd_size == SIZE_SPEC_REG)
  1690. {
  1691. const struct cris_spec_reg *sregp
  1692. = spec_reg_info ((insn >> 12) & 15, disdata->distype);
  1693. /* A NULL return should have been as a non-match earlier,
  1694. so catch it as an internal error in the error-case
  1695. below. */
  1696. if (sregp == NULL)
  1697. /* Whatever non-valid size. */
  1698. nbytes = 42;
  1699. else
  1700. /* PC is always incremented by a multiple of two.
  1701. For CRISv32, immediates are always 4 bytes for
  1702. special registers. */
  1703. nbytes = disdata->distype == cris_dis_v32
  1704. ? 4 : (sregp->reg_size + 1) & ~1;
  1705. }
  1706. else
  1707. {
  1708. int mode_size = 1 << ((insn >> 4) & (*cs == 'z' ? 1 : 3));
  1709. if (mode_size == 1)
  1710. nbytes = 2;
  1711. else
  1712. nbytes = mode_size;
  1713. }
  1714. switch (nbytes)
  1715. {
  1716. case 1:
  1717. number = buffer[2];
  1718. if (signedp && number > 127)
  1719. number -= 256;
  1720. break;
  1721. case 2:
  1722. number = buffer[2] + buffer[3] * 256;
  1723. if (signedp && number > 32767)
  1724. number -= 65536;
  1725. break;
  1726. case 4:
  1727. number
  1728. = buffer[2] + buffer[3] * 256 + buffer[4] * 65536
  1729. + buffer[5] * 0x1000000;
  1730. break;
  1731. default:
  1732. strcpy (tp, "bug");
  1733. tp += 3;
  1734. number = 42;
  1735. }
  1736. if ((*cs == 'z' && (insn & 0x20))
  1737. || (opcodep->match == BDAP_QUICK_OPCODE
  1738. && (nbytes <= 2 || buffer[1 + nbytes] == 0)))
  1739. tp = format_dec (number, tp, signedp);
  1740. else
  1741. {
  1742. unsigned int highbyte = (number >> 24) & 0xff;
  1743. /* Either output this as an address or as a number. If it's
  1744. a dword with the same high-byte as the address of the
  1745. insn, assume it's an address, and also if it's a non-zero
  1746. non-0xff high-byte. If this is a jsr or a jump, then
  1747. it's definitely an address. */
  1748. if (nbytes == 4
  1749. && (highbyte == ((addr >> 24) & 0xff)
  1750. || (highbyte != 0 && highbyte != 0xff)
  1751. || info->insn_type == dis_branch
  1752. || info->insn_type == dis_jsr))
  1753. {
  1754. /* Finish off and output previous formatted bytes. */
  1755. *tp = 0;
  1756. tp = temp;
  1757. if (temp[0])
  1758. (*info->fprintf_func) (info->stream, "%s", temp);
  1759. (*info->print_address_func) ((bfd_vma) number, info);
  1760. info->target = number;
  1761. }
  1762. else
  1763. tp = format_hex (number, tp, disdata);
  1764. }
  1765. }
  1766. else
  1767. {
  1768. /* Not an immediate number. Then this is a (possibly
  1769. prefixed) memory operand. */
  1770. if (info->insn_type != dis_nonbranch)
  1771. {
  1772. int mode_size
  1773. = 1 << ((insn >> 4)
  1774. & (opcodep->args[0] == 'z' ? 1 : 3));
  1775. int size;
  1776. info->insn_type = dis_dref;
  1777. info->flags |= CRIS_DIS_FLAG_MEMREF;
  1778. if (opcodep->imm_oprnd_size == SIZE_FIX_32)
  1779. size = 4;
  1780. else if (opcodep->imm_oprnd_size == SIZE_SPEC_REG)
  1781. {
  1782. const struct cris_spec_reg *sregp
  1783. = spec_reg_info ((insn >> 12) & 15, disdata->distype);
  1784. /* FIXME: Improve error handling; should have been caught
  1785. earlier. */
  1786. if (sregp == NULL)
  1787. size = 4;
  1788. else
  1789. size = sregp->reg_size;
  1790. }
  1791. else
  1792. size = mode_size;
  1793. info->data_size = size;
  1794. }
  1795. *tp++ = '[';
  1796. if (prefix_opcodep
  1797. /* We don't match dip with a postincremented field
  1798. as a side-effect address mode. */
  1799. && ((insn & 0x400) == 0
  1800. || prefix_opcodep->match != DIP_OPCODE))
  1801. {
  1802. if (insn & 0x400)
  1803. {
  1804. tp = format_reg (disdata, insn & 15, tp, with_reg_prefix);
  1805. *tp++ = '=';
  1806. }
  1807. /* We mainly ignore the prefix format string when the
  1808. address-mode syntax is output. */
  1809. switch (prefix_opcodep->match)
  1810. {
  1811. case DIP_OPCODE:
  1812. /* It's [r], [r+] or [pc+]. */
  1813. if ((prefix_insn & 0x400) && (prefix_insn & 15) == 15)
  1814. {
  1815. /* It's [pc+]. This cannot possibly be anything
  1816. but an address. */
  1817. unsigned long number
  1818. = prefix_buffer[2] + prefix_buffer[3] * 256
  1819. + prefix_buffer[4] * 65536
  1820. + prefix_buffer[5] * 0x1000000;
  1821. info->target = (bfd_vma) number;
  1822. /* Finish off and output previous formatted
  1823. data. */
  1824. *tp = 0;
  1825. tp = temp;
  1826. if (temp[0])
  1827. (*info->fprintf_func) (info->stream, "%s", temp);
  1828. (*info->print_address_func) ((bfd_vma) number, info);
  1829. }
  1830. else
  1831. {
  1832. /* For a memref in an address, we use target2.
  1833. In this case, target is zero. */
  1834. info->flags
  1835. |= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
  1836. | CRIS_DIS_FLAG_MEM_TARGET2_MEM);
  1837. info->target2 = prefix_insn & 15;
  1838. *tp++ = '[';
  1839. tp = format_reg (disdata, prefix_insn & 15, tp,
  1840. with_reg_prefix);
  1841. if (prefix_insn & 0x400)
  1842. *tp++ = '+';
  1843. *tp++ = ']';
  1844. }
  1845. break;
  1846. case BDAP_QUICK_OPCODE:
  1847. {
  1848. int number;
  1849. number = prefix_buffer[0];
  1850. if (number > 127)
  1851. number -= 256;
  1852. /* Output "reg+num" or, if num < 0, "reg-num". */
  1853. tp = format_reg (disdata, (prefix_insn >> 12) & 15, tp,
  1854. with_reg_prefix);
  1855. if (number >= 0)
  1856. *tp++ = '+';
  1857. tp = format_dec (number, tp, 1);
  1858. info->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;
  1859. info->target = (prefix_insn >> 12) & 15;
  1860. info->target2 = (bfd_vma) number;
  1861. break;
  1862. }
  1863. case BIAP_OPCODE:
  1864. /* Output "r+R.m". */
  1865. tp = format_reg (disdata, prefix_insn & 15, tp,
  1866. with_reg_prefix);
  1867. *tp++ = '+';
  1868. tp = format_reg (disdata, (prefix_insn >> 12) & 15, tp,
  1869. with_reg_prefix);
  1870. *tp++ = '.';
  1871. *tp++ = mode_char[(prefix_insn >> 4) & 3];
  1872. info->flags
  1873. |= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
  1874. | CRIS_DIS_FLAG_MEM_TARGET_IS_REG
  1875. | ((prefix_insn & 0x8000)
  1876. ? CRIS_DIS_FLAG_MEM_TARGET2_MULT4
  1877. : ((prefix_insn & 0x8000)
  1878. ? CRIS_DIS_FLAG_MEM_TARGET2_MULT2 : 0)));
  1879. /* Is it the casejump? It's a "adds.w [pc+r%d.w],pc". */
  1880. if (insn == 0xf83f && (prefix_insn & ~0xf000) == 0x55f)
  1881. /* Then start interpreting data as offsets. */
  1882. case_offset_counter = no_of_case_offsets;
  1883. break;
  1884. case BDAP_INDIR_OPCODE:
  1885. /* Output "r+s.m", or, if "s" is [pc+], "r+s" or
  1886. "r-s". */
  1887. tp = format_reg (disdata, (prefix_insn >> 12) & 15, tp,
  1888. with_reg_prefix);
  1889. if ((prefix_insn & 0x400) && (prefix_insn & 15) == 15)
  1890. {
  1891. long number;
  1892. unsigned int nbytes;
  1893. /* It's a value. Get its size. */
  1894. int mode_size = 1 << ((prefix_insn >> 4) & 3);
  1895. if (mode_size == 1)
  1896. nbytes = 2;
  1897. else
  1898. nbytes = mode_size;
  1899. switch (nbytes)
  1900. {
  1901. case 1:
  1902. number = prefix_buffer[2];
  1903. if (number > 127)
  1904. number -= 256;
  1905. break;
  1906. case 2:
  1907. number = prefix_buffer[2] + prefix_buffer[3] * 256;
  1908. if (number > 32767)
  1909. number -= 65536;
  1910. break;
  1911. case 4:
  1912. number
  1913. = prefix_buffer[2] + prefix_buffer[3] * 256
  1914. + prefix_buffer[4] * 65536
  1915. + prefix_buffer[5] * 0x1000000;
  1916. break;
  1917. default:
  1918. strcpy (tp, "bug");
  1919. tp += 3;
  1920. number = 42;
  1921. }
  1922. info->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;
  1923. info->target2 = (bfd_vma) number;
  1924. /* If the size is dword, then assume it's an
  1925. address. */
  1926. if (nbytes == 4)
  1927. {
  1928. /* Finish off and output previous formatted
  1929. bytes. */
  1930. *tp++ = '+';
  1931. *tp = 0;
  1932. tp = temp;
  1933. (*info->fprintf_func) (info->stream, "%s", temp);
  1934. (*info->print_address_func) ((bfd_vma) number, info);
  1935. }
  1936. else
  1937. {
  1938. if (number >= 0)
  1939. *tp++ = '+';
  1940. tp = format_dec (number, tp, 1);
  1941. }
  1942. }
  1943. else
  1944. {
  1945. /* Output "r+[R].m" or "r+[R+].m". */
  1946. *tp++ = '+';
  1947. *tp++ = '[';
  1948. tp = format_reg (disdata, prefix_insn & 15, tp,
  1949. with_reg_prefix);
  1950. if (prefix_insn & 0x400)
  1951. *tp++ = '+';
  1952. *tp++ = ']';
  1953. *tp++ = '.';
  1954. *tp++ = mode_char[(prefix_insn >> 4) & 3];
  1955. info->flags
  1956. |= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
  1957. | CRIS_DIS_FLAG_MEM_TARGET2_MEM
  1958. | CRIS_DIS_FLAG_MEM_TARGET_IS_REG
  1959. | (((prefix_insn >> 4) == 2)
  1960. ? 0
  1961. : (((prefix_insn >> 4) & 3) == 1
  1962. ? CRIS_DIS_FLAG_MEM_TARGET2_MEM_WORD
  1963. : CRIS_DIS_FLAG_MEM_TARGET2_MEM_BYTE)));
  1964. }
  1965. break;
  1966. default:
  1967. (*info->fprintf_func) (info->stream, "?prefix-bug");
  1968. }
  1969. /* To mark that the prefix is used, reset it. */
  1970. prefix_opcodep = NULL;
  1971. }
  1972. else
  1973. {
  1974. tp = format_reg (disdata, insn & 15, tp, with_reg_prefix);
  1975. info->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;
  1976. info->target = insn & 15;
  1977. if (insn & 0x400)
  1978. *tp++ = '+';
  1979. }
  1980. *tp++ = ']';
  1981. }
  1982. break;
  1983. case 'x':
  1984. tp = format_reg (disdata, (insn >> 12) & 15, tp, with_reg_prefix);
  1985. *tp++ = '.';
  1986. *tp++ = mode_char[(insn >> 4) & 3];
  1987. break;
  1988. case 'I':
  1989. tp = format_dec (insn & 63, tp, 0);
  1990. break;
  1991. case 'b':
  1992. {
  1993. int where = buffer[2] + buffer[3] * 256;
  1994. if (where > 32767)
  1995. where -= 65536;
  1996. where += addr + ((disdata->distype == cris_dis_v32) ? 0 : 4);
  1997. if (insn == BA_PC_INCR_OPCODE)
  1998. info->insn_type = dis_branch;
  1999. else
  2000. info->insn_type = dis_condbranch;
  2001. info->target = (bfd_vma) where;
  2002. *tp = 0;
  2003. tp = temp;
  2004. (*info->fprintf_func) (info->stream, "%s%s ",
  2005. temp, cris_cc_strings[insn >> 12]);
  2006. (*info->print_address_func) ((bfd_vma) where, info);
  2007. }
  2008. break;
  2009. case 'c':
  2010. tp = format_dec (insn & 31, tp, 0);
  2011. break;
  2012. case 'C':
  2013. tp = format_dec (insn & 15, tp, 0);
  2014. break;
  2015. case 'o':
  2016. {
  2017. long offset = insn & 0xfe;
  2018. bfd_vma target;
  2019. if (insn & 1)
  2020. offset |= ~0xff;
  2021. if (opcodep->match == BA_QUICK_OPCODE)
  2022. info->insn_type = dis_branch;
  2023. else
  2024. info->insn_type = dis_condbranch;
  2025. target = addr + ((disdata->distype == cris_dis_v32) ? 0 : 2) + offset;
  2026. info->target = target;
  2027. *tp = 0;
  2028. tp = temp;
  2029. (*info->fprintf_func) (info->stream, "%s", temp);
  2030. (*info->print_address_func) (target, info);
  2031. }
  2032. break;
  2033. case 'Q':
  2034. case 'O':
  2035. {
  2036. long number = buffer[0];
  2037. if (number > 127)
  2038. number = number - 256;
  2039. tp = format_dec (number, tp, 1);
  2040. *tp++ = ',';
  2041. tp = format_reg (disdata, (insn >> 12) & 15, tp, with_reg_prefix);
  2042. }
  2043. break;
  2044. case 'f':
  2045. tp = print_flags (disdata, insn, tp);
  2046. break;
  2047. case 'i':
  2048. tp = format_dec ((insn & 32) ? (insn & 31) | ~31L : insn & 31, tp, 1);
  2049. break;
  2050. case 'P':
  2051. {
  2052. const struct cris_spec_reg *sregp
  2053. = spec_reg_info ((insn >> 12) & 15, disdata->distype);
  2054. if (sregp->name == NULL)
  2055. /* Should have been caught as a non-match eariler. */
  2056. *tp++ = '?';
  2057. else
  2058. {
  2059. if (with_reg_prefix)
  2060. *tp++ = REGISTER_PREFIX_CHAR;
  2061. strcpy (tp, sregp->name);
  2062. tp += strlen (tp);
  2063. }
  2064. }
  2065. break;
  2066. default:
  2067. strcpy (tp, "???");
  2068. tp += 3;
  2069. }
  2070. }
  2071. *tp = 0;
  2072. if (prefix_opcodep)
  2073. (*info->fprintf_func) (info->stream, " (OOPS unused prefix \"%s: %s\")",
  2074. prefix_opcodep->name, prefix_opcodep->args);
  2075. (*info->fprintf_func) (info->stream, "%s", temp);
  2076. /* Get info for matching case-tables, if we don't have any active.
  2077. We assume that the last constant seen is used; either in the insn
  2078. itself or in a "move.d const,rN, sub.d rN,rM"-like sequence. */
  2079. if (TRACE_CASE && case_offset_counter == 0)
  2080. {
  2081. if (CONST_STRNEQ (opcodep->name, "sub"))
  2082. case_offset = last_immediate;
  2083. /* It could also be an "add", if there are negative case-values. */
  2084. else if (CONST_STRNEQ (opcodep->name, "add"))
  2085. /* The first case is the negated operand to the add. */
  2086. case_offset = -last_immediate;
  2087. /* A bound insn will tell us the number of cases. */
  2088. else if (CONST_STRNEQ (opcodep->name, "bound"))
  2089. no_of_case_offsets = last_immediate + 1;
  2090. /* A jump or jsr or branch breaks the chain of insns for a
  2091. case-table, so assume default first-case again. */
  2092. else if (info->insn_type == dis_jsr
  2093. || info->insn_type == dis_branch
  2094. || info->insn_type == dis_condbranch)
  2095. case_offset = 0;
  2096. }
  2097. }
  2098. /* Print the CRIS instruction at address memaddr on stream. Returns
  2099. length of the instruction, in bytes. Prefix register names with `$' if
  2100. WITH_REG_PREFIX. */
  2101. static int
  2102. print_insn_cris_generic (bfd_vma memaddr,
  2103. disassemble_info *info,
  2104. bfd_boolean with_reg_prefix)
  2105. {
  2106. int nbytes;
  2107. unsigned int insn;
  2108. const struct cris_opcode *matchedp;
  2109. int advance = 0;
  2110. struct cris_disasm_data *disdata
  2111. = (struct cris_disasm_data *) info->private_data;
  2112. /* No instruction will be disassembled as longer than this number of
  2113. bytes; stacked prefixes will not be expanded. */
  2114. unsigned char buffer[MAX_BYTES_PER_CRIS_INSN];
  2115. unsigned char *bufp;
  2116. int status = 0;
  2117. bfd_vma addr;
  2118. /* There will be an "out of range" error after the last instruction.
  2119. Reading pairs of bytes in decreasing number, we hope that we will get
  2120. at least the amount that we will consume.
  2121. If we can't get any data, or we do not get enough data, we print
  2122. the error message. */
  2123. nbytes = info->buffer_length;
  2124. if (nbytes > MAX_BYTES_PER_CRIS_INSN)
  2125. nbytes = MAX_BYTES_PER_CRIS_INSN;
  2126. status = (*info->read_memory_func) (memaddr, buffer, nbytes, info);
  2127. /* If we did not get all we asked for, then clear the rest.
  2128. Hopefully this makes a reproducible result in case of errors. */
  2129. if (nbytes != MAX_BYTES_PER_CRIS_INSN)
  2130. memset (buffer + nbytes, 0, MAX_BYTES_PER_CRIS_INSN - nbytes);
  2131. addr = memaddr;
  2132. bufp = buffer;
  2133. /* Set some defaults for the insn info. */
  2134. info->insn_info_valid = 1;
  2135. info->branch_delay_insns = 0;
  2136. info->data_size = 0;
  2137. info->insn_type = dis_nonbranch;
  2138. info->flags = 0;
  2139. info->target = 0;
  2140. info->target2 = 0;
  2141. /* If we got any data, disassemble it. */
  2142. if (nbytes != 0)
  2143. {
  2144. matchedp = NULL;
  2145. insn = bufp[0] + bufp[1] * 256;
  2146. /* If we're in a case-table, don't disassemble the offsets. */
  2147. if (TRACE_CASE && case_offset_counter != 0)
  2148. {
  2149. info->insn_type = dis_noninsn;
  2150. advance += 2;
  2151. /* If to print data as offsets, then shortcut here. */
  2152. (*info->fprintf_func) (info->stream, "case %ld%s: -> ",
  2153. case_offset + no_of_case_offsets
  2154. - case_offset_counter,
  2155. case_offset_counter == 1 ? "/default" :
  2156. "");
  2157. (*info->print_address_func) ((bfd_vma)
  2158. ((short) (insn)
  2159. + (long) (addr
  2160. - (no_of_case_offsets
  2161. - case_offset_counter)
  2162. * 2)), info);
  2163. case_offset_counter--;
  2164. /* The default case start (without a "sub" or "add") must be
  2165. zero. */
  2166. if (case_offset_counter == 0)
  2167. case_offset = 0;
  2168. }
  2169. else if (insn == 0)
  2170. {
  2171. /* We're often called to disassemble zeroes. While this is a
  2172. valid "bcc .+2" insn, it is also useless enough and enough
  2173. of a nuiscance that we will just output "bcc .+2" for it
  2174. and signal it as a noninsn. */
  2175. (*info->fprintf_func) (info->stream,
  2176. disdata->distype == cris_dis_v32
  2177. ? "bcc ." : "bcc .+2");
  2178. info->insn_type = dis_noninsn;
  2179. advance += 2;
  2180. }
  2181. else
  2182. {
  2183. const struct cris_opcode *prefix_opcodep = NULL;
  2184. unsigned char *prefix_buffer = bufp;
  2185. unsigned int prefix_insn = insn;
  2186. int prefix_size = 0;
  2187. matchedp = get_opcode_entry (insn, NO_CRIS_PREFIX, disdata);
  2188. /* Check if we're supposed to write out prefixes as address
  2189. modes and if this was a prefix. */
  2190. if (matchedp != NULL && PARSE_PREFIX && matchedp->args[0] == 'p')
  2191. {
  2192. /* If it's a prefix, put it into the prefix vars and get the
  2193. main insn. */
  2194. prefix_size = bytes_to_skip (prefix_insn, matchedp,
  2195. disdata->distype, NULL);
  2196. prefix_opcodep = matchedp;
  2197. insn = bufp[prefix_size] + bufp[prefix_size + 1] * 256;
  2198. matchedp = get_opcode_entry (insn, prefix_insn, disdata);
  2199. if (matchedp != NULL)
  2200. {
  2201. addr += prefix_size;
  2202. bufp += prefix_size;
  2203. advance += prefix_size;
  2204. }
  2205. else
  2206. {
  2207. /* The "main" insn wasn't valid, at least not when
  2208. prefixed. Put back things enough to output the
  2209. prefix insn only, as a normal insn. */
  2210. matchedp = prefix_opcodep;
  2211. insn = prefix_insn;
  2212. prefix_opcodep = NULL;
  2213. }
  2214. }
  2215. if (matchedp == NULL)
  2216. {
  2217. (*info->fprintf_func) (info->stream, "??0x%x", insn);
  2218. advance += 2;
  2219. info->insn_type = dis_noninsn;
  2220. }
  2221. else
  2222. {
  2223. advance
  2224. += bytes_to_skip (insn, matchedp, disdata->distype,
  2225. prefix_opcodep);
  2226. /* The info_type and assorted fields will be set according
  2227. to the operands. */
  2228. print_with_operands (matchedp, insn, bufp, addr, info,
  2229. prefix_opcodep, prefix_insn,
  2230. prefix_buffer, with_reg_prefix);
  2231. }
  2232. }
  2233. }
  2234. else
  2235. info->insn_type = dis_noninsn;
  2236. /* If we read less than MAX_BYTES_PER_CRIS_INSN, i.e. we got an error
  2237. status when reading that much, and the insn decoding indicated a
  2238. length exceeding what we read, there is an error. */
  2239. if (status != 0 && (nbytes == 0 || advance > nbytes))
  2240. {
  2241. (*info->memory_error_func) (status, memaddr, info);
  2242. return -1;
  2243. }
  2244. /* Max supported insn size with one folded prefix insn. */
  2245. info->bytes_per_line = MAX_BYTES_PER_CRIS_INSN;
  2246. /* I would like to set this to a fixed value larger than the actual
  2247. number of bytes to print in order to avoid spaces between bytes,
  2248. but objdump.c (2.9.1) does not like that, so we print 16-bit
  2249. chunks, which is the next choice. */
  2250. info->bytes_per_chunk = 2;
  2251. /* Printing bytes in order of increasing addresses makes sense,
  2252. especially on a little-endian target.
  2253. This is completely the opposite of what you think; setting this to
  2254. BFD_ENDIAN_LITTLE will print bytes in order N..0 rather than the 0..N
  2255. we want. */
  2256. info->display_endian = BFD_ENDIAN_BIG;
  2257. return advance;
  2258. }
  2259. /* Disassemble, prefixing register names with `$'. CRIS v0..v10. */
  2260. #if 0
  2261. static int
  2262. print_insn_cris_with_register_prefix (bfd_vma vma,
  2263. disassemble_info *info)
  2264. {
  2265. if (info->private_data == NULL
  2266. && !cris_parse_disassembler_options (info, cris_dis_v0_v10))
  2267. return -1;
  2268. return print_insn_cris_generic (vma, info, TRUE);
  2269. }
  2270. #endif
  2271. /* Disassemble, prefixing register names with `$'. CRIS v32. */
  2272. static int
  2273. print_insn_crisv32_with_register_prefix (bfd_vma vma,
  2274. disassemble_info *info)
  2275. {
  2276. if (info->private_data == NULL
  2277. && !cris_parse_disassembler_options (info, cris_dis_v32))
  2278. return -1;
  2279. return print_insn_cris_generic (vma, info, TRUE);
  2280. }
  2281. #if 0
  2282. /* Disassemble, prefixing register names with `$'.
  2283. Common v10 and v32 subset. */
  2284. static int
  2285. print_insn_crisv10_v32_with_register_prefix (bfd_vma vma,
  2286. disassemble_info *info)
  2287. {
  2288. if (info->private_data == NULL
  2289. && !cris_parse_disassembler_options (info, cris_dis_common_v10_v32))
  2290. return -1;
  2291. return print_insn_cris_generic (vma, info, TRUE);
  2292. }
  2293. /* Disassemble, no prefixes on register names. CRIS v0..v10. */
  2294. static int
  2295. print_insn_cris_without_register_prefix (bfd_vma vma,
  2296. disassemble_info *info)
  2297. {
  2298. if (info->private_data == NULL
  2299. && !cris_parse_disassembler_options (info, cris_dis_v0_v10))
  2300. return -1;
  2301. return print_insn_cris_generic (vma, info, FALSE);
  2302. }
  2303. /* Disassemble, no prefixes on register names. CRIS v32. */
  2304. static int
  2305. print_insn_crisv32_without_register_prefix (bfd_vma vma,
  2306. disassemble_info *info)
  2307. {
  2308. if (info->private_data == NULL
  2309. && !cris_parse_disassembler_options (info, cris_dis_v32))
  2310. return -1;
  2311. return print_insn_cris_generic (vma, info, FALSE);
  2312. }
  2313. /* Disassemble, no prefixes on register names.
  2314. Common v10 and v32 subset. */
  2315. static int
  2316. print_insn_crisv10_v32_without_register_prefix (bfd_vma vma,
  2317. disassemble_info *info)
  2318. {
  2319. if (info->private_data == NULL
  2320. && !cris_parse_disassembler_options (info, cris_dis_common_v10_v32))
  2321. return -1;
  2322. return print_insn_cris_generic (vma, info, FALSE);
  2323. }
  2324. #endif
  2325. int
  2326. print_insn_crisv32 (bfd_vma vma,
  2327. disassemble_info *info)
  2328. {
  2329. return print_insn_crisv32_with_register_prefix(vma, info);
  2330. }
  2331. /* Return a disassembler-function that prints registers with a `$' prefix,
  2332. or one that prints registers without a prefix.
  2333. FIXME: We should improve the solution to avoid the multitude of
  2334. functions seen above. */
  2335. #if 0
  2336. disassembler_ftype
  2337. cris_get_disassembler (bfd *abfd)
  2338. {
  2339. /* If there's no bfd in sight, we return what is valid as input in all
  2340. contexts if fed back to the assembler: disassembly *with* register
  2341. prefix. Unfortunately this will be totally wrong for v32. */
  2342. if (abfd == NULL)
  2343. return print_insn_cris_with_register_prefix;
  2344. if (bfd_get_symbol_leading_char (abfd) == 0)
  2345. {
  2346. if (bfd_get_mach (abfd) == bfd_mach_cris_v32)
  2347. return print_insn_crisv32_with_register_prefix;
  2348. if (bfd_get_mach (abfd) == bfd_mach_cris_v10_v32)
  2349. return print_insn_crisv10_v32_with_register_prefix;
  2350. /* We default to v10. This may be specifically specified in the
  2351. bfd mach, but is also the default setting. */
  2352. return print_insn_cris_with_register_prefix;
  2353. }
  2354. if (bfd_get_mach (abfd) == bfd_mach_cris_v32)
  2355. return print_insn_crisv32_without_register_prefix;
  2356. if (bfd_get_mach (abfd) == bfd_mach_cris_v10_v32)
  2357. return print_insn_crisv10_v32_without_register_prefix;
  2358. return print_insn_cris_without_register_prefix;
  2359. }
  2360. #endif
  2361. /* Local variables:
  2362. eval: (c-set-style "gnu")
  2363. indent-tabs-mode: t
  2364. End: */