bfin-dis.c 131 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823
  1. /* Disassemble ADI Blackfin Instructions.
  2. Copyright (C) 2005-2022 Free Software Foundation, Inc.
  3. This file is part of libopcodes.
  4. This library is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3, or (at your option)
  7. any later version.
  8. It is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  11. License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  15. MA 02110-1301, USA. */
  16. #include "sysdep.h"
  17. #include <stdio.h>
  18. #include "opcode/bfin.h"
  19. #ifndef PRINTF
  20. #define PRINTF printf
  21. #endif
  22. #ifndef EXIT
  23. #define EXIT exit
  24. #endif
  25. typedef long TIword;
  26. #define SIGNBIT(bits) (1ul << ((bits) - 1))
  27. #define MASKBITS(val, bits) ((val) & ((SIGNBIT (bits) << 1) - 1))
  28. #define SIGNEXTEND(v, n) ((MASKBITS (v, n) ^ SIGNBIT (n)) - SIGNBIT (n))
  29. #include "disassemble.h"
  30. typedef unsigned int bu32;
  31. struct private
  32. {
  33. TIword iw0;
  34. bool comment, parallel;
  35. };
  36. typedef enum
  37. {
  38. c_0, c_1, c_4, c_2, c_uimm2, c_uimm3, c_imm3, c_pcrel4,
  39. c_imm4, c_uimm4s4, c_uimm4s4d, c_uimm4, c_uimm4s2, c_negimm5s4, c_imm5, c_imm5d, c_uimm5, c_imm6,
  40. c_imm7, c_imm7d, c_imm8, c_uimm8, c_pcrel8, c_uimm8s4, c_pcrel8s4, c_lppcrel10, c_pcrel10,
  41. c_pcrel12, c_imm16s4, c_luimm16, c_imm16, c_imm16d, c_huimm16, c_rimm16, c_imm16s2, c_uimm16s4,
  42. c_uimm16s4d, c_uimm16, c_pcrel24, c_uimm32, c_imm32, c_huimm32, c_huimm32e,
  43. } const_forms_t;
  44. static const struct
  45. {
  46. const char *name;
  47. const int nbits;
  48. const char reloc;
  49. const char issigned;
  50. const char pcrel;
  51. const char scale;
  52. const char offset;
  53. const char negative;
  54. const char positive;
  55. const char decimal;
  56. const char leading;
  57. const char exact;
  58. } constant_formats[] =
  59. {
  60. { "0", 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
  61. { "1", 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
  62. { "4", 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
  63. { "2", 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
  64. { "uimm2", 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  65. { "uimm3", 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  66. { "imm3", 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
  67. { "pcrel4", 4, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0},
  68. { "imm4", 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
  69. { "uimm4s4", 4, 0, 0, 0, 2, 0, 0, 1, 0, 0, 0},
  70. { "uimm4s4d", 4, 0, 0, 0, 2, 0, 0, 1, 1, 0, 0},
  71. { "uimm4", 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  72. { "uimm4s2", 4, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0},
  73. { "negimm5s4", 5, 0, 1, 0, 2, 0, 1, 0, 0, 0, 0},
  74. { "imm5", 5, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
  75. { "imm5d", 5, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0},
  76. { "uimm5", 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  77. { "imm6", 6, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
  78. { "imm7", 7, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
  79. { "imm7d", 7, 0, 1, 0, 0, 0, 0, 0, 1, 3, 0},
  80. { "imm8", 8, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
  81. { "uimm8", 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  82. { "pcrel8", 8, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0},
  83. { "uimm8s4", 8, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0},
  84. { "pcrel8s4", 8, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0},
  85. { "lppcrel10", 10, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0},
  86. { "pcrel10", 10, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0},
  87. { "pcrel12", 12, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0},
  88. { "imm16s4", 16, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0},
  89. { "luimm16", 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  90. { "imm16", 16, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
  91. { "imm16d", 16, 0, 1, 0, 0, 0, 0, 0, 1, 3, 0},
  92. { "huimm16", 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  93. { "rimm16", 16, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0},
  94. { "imm16s2", 16, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0},
  95. { "uimm16s4", 16, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0},
  96. { "uimm16s4d", 16, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0},
  97. { "uimm16", 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  98. { "pcrel24", 24, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0},
  99. { "uimm32", 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  100. { "imm32", 32, 0, 1, 0, 0, 0, 0, 0, 1, 3, 0},
  101. { "huimm32", 32, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  102. { "huimm32e", 32, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
  103. };
  104. static const char *
  105. fmtconst (const_forms_t cf, TIword x, bfd_vma pc, disassemble_info *outf)
  106. {
  107. static char buf[60];
  108. if (constant_formats[cf].reloc)
  109. {
  110. bfd_vma ea;
  111. if (constant_formats[cf].pcrel)
  112. x = SIGNEXTEND (x, constant_formats[cf].nbits);
  113. ea = x + constant_formats[cf].offset;
  114. ea = ea << constant_formats[cf].scale;
  115. if (constant_formats[cf].pcrel)
  116. ea += pc;
  117. /* truncate to 32-bits for proper symbol lookup/matching */
  118. ea = (bu32)ea;
  119. if (outf->symbol_at_address_func (ea, outf) || !constant_formats[cf].exact)
  120. {
  121. outf->print_address_func (ea, outf);
  122. return "";
  123. }
  124. else
  125. {
  126. sprintf (buf, "%lx", (unsigned long) x);
  127. return buf;
  128. }
  129. }
  130. /* Negative constants have an implied sign bit. */
  131. if (constant_formats[cf].negative)
  132. {
  133. int nb = constant_formats[cf].nbits + 1;
  134. x = x | (1ul << constant_formats[cf].nbits);
  135. x = SIGNEXTEND (x, nb);
  136. }
  137. else if (constant_formats[cf].issigned)
  138. x = SIGNEXTEND (x, constant_formats[cf].nbits);
  139. x += constant_formats[cf].offset;
  140. x = (unsigned long) x << constant_formats[cf].scale;
  141. if (constant_formats[cf].decimal)
  142. sprintf (buf, "%*li", constant_formats[cf].leading, x);
  143. else
  144. {
  145. if (constant_formats[cf].issigned && x < 0)
  146. sprintf (buf, "-0x%lx", (unsigned long)(- x));
  147. else
  148. sprintf (buf, "0x%lx", (unsigned long) x);
  149. }
  150. return buf;
  151. }
  152. static bu32
  153. fmtconst_val (const_forms_t cf, unsigned int x, unsigned int pc)
  154. {
  155. if (0 && constant_formats[cf].reloc)
  156. {
  157. bu32 ea;
  158. if (constant_formats[cf].pcrel)
  159. x = SIGNEXTEND (x, constant_formats[cf].nbits);
  160. ea = x + constant_formats[cf].offset;
  161. ea = ea << constant_formats[cf].scale;
  162. if (constant_formats[cf].pcrel)
  163. ea += pc;
  164. return ea;
  165. }
  166. /* Negative constants have an implied sign bit. */
  167. if (constant_formats[cf].negative)
  168. {
  169. int nb = constant_formats[cf].nbits + 1;
  170. x = x | (1ul << constant_formats[cf].nbits);
  171. x = SIGNEXTEND (x, nb);
  172. }
  173. else if (constant_formats[cf].issigned)
  174. x = SIGNEXTEND (x, constant_formats[cf].nbits);
  175. x += constant_formats[cf].offset;
  176. x <<= constant_formats[cf].scale;
  177. return x;
  178. }
  179. enum machine_registers
  180. {
  181. REG_RL0, REG_RL1, REG_RL2, REG_RL3, REG_RL4, REG_RL5, REG_RL6, REG_RL7,
  182. REG_RH0, REG_RH1, REG_RH2, REG_RH3, REG_RH4, REG_RH5, REG_RH6, REG_RH7,
  183. REG_R0, REG_R1, REG_R2, REG_R3, REG_R4, REG_R5, REG_R6, REG_R7,
  184. REG_R1_0, REG_R3_2, REG_R5_4, REG_R7_6, REG_P0, REG_P1, REG_P2, REG_P3,
  185. REG_P4, REG_P5, REG_SP, REG_FP, REG_A0x, REG_A1x, REG_A0w, REG_A1w,
  186. REG_A0, REG_A1, REG_I0, REG_I1, REG_I2, REG_I3, REG_M0, REG_M1,
  187. REG_M2, REG_M3, REG_B0, REG_B1, REG_B2, REG_B3, REG_L0, REG_L1,
  188. REG_L2, REG_L3,
  189. REG_AZ, REG_AN, REG_AC0, REG_AC1, REG_AV0, REG_AV1, REG_AV0S, REG_AV1S,
  190. REG_AQ, REG_V, REG_VS,
  191. REG_sftreset, REG_omode, REG_excause, REG_emucause, REG_idle_req, REG_hwerrcause, REG_CC, REG_LC0,
  192. REG_LC1, REG_ASTAT, REG_RETS, REG_LT0, REG_LB0, REG_LT1, REG_LB1,
  193. REG_CYCLES, REG_CYCLES2, REG_USP, REG_SEQSTAT, REG_SYSCFG, REG_RETI, REG_RETX, REG_RETN,
  194. REG_RETE, REG_EMUDAT, REG_BR0, REG_BR1, REG_BR2, REG_BR3, REG_BR4, REG_BR5, REG_BR6,
  195. REG_BR7, REG_PL0, REG_PL1, REG_PL2, REG_PL3, REG_PL4, REG_PL5, REG_SLP, REG_FLP,
  196. REG_PH0, REG_PH1, REG_PH2, REG_PH3, REG_PH4, REG_PH5, REG_SHP, REG_FHP,
  197. REG_IL0, REG_IL1, REG_IL2, REG_IL3, REG_ML0, REG_ML1, REG_ML2, REG_ML3,
  198. REG_BL0, REG_BL1, REG_BL2, REG_BL3, REG_LL0, REG_LL1, REG_LL2, REG_LL3,
  199. REG_IH0, REG_IH1, REG_IH2, REG_IH3, REG_MH0, REG_MH1, REG_MH2, REG_MH3,
  200. REG_BH0, REG_BH1, REG_BH2, REG_BH3, REG_LH0, REG_LH1, REG_LH2, REG_LH3,
  201. REG_AC0_COPY, REG_V_COPY, REG_RND_MOD,
  202. REG_LASTREG,
  203. };
  204. enum reg_class
  205. {
  206. rc_dregs_lo, rc_dregs_hi, rc_dregs, rc_dregs_pair, rc_pregs, rc_spfp, rc_dregs_hilo, rc_accum_ext,
  207. rc_accum_word, rc_accum, rc_iregs, rc_mregs, rc_bregs, rc_lregs, rc_dpregs, rc_gregs,
  208. rc_regs, rc_statbits, rc_ignore_bits, rc_ccstat, rc_counters, rc_dregs2_sysregs1, rc_open, rc_sysregs2,
  209. rc_sysregs3, rc_allregs,
  210. LIM_REG_CLASSES
  211. };
  212. static const char * const reg_names[] =
  213. {
  214. "R0.L", "R1.L", "R2.L", "R3.L", "R4.L", "R5.L", "R6.L", "R7.L",
  215. "R0.H", "R1.H", "R2.H", "R3.H", "R4.H", "R5.H", "R6.H", "R7.H",
  216. "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7",
  217. "R1:0", "R3:2", "R5:4", "R7:6", "P0", "P1", "P2", "P3",
  218. "P4", "P5", "SP", "FP", "A0.X", "A1.X", "A0.W", "A1.W",
  219. "A0", "A1", "I0", "I1", "I2", "I3", "M0", "M1",
  220. "M2", "M3", "B0", "B1", "B2", "B3", "L0", "L1",
  221. "L2", "L3",
  222. "AZ", "AN", "AC0", "AC1", "AV0", "AV1", "AV0S", "AV1S",
  223. "AQ", "V", "VS",
  224. "sftreset", "omode", "excause", "emucause", "idle_req", "hwerrcause", "CC", "LC0",
  225. "LC1", "ASTAT", "RETS", "LT0", "LB0", "LT1", "LB1",
  226. "CYCLES", "CYCLES2", "USP", "SEQSTAT", "SYSCFG", "RETI", "RETX", "RETN",
  227. "RETE", "EMUDAT",
  228. "R0.B", "R1.B", "R2.B", "R3.B", "R4.B", "R5.B", "R6.B", "R7.B",
  229. "P0.L", "P1.L", "P2.L", "P3.L", "P4.L", "P5.L", "SP.L", "FP.L",
  230. "P0.H", "P1.H", "P2.H", "P3.H", "P4.H", "P5.H", "SP.H", "FP.H",
  231. "I0.L", "I1.L", "I2.L", "I3.L", "M0.L", "M1.L", "M2.L", "M3.L",
  232. "B0.L", "B1.L", "B2.L", "B3.L", "L0.L", "L1.L", "L2.L", "L3.L",
  233. "I0.H", "I1.H", "I2.H", "I3.H", "M0.H", "M1.H", "M2.H", "M3.H",
  234. "B0.H", "B1.H", "B2.H", "B3.H", "L0.H", "L1.H", "L2.H", "L3.H",
  235. "AC0_COPY", "V_COPY", "RND_MOD",
  236. "LASTREG",
  237. 0
  238. };
  239. #define REGNAME(x) ((x) < REG_LASTREG ? (reg_names[x]) : "...... Illegal register .......")
  240. /* RL(0..7). */
  241. static const enum machine_registers decode_dregs_lo[] =
  242. {
  243. REG_RL0, REG_RL1, REG_RL2, REG_RL3, REG_RL4, REG_RL5, REG_RL6, REG_RL7,
  244. };
  245. #define dregs_lo(x) REGNAME (decode_dregs_lo[(x) & 7])
  246. /* RH(0..7). */
  247. static const enum machine_registers decode_dregs_hi[] =
  248. {
  249. REG_RH0, REG_RH1, REG_RH2, REG_RH3, REG_RH4, REG_RH5, REG_RH6, REG_RH7,
  250. };
  251. #define dregs_hi(x) REGNAME (decode_dregs_hi[(x) & 7])
  252. /* R(0..7). */
  253. static const enum machine_registers decode_dregs[] =
  254. {
  255. REG_R0, REG_R1, REG_R2, REG_R3, REG_R4, REG_R5, REG_R6, REG_R7,
  256. };
  257. #define dregs(x) REGNAME (decode_dregs[(x) & 7])
  258. /* R BYTE(0..7). */
  259. static const enum machine_registers decode_dregs_byte[] =
  260. {
  261. REG_BR0, REG_BR1, REG_BR2, REG_BR3, REG_BR4, REG_BR5, REG_BR6, REG_BR7,
  262. };
  263. #define dregs_byte(x) REGNAME (decode_dregs_byte[(x) & 7])
  264. /* P(0..5) SP FP. */
  265. static const enum machine_registers decode_pregs[] =
  266. {
  267. REG_P0, REG_P1, REG_P2, REG_P3, REG_P4, REG_P5, REG_SP, REG_FP,
  268. };
  269. #define pregs(x) REGNAME (decode_pregs[(x) & 7])
  270. #define spfp(x) REGNAME (decode_spfp[(x) & 1])
  271. #define dregs_hilo(x, i) REGNAME (decode_dregs_hilo[((i) << 3) | (x)])
  272. #define accum_ext(x) REGNAME (decode_accum_ext[(x) & 1])
  273. #define accum_word(x) REGNAME (decode_accum_word[(x) & 1])
  274. #define accum(x) REGNAME (decode_accum[(x) & 1])
  275. /* I(0..3). */
  276. static const enum machine_registers decode_iregs[] =
  277. {
  278. REG_I0, REG_I1, REG_I2, REG_I3,
  279. };
  280. #define iregs(x) REGNAME (decode_iregs[(x) & 3])
  281. /* M(0..3). */
  282. static const enum machine_registers decode_mregs[] =
  283. {
  284. REG_M0, REG_M1, REG_M2, REG_M3,
  285. };
  286. #define mregs(x) REGNAME (decode_mregs[(x) & 3])
  287. #define bregs(x) REGNAME (decode_bregs[(x) & 3])
  288. #define lregs(x) REGNAME (decode_lregs[(x) & 3])
  289. /* dregs pregs. */
  290. static const enum machine_registers decode_dpregs[] =
  291. {
  292. REG_R0, REG_R1, REG_R2, REG_R3, REG_R4, REG_R5, REG_R6, REG_R7,
  293. REG_P0, REG_P1, REG_P2, REG_P3, REG_P4, REG_P5, REG_SP, REG_FP,
  294. };
  295. #define dpregs(x) REGNAME (decode_dpregs[(x) & 15])
  296. /* [dregs pregs]. */
  297. static const enum machine_registers decode_gregs[] =
  298. {
  299. REG_R0, REG_R1, REG_R2, REG_R3, REG_R4, REG_R5, REG_R6, REG_R7,
  300. REG_P0, REG_P1, REG_P2, REG_P3, REG_P4, REG_P5, REG_SP, REG_FP,
  301. };
  302. #define gregs(x, i) REGNAME (decode_gregs[(((i) << 3) | (x)) & 15])
  303. /* [dregs pregs (iregs mregs) (bregs lregs)]. */
  304. static const enum machine_registers decode_regs[] =
  305. {
  306. REG_R0, REG_R1, REG_R2, REG_R3, REG_R4, REG_R5, REG_R6, REG_R7,
  307. REG_P0, REG_P1, REG_P2, REG_P3, REG_P4, REG_P5, REG_SP, REG_FP,
  308. REG_I0, REG_I1, REG_I2, REG_I3, REG_M0, REG_M1, REG_M2, REG_M3,
  309. REG_B0, REG_B1, REG_B2, REG_B3, REG_L0, REG_L1, REG_L2, REG_L3,
  310. };
  311. #define regs(x, i) REGNAME (decode_regs[(((i) << 3) | (x)) & 31])
  312. /* [dregs pregs (iregs mregs) (bregs lregs) Low Half]. */
  313. static const enum machine_registers decode_regs_lo[] =
  314. {
  315. REG_RL0, REG_RL1, REG_RL2, REG_RL3, REG_RL4, REG_RL5, REG_RL6, REG_RL7,
  316. REG_PL0, REG_PL1, REG_PL2, REG_PL3, REG_PL4, REG_PL5, REG_SLP, REG_FLP,
  317. REG_IL0, REG_IL1, REG_IL2, REG_IL3, REG_ML0, REG_ML1, REG_ML2, REG_ML3,
  318. REG_BL0, REG_BL1, REG_BL2, REG_BL3, REG_LL0, REG_LL1, REG_LL2, REG_LL3,
  319. };
  320. #define regs_lo(x, i) REGNAME (decode_regs_lo[(((i) << 3) | (x)) & 31])
  321. /* [dregs pregs (iregs mregs) (bregs lregs) High Half]. */
  322. static const enum machine_registers decode_regs_hi[] =
  323. {
  324. REG_RH0, REG_RH1, REG_RH2, REG_RH3, REG_RH4, REG_RH5, REG_RH6, REG_RH7,
  325. REG_PH0, REG_PH1, REG_PH2, REG_PH3, REG_PH4, REG_PH5, REG_SHP, REG_FHP,
  326. REG_IH0, REG_IH1, REG_IH2, REG_IH3, REG_MH0, REG_MH1, REG_MH2, REG_MH3,
  327. REG_BH0, REG_BH1, REG_BH2, REG_BH3, REG_LH0, REG_LH1, REG_LH2, REG_LH3,
  328. };
  329. #define regs_hi(x, i) REGNAME (decode_regs_hi[(((i) << 3) | (x)) & 31])
  330. static const enum machine_registers decode_statbits[] =
  331. {
  332. REG_AZ, REG_AN, REG_AC0_COPY, REG_V_COPY,
  333. REG_LASTREG, REG_LASTREG, REG_AQ, REG_LASTREG,
  334. REG_RND_MOD, REG_LASTREG, REG_LASTREG, REG_LASTREG,
  335. REG_AC0, REG_AC1, REG_LASTREG, REG_LASTREG,
  336. REG_AV0, REG_AV0S, REG_AV1, REG_AV1S,
  337. REG_LASTREG, REG_LASTREG, REG_LASTREG, REG_LASTREG,
  338. REG_V, REG_VS, REG_LASTREG, REG_LASTREG,
  339. REG_LASTREG, REG_LASTREG, REG_LASTREG, REG_LASTREG,
  340. };
  341. #define statbits(x) REGNAME (decode_statbits[(x) & 31])
  342. /* LC0 LC1. */
  343. static const enum machine_registers decode_counters[] =
  344. {
  345. REG_LC0, REG_LC1,
  346. };
  347. #define counters(x) REGNAME (decode_counters[(x) & 1])
  348. #define dregs2_sysregs1(x) REGNAME (decode_dregs2_sysregs1[(x) & 7])
  349. /* [dregs pregs (iregs mregs) (bregs lregs)
  350. dregs2_sysregs1 open sysregs2 sysregs3]. */
  351. static const enum machine_registers decode_allregs[] =
  352. {
  353. REG_R0, REG_R1, REG_R2, REG_R3, REG_R4, REG_R5, REG_R6, REG_R7,
  354. REG_P0, REG_P1, REG_P2, REG_P3, REG_P4, REG_P5, REG_SP, REG_FP,
  355. REG_I0, REG_I1, REG_I2, REG_I3, REG_M0, REG_M1, REG_M2, REG_M3,
  356. REG_B0, REG_B1, REG_B2, REG_B3, REG_L0, REG_L1, REG_L2, REG_L3,
  357. REG_A0x, REG_A0w, REG_A1x, REG_A1w, REG_LASTREG, REG_LASTREG, REG_ASTAT, REG_RETS,
  358. REG_LASTREG, REG_LASTREG, REG_LASTREG, REG_LASTREG, REG_LASTREG, REG_LASTREG, REG_LASTREG, REG_LASTREG,
  359. REG_LC0, REG_LT0, REG_LB0, REG_LC1, REG_LT1, REG_LB1, REG_CYCLES, REG_CYCLES2,
  360. REG_USP, REG_SEQSTAT, REG_SYSCFG, REG_RETI, REG_RETX, REG_RETN, REG_RETE, REG_EMUDAT,
  361. REG_LASTREG,
  362. };
  363. #define IS_DREG(g,r) ((g) == 0 && (r) < 8)
  364. #define IS_PREG(g,r) ((g) == 1 && (r) < 8)
  365. #define IS_AREG(g,r) ((g) == 4 && (r) >= 0 && (r) < 4)
  366. #define IS_GENREG(g,r) ((((g) == 0 || (g) == 1) && (r) < 8) || IS_AREG (g, r))
  367. #define IS_DAGREG(g,r) (((g) == 2 || (g) == 3) && (r) < 8)
  368. #define IS_SYSREG(g,r) \
  369. (((g) == 4 && ((r) == 6 || (r) == 7)) || (g) == 6 || (g) == 7)
  370. #define IS_RESERVEDREG(g,r) \
  371. (((r) > 7) || ((g) == 4 && ((r) == 4 || (r) == 5)) || (g) == 5)
  372. #define allreg(r,g) (!IS_RESERVEDREG (g, r))
  373. #define mostreg(r,g) (!(IS_DREG (g, r) || IS_PREG (g, r) || IS_RESERVEDREG (g, r)))
  374. #define allregs(x, i) REGNAME (decode_allregs[((i) << 3) | (x)])
  375. #define uimm16s4(x) fmtconst (c_uimm16s4, x, 0, outf)
  376. #define uimm16s4d(x) fmtconst (c_uimm16s4d, x, 0, outf)
  377. #define pcrel4(x) fmtconst (c_pcrel4, x, pc, outf)
  378. #define pcrel8(x) fmtconst (c_pcrel8, x, pc, outf)
  379. #define pcrel8s4(x) fmtconst (c_pcrel8s4, x, pc, outf)
  380. #define pcrel10(x) fmtconst (c_pcrel10, x, pc, outf)
  381. #define pcrel12(x) fmtconst (c_pcrel12, x, pc, outf)
  382. #define negimm5s4(x) fmtconst (c_negimm5s4, x, 0, outf)
  383. #define rimm16(x) fmtconst (c_rimm16, x, 0, outf)
  384. #define huimm16(x) fmtconst (c_huimm16, x, 0, outf)
  385. #define imm16(x) fmtconst (c_imm16, x, 0, outf)
  386. #define imm16d(x) fmtconst (c_imm16d, x, 0, outf)
  387. #define uimm2(x) fmtconst (c_uimm2, x, 0, outf)
  388. #define uimm3(x) fmtconst (c_uimm3, x, 0, outf)
  389. #define luimm16(x) fmtconst (c_luimm16, x, 0, outf)
  390. #define uimm4(x) fmtconst (c_uimm4, x, 0, outf)
  391. #define uimm5(x) fmtconst (c_uimm5, x, 0, outf)
  392. #define imm16s2(x) fmtconst (c_imm16s2, x, 0, outf)
  393. #define uimm8(x) fmtconst (c_uimm8, x, 0, outf)
  394. #define imm16s4(x) fmtconst (c_imm16s4, x, 0, outf)
  395. #define uimm4s2(x) fmtconst (c_uimm4s2, x, 0, outf)
  396. #define uimm4s4(x) fmtconst (c_uimm4s4, x, 0, outf)
  397. #define uimm4s4d(x) fmtconst (c_uimm4s4d, x, 0, outf)
  398. #define lppcrel10(x) fmtconst (c_lppcrel10, x, pc, outf)
  399. #define imm3(x) fmtconst (c_imm3, x, 0, outf)
  400. #define imm4(x) fmtconst (c_imm4, x, 0, outf)
  401. #define uimm8s4(x) fmtconst (c_uimm8s4, x, 0, outf)
  402. #define imm5(x) fmtconst (c_imm5, x, 0, outf)
  403. #define imm5d(x) fmtconst (c_imm5d, x, 0, outf)
  404. #define imm6(x) fmtconst (c_imm6, x, 0, outf)
  405. #define imm7(x) fmtconst (c_imm7, x, 0, outf)
  406. #define imm7d(x) fmtconst (c_imm7d, x, 0, outf)
  407. #define imm8(x) fmtconst (c_imm8, x, 0, outf)
  408. #define pcrel24(x) fmtconst (c_pcrel24, x, pc, outf)
  409. #define uimm16(x) fmtconst (c_uimm16, x, 0, outf)
  410. #define uimm32(x) fmtconst (c_uimm32, x, 0, outf)
  411. #define imm32(x) fmtconst (c_imm32, x, 0, outf)
  412. #define huimm32(x) fmtconst (c_huimm32, x, 0, outf)
  413. #define huimm32e(x) fmtconst (c_huimm32e, x, 0, outf)
  414. #define imm7_val(x) fmtconst_val (c_imm7, x, 0)
  415. #define imm16_val(x) fmtconst_val (c_uimm16, x, 0)
  416. #define luimm16_val(x) fmtconst_val (c_luimm16, x, 0)
  417. /* (arch.pm)arch_disassembler_functions. */
  418. #ifndef OUTS
  419. #define OUTS(p, txt) (p)->fprintf_func ((p)->stream, "%s", txt)
  420. #endif
  421. #define OUT(p, txt, ...) (p)->fprintf_func ((p)->stream, txt, ## __VA_ARGS__)
  422. static void
  423. amod0 (int s0, int x0, disassemble_info *outf)
  424. {
  425. if (s0 == 1 && x0 == 0)
  426. OUTS (outf, " (S)");
  427. else if (s0 == 0 && x0 == 1)
  428. OUTS (outf, " (CO)");
  429. else if (s0 == 1 && x0 == 1)
  430. OUTS (outf, " (SCO)");
  431. }
  432. static void
  433. amod1 (int s0, int x0, disassemble_info *outf)
  434. {
  435. if (s0 == 0 && x0 == 0)
  436. OUTS (outf, " (NS)");
  437. else if (s0 == 1 && x0 == 0)
  438. OUTS (outf, " (S)");
  439. }
  440. static void
  441. amod0amod2 (int s0, int x0, int aop0, disassemble_info *outf)
  442. {
  443. if (s0 == 1 && x0 == 0 && aop0 == 0)
  444. OUTS (outf, " (S)");
  445. else if (s0 == 0 && x0 == 1 && aop0 == 0)
  446. OUTS (outf, " (CO)");
  447. else if (s0 == 1 && x0 == 1 && aop0 == 0)
  448. OUTS (outf, " (SCO)");
  449. else if (s0 == 0 && x0 == 0 && aop0 == 2)
  450. OUTS (outf, " (ASR)");
  451. else if (s0 == 1 && x0 == 0 && aop0 == 2)
  452. OUTS (outf, " (S, ASR)");
  453. else if (s0 == 0 && x0 == 1 && aop0 == 2)
  454. OUTS (outf, " (CO, ASR)");
  455. else if (s0 == 1 && x0 == 1 && aop0 == 2)
  456. OUTS (outf, " (SCO, ASR)");
  457. else if (s0 == 0 && x0 == 0 && aop0 == 3)
  458. OUTS (outf, " (ASL)");
  459. else if (s0 == 1 && x0 == 0 && aop0 == 3)
  460. OUTS (outf, " (S, ASL)");
  461. else if (s0 == 0 && x0 == 1 && aop0 == 3)
  462. OUTS (outf, " (CO, ASL)");
  463. else if (s0 == 1 && x0 == 1 && aop0 == 3)
  464. OUTS (outf, " (SCO, ASL)");
  465. }
  466. static void
  467. searchmod (int r0, disassemble_info *outf)
  468. {
  469. if (r0 == 0)
  470. OUTS (outf, "GT");
  471. else if (r0 == 1)
  472. OUTS (outf, "GE");
  473. else if (r0 == 2)
  474. OUTS (outf, "LT");
  475. else if (r0 == 3)
  476. OUTS (outf, "LE");
  477. }
  478. static void
  479. aligndir (int r0, disassemble_info *outf)
  480. {
  481. if (r0 == 1)
  482. OUTS (outf, " (R)");
  483. }
  484. static int
  485. decode_multfunc (int h0, int h1, int src0, int src1, disassemble_info *outf)
  486. {
  487. const char *s0, *s1;
  488. if (h0)
  489. s0 = dregs_hi (src0);
  490. else
  491. s0 = dregs_lo (src0);
  492. if (h1)
  493. s1 = dregs_hi (src1);
  494. else
  495. s1 = dregs_lo (src1);
  496. OUTS (outf, s0);
  497. OUTS (outf, " * ");
  498. OUTS (outf, s1);
  499. return 0;
  500. }
  501. static int
  502. decode_macfunc (int which, int op, int h0, int h1, int src0, int src1, disassemble_info *outf)
  503. {
  504. const char *a;
  505. const char *sop = "<unknown op>";
  506. if (which)
  507. a = "A1";
  508. else
  509. a = "A0";
  510. if (op == 3)
  511. {
  512. OUTS (outf, a);
  513. return 0;
  514. }
  515. switch (op)
  516. {
  517. case 0: sop = " = "; break;
  518. case 1: sop = " += "; break;
  519. case 2: sop = " -= "; break;
  520. default: break;
  521. }
  522. OUTS (outf, a);
  523. OUTS (outf, sop);
  524. decode_multfunc (h0, h1, src0, src1, outf);
  525. return 0;
  526. }
  527. static void
  528. decode_optmode (int mod, int MM, disassemble_info *outf)
  529. {
  530. if (mod == 0 && MM == 0)
  531. return;
  532. OUTS (outf, " (");
  533. if (MM && !mod)
  534. {
  535. OUTS (outf, "M)");
  536. return;
  537. }
  538. if (MM)
  539. OUTS (outf, "M, ");
  540. if (mod == M_S2RND)
  541. OUTS (outf, "S2RND");
  542. else if (mod == M_T)
  543. OUTS (outf, "T");
  544. else if (mod == M_W32)
  545. OUTS (outf, "W32");
  546. else if (mod == M_FU)
  547. OUTS (outf, "FU");
  548. else if (mod == M_TFU)
  549. OUTS (outf, "TFU");
  550. else if (mod == M_IS)
  551. OUTS (outf, "IS");
  552. else if (mod == M_ISS2)
  553. OUTS (outf, "ISS2");
  554. else if (mod == M_IH)
  555. OUTS (outf, "IH");
  556. else if (mod == M_IU)
  557. OUTS (outf, "IU");
  558. else
  559. abort ();
  560. OUTS (outf, ")");
  561. }
  562. static struct saved_state
  563. {
  564. bu32 dpregs[16], iregs[4], mregs[4], bregs[4], lregs[4];
  565. bu32 ax[2], aw[2];
  566. bu32 lt[2], lc[2], lb[2];
  567. bu32 rets;
  568. } saved_state;
  569. #define DREG(x) (saved_state.dpregs[x])
  570. #define GREG(x, i) DPREG ((x) | ((i) << 3))
  571. #define DPREG(x) (saved_state.dpregs[x])
  572. #define DREG(x) (saved_state.dpregs[x])
  573. #define PREG(x) (saved_state.dpregs[(x) + 8])
  574. #define SPREG PREG (6)
  575. #define FPREG PREG (7)
  576. #define IREG(x) (saved_state.iregs[x])
  577. #define MREG(x) (saved_state.mregs[x])
  578. #define BREG(x) (saved_state.bregs[x])
  579. #define LREG(x) (saved_state.lregs[x])
  580. #define AXREG(x) (saved_state.ax[x])
  581. #define AWREG(x) (saved_state.aw[x])
  582. #define LCREG(x) (saved_state.lc[x])
  583. #define LTREG(x) (saved_state.lt[x])
  584. #define LBREG(x) (saved_state.lb[x])
  585. #define RETSREG (saved_state.rets)
  586. static bu32 *
  587. get_allreg (int grp, int reg)
  588. {
  589. int fullreg = (grp << 3) | reg;
  590. /* REG_R0, REG_R1, REG_R2, REG_R3, REG_R4, REG_R5, REG_R6, REG_R7,
  591. REG_P0, REG_P1, REG_P2, REG_P3, REG_P4, REG_P5, REG_SP, REG_FP,
  592. REG_I0, REG_I1, REG_I2, REG_I3, REG_M0, REG_M1, REG_M2, REG_M3,
  593. REG_B0, REG_B1, REG_B2, REG_B3, REG_L0, REG_L1, REG_L2, REG_L3,
  594. REG_A0x, REG_A0w, REG_A1x, REG_A1w, , , REG_ASTAT, REG_RETS,
  595. , , , , , , , ,
  596. REG_LC0, REG_LT0, REG_LB0, REG_LC1, REG_LT1, REG_LB1, REG_CYCLES,
  597. REG_CYCLES2,
  598. REG_USP, REG_SEQSTAT, REG_SYSCFG, REG_RETI, REG_RETX, REG_RETN, REG_RETE,
  599. REG_LASTREG */
  600. switch (fullreg >> 2)
  601. {
  602. case 0: case 1: return &DREG (reg);
  603. case 2: case 3: return &PREG (reg);
  604. case 4: return &IREG (reg & 3);
  605. case 5: return &MREG (reg & 3);
  606. case 6: return &BREG (reg & 3);
  607. case 7: return &LREG (reg & 3);
  608. default:
  609. switch (fullreg)
  610. {
  611. case 32: return &AXREG (0);
  612. case 33: return &AWREG (0);
  613. case 34: return &AXREG (1);
  614. case 35: return &AWREG (1);
  615. case 39: return &RETSREG;
  616. case 48: return &LCREG (0);
  617. case 49: return &LTREG (0);
  618. case 50: return &LBREG (0);
  619. case 51: return &LCREG (1);
  620. case 52: return &LTREG (1);
  621. case 53: return &LBREG (1);
  622. }
  623. }
  624. abort ();
  625. }
  626. static int
  627. decode_ProgCtrl_0 (TIword iw0, disassemble_info *outf)
  628. {
  629. struct private *priv = outf->private_data;
  630. /* ProgCtrl
  631. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  632. | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |.prgfunc.......|.poprnd........|
  633. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  634. int poprnd = ((iw0 >> ProgCtrl_poprnd_bits) & ProgCtrl_poprnd_mask);
  635. int prgfunc = ((iw0 >> ProgCtrl_prgfunc_bits) & ProgCtrl_prgfunc_mask);
  636. if (prgfunc == 0 && poprnd == 0)
  637. OUTS (outf, "NOP");
  638. else if (priv->parallel)
  639. return 0;
  640. else if (prgfunc == 1 && poprnd == 0)
  641. OUTS (outf, "RTS");
  642. else if (prgfunc == 1 && poprnd == 1)
  643. OUTS (outf, "RTI");
  644. else if (prgfunc == 1 && poprnd == 2)
  645. OUTS (outf, "RTX");
  646. else if (prgfunc == 1 && poprnd == 3)
  647. OUTS (outf, "RTN");
  648. else if (prgfunc == 1 && poprnd == 4)
  649. OUTS (outf, "RTE");
  650. else if (prgfunc == 2 && poprnd == 0)
  651. OUTS (outf, "IDLE");
  652. else if (prgfunc == 2 && poprnd == 3)
  653. OUTS (outf, "CSYNC");
  654. else if (prgfunc == 2 && poprnd == 4)
  655. OUTS (outf, "SSYNC");
  656. else if (prgfunc == 2 && poprnd == 5)
  657. OUTS (outf, "EMUEXCPT");
  658. else if (prgfunc == 3 && IS_DREG (0, poprnd))
  659. {
  660. OUTS (outf, "CLI ");
  661. OUTS (outf, dregs (poprnd));
  662. }
  663. else if (prgfunc == 4 && IS_DREG (0, poprnd))
  664. {
  665. OUTS (outf, "STI ");
  666. OUTS (outf, dregs (poprnd));
  667. }
  668. else if (prgfunc == 5 && IS_PREG (1, poprnd))
  669. {
  670. OUTS (outf, "JUMP (");
  671. OUTS (outf, pregs (poprnd));
  672. OUTS (outf, ")");
  673. }
  674. else if (prgfunc == 6 && IS_PREG (1, poprnd))
  675. {
  676. OUTS (outf, "CALL (");
  677. OUTS (outf, pregs (poprnd));
  678. OUTS (outf, ")");
  679. }
  680. else if (prgfunc == 7 && IS_PREG (1, poprnd))
  681. {
  682. OUTS (outf, "CALL (PC + ");
  683. OUTS (outf, pregs (poprnd));
  684. OUTS (outf, ")");
  685. }
  686. else if (prgfunc == 8 && IS_PREG (1, poprnd))
  687. {
  688. OUTS (outf, "JUMP (PC + ");
  689. OUTS (outf, pregs (poprnd));
  690. OUTS (outf, ")");
  691. }
  692. else if (prgfunc == 9)
  693. {
  694. OUTS (outf, "RAISE ");
  695. OUTS (outf, uimm4 (poprnd));
  696. }
  697. else if (prgfunc == 10)
  698. {
  699. OUTS (outf, "EXCPT ");
  700. OUTS (outf, uimm4 (poprnd));
  701. }
  702. else if (prgfunc == 11 && IS_PREG (1, poprnd) && poprnd <= 5)
  703. {
  704. OUTS (outf, "TESTSET (");
  705. OUTS (outf, pregs (poprnd));
  706. OUTS (outf, ")");
  707. }
  708. else
  709. return 0;
  710. return 2;
  711. }
  712. static int
  713. decode_CaCTRL_0 (TIword iw0, disassemble_info *outf)
  714. {
  715. struct private *priv = outf->private_data;
  716. /* CaCTRL
  717. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  718. | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 |.a.|.op....|.reg.......|
  719. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  720. int a = ((iw0 >> CaCTRL_a_bits) & CaCTRL_a_mask);
  721. int op = ((iw0 >> CaCTRL_op_bits) & CaCTRL_op_mask);
  722. int reg = ((iw0 >> CaCTRL_reg_bits) & CaCTRL_reg_mask);
  723. if (priv->parallel)
  724. return 0;
  725. if (a == 0 && op == 0)
  726. {
  727. OUTS (outf, "PREFETCH[");
  728. OUTS (outf, pregs (reg));
  729. OUTS (outf, "]");
  730. }
  731. else if (a == 0 && op == 1)
  732. {
  733. OUTS (outf, "FLUSHINV[");
  734. OUTS (outf, pregs (reg));
  735. OUTS (outf, "]");
  736. }
  737. else if (a == 0 && op == 2)
  738. {
  739. OUTS (outf, "FLUSH[");
  740. OUTS (outf, pregs (reg));
  741. OUTS (outf, "]");
  742. }
  743. else if (a == 0 && op == 3)
  744. {
  745. OUTS (outf, "IFLUSH[");
  746. OUTS (outf, pregs (reg));
  747. OUTS (outf, "]");
  748. }
  749. else if (a == 1 && op == 0)
  750. {
  751. OUTS (outf, "PREFETCH[");
  752. OUTS (outf, pregs (reg));
  753. OUTS (outf, "++]");
  754. }
  755. else if (a == 1 && op == 1)
  756. {
  757. OUTS (outf, "FLUSHINV[");
  758. OUTS (outf, pregs (reg));
  759. OUTS (outf, "++]");
  760. }
  761. else if (a == 1 && op == 2)
  762. {
  763. OUTS (outf, "FLUSH[");
  764. OUTS (outf, pregs (reg));
  765. OUTS (outf, "++]");
  766. }
  767. else if (a == 1 && op == 3)
  768. {
  769. OUTS (outf, "IFLUSH[");
  770. OUTS (outf, pregs (reg));
  771. OUTS (outf, "++]");
  772. }
  773. else
  774. return 0;
  775. return 2;
  776. }
  777. static int
  778. decode_PushPopReg_0 (TIword iw0, disassemble_info *outf)
  779. {
  780. struct private *priv = outf->private_data;
  781. /* PushPopReg
  782. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  783. | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |.W.|.grp.......|.reg.......|
  784. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  785. int W = ((iw0 >> PushPopReg_W_bits) & PushPopReg_W_mask);
  786. int grp = ((iw0 >> PushPopReg_grp_bits) & PushPopReg_grp_mask);
  787. int reg = ((iw0 >> PushPopReg_reg_bits) & PushPopReg_reg_mask);
  788. if (priv->parallel)
  789. return 0;
  790. if (W == 0 && mostreg (reg, grp))
  791. {
  792. OUTS (outf, allregs (reg, grp));
  793. OUTS (outf, " = [SP++]");
  794. }
  795. else if (W == 1 && allreg (reg, grp) && !(grp == 1 && reg == 6))
  796. {
  797. OUTS (outf, "[--SP] = ");
  798. OUTS (outf, allregs (reg, grp));
  799. }
  800. else
  801. return 0;
  802. return 2;
  803. }
  804. static int
  805. decode_PushPopMultiple_0 (TIword iw0, disassemble_info *outf)
  806. {
  807. struct private *priv = outf->private_data;
  808. /* PushPopMultiple
  809. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  810. | 0 | 0 | 0 | 0 | 0 | 1 | 0 |.d.|.p.|.W.|.dr........|.pr........|
  811. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  812. int p = ((iw0 >> PushPopMultiple_p_bits) & PushPopMultiple_p_mask);
  813. int d = ((iw0 >> PushPopMultiple_d_bits) & PushPopMultiple_d_mask);
  814. int W = ((iw0 >> PushPopMultiple_W_bits) & PushPopMultiple_W_mask);
  815. int dr = ((iw0 >> PushPopMultiple_dr_bits) & PushPopMultiple_dr_mask);
  816. int pr = ((iw0 >> PushPopMultiple_pr_bits) & PushPopMultiple_pr_mask);
  817. if (priv->parallel)
  818. return 0;
  819. if (pr > 5)
  820. return 0;
  821. if (W == 1 && d == 1 && p == 1)
  822. {
  823. OUTS (outf, "[--SP] = (R7:");
  824. OUTS (outf, imm5d (dr));
  825. OUTS (outf, ", P5:");
  826. OUTS (outf, imm5d (pr));
  827. OUTS (outf, ")");
  828. }
  829. else if (W == 1 && d == 1 && p == 0 && pr == 0)
  830. {
  831. OUTS (outf, "[--SP] = (R7:");
  832. OUTS (outf, imm5d (dr));
  833. OUTS (outf, ")");
  834. }
  835. else if (W == 1 && d == 0 && p == 1 && dr == 0)
  836. {
  837. OUTS (outf, "[--SP] = (P5:");
  838. OUTS (outf, imm5d (pr));
  839. OUTS (outf, ")");
  840. }
  841. else if (W == 0 && d == 1 && p == 1)
  842. {
  843. OUTS (outf, "(R7:");
  844. OUTS (outf, imm5d (dr));
  845. OUTS (outf, ", P5:");
  846. OUTS (outf, imm5d (pr));
  847. OUTS (outf, ") = [SP++]");
  848. }
  849. else if (W == 0 && d == 1 && p == 0 && pr == 0)
  850. {
  851. OUTS (outf, "(R7:");
  852. OUTS (outf, imm5d (dr));
  853. OUTS (outf, ") = [SP++]");
  854. }
  855. else if (W == 0 && d == 0 && p == 1 && dr == 0)
  856. {
  857. OUTS (outf, "(P5:");
  858. OUTS (outf, imm5d (pr));
  859. OUTS (outf, ") = [SP++]");
  860. }
  861. else
  862. return 0;
  863. return 2;
  864. }
  865. static int
  866. decode_ccMV_0 (TIword iw0, disassemble_info *outf)
  867. {
  868. struct private *priv = outf->private_data;
  869. /* ccMV
  870. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  871. | 0 | 0 | 0 | 0 | 0 | 1 | 1 |.T.|.d.|.s.|.dst.......|.src.......|
  872. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  873. int s = ((iw0 >> CCmv_s_bits) & CCmv_s_mask);
  874. int d = ((iw0 >> CCmv_d_bits) & CCmv_d_mask);
  875. int T = ((iw0 >> CCmv_T_bits) & CCmv_T_mask);
  876. int src = ((iw0 >> CCmv_src_bits) & CCmv_src_mask);
  877. int dst = ((iw0 >> CCmv_dst_bits) & CCmv_dst_mask);
  878. if (priv->parallel)
  879. return 0;
  880. if (T == 1)
  881. {
  882. OUTS (outf, "IF CC ");
  883. OUTS (outf, gregs (dst, d));
  884. OUTS (outf, " = ");
  885. OUTS (outf, gregs (src, s));
  886. }
  887. else if (T == 0)
  888. {
  889. OUTS (outf, "IF !CC ");
  890. OUTS (outf, gregs (dst, d));
  891. OUTS (outf, " = ");
  892. OUTS (outf, gregs (src, s));
  893. }
  894. else
  895. return 0;
  896. return 2;
  897. }
  898. static int
  899. decode_CCflag_0 (TIword iw0, disassemble_info *outf)
  900. {
  901. struct private *priv = outf->private_data;
  902. /* CCflag
  903. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  904. | 0 | 0 | 0 | 0 | 1 |.I.|.opc.......|.G.|.y.........|.x.........|
  905. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  906. int x = ((iw0 >> CCflag_x_bits) & CCflag_x_mask);
  907. int y = ((iw0 >> CCflag_y_bits) & CCflag_y_mask);
  908. int I = ((iw0 >> CCflag_I_bits) & CCflag_I_mask);
  909. int G = ((iw0 >> CCflag_G_bits) & CCflag_G_mask);
  910. int opc = ((iw0 >> CCflag_opc_bits) & CCflag_opc_mask);
  911. if (priv->parallel)
  912. return 0;
  913. if (opc == 0 && I == 0 && G == 0)
  914. {
  915. OUTS (outf, "CC = ");
  916. OUTS (outf, dregs (x));
  917. OUTS (outf, " == ");
  918. OUTS (outf, dregs (y));
  919. }
  920. else if (opc == 1 && I == 0 && G == 0)
  921. {
  922. OUTS (outf, "CC = ");
  923. OUTS (outf, dregs (x));
  924. OUTS (outf, " < ");
  925. OUTS (outf, dregs (y));
  926. }
  927. else if (opc == 2 && I == 0 && G == 0)
  928. {
  929. OUTS (outf, "CC = ");
  930. OUTS (outf, dregs (x));
  931. OUTS (outf, " <= ");
  932. OUTS (outf, dregs (y));
  933. }
  934. else if (opc == 3 && I == 0 && G == 0)
  935. {
  936. OUTS (outf, "CC = ");
  937. OUTS (outf, dregs (x));
  938. OUTS (outf, " < ");
  939. OUTS (outf, dregs (y));
  940. OUTS (outf, " (IU)");
  941. }
  942. else if (opc == 4 && I == 0 && G == 0)
  943. {
  944. OUTS (outf, "CC = ");
  945. OUTS (outf, dregs (x));
  946. OUTS (outf, " <= ");
  947. OUTS (outf, dregs (y));
  948. OUTS (outf, " (IU)");
  949. }
  950. else if (opc == 0 && I == 1 && G == 0)
  951. {
  952. OUTS (outf, "CC = ");
  953. OUTS (outf, dregs (x));
  954. OUTS (outf, " == ");
  955. OUTS (outf, imm3 (y));
  956. }
  957. else if (opc == 1 && I == 1 && G == 0)
  958. {
  959. OUTS (outf, "CC = ");
  960. OUTS (outf, dregs (x));
  961. OUTS (outf, " < ");
  962. OUTS (outf, imm3 (y));
  963. }
  964. else if (opc == 2 && I == 1 && G == 0)
  965. {
  966. OUTS (outf, "CC = ");
  967. OUTS (outf, dregs (x));
  968. OUTS (outf, " <= ");
  969. OUTS (outf, imm3 (y));
  970. }
  971. else if (opc == 3 && I == 1 && G == 0)
  972. {
  973. OUTS (outf, "CC = ");
  974. OUTS (outf, dregs (x));
  975. OUTS (outf, " < ");
  976. OUTS (outf, uimm3 (y));
  977. OUTS (outf, " (IU)");
  978. }
  979. else if (opc == 4 && I == 1 && G == 0)
  980. {
  981. OUTS (outf, "CC = ");
  982. OUTS (outf, dregs (x));
  983. OUTS (outf, " <= ");
  984. OUTS (outf, uimm3 (y));
  985. OUTS (outf, " (IU)");
  986. }
  987. else if (opc == 0 && I == 0 && G == 1)
  988. {
  989. OUTS (outf, "CC = ");
  990. OUTS (outf, pregs (x));
  991. OUTS (outf, " == ");
  992. OUTS (outf, pregs (y));
  993. }
  994. else if (opc == 1 && I == 0 && G == 1)
  995. {
  996. OUTS (outf, "CC = ");
  997. OUTS (outf, pregs (x));
  998. OUTS (outf, " < ");
  999. OUTS (outf, pregs (y));
  1000. }
  1001. else if (opc == 2 && I == 0 && G == 1)
  1002. {
  1003. OUTS (outf, "CC = ");
  1004. OUTS (outf, pregs (x));
  1005. OUTS (outf, " <= ");
  1006. OUTS (outf, pregs (y));
  1007. }
  1008. else if (opc == 3 && I == 0 && G == 1)
  1009. {
  1010. OUTS (outf, "CC = ");
  1011. OUTS (outf, pregs (x));
  1012. OUTS (outf, " < ");
  1013. OUTS (outf, pregs (y));
  1014. OUTS (outf, " (IU)");
  1015. }
  1016. else if (opc == 4 && I == 0 && G == 1)
  1017. {
  1018. OUTS (outf, "CC = ");
  1019. OUTS (outf, pregs (x));
  1020. OUTS (outf, " <= ");
  1021. OUTS (outf, pregs (y));
  1022. OUTS (outf, " (IU)");
  1023. }
  1024. else if (opc == 0 && I == 1 && G == 1)
  1025. {
  1026. OUTS (outf, "CC = ");
  1027. OUTS (outf, pregs (x));
  1028. OUTS (outf, " == ");
  1029. OUTS (outf, imm3 (y));
  1030. }
  1031. else if (opc == 1 && I == 1 && G == 1)
  1032. {
  1033. OUTS (outf, "CC = ");
  1034. OUTS (outf, pregs (x));
  1035. OUTS (outf, " < ");
  1036. OUTS (outf, imm3 (y));
  1037. }
  1038. else if (opc == 2 && I == 1 && G == 1)
  1039. {
  1040. OUTS (outf, "CC = ");
  1041. OUTS (outf, pregs (x));
  1042. OUTS (outf, " <= ");
  1043. OUTS (outf, imm3 (y));
  1044. }
  1045. else if (opc == 3 && I == 1 && G == 1)
  1046. {
  1047. OUTS (outf, "CC = ");
  1048. OUTS (outf, pregs (x));
  1049. OUTS (outf, " < ");
  1050. OUTS (outf, uimm3 (y));
  1051. OUTS (outf, " (IU)");
  1052. }
  1053. else if (opc == 4 && I == 1 && G == 1)
  1054. {
  1055. OUTS (outf, "CC = ");
  1056. OUTS (outf, pregs (x));
  1057. OUTS (outf, " <= ");
  1058. OUTS (outf, uimm3 (y));
  1059. OUTS (outf, " (IU)");
  1060. }
  1061. else if (opc == 5 && I == 0 && G == 0 && x == 0 && y == 0)
  1062. OUTS (outf, "CC = A0 == A1");
  1063. else if (opc == 6 && I == 0 && G == 0 && x == 0 && y == 0)
  1064. OUTS (outf, "CC = A0 < A1");
  1065. else if (opc == 7 && I == 0 && G == 0 && x == 0 && y == 0)
  1066. OUTS (outf, "CC = A0 <= A1");
  1067. else
  1068. return 0;
  1069. return 2;
  1070. }
  1071. static int
  1072. decode_CC2dreg_0 (TIword iw0, disassemble_info *outf)
  1073. {
  1074. struct private *priv = outf->private_data;
  1075. /* CC2dreg
  1076. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  1077. | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |.op....|.reg.......|
  1078. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  1079. int op = ((iw0 >> CC2dreg_op_bits) & CC2dreg_op_mask);
  1080. int reg = ((iw0 >> CC2dreg_reg_bits) & CC2dreg_reg_mask);
  1081. if (priv->parallel)
  1082. return 0;
  1083. if (op == 0)
  1084. {
  1085. OUTS (outf, dregs (reg));
  1086. OUTS (outf, " = CC");
  1087. }
  1088. else if (op == 1)
  1089. {
  1090. OUTS (outf, "CC = ");
  1091. OUTS (outf, dregs (reg));
  1092. }
  1093. else if (op == 3 && reg == 0)
  1094. OUTS (outf, "CC = !CC");
  1095. else
  1096. return 0;
  1097. return 2;
  1098. }
  1099. static int
  1100. decode_CC2stat_0 (TIword iw0, disassemble_info *outf)
  1101. {
  1102. struct private *priv = outf->private_data;
  1103. /* CC2stat
  1104. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  1105. | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |.D.|.op....|.cbit..............|
  1106. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  1107. int D = ((iw0 >> CC2stat_D_bits) & CC2stat_D_mask);
  1108. int op = ((iw0 >> CC2stat_op_bits) & CC2stat_op_mask);
  1109. int cbit = ((iw0 >> CC2stat_cbit_bits) & CC2stat_cbit_mask);
  1110. const char *bitname = statbits (cbit);
  1111. const char * const op_names[] = { "", "|", "&", "^" } ;
  1112. if (priv->parallel)
  1113. return 0;
  1114. if (decode_statbits[cbit] == REG_LASTREG)
  1115. {
  1116. /* All ASTAT bits except CC may be operated on in hardware, but may
  1117. not have a dedicated insn, so still decode "valid" insns. */
  1118. static char bitnames[64];
  1119. if (cbit != 5)
  1120. sprintf (bitnames, "ASTAT[%i /* unused bit */]", cbit);
  1121. else
  1122. return 0;
  1123. bitname = bitnames;
  1124. }
  1125. if (D == 0)
  1126. OUT (outf, "CC %s= %s", op_names[op], bitname);
  1127. else
  1128. OUT (outf, "%s %s= CC", bitname, op_names[op]);
  1129. return 2;
  1130. }
  1131. static int
  1132. decode_BRCC_0 (TIword iw0, bfd_vma pc, disassemble_info *outf)
  1133. {
  1134. struct private *priv = outf->private_data;
  1135. /* BRCC
  1136. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  1137. | 0 | 0 | 0 | 1 |.T.|.B.|.offset................................|
  1138. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  1139. int B = ((iw0 >> BRCC_B_bits) & BRCC_B_mask);
  1140. int T = ((iw0 >> BRCC_T_bits) & BRCC_T_mask);
  1141. int offset = ((iw0 >> BRCC_offset_bits) & BRCC_offset_mask);
  1142. if (priv->parallel)
  1143. return 0;
  1144. if (T == 1 && B == 1)
  1145. {
  1146. OUTS (outf, "IF CC JUMP 0x");
  1147. OUTS (outf, pcrel10 (offset));
  1148. OUTS (outf, " (BP)");
  1149. }
  1150. else if (T == 0 && B == 1)
  1151. {
  1152. OUTS (outf, "IF !CC JUMP 0x");
  1153. OUTS (outf, pcrel10 (offset));
  1154. OUTS (outf, " (BP)");
  1155. }
  1156. else if (T == 1)
  1157. {
  1158. OUTS (outf, "IF CC JUMP 0x");
  1159. OUTS (outf, pcrel10 (offset));
  1160. }
  1161. else if (T == 0)
  1162. {
  1163. OUTS (outf, "IF !CC JUMP 0x");
  1164. OUTS (outf, pcrel10 (offset));
  1165. }
  1166. else
  1167. return 0;
  1168. return 2;
  1169. }
  1170. static int
  1171. decode_UJUMP_0 (TIword iw0, bfd_vma pc, disassemble_info *outf)
  1172. {
  1173. struct private *priv = outf->private_data;
  1174. /* UJUMP
  1175. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  1176. | 0 | 0 | 1 | 0 |.offset........................................|
  1177. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  1178. int offset = ((iw0 >> UJump_offset_bits) & UJump_offset_mask);
  1179. if (priv->parallel)
  1180. return 0;
  1181. OUTS (outf, "JUMP.S 0x");
  1182. OUTS (outf, pcrel12 (offset));
  1183. return 2;
  1184. }
  1185. static int
  1186. decode_REGMV_0 (TIword iw0, disassemble_info *outf)
  1187. {
  1188. /* REGMV
  1189. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  1190. | 0 | 0 | 1 | 1 |.gd........|.gs........|.dst.......|.src.......|
  1191. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  1192. int gs = ((iw0 >> RegMv_gs_bits) & RegMv_gs_mask);
  1193. int gd = ((iw0 >> RegMv_gd_bits) & RegMv_gd_mask);
  1194. int src = ((iw0 >> RegMv_src_bits) & RegMv_src_mask);
  1195. int dst = ((iw0 >> RegMv_dst_bits) & RegMv_dst_mask);
  1196. /* Reserved slots cannot be a src/dst. */
  1197. if (IS_RESERVEDREG (gs, src) || IS_RESERVEDREG (gd, dst))
  1198. goto invalid_move;
  1199. /* Standard register moves */
  1200. if ((gs < 2) || /* Dregs/Pregs as source */
  1201. (gd < 2) || /* Dregs/Pregs as dest */
  1202. (gs == 4 && src < 4) || /* Accumulators as source */
  1203. (gd == 4 && dst < 4 && (gs < 4)) || /* Accumulators as dest */
  1204. (gs == 7 && src == 7 && !(gd == 4 && dst < 4)) || /* EMUDAT as src */
  1205. (gd == 7 && dst == 7)) /* EMUDAT as dest */
  1206. goto valid_move;
  1207. /* dareg = dareg (IMBL) */
  1208. if (gs < 4 && gd < 4)
  1209. goto valid_move;
  1210. /* USP can be src to sysregs, but not dagregs. */
  1211. if ((gs == 7 && src == 0) && (gd >= 4))
  1212. goto valid_move;
  1213. /* USP can move between genregs (only check Accumulators). */
  1214. if (((gs == 7 && src == 0) && (gd == 4 && dst < 4)) ||
  1215. ((gd == 7 && dst == 0) && (gs == 4 && src < 4)))
  1216. goto valid_move;
  1217. /* Still here ? Invalid reg pair. */
  1218. invalid_move:
  1219. return 0;
  1220. valid_move:
  1221. OUTS (outf, allregs (dst, gd));
  1222. OUTS (outf, " = ");
  1223. OUTS (outf, allregs (src, gs));
  1224. return 2;
  1225. }
  1226. static int
  1227. decode_ALU2op_0 (TIword iw0, disassemble_info *outf)
  1228. {
  1229. /* ALU2op
  1230. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  1231. | 0 | 1 | 0 | 0 | 0 | 0 |.opc...........|.src.......|.dst.......|
  1232. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  1233. int src = ((iw0 >> ALU2op_src_bits) & ALU2op_src_mask);
  1234. int opc = ((iw0 >> ALU2op_opc_bits) & ALU2op_opc_mask);
  1235. int dst = ((iw0 >> ALU2op_dst_bits) & ALU2op_dst_mask);
  1236. if (opc == 0)
  1237. {
  1238. OUTS (outf, dregs (dst));
  1239. OUTS (outf, " >>>= ");
  1240. OUTS (outf, dregs (src));
  1241. }
  1242. else if (opc == 1)
  1243. {
  1244. OUTS (outf, dregs (dst));
  1245. OUTS (outf, " >>= ");
  1246. OUTS (outf, dregs (src));
  1247. }
  1248. else if (opc == 2)
  1249. {
  1250. OUTS (outf, dregs (dst));
  1251. OUTS (outf, " <<= ");
  1252. OUTS (outf, dregs (src));
  1253. }
  1254. else if (opc == 3)
  1255. {
  1256. OUTS (outf, dregs (dst));
  1257. OUTS (outf, " *= ");
  1258. OUTS (outf, dregs (src));
  1259. }
  1260. else if (opc == 4)
  1261. {
  1262. OUTS (outf, dregs (dst));
  1263. OUTS (outf, " = (");
  1264. OUTS (outf, dregs (dst));
  1265. OUTS (outf, " + ");
  1266. OUTS (outf, dregs (src));
  1267. OUTS (outf, ") << 0x1");
  1268. }
  1269. else if (opc == 5)
  1270. {
  1271. OUTS (outf, dregs (dst));
  1272. OUTS (outf, " = (");
  1273. OUTS (outf, dregs (dst));
  1274. OUTS (outf, " + ");
  1275. OUTS (outf, dregs (src));
  1276. OUTS (outf, ") << 0x2");
  1277. }
  1278. else if (opc == 8)
  1279. {
  1280. OUTS (outf, "DIVQ (");
  1281. OUTS (outf, dregs (dst));
  1282. OUTS (outf, ", ");
  1283. OUTS (outf, dregs (src));
  1284. OUTS (outf, ")");
  1285. }
  1286. else if (opc == 9)
  1287. {
  1288. OUTS (outf, "DIVS (");
  1289. OUTS (outf, dregs (dst));
  1290. OUTS (outf, ", ");
  1291. OUTS (outf, dregs (src));
  1292. OUTS (outf, ")");
  1293. }
  1294. else if (opc == 10)
  1295. {
  1296. OUTS (outf, dregs (dst));
  1297. OUTS (outf, " = ");
  1298. OUTS (outf, dregs_lo (src));
  1299. OUTS (outf, " (X)");
  1300. }
  1301. else if (opc == 11)
  1302. {
  1303. OUTS (outf, dregs (dst));
  1304. OUTS (outf, " = ");
  1305. OUTS (outf, dregs_lo (src));
  1306. OUTS (outf, " (Z)");
  1307. }
  1308. else if (opc == 12)
  1309. {
  1310. OUTS (outf, dregs (dst));
  1311. OUTS (outf, " = ");
  1312. OUTS (outf, dregs_byte (src));
  1313. OUTS (outf, " (X)");
  1314. }
  1315. else if (opc == 13)
  1316. {
  1317. OUTS (outf, dregs (dst));
  1318. OUTS (outf, " = ");
  1319. OUTS (outf, dregs_byte (src));
  1320. OUTS (outf, " (Z)");
  1321. }
  1322. else if (opc == 14)
  1323. {
  1324. OUTS (outf, dregs (dst));
  1325. OUTS (outf, " = -");
  1326. OUTS (outf, dregs (src));
  1327. }
  1328. else if (opc == 15)
  1329. {
  1330. OUTS (outf, dregs (dst));
  1331. OUTS (outf, " =~ ");
  1332. OUTS (outf, dregs (src));
  1333. }
  1334. else
  1335. return 0;
  1336. return 2;
  1337. }
  1338. static int
  1339. decode_PTR2op_0 (TIword iw0, disassemble_info *outf)
  1340. {
  1341. /* PTR2op
  1342. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  1343. | 0 | 1 | 0 | 0 | 0 | 1 | 0 |.opc.......|.src.......|.dst.......|
  1344. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  1345. int src = ((iw0 >> PTR2op_src_bits) & PTR2op_dst_mask);
  1346. int opc = ((iw0 >> PTR2op_opc_bits) & PTR2op_opc_mask);
  1347. int dst = ((iw0 >> PTR2op_dst_bits) & PTR2op_dst_mask);
  1348. if (opc == 0)
  1349. {
  1350. OUTS (outf, pregs (dst));
  1351. OUTS (outf, " -= ");
  1352. OUTS (outf, pregs (src));
  1353. }
  1354. else if (opc == 1)
  1355. {
  1356. OUTS (outf, pregs (dst));
  1357. OUTS (outf, " = ");
  1358. OUTS (outf, pregs (src));
  1359. OUTS (outf, " << 0x2");
  1360. }
  1361. else if (opc == 3)
  1362. {
  1363. OUTS (outf, pregs (dst));
  1364. OUTS (outf, " = ");
  1365. OUTS (outf, pregs (src));
  1366. OUTS (outf, " >> 0x2");
  1367. }
  1368. else if (opc == 4)
  1369. {
  1370. OUTS (outf, pregs (dst));
  1371. OUTS (outf, " = ");
  1372. OUTS (outf, pregs (src));
  1373. OUTS (outf, " >> 0x1");
  1374. }
  1375. else if (opc == 5)
  1376. {
  1377. OUTS (outf, pregs (dst));
  1378. OUTS (outf, " += ");
  1379. OUTS (outf, pregs (src));
  1380. OUTS (outf, " (BREV)");
  1381. }
  1382. else if (opc == 6)
  1383. {
  1384. OUTS (outf, pregs (dst));
  1385. OUTS (outf, " = (");
  1386. OUTS (outf, pregs (dst));
  1387. OUTS (outf, " + ");
  1388. OUTS (outf, pregs (src));
  1389. OUTS (outf, ") << 0x1");
  1390. }
  1391. else if (opc == 7)
  1392. {
  1393. OUTS (outf, pregs (dst));
  1394. OUTS (outf, " = (");
  1395. OUTS (outf, pregs (dst));
  1396. OUTS (outf, " + ");
  1397. OUTS (outf, pregs (src));
  1398. OUTS (outf, ") << 0x2");
  1399. }
  1400. else
  1401. return 0;
  1402. return 2;
  1403. }
  1404. static int
  1405. decode_LOGI2op_0 (TIword iw0, disassemble_info *outf)
  1406. {
  1407. struct private *priv = outf->private_data;
  1408. /* LOGI2op
  1409. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  1410. | 0 | 1 | 0 | 0 | 1 |.opc.......|.src...............|.dst.......|
  1411. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  1412. int src = ((iw0 >> LOGI2op_src_bits) & LOGI2op_src_mask);
  1413. int opc = ((iw0 >> LOGI2op_opc_bits) & LOGI2op_opc_mask);
  1414. int dst = ((iw0 >> LOGI2op_dst_bits) & LOGI2op_dst_mask);
  1415. if (priv->parallel)
  1416. return 0;
  1417. if (opc == 0)
  1418. {
  1419. OUTS (outf, "CC = !BITTST (");
  1420. OUTS (outf, dregs (dst));
  1421. OUTS (outf, ", ");
  1422. OUTS (outf, uimm5 (src));
  1423. OUTS (outf, ");\t\t/* bit");
  1424. OUTS (outf, imm7d (src));
  1425. OUTS (outf, " */");
  1426. priv->comment = true;
  1427. }
  1428. else if (opc == 1)
  1429. {
  1430. OUTS (outf, "CC = BITTST (");
  1431. OUTS (outf, dregs (dst));
  1432. OUTS (outf, ", ");
  1433. OUTS (outf, uimm5 (src));
  1434. OUTS (outf, ");\t\t/* bit");
  1435. OUTS (outf, imm7d (src));
  1436. OUTS (outf, " */");
  1437. priv->comment = true;
  1438. }
  1439. else if (opc == 2)
  1440. {
  1441. OUTS (outf, "BITSET (");
  1442. OUTS (outf, dregs (dst));
  1443. OUTS (outf, ", ");
  1444. OUTS (outf, uimm5 (src));
  1445. OUTS (outf, ");\t\t/* bit");
  1446. OUTS (outf, imm7d (src));
  1447. OUTS (outf, " */");
  1448. priv->comment = true;
  1449. }
  1450. else if (opc == 3)
  1451. {
  1452. OUTS (outf, "BITTGL (");
  1453. OUTS (outf, dregs (dst));
  1454. OUTS (outf, ", ");
  1455. OUTS (outf, uimm5 (src));
  1456. OUTS (outf, ");\t\t/* bit");
  1457. OUTS (outf, imm7d (src));
  1458. OUTS (outf, " */");
  1459. priv->comment = true;
  1460. }
  1461. else if (opc == 4)
  1462. {
  1463. OUTS (outf, "BITCLR (");
  1464. OUTS (outf, dregs (dst));
  1465. OUTS (outf, ", ");
  1466. OUTS (outf, uimm5 (src));
  1467. OUTS (outf, ");\t\t/* bit");
  1468. OUTS (outf, imm7d (src));
  1469. OUTS (outf, " */");
  1470. priv->comment = true;
  1471. }
  1472. else if (opc == 5)
  1473. {
  1474. OUTS (outf, dregs (dst));
  1475. OUTS (outf, " >>>= ");
  1476. OUTS (outf, uimm5 (src));
  1477. }
  1478. else if (opc == 6)
  1479. {
  1480. OUTS (outf, dregs (dst));
  1481. OUTS (outf, " >>= ");
  1482. OUTS (outf, uimm5 (src));
  1483. }
  1484. else if (opc == 7)
  1485. {
  1486. OUTS (outf, dregs (dst));
  1487. OUTS (outf, " <<= ");
  1488. OUTS (outf, uimm5 (src));
  1489. }
  1490. else
  1491. return 0;
  1492. return 2;
  1493. }
  1494. static int
  1495. decode_COMP3op_0 (TIword iw0, disassemble_info *outf)
  1496. {
  1497. /* COMP3op
  1498. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  1499. | 0 | 1 | 0 | 1 |.opc.......|.dst.......|.src1......|.src0......|
  1500. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  1501. int opc = ((iw0 >> COMP3op_opc_bits) & COMP3op_opc_mask);
  1502. int dst = ((iw0 >> COMP3op_dst_bits) & COMP3op_dst_mask);
  1503. int src0 = ((iw0 >> COMP3op_src0_bits) & COMP3op_src0_mask);
  1504. int src1 = ((iw0 >> COMP3op_src1_bits) & COMP3op_src1_mask);
  1505. if (opc == 5 && src1 == src0)
  1506. {
  1507. OUTS (outf, pregs (dst));
  1508. OUTS (outf, " = ");
  1509. OUTS (outf, pregs (src0));
  1510. OUTS (outf, " << 0x1");
  1511. }
  1512. else if (opc == 1)
  1513. {
  1514. OUTS (outf, dregs (dst));
  1515. OUTS (outf, " = ");
  1516. OUTS (outf, dregs (src0));
  1517. OUTS (outf, " - ");
  1518. OUTS (outf, dregs (src1));
  1519. }
  1520. else if (opc == 2)
  1521. {
  1522. OUTS (outf, dregs (dst));
  1523. OUTS (outf, " = ");
  1524. OUTS (outf, dregs (src0));
  1525. OUTS (outf, " & ");
  1526. OUTS (outf, dregs (src1));
  1527. }
  1528. else if (opc == 3)
  1529. {
  1530. OUTS (outf, dregs (dst));
  1531. OUTS (outf, " = ");
  1532. OUTS (outf, dregs (src0));
  1533. OUTS (outf, " | ");
  1534. OUTS (outf, dregs (src1));
  1535. }
  1536. else if (opc == 4)
  1537. {
  1538. OUTS (outf, dregs (dst));
  1539. OUTS (outf, " = ");
  1540. OUTS (outf, dregs (src0));
  1541. OUTS (outf, " ^ ");
  1542. OUTS (outf, dregs (src1));
  1543. }
  1544. else if (opc == 5)
  1545. {
  1546. OUTS (outf, pregs (dst));
  1547. OUTS (outf, " = ");
  1548. OUTS (outf, pregs (src0));
  1549. OUTS (outf, " + ");
  1550. OUTS (outf, pregs (src1));
  1551. }
  1552. else if (opc == 6)
  1553. {
  1554. OUTS (outf, pregs (dst));
  1555. OUTS (outf, " = ");
  1556. OUTS (outf, pregs (src0));
  1557. OUTS (outf, " + (");
  1558. OUTS (outf, pregs (src1));
  1559. OUTS (outf, " << 0x1)");
  1560. }
  1561. else if (opc == 7)
  1562. {
  1563. OUTS (outf, pregs (dst));
  1564. OUTS (outf, " = ");
  1565. OUTS (outf, pregs (src0));
  1566. OUTS (outf, " + (");
  1567. OUTS (outf, pregs (src1));
  1568. OUTS (outf, " << 0x2)");
  1569. }
  1570. else if (opc == 0)
  1571. {
  1572. OUTS (outf, dregs (dst));
  1573. OUTS (outf, " = ");
  1574. OUTS (outf, dregs (src0));
  1575. OUTS (outf, " + ");
  1576. OUTS (outf, dregs (src1));
  1577. }
  1578. else
  1579. return 0;
  1580. return 2;
  1581. }
  1582. static int
  1583. decode_COMPI2opD_0 (TIword iw0, disassemble_info *outf)
  1584. {
  1585. struct private *priv = outf->private_data;
  1586. /* COMPI2opD
  1587. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  1588. | 0 | 1 | 1 | 0 | 0 |.op|..src......................|.dst.......|
  1589. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  1590. int op = ((iw0 >> COMPI2opD_op_bits) & COMPI2opD_op_mask);
  1591. int dst = ((iw0 >> COMPI2opD_dst_bits) & COMPI2opD_dst_mask);
  1592. int src = ((iw0 >> COMPI2opD_src_bits) & COMPI2opD_src_mask);
  1593. bu32 *pval = get_allreg (0, dst);
  1594. if (priv->parallel)
  1595. return 0;
  1596. /* Since we don't have 32-bit immediate loads, we allow the disassembler
  1597. to combine them, so it prints out the right values.
  1598. Here we keep track of the registers. */
  1599. if (op == 0)
  1600. {
  1601. *pval = imm7_val (src);
  1602. if (src & 0x40)
  1603. *pval |= 0xFFFFFF80;
  1604. else
  1605. *pval &= 0x7F;
  1606. }
  1607. if (op == 0)
  1608. {
  1609. OUTS (outf, dregs (dst));
  1610. OUTS (outf, " = ");
  1611. OUTS (outf, imm7 (src));
  1612. OUTS (outf, " (X);\t\t/*\t\t");
  1613. OUTS (outf, dregs (dst));
  1614. OUTS (outf, "=");
  1615. OUTS (outf, uimm32 (*pval));
  1616. OUTS (outf, "(");
  1617. OUTS (outf, imm32 (*pval));
  1618. OUTS (outf, ") */");
  1619. priv->comment = true;
  1620. }
  1621. else if (op == 1)
  1622. {
  1623. OUTS (outf, dregs (dst));
  1624. OUTS (outf, " += ");
  1625. OUTS (outf, imm7 (src));
  1626. OUTS (outf, ";\t\t/* (");
  1627. OUTS (outf, imm7d (src));
  1628. OUTS (outf, ") */");
  1629. priv->comment = true;
  1630. }
  1631. else
  1632. return 0;
  1633. return 2;
  1634. }
  1635. static int
  1636. decode_COMPI2opP_0 (TIword iw0, disassemble_info *outf)
  1637. {
  1638. struct private *priv = outf->private_data;
  1639. /* COMPI2opP
  1640. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  1641. | 0 | 1 | 1 | 0 | 1 |.op|.src.......................|.dst.......|
  1642. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  1643. int op = ((iw0 >> COMPI2opP_op_bits) & COMPI2opP_op_mask);
  1644. int src = ((iw0 >> COMPI2opP_src_bits) & COMPI2opP_src_mask);
  1645. int dst = ((iw0 >> COMPI2opP_dst_bits) & COMPI2opP_dst_mask);
  1646. bu32 *pval = get_allreg (1, dst);
  1647. if (priv->parallel)
  1648. return 0;
  1649. if (op == 0)
  1650. {
  1651. *pval = imm7_val (src);
  1652. if (src & 0x40)
  1653. *pval |= 0xFFFFFF80;
  1654. else
  1655. *pval &= 0x7F;
  1656. }
  1657. if (op == 0)
  1658. {
  1659. OUTS (outf, pregs (dst));
  1660. OUTS (outf, " = ");
  1661. OUTS (outf, imm7 (src));
  1662. OUTS (outf, " (X);\t\t/*\t\t");
  1663. OUTS (outf, pregs (dst));
  1664. OUTS (outf, "=");
  1665. OUTS (outf, uimm32 (*pval));
  1666. OUTS (outf, "(");
  1667. OUTS (outf, imm32 (*pval));
  1668. OUTS (outf, ") */");
  1669. priv->comment = true;
  1670. }
  1671. else if (op == 1)
  1672. {
  1673. OUTS (outf, pregs (dst));
  1674. OUTS (outf, " += ");
  1675. OUTS (outf, imm7 (src));
  1676. OUTS (outf, ";\t\t/* (");
  1677. OUTS (outf, imm7d (src));
  1678. OUTS (outf, ") */");
  1679. priv->comment = true;
  1680. }
  1681. else
  1682. return 0;
  1683. return 2;
  1684. }
  1685. static int
  1686. decode_LDSTpmod_0 (TIword iw0, disassemble_info *outf)
  1687. {
  1688. /* LDSTpmod
  1689. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  1690. | 1 | 0 | 0 | 0 |.W.|.aop...|.reg.......|.idx.......|.ptr.......|
  1691. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  1692. int W = ((iw0 >> LDSTpmod_W_bits) & LDSTpmod_W_mask);
  1693. int aop = ((iw0 >> LDSTpmod_aop_bits) & LDSTpmod_aop_mask);
  1694. int idx = ((iw0 >> LDSTpmod_idx_bits) & LDSTpmod_idx_mask);
  1695. int ptr = ((iw0 >> LDSTpmod_ptr_bits) & LDSTpmod_ptr_mask);
  1696. int reg = ((iw0 >> LDSTpmod_reg_bits) & LDSTpmod_reg_mask);
  1697. if (aop == 1 && W == 0 && idx == ptr)
  1698. {
  1699. OUTS (outf, dregs_lo (reg));
  1700. OUTS (outf, " = W[");
  1701. OUTS (outf, pregs (ptr));
  1702. OUTS (outf, "]");
  1703. }
  1704. else if (aop == 2 && W == 0 && idx == ptr)
  1705. {
  1706. OUTS (outf, dregs_hi (reg));
  1707. OUTS (outf, " = W[");
  1708. OUTS (outf, pregs (ptr));
  1709. OUTS (outf, "]");
  1710. }
  1711. else if (aop == 1 && W == 1 && idx == ptr)
  1712. {
  1713. OUTS (outf, "W[");
  1714. OUTS (outf, pregs (ptr));
  1715. OUTS (outf, "] = ");
  1716. OUTS (outf, dregs_lo (reg));
  1717. }
  1718. else if (aop == 2 && W == 1 && idx == ptr)
  1719. {
  1720. OUTS (outf, "W[");
  1721. OUTS (outf, pregs (ptr));
  1722. OUTS (outf, "] = ");
  1723. OUTS (outf, dregs_hi (reg));
  1724. }
  1725. else if (aop == 0 && W == 0)
  1726. {
  1727. OUTS (outf, dregs (reg));
  1728. OUTS (outf, " = [");
  1729. OUTS (outf, pregs (ptr));
  1730. OUTS (outf, " ++ ");
  1731. OUTS (outf, pregs (idx));
  1732. OUTS (outf, "]");
  1733. }
  1734. else if (aop == 1 && W == 0)
  1735. {
  1736. OUTS (outf, dregs_lo (reg));
  1737. OUTS (outf, " = W[");
  1738. OUTS (outf, pregs (ptr));
  1739. OUTS (outf, " ++ ");
  1740. OUTS (outf, pregs (idx));
  1741. OUTS (outf, "]");
  1742. }
  1743. else if (aop == 2 && W == 0)
  1744. {
  1745. OUTS (outf, dregs_hi (reg));
  1746. OUTS (outf, " = W[");
  1747. OUTS (outf, pregs (ptr));
  1748. OUTS (outf, " ++ ");
  1749. OUTS (outf, pregs (idx));
  1750. OUTS (outf, "]");
  1751. }
  1752. else if (aop == 3 && W == 0)
  1753. {
  1754. OUTS (outf, dregs (reg));
  1755. OUTS (outf, " = W[");
  1756. OUTS (outf, pregs (ptr));
  1757. OUTS (outf, " ++ ");
  1758. OUTS (outf, pregs (idx));
  1759. OUTS (outf, "] (Z)");
  1760. }
  1761. else if (aop == 3 && W == 1)
  1762. {
  1763. OUTS (outf, dregs (reg));
  1764. OUTS (outf, " = W[");
  1765. OUTS (outf, pregs (ptr));
  1766. OUTS (outf, " ++ ");
  1767. OUTS (outf, pregs (idx));
  1768. OUTS (outf, "] (X)");
  1769. }
  1770. else if (aop == 0 && W == 1)
  1771. {
  1772. OUTS (outf, "[");
  1773. OUTS (outf, pregs (ptr));
  1774. OUTS (outf, " ++ ");
  1775. OUTS (outf, pregs (idx));
  1776. OUTS (outf, "] = ");
  1777. OUTS (outf, dregs (reg));
  1778. }
  1779. else if (aop == 1 && W == 1)
  1780. {
  1781. OUTS (outf, "W[");
  1782. OUTS (outf, pregs (ptr));
  1783. OUTS (outf, " ++ ");
  1784. OUTS (outf, pregs (idx));
  1785. OUTS (outf, "] = ");
  1786. OUTS (outf, dregs_lo (reg));
  1787. }
  1788. else if (aop == 2 && W == 1)
  1789. {
  1790. OUTS (outf, "W[");
  1791. OUTS (outf, pregs (ptr));
  1792. OUTS (outf, " ++ ");
  1793. OUTS (outf, pregs (idx));
  1794. OUTS (outf, "] = ");
  1795. OUTS (outf, dregs_hi (reg));
  1796. }
  1797. else
  1798. return 0;
  1799. return 2;
  1800. }
  1801. static int
  1802. decode_dagMODim_0 (TIword iw0, disassemble_info *outf)
  1803. {
  1804. /* dagMODim
  1805. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  1806. | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 0 |.br| 1 | 1 |.op|.m.....|.i.....|
  1807. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  1808. int i = ((iw0 >> DagMODim_i_bits) & DagMODim_i_mask);
  1809. int m = ((iw0 >> DagMODim_m_bits) & DagMODim_m_mask);
  1810. int br = ((iw0 >> DagMODim_br_bits) & DagMODim_br_mask);
  1811. int op = ((iw0 >> DagMODim_op_bits) & DagMODim_op_mask);
  1812. if (op == 0 && br == 1)
  1813. {
  1814. OUTS (outf, iregs (i));
  1815. OUTS (outf, " += ");
  1816. OUTS (outf, mregs (m));
  1817. OUTS (outf, " (BREV)");
  1818. }
  1819. else if (op == 0)
  1820. {
  1821. OUTS (outf, iregs (i));
  1822. OUTS (outf, " += ");
  1823. OUTS (outf, mregs (m));
  1824. }
  1825. else if (op == 1 && br == 0)
  1826. {
  1827. OUTS (outf, iregs (i));
  1828. OUTS (outf, " -= ");
  1829. OUTS (outf, mregs (m));
  1830. }
  1831. else
  1832. return 0;
  1833. return 2;
  1834. }
  1835. static int
  1836. decode_dagMODik_0 (TIword iw0, disassemble_info *outf)
  1837. {
  1838. struct private *priv = outf->private_data;
  1839. /* dagMODik
  1840. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  1841. | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 0 |.op....|.i.....|
  1842. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  1843. int i = ((iw0 >> DagMODik_i_bits) & DagMODik_i_mask);
  1844. int op = ((iw0 >> DagMODik_op_bits) & DagMODik_op_mask);
  1845. if (op == 0)
  1846. {
  1847. OUTS (outf, iregs (i));
  1848. OUTS (outf, " += 0x2");
  1849. }
  1850. else if (op == 1)
  1851. {
  1852. OUTS (outf, iregs (i));
  1853. OUTS (outf, " -= 0x2");
  1854. }
  1855. else if (op == 2)
  1856. {
  1857. OUTS (outf, iregs (i));
  1858. OUTS (outf, " += 0x4");
  1859. }
  1860. else if (op == 3)
  1861. {
  1862. OUTS (outf, iregs (i));
  1863. OUTS (outf, " -= 0x4");
  1864. }
  1865. else
  1866. return 0;
  1867. if (!priv->parallel)
  1868. {
  1869. OUTS (outf, ";\t\t/* ( ");
  1870. if (op == 0 || op == 1)
  1871. OUTS (outf, "2");
  1872. else if (op == 2 || op == 3)
  1873. OUTS (outf, "4");
  1874. OUTS (outf, ") */");
  1875. priv->comment = true;
  1876. }
  1877. return 2;
  1878. }
  1879. static int
  1880. decode_dspLDST_0 (TIword iw0, disassemble_info *outf)
  1881. {
  1882. /* dspLDST
  1883. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  1884. | 1 | 0 | 0 | 1 | 1 | 1 |.W.|.aop...|.m.....|.i.....|.reg.......|
  1885. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  1886. int i = ((iw0 >> DspLDST_i_bits) & DspLDST_i_mask);
  1887. int m = ((iw0 >> DspLDST_m_bits) & DspLDST_m_mask);
  1888. int W = ((iw0 >> DspLDST_W_bits) & DspLDST_W_mask);
  1889. int aop = ((iw0 >> DspLDST_aop_bits) & DspLDST_aop_mask);
  1890. int reg = ((iw0 >> DspLDST_reg_bits) & DspLDST_reg_mask);
  1891. if (aop == 0 && W == 0 && m == 0)
  1892. {
  1893. OUTS (outf, dregs (reg));
  1894. OUTS (outf, " = [");
  1895. OUTS (outf, iregs (i));
  1896. OUTS (outf, "++]");
  1897. }
  1898. else if (aop == 0 && W == 0 && m == 1)
  1899. {
  1900. OUTS (outf, dregs_lo (reg));
  1901. OUTS (outf, " = W[");
  1902. OUTS (outf, iregs (i));
  1903. OUTS (outf, "++]");
  1904. }
  1905. else if (aop == 0 && W == 0 && m == 2)
  1906. {
  1907. OUTS (outf, dregs_hi (reg));
  1908. OUTS (outf, " = W[");
  1909. OUTS (outf, iregs (i));
  1910. OUTS (outf, "++]");
  1911. }
  1912. else if (aop == 1 && W == 0 && m == 0)
  1913. {
  1914. OUTS (outf, dregs (reg));
  1915. OUTS (outf, " = [");
  1916. OUTS (outf, iregs (i));
  1917. OUTS (outf, "--]");
  1918. }
  1919. else if (aop == 1 && W == 0 && m == 1)
  1920. {
  1921. OUTS (outf, dregs_lo (reg));
  1922. OUTS (outf, " = W[");
  1923. OUTS (outf, iregs (i));
  1924. OUTS (outf, "--]");
  1925. }
  1926. else if (aop == 1 && W == 0 && m == 2)
  1927. {
  1928. OUTS (outf, dregs_hi (reg));
  1929. OUTS (outf, " = W[");
  1930. OUTS (outf, iregs (i));
  1931. OUTS (outf, "--]");
  1932. }
  1933. else if (aop == 2 && W == 0 && m == 0)
  1934. {
  1935. OUTS (outf, dregs (reg));
  1936. OUTS (outf, " = [");
  1937. OUTS (outf, iregs (i));
  1938. OUTS (outf, "]");
  1939. }
  1940. else if (aop == 2 && W == 0 && m == 1)
  1941. {
  1942. OUTS (outf, dregs_lo (reg));
  1943. OUTS (outf, " = W[");
  1944. OUTS (outf, iregs (i));
  1945. OUTS (outf, "]");
  1946. }
  1947. else if (aop == 2 && W == 0 && m == 2)
  1948. {
  1949. OUTS (outf, dregs_hi (reg));
  1950. OUTS (outf, " = W[");
  1951. OUTS (outf, iregs (i));
  1952. OUTS (outf, "]");
  1953. }
  1954. else if (aop == 0 && W == 1 && m == 0)
  1955. {
  1956. OUTS (outf, "[");
  1957. OUTS (outf, iregs (i));
  1958. OUTS (outf, "++] = ");
  1959. OUTS (outf, dregs (reg));
  1960. }
  1961. else if (aop == 0 && W == 1 && m == 1)
  1962. {
  1963. OUTS (outf, "W[");
  1964. OUTS (outf, iregs (i));
  1965. OUTS (outf, "++] = ");
  1966. OUTS (outf, dregs_lo (reg));
  1967. }
  1968. else if (aop == 0 && W == 1 && m == 2)
  1969. {
  1970. OUTS (outf, "W[");
  1971. OUTS (outf, iregs (i));
  1972. OUTS (outf, "++] = ");
  1973. OUTS (outf, dregs_hi (reg));
  1974. }
  1975. else if (aop == 1 && W == 1 && m == 0)
  1976. {
  1977. OUTS (outf, "[");
  1978. OUTS (outf, iregs (i));
  1979. OUTS (outf, "--] = ");
  1980. OUTS (outf, dregs (reg));
  1981. }
  1982. else if (aop == 1 && W == 1 && m == 1)
  1983. {
  1984. OUTS (outf, "W[");
  1985. OUTS (outf, iregs (i));
  1986. OUTS (outf, "--] = ");
  1987. OUTS (outf, dregs_lo (reg));
  1988. }
  1989. else if (aop == 1 && W == 1 && m == 2)
  1990. {
  1991. OUTS (outf, "W[");
  1992. OUTS (outf, iregs (i));
  1993. OUTS (outf, "--] = ");
  1994. OUTS (outf, dregs_hi (reg));
  1995. }
  1996. else if (aop == 2 && W == 1 && m == 0)
  1997. {
  1998. OUTS (outf, "[");
  1999. OUTS (outf, iregs (i));
  2000. OUTS (outf, "] = ");
  2001. OUTS (outf, dregs (reg));
  2002. }
  2003. else if (aop == 2 && W == 1 && m == 1)
  2004. {
  2005. OUTS (outf, "W[");
  2006. OUTS (outf, iregs (i));
  2007. OUTS (outf, "] = ");
  2008. OUTS (outf, dregs_lo (reg));
  2009. }
  2010. else if (aop == 2 && W == 1 && m == 2)
  2011. {
  2012. OUTS (outf, "W[");
  2013. OUTS (outf, iregs (i));
  2014. OUTS (outf, "] = ");
  2015. OUTS (outf, dregs_hi (reg));
  2016. }
  2017. else if (aop == 3 && W == 0)
  2018. {
  2019. OUTS (outf, dregs (reg));
  2020. OUTS (outf, " = [");
  2021. OUTS (outf, iregs (i));
  2022. OUTS (outf, " ++ ");
  2023. OUTS (outf, mregs (m));
  2024. OUTS (outf, "]");
  2025. }
  2026. else if (aop == 3 && W == 1)
  2027. {
  2028. OUTS (outf, "[");
  2029. OUTS (outf, iregs (i));
  2030. OUTS (outf, " ++ ");
  2031. OUTS (outf, mregs (m));
  2032. OUTS (outf, "] = ");
  2033. OUTS (outf, dregs (reg));
  2034. }
  2035. else
  2036. return 0;
  2037. return 2;
  2038. }
  2039. static int
  2040. decode_LDST_0 (TIword iw0, disassemble_info *outf)
  2041. {
  2042. /* LDST
  2043. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  2044. | 1 | 0 | 0 | 1 |.sz....|.W.|.aop...|.Z.|.ptr.......|.reg.......|
  2045. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  2046. int Z = ((iw0 >> LDST_Z_bits) & LDST_Z_mask);
  2047. int W = ((iw0 >> LDST_W_bits) & LDST_W_mask);
  2048. int sz = ((iw0 >> LDST_sz_bits) & LDST_sz_mask);
  2049. int aop = ((iw0 >> LDST_aop_bits) & LDST_aop_mask);
  2050. int reg = ((iw0 >> LDST_reg_bits) & LDST_reg_mask);
  2051. int ptr = ((iw0 >> LDST_ptr_bits) & LDST_ptr_mask);
  2052. if (aop == 0 && sz == 0 && Z == 0 && W == 0)
  2053. {
  2054. OUTS (outf, dregs (reg));
  2055. OUTS (outf, " = [");
  2056. OUTS (outf, pregs (ptr));
  2057. OUTS (outf, "++]");
  2058. }
  2059. else if (aop == 0 && sz == 0 && Z == 1 && W == 0 && reg != ptr)
  2060. {
  2061. OUTS (outf, pregs (reg));
  2062. OUTS (outf, " = [");
  2063. OUTS (outf, pregs (ptr));
  2064. OUTS (outf, "++]");
  2065. }
  2066. else if (aop == 0 && sz == 1 && Z == 0 && W == 0)
  2067. {
  2068. OUTS (outf, dregs (reg));
  2069. OUTS (outf, " = W[");
  2070. OUTS (outf, pregs (ptr));
  2071. OUTS (outf, "++] (Z)");
  2072. }
  2073. else if (aop == 0 && sz == 1 && Z == 1 && W == 0)
  2074. {
  2075. OUTS (outf, dregs (reg));
  2076. OUTS (outf, " = W[");
  2077. OUTS (outf, pregs (ptr));
  2078. OUTS (outf, "++] (X)");
  2079. }
  2080. else if (aop == 0 && sz == 2 && Z == 0 && W == 0)
  2081. {
  2082. OUTS (outf, dregs (reg));
  2083. OUTS (outf, " = B[");
  2084. OUTS (outf, pregs (ptr));
  2085. OUTS (outf, "++] (Z)");
  2086. }
  2087. else if (aop == 0 && sz == 2 && Z == 1 && W == 0)
  2088. {
  2089. OUTS (outf, dregs (reg));
  2090. OUTS (outf, " = B[");
  2091. OUTS (outf, pregs (ptr));
  2092. OUTS (outf, "++] (X)");
  2093. }
  2094. else if (aop == 1 && sz == 0 && Z == 0 && W == 0)
  2095. {
  2096. OUTS (outf, dregs (reg));
  2097. OUTS (outf, " = [");
  2098. OUTS (outf, pregs (ptr));
  2099. OUTS (outf, "--]");
  2100. }
  2101. else if (aop == 1 && sz == 0 && Z == 1 && W == 0 && reg != ptr)
  2102. {
  2103. OUTS (outf, pregs (reg));
  2104. OUTS (outf, " = [");
  2105. OUTS (outf, pregs (ptr));
  2106. OUTS (outf, "--]");
  2107. }
  2108. else if (aop == 1 && sz == 1 && Z == 0 && W == 0)
  2109. {
  2110. OUTS (outf, dregs (reg));
  2111. OUTS (outf, " = W[");
  2112. OUTS (outf, pregs (ptr));
  2113. OUTS (outf, "--] (Z)");
  2114. }
  2115. else if (aop == 1 && sz == 1 && Z == 1 && W == 0)
  2116. {
  2117. OUTS (outf, dregs (reg));
  2118. OUTS (outf, " = W[");
  2119. OUTS (outf, pregs (ptr));
  2120. OUTS (outf, "--] (X)");
  2121. }
  2122. else if (aop == 1 && sz == 2 && Z == 0 && W == 0)
  2123. {
  2124. OUTS (outf, dregs (reg));
  2125. OUTS (outf, " = B[");
  2126. OUTS (outf, pregs (ptr));
  2127. OUTS (outf, "--] (Z)");
  2128. }
  2129. else if (aop == 1 && sz == 2 && Z == 1 && W == 0)
  2130. {
  2131. OUTS (outf, dregs (reg));
  2132. OUTS (outf, " = B[");
  2133. OUTS (outf, pregs (ptr));
  2134. OUTS (outf, "--] (X)");
  2135. }
  2136. else if (aop == 2 && sz == 0 && Z == 0 && W == 0)
  2137. {
  2138. OUTS (outf, dregs (reg));
  2139. OUTS (outf, " = [");
  2140. OUTS (outf, pregs (ptr));
  2141. OUTS (outf, "]");
  2142. }
  2143. else if (aop == 2 && sz == 0 && Z == 1 && W == 0)
  2144. {
  2145. OUTS (outf, pregs (reg));
  2146. OUTS (outf, " = [");
  2147. OUTS (outf, pregs (ptr));
  2148. OUTS (outf, "]");
  2149. }
  2150. else if (aop == 2 && sz == 1 && Z == 0 && W == 0)
  2151. {
  2152. OUTS (outf, dregs (reg));
  2153. OUTS (outf, " = W[");
  2154. OUTS (outf, pregs (ptr));
  2155. OUTS (outf, "] (Z)");
  2156. }
  2157. else if (aop == 2 && sz == 1 && Z == 1 && W == 0)
  2158. {
  2159. OUTS (outf, dregs (reg));
  2160. OUTS (outf, " = W[");
  2161. OUTS (outf, pregs (ptr));
  2162. OUTS (outf, "] (X)");
  2163. }
  2164. else if (aop == 2 && sz == 2 && Z == 0 && W == 0)
  2165. {
  2166. OUTS (outf, dregs (reg));
  2167. OUTS (outf, " = B[");
  2168. OUTS (outf, pregs (ptr));
  2169. OUTS (outf, "] (Z)");
  2170. }
  2171. else if (aop == 2 && sz == 2 && Z == 1 && W == 0)
  2172. {
  2173. OUTS (outf, dregs (reg));
  2174. OUTS (outf, " = B[");
  2175. OUTS (outf, pregs (ptr));
  2176. OUTS (outf, "] (X)");
  2177. }
  2178. else if (aop == 0 && sz == 0 && Z == 0 && W == 1)
  2179. {
  2180. OUTS (outf, "[");
  2181. OUTS (outf, pregs (ptr));
  2182. OUTS (outf, "++] = ");
  2183. OUTS (outf, dregs (reg));
  2184. }
  2185. else if (aop == 0 && sz == 0 && Z == 1 && W == 1)
  2186. {
  2187. OUTS (outf, "[");
  2188. OUTS (outf, pregs (ptr));
  2189. OUTS (outf, "++] = ");
  2190. OUTS (outf, pregs (reg));
  2191. }
  2192. else if (aop == 0 && sz == 1 && Z == 0 && W == 1)
  2193. {
  2194. OUTS (outf, "W[");
  2195. OUTS (outf, pregs (ptr));
  2196. OUTS (outf, "++] = ");
  2197. OUTS (outf, dregs (reg));
  2198. }
  2199. else if (aop == 0 && sz == 2 && Z == 0 && W == 1)
  2200. {
  2201. OUTS (outf, "B[");
  2202. OUTS (outf, pregs (ptr));
  2203. OUTS (outf, "++] = ");
  2204. OUTS (outf, dregs (reg));
  2205. }
  2206. else if (aop == 1 && sz == 0 && Z == 0 && W == 1)
  2207. {
  2208. OUTS (outf, "[");
  2209. OUTS (outf, pregs (ptr));
  2210. OUTS (outf, "--] = ");
  2211. OUTS (outf, dregs (reg));
  2212. }
  2213. else if (aop == 1 && sz == 0 && Z == 1 && W == 1)
  2214. {
  2215. OUTS (outf, "[");
  2216. OUTS (outf, pregs (ptr));
  2217. OUTS (outf, "--] = ");
  2218. OUTS (outf, pregs (reg));
  2219. }
  2220. else if (aop == 1 && sz == 1 && Z == 0 && W == 1)
  2221. {
  2222. OUTS (outf, "W[");
  2223. OUTS (outf, pregs (ptr));
  2224. OUTS (outf, "--] = ");
  2225. OUTS (outf, dregs (reg));
  2226. }
  2227. else if (aop == 1 && sz == 2 && Z == 0 && W == 1)
  2228. {
  2229. OUTS (outf, "B[");
  2230. OUTS (outf, pregs (ptr));
  2231. OUTS (outf, "--] = ");
  2232. OUTS (outf, dregs (reg));
  2233. }
  2234. else if (aop == 2 && sz == 0 && Z == 0 && W == 1)
  2235. {
  2236. OUTS (outf, "[");
  2237. OUTS (outf, pregs (ptr));
  2238. OUTS (outf, "] = ");
  2239. OUTS (outf, dregs (reg));
  2240. }
  2241. else if (aop == 2 && sz == 0 && Z == 1 && W == 1)
  2242. {
  2243. OUTS (outf, "[");
  2244. OUTS (outf, pregs (ptr));
  2245. OUTS (outf, "] = ");
  2246. OUTS (outf, pregs (reg));
  2247. }
  2248. else if (aop == 2 && sz == 1 && Z == 0 && W == 1)
  2249. {
  2250. OUTS (outf, "W[");
  2251. OUTS (outf, pregs (ptr));
  2252. OUTS (outf, "] = ");
  2253. OUTS (outf, dregs (reg));
  2254. }
  2255. else if (aop == 2 && sz == 2 && Z == 0 && W == 1)
  2256. {
  2257. OUTS (outf, "B[");
  2258. OUTS (outf, pregs (ptr));
  2259. OUTS (outf, "] = ");
  2260. OUTS (outf, dregs (reg));
  2261. }
  2262. else
  2263. return 0;
  2264. return 2;
  2265. }
  2266. static int
  2267. decode_LDSTiiFP_0 (TIword iw0, disassemble_info *outf)
  2268. {
  2269. /* LDSTiiFP
  2270. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  2271. | 1 | 0 | 1 | 1 | 1 | 0 |.W.|.offset............|.reg...........|
  2272. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  2273. int reg = ((iw0 >> LDSTiiFP_reg_bits) & LDSTiiFP_reg_mask);
  2274. int offset = ((iw0 >> LDSTiiFP_offset_bits) & LDSTiiFP_offset_mask);
  2275. int W = ((iw0 >> LDSTiiFP_W_bits) & LDSTiiFP_W_mask);
  2276. if (W == 0)
  2277. {
  2278. OUTS (outf, dpregs (reg));
  2279. OUTS (outf, " = [FP ");
  2280. OUTS (outf, negimm5s4 (offset));
  2281. OUTS (outf, "]");
  2282. }
  2283. else if (W == 1)
  2284. {
  2285. OUTS (outf, "[FP ");
  2286. OUTS (outf, negimm5s4 (offset));
  2287. OUTS (outf, "] = ");
  2288. OUTS (outf, dpregs (reg));
  2289. }
  2290. else
  2291. return 0;
  2292. return 2;
  2293. }
  2294. static int
  2295. decode_LDSTii_0 (TIword iw0, disassemble_info *outf)
  2296. {
  2297. /* LDSTii
  2298. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  2299. | 1 | 0 | 1 |.W.|.op....|.offset........|.ptr.......|.reg.......|
  2300. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  2301. int reg = ((iw0 >> LDSTii_reg_bit) & LDSTii_reg_mask);
  2302. int ptr = ((iw0 >> LDSTii_ptr_bit) & LDSTii_ptr_mask);
  2303. int offset = ((iw0 >> LDSTii_offset_bit) & LDSTii_offset_mask);
  2304. int op = ((iw0 >> LDSTii_op_bit) & LDSTii_op_mask);
  2305. int W = ((iw0 >> LDSTii_W_bit) & LDSTii_W_mask);
  2306. if (W == 0 && op == 0)
  2307. {
  2308. OUTS (outf, dregs (reg));
  2309. OUTS (outf, " = [");
  2310. OUTS (outf, pregs (ptr));
  2311. OUTS (outf, " + ");
  2312. OUTS (outf, uimm4s4 (offset));
  2313. OUTS (outf, "]");
  2314. }
  2315. else if (W == 0 && op == 1)
  2316. {
  2317. OUTS (outf, dregs (reg));
  2318. OUTS (outf, " = W[");
  2319. OUTS (outf, pregs (ptr));
  2320. OUTS (outf, " + ");
  2321. OUTS (outf, uimm4s2 (offset));
  2322. OUTS (outf, "] (Z)");
  2323. }
  2324. else if (W == 0 && op == 2)
  2325. {
  2326. OUTS (outf, dregs (reg));
  2327. OUTS (outf, " = W[");
  2328. OUTS (outf, pregs (ptr));
  2329. OUTS (outf, " + ");
  2330. OUTS (outf, uimm4s2 (offset));
  2331. OUTS (outf, "] (X)");
  2332. }
  2333. else if (W == 0 && op == 3)
  2334. {
  2335. OUTS (outf, pregs (reg));
  2336. OUTS (outf, " = [");
  2337. OUTS (outf, pregs (ptr));
  2338. OUTS (outf, " + ");
  2339. OUTS (outf, uimm4s4 (offset));
  2340. OUTS (outf, "]");
  2341. }
  2342. else if (W == 1 && op == 0)
  2343. {
  2344. OUTS (outf, "[");
  2345. OUTS (outf, pregs (ptr));
  2346. OUTS (outf, " + ");
  2347. OUTS (outf, uimm4s4 (offset));
  2348. OUTS (outf, "] = ");
  2349. OUTS (outf, dregs (reg));
  2350. }
  2351. else if (W == 1 && op == 1)
  2352. {
  2353. OUTS (outf, "W[");
  2354. OUTS (outf, pregs (ptr));
  2355. OUTS (outf, " + ");
  2356. OUTS (outf, uimm4s2 (offset));
  2357. OUTS (outf, "] = ");
  2358. OUTS (outf, dregs (reg));
  2359. }
  2360. else if (W == 1 && op == 3)
  2361. {
  2362. OUTS (outf, "[");
  2363. OUTS (outf, pregs (ptr));
  2364. OUTS (outf, " + ");
  2365. OUTS (outf, uimm4s4 (offset));
  2366. OUTS (outf, "] = ");
  2367. OUTS (outf, pregs (reg));
  2368. }
  2369. else
  2370. return 0;
  2371. return 2;
  2372. }
  2373. static int
  2374. decode_LoopSetup_0 (TIword iw0, TIword iw1, bfd_vma pc, disassemble_info *outf)
  2375. {
  2376. struct private *priv = outf->private_data;
  2377. /* LoopSetup
  2378. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  2379. | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 |.rop...|.c.|.soffset.......|
  2380. |.reg...........| - | - |.eoffset...............................|
  2381. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  2382. int c = ((iw0 >> (LoopSetup_c_bits - 16)) & LoopSetup_c_mask);
  2383. int reg = ((iw1 >> LoopSetup_reg_bits) & LoopSetup_reg_mask);
  2384. int rop = ((iw0 >> (LoopSetup_rop_bits - 16)) & LoopSetup_rop_mask);
  2385. int soffset = ((iw0 >> (LoopSetup_soffset_bits - 16)) & LoopSetup_soffset_mask);
  2386. int eoffset = ((iw1 >> LoopSetup_eoffset_bits) & LoopSetup_eoffset_mask);
  2387. if (priv->parallel)
  2388. return 0;
  2389. if (reg > 7)
  2390. return 0;
  2391. if (rop == 0)
  2392. {
  2393. OUTS (outf, "LSETUP");
  2394. OUTS (outf, "(0x");
  2395. OUTS (outf, pcrel4 (soffset));
  2396. OUTS (outf, ", 0x");
  2397. OUTS (outf, lppcrel10 (eoffset));
  2398. OUTS (outf, ") ");
  2399. OUTS (outf, counters (c));
  2400. }
  2401. else if (rop == 1)
  2402. {
  2403. OUTS (outf, "LSETUP");
  2404. OUTS (outf, "(0x");
  2405. OUTS (outf, pcrel4 (soffset));
  2406. OUTS (outf, ", 0x");
  2407. OUTS (outf, lppcrel10 (eoffset));
  2408. OUTS (outf, ") ");
  2409. OUTS (outf, counters (c));
  2410. OUTS (outf, " = ");
  2411. OUTS (outf, pregs (reg));
  2412. }
  2413. else if (rop == 3)
  2414. {
  2415. OUTS (outf, "LSETUP");
  2416. OUTS (outf, "(0x");
  2417. OUTS (outf, pcrel4 (soffset));
  2418. OUTS (outf, ", 0x");
  2419. OUTS (outf, lppcrel10 (eoffset));
  2420. OUTS (outf, ") ");
  2421. OUTS (outf, counters (c));
  2422. OUTS (outf, " = ");
  2423. OUTS (outf, pregs (reg));
  2424. OUTS (outf, " >> 0x1");
  2425. }
  2426. else
  2427. return 0;
  2428. return 4;
  2429. }
  2430. static int
  2431. decode_LDIMMhalf_0 (TIword iw0, TIword iw1, disassemble_info *outf)
  2432. {
  2433. struct private *priv = outf->private_data;
  2434. /* LDIMMhalf
  2435. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  2436. | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 1 |.Z.|.H.|.S.|.grp...|.reg.......|
  2437. |.hword.........................................................|
  2438. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  2439. int H = ((iw0 >> (LDIMMhalf_H_bits - 16)) & LDIMMhalf_H_mask);
  2440. int Z = ((iw0 >> (LDIMMhalf_Z_bits - 16)) & LDIMMhalf_Z_mask);
  2441. int S = ((iw0 >> (LDIMMhalf_S_bits - 16)) & LDIMMhalf_S_mask);
  2442. int reg = ((iw0 >> (LDIMMhalf_reg_bits - 16)) & LDIMMhalf_reg_mask);
  2443. int grp = ((iw0 >> (LDIMMhalf_grp_bits - 16)) & LDIMMhalf_grp_mask);
  2444. int hword = ((iw1 >> LDIMMhalf_hword_bits) & LDIMMhalf_hword_mask);
  2445. bu32 *pval = get_allreg (grp, reg);
  2446. if (priv->parallel)
  2447. return 0;
  2448. /* Since we don't have 32-bit immediate loads, we allow the disassembler
  2449. to combine them, so it prints out the right values.
  2450. Here we keep track of the registers. */
  2451. if (H == 0 && S == 1 && Z == 0)
  2452. {
  2453. /* regs = imm16 (x) */
  2454. *pval = imm16_val (hword);
  2455. if (hword & 0x8000)
  2456. *pval |= 0xFFFF0000;
  2457. else
  2458. *pval &= 0xFFFF;
  2459. }
  2460. else if (H == 0 && S == 0 && Z == 1)
  2461. {
  2462. /* regs = luimm16 (Z) */
  2463. *pval = luimm16_val (hword);
  2464. *pval &= 0xFFFF;
  2465. }
  2466. else if (H == 0 && S == 0 && Z == 0)
  2467. {
  2468. /* regs_lo = luimm16 */
  2469. *pval &= 0xFFFF0000;
  2470. *pval |= luimm16_val (hword);
  2471. }
  2472. else if (H == 1 && S == 0 && Z == 0)
  2473. {
  2474. /* regs_hi = huimm16 */
  2475. *pval &= 0xFFFF;
  2476. *pval |= luimm16_val (hword) << 16;
  2477. }
  2478. /* Here we do the disassembly */
  2479. if (grp == 0 && H == 0 && S == 0 && Z == 0)
  2480. {
  2481. OUTS (outf, dregs_lo (reg));
  2482. OUTS (outf, " = ");
  2483. OUTS (outf, uimm16 (hword));
  2484. }
  2485. else if (grp == 0 && H == 1 && S == 0 && Z == 0)
  2486. {
  2487. OUTS (outf, dregs_hi (reg));
  2488. OUTS (outf, " = ");
  2489. OUTS (outf, uimm16 (hword));
  2490. }
  2491. else if (grp == 0 && H == 0 && S == 1 && Z == 0)
  2492. {
  2493. OUTS (outf, dregs (reg));
  2494. OUTS (outf, " = ");
  2495. OUTS (outf, imm16 (hword));
  2496. OUTS (outf, " (X)");
  2497. }
  2498. else if (H == 0 && S == 1 && Z == 0)
  2499. {
  2500. OUTS (outf, regs (reg, grp));
  2501. OUTS (outf, " = ");
  2502. OUTS (outf, imm16 (hword));
  2503. OUTS (outf, " (X)");
  2504. }
  2505. else if (H == 0 && S == 0 && Z == 1)
  2506. {
  2507. OUTS (outf, regs (reg, grp));
  2508. OUTS (outf, " = ");
  2509. OUTS (outf, uimm16 (hword));
  2510. OUTS (outf, " (Z)");
  2511. }
  2512. else if (H == 0 && S == 0 && Z == 0)
  2513. {
  2514. OUTS (outf, regs_lo (reg, grp));
  2515. OUTS (outf, " = ");
  2516. OUTS (outf, uimm16 (hword));
  2517. }
  2518. else if (H == 1 && S == 0 && Z == 0)
  2519. {
  2520. OUTS (outf, regs_hi (reg, grp));
  2521. OUTS (outf, " = ");
  2522. OUTS (outf, uimm16 (hword));
  2523. }
  2524. else
  2525. return 0;
  2526. /* And we print out the 32-bit value if it is a pointer. */
  2527. if (S == 0 && Z == 0)
  2528. {
  2529. OUTS (outf, ";\t\t/* (");
  2530. OUTS (outf, imm16d (hword));
  2531. OUTS (outf, ")\t");
  2532. /* If it is an MMR, don't print the symbol. */
  2533. if (*pval < 0xFFC00000 && grp == 1)
  2534. {
  2535. OUTS (outf, regs (reg, grp));
  2536. OUTS (outf, "=0x");
  2537. OUTS (outf, huimm32e (*pval));
  2538. }
  2539. else
  2540. {
  2541. OUTS (outf, regs (reg, grp));
  2542. OUTS (outf, "=0x");
  2543. OUTS (outf, huimm32e (*pval));
  2544. OUTS (outf, "(");
  2545. OUTS (outf, imm32 (*pval));
  2546. OUTS (outf, ")");
  2547. }
  2548. OUTS (outf, " */");
  2549. priv->comment = true;
  2550. }
  2551. if (S == 1 || Z == 1)
  2552. {
  2553. OUTS (outf, ";\t\t/*\t\t");
  2554. OUTS (outf, regs (reg, grp));
  2555. OUTS (outf, "=0x");
  2556. OUTS (outf, huimm32e (*pval));
  2557. OUTS (outf, "(");
  2558. OUTS (outf, imm32 (*pval));
  2559. OUTS (outf, ") */");
  2560. priv->comment = true;
  2561. }
  2562. return 4;
  2563. }
  2564. static int
  2565. decode_CALLa_0 (TIword iw0, TIword iw1, bfd_vma pc, disassemble_info *outf)
  2566. {
  2567. struct private *priv = outf->private_data;
  2568. /* CALLa
  2569. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  2570. | 1 | 1 | 1 | 0 | 0 | 0 | 1 |.S.|.msw...........................|
  2571. |.lsw...........................................................|
  2572. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  2573. int S = ((iw0 >> (CALLa_S_bits - 16)) & CALLa_S_mask);
  2574. int lsw = ((iw1 >> 0) & 0xffff);
  2575. int msw = ((iw0 >> 0) & 0xff);
  2576. if (priv->parallel)
  2577. return 0;
  2578. if (S == 1)
  2579. OUTS (outf, "CALL 0x");
  2580. else if (S == 0)
  2581. OUTS (outf, "JUMP.L 0x");
  2582. else
  2583. return 0;
  2584. OUTS (outf, pcrel24 (((msw) << 16) | (lsw)));
  2585. return 4;
  2586. }
  2587. static int
  2588. decode_LDSTidxI_0 (TIword iw0, TIword iw1, disassemble_info *outf)
  2589. {
  2590. /* LDSTidxI
  2591. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  2592. | 1 | 1 | 1 | 0 | 0 | 1 |.W.|.Z.|.sz....|.ptr.......|.reg.......|
  2593. |.offset........................................................|
  2594. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  2595. int Z = ((iw0 >> (LDSTidxI_Z_bits - 16)) & LDSTidxI_Z_mask);
  2596. int W = ((iw0 >> (LDSTidxI_W_bits - 16)) & LDSTidxI_W_mask);
  2597. int sz = ((iw0 >> (LDSTidxI_sz_bits - 16)) & LDSTidxI_sz_mask);
  2598. int reg = ((iw0 >> (LDSTidxI_reg_bits - 16)) & LDSTidxI_reg_mask);
  2599. int ptr = ((iw0 >> (LDSTidxI_ptr_bits - 16)) & LDSTidxI_ptr_mask);
  2600. int offset = ((iw1 >> LDSTidxI_offset_bits) & LDSTidxI_offset_mask);
  2601. if (W == 0 && sz == 0 && Z == 0)
  2602. {
  2603. OUTS (outf, dregs (reg));
  2604. OUTS (outf, " = [");
  2605. OUTS (outf, pregs (ptr));
  2606. OUTS (outf, " + ");
  2607. OUTS (outf, imm16s4 (offset));
  2608. OUTS (outf, "]");
  2609. }
  2610. else if (W == 0 && sz == 0 && Z == 1)
  2611. {
  2612. OUTS (outf, pregs (reg));
  2613. OUTS (outf, " = [");
  2614. OUTS (outf, pregs (ptr));
  2615. OUTS (outf, " + ");
  2616. OUTS (outf, imm16s4 (offset));
  2617. OUTS (outf, "]");
  2618. }
  2619. else if (W == 0 && sz == 1 && Z == 0)
  2620. {
  2621. OUTS (outf, dregs (reg));
  2622. OUTS (outf, " = W[");
  2623. OUTS (outf, pregs (ptr));
  2624. OUTS (outf, " + ");
  2625. OUTS (outf, imm16s2 (offset));
  2626. OUTS (outf, "] (Z)");
  2627. }
  2628. else if (W == 0 && sz == 1 && Z == 1)
  2629. {
  2630. OUTS (outf, dregs (reg));
  2631. OUTS (outf, " = W[");
  2632. OUTS (outf, pregs (ptr));
  2633. OUTS (outf, " + ");
  2634. OUTS (outf, imm16s2 (offset));
  2635. OUTS (outf, "] (X)");
  2636. }
  2637. else if (W == 0 && sz == 2 && Z == 0)
  2638. {
  2639. OUTS (outf, dregs (reg));
  2640. OUTS (outf, " = B[");
  2641. OUTS (outf, pregs (ptr));
  2642. OUTS (outf, " + ");
  2643. OUTS (outf, imm16 (offset));
  2644. OUTS (outf, "] (Z)");
  2645. }
  2646. else if (W == 0 && sz == 2 && Z == 1)
  2647. {
  2648. OUTS (outf, dregs (reg));
  2649. OUTS (outf, " = B[");
  2650. OUTS (outf, pregs (ptr));
  2651. OUTS (outf, " + ");
  2652. OUTS (outf, imm16 (offset));
  2653. OUTS (outf, "] (X)");
  2654. }
  2655. else if (W == 1 && sz == 0 && Z == 0)
  2656. {
  2657. OUTS (outf, "[");
  2658. OUTS (outf, pregs (ptr));
  2659. OUTS (outf, " + ");
  2660. OUTS (outf, imm16s4 (offset));
  2661. OUTS (outf, "] = ");
  2662. OUTS (outf, dregs (reg));
  2663. }
  2664. else if (W == 1 && sz == 0 && Z == 1)
  2665. {
  2666. OUTS (outf, "[");
  2667. OUTS (outf, pregs (ptr));
  2668. OUTS (outf, " + ");
  2669. OUTS (outf, imm16s4 (offset));
  2670. OUTS (outf, "] = ");
  2671. OUTS (outf, pregs (reg));
  2672. }
  2673. else if (W == 1 && sz == 1 && Z == 0)
  2674. {
  2675. OUTS (outf, "W[");
  2676. OUTS (outf, pregs (ptr));
  2677. OUTS (outf, " + ");
  2678. OUTS (outf, imm16s2 (offset));
  2679. OUTS (outf, "] = ");
  2680. OUTS (outf, dregs (reg));
  2681. }
  2682. else if (W == 1 && sz == 2 && Z == 0)
  2683. {
  2684. OUTS (outf, "B[");
  2685. OUTS (outf, pregs (ptr));
  2686. OUTS (outf, " + ");
  2687. OUTS (outf, imm16 (offset));
  2688. OUTS (outf, "] = ");
  2689. OUTS (outf, dregs (reg));
  2690. }
  2691. else
  2692. return 0;
  2693. return 4;
  2694. }
  2695. static int
  2696. decode_linkage_0 (TIword iw0, TIword iw1, disassemble_info *outf)
  2697. {
  2698. struct private *priv = outf->private_data;
  2699. /* linkage
  2700. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  2701. | 1 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |.R.|
  2702. |.framesize.....................................................|
  2703. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  2704. int R = ((iw0 >> (Linkage_R_bits - 16)) & Linkage_R_mask);
  2705. int framesize = ((iw1 >> Linkage_framesize_bits) & Linkage_framesize_mask);
  2706. if (priv->parallel)
  2707. return 0;
  2708. if (R == 0)
  2709. {
  2710. OUTS (outf, "LINK ");
  2711. OUTS (outf, uimm16s4 (framesize));
  2712. OUTS (outf, ";\t\t/* (");
  2713. OUTS (outf, uimm16s4d (framesize));
  2714. OUTS (outf, ") */");
  2715. priv->comment = true;
  2716. }
  2717. else if (R == 1)
  2718. OUTS (outf, "UNLINK");
  2719. else
  2720. return 0;
  2721. return 4;
  2722. }
  2723. static int
  2724. decode_dsp32mac_0 (TIword iw0, TIword iw1, disassemble_info *outf)
  2725. {
  2726. /* dsp32mac
  2727. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  2728. | 1 | 1 | 0 | 0 |.M.| 0 | 0 |.mmod..........|.MM|.P.|.w1|.op1...|
  2729. |.h01|.h11|.w0|.op0...|.h00|.h10|.dst.......|.src0......|.src1..|
  2730. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  2731. int op1 = ((iw0 >> (DSP32Mac_op1_bits - 16)) & DSP32Mac_op1_mask);
  2732. int w1 = ((iw0 >> (DSP32Mac_w1_bits - 16)) & DSP32Mac_w1_mask);
  2733. int P = ((iw0 >> (DSP32Mac_p_bits - 16)) & DSP32Mac_p_mask);
  2734. int MM = ((iw0 >> (DSP32Mac_MM_bits - 16)) & DSP32Mac_MM_mask);
  2735. int mmod = ((iw0 >> (DSP32Mac_mmod_bits - 16)) & DSP32Mac_mmod_mask);
  2736. int w0 = ((iw1 >> DSP32Mac_w0_bits) & DSP32Mac_w0_mask);
  2737. int src0 = ((iw1 >> DSP32Mac_src0_bits) & DSP32Mac_src0_mask);
  2738. int src1 = ((iw1 >> DSP32Mac_src1_bits) & DSP32Mac_src1_mask);
  2739. int dst = ((iw1 >> DSP32Mac_dst_bits) & DSP32Mac_dst_mask);
  2740. int h10 = ((iw1 >> DSP32Mac_h10_bits) & DSP32Mac_h10_mask);
  2741. int h00 = ((iw1 >> DSP32Mac_h00_bits) & DSP32Mac_h00_mask);
  2742. int op0 = ((iw1 >> DSP32Mac_op0_bits) & DSP32Mac_op0_mask);
  2743. int h11 = ((iw1 >> DSP32Mac_h11_bits) & DSP32Mac_h11_mask);
  2744. int h01 = ((iw1 >> DSP32Mac_h01_bits) & DSP32Mac_h01_mask);
  2745. if (w0 == 0 && w1 == 0 && op1 == 3 && op0 == 3)
  2746. return 0;
  2747. if (op1 == 3 && MM)
  2748. return 0;
  2749. if ((w1 || w0) && mmod == M_W32)
  2750. return 0;
  2751. if (((1 << mmod) & (P ? 0x131b : 0x1b5f)) == 0)
  2752. return 0;
  2753. if (w1 == 1 || op1 != 3)
  2754. {
  2755. if (w1)
  2756. OUTS (outf, P ? dregs (dst + 1) : dregs_hi (dst));
  2757. if (op1 == 3)
  2758. OUTS (outf, " = A1");
  2759. else
  2760. {
  2761. if (w1)
  2762. OUTS (outf, " = (");
  2763. decode_macfunc (1, op1, h01, h11, src0, src1, outf);
  2764. if (w1)
  2765. OUTS (outf, ")");
  2766. }
  2767. if (w0 == 1 || op0 != 3)
  2768. {
  2769. if (MM)
  2770. OUTS (outf, " (M)");
  2771. OUTS (outf, ", ");
  2772. }
  2773. }
  2774. if (w0 == 1 || op0 != 3)
  2775. {
  2776. /* Clear MM option since it only matters for MAC1, and if we made
  2777. it this far, we've already shown it or we want to ignore it. */
  2778. MM = 0;
  2779. if (w0)
  2780. OUTS (outf, P ? dregs (dst) : dregs_lo (dst));
  2781. if (op0 == 3)
  2782. OUTS (outf, " = A0");
  2783. else
  2784. {
  2785. if (w0)
  2786. OUTS (outf, " = (");
  2787. decode_macfunc (0, op0, h00, h10, src0, src1, outf);
  2788. if (w0)
  2789. OUTS (outf, ")");
  2790. }
  2791. }
  2792. decode_optmode (mmod, MM, outf);
  2793. return 4;
  2794. }
  2795. static int
  2796. decode_dsp32mult_0 (TIword iw0, TIword iw1, disassemble_info *outf)
  2797. {
  2798. /* dsp32mult
  2799. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  2800. | 1 | 1 | 0 | 0 |.M.| 0 | 1 |.mmod..........|.MM|.P.|.w1|.op1...|
  2801. |.h01|.h11|.w0|.op0...|.h00|.h10|.dst.......|.src0......|.src1..|
  2802. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  2803. int w1 = ((iw0 >> (DSP32Mac_w1_bits - 16)) & DSP32Mac_w1_mask);
  2804. int P = ((iw0 >> (DSP32Mac_p_bits - 16)) & DSP32Mac_p_mask);
  2805. int MM = ((iw0 >> (DSP32Mac_MM_bits - 16)) & DSP32Mac_MM_mask);
  2806. int mmod = ((iw0 >> (DSP32Mac_mmod_bits - 16)) & DSP32Mac_mmod_mask);
  2807. int w0 = ((iw1 >> DSP32Mac_w0_bits) & DSP32Mac_w0_mask);
  2808. int src0 = ((iw1 >> DSP32Mac_src0_bits) & DSP32Mac_src0_mask);
  2809. int src1 = ((iw1 >> DSP32Mac_src1_bits) & DSP32Mac_src1_mask);
  2810. int dst = ((iw1 >> DSP32Mac_dst_bits) & DSP32Mac_dst_mask);
  2811. int h10 = ((iw1 >> DSP32Mac_h10_bits) & DSP32Mac_h10_mask);
  2812. int h00 = ((iw1 >> DSP32Mac_h00_bits) & DSP32Mac_h00_mask);
  2813. int h11 = ((iw1 >> DSP32Mac_h11_bits) & DSP32Mac_h11_mask);
  2814. int h01 = ((iw1 >> DSP32Mac_h01_bits) & DSP32Mac_h01_mask);
  2815. if (w1 == 0 && w0 == 0)
  2816. return 0;
  2817. if (((1 << mmod) & (P ? 0x313 : 0x1b57)) == 0)
  2818. return 0;
  2819. if (w1)
  2820. {
  2821. OUTS (outf, P ? dregs (dst + 1) : dregs_hi (dst));
  2822. OUTS (outf, " = ");
  2823. decode_multfunc (h01, h11, src0, src1, outf);
  2824. if (w0)
  2825. {
  2826. if (MM)
  2827. OUTS (outf, " (M)");
  2828. MM = 0;
  2829. OUTS (outf, ", ");
  2830. }
  2831. }
  2832. if (w0)
  2833. {
  2834. OUTS (outf, P ? dregs (dst) : dregs_lo (dst));
  2835. OUTS (outf, " = ");
  2836. decode_multfunc (h00, h10, src0, src1, outf);
  2837. }
  2838. decode_optmode (mmod, MM, outf);
  2839. return 4;
  2840. }
  2841. static int
  2842. decode_dsp32alu_0 (TIword iw0, TIword iw1, disassemble_info *outf)
  2843. {
  2844. /* dsp32alu
  2845. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  2846. | 1 | 1 | 0 | 0 |.M.| 1 | 0 | - | - | - |.HL|.aopcde............|
  2847. |.aop...|.s.|.x.|.dst0......|.dst1......|.src0......|.src1......|
  2848. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  2849. int s = ((iw1 >> DSP32Alu_s_bits) & DSP32Alu_s_mask);
  2850. int x = ((iw1 >> DSP32Alu_x_bits) & DSP32Alu_x_mask);
  2851. int aop = ((iw1 >> DSP32Alu_aop_bits) & DSP32Alu_aop_mask);
  2852. int src0 = ((iw1 >> DSP32Alu_src0_bits) & DSP32Alu_src0_mask);
  2853. int src1 = ((iw1 >> DSP32Alu_src1_bits) & DSP32Alu_src1_mask);
  2854. int dst0 = ((iw1 >> DSP32Alu_dst0_bits) & DSP32Alu_dst0_mask);
  2855. int dst1 = ((iw1 >> DSP32Alu_dst1_bits) & DSP32Alu_dst1_mask);
  2856. int HL = ((iw0 >> (DSP32Alu_HL_bits - 16)) & DSP32Alu_HL_mask);
  2857. int aopcde = ((iw0 >> (DSP32Alu_aopcde_bits - 16)) & DSP32Alu_aopcde_mask);
  2858. if (aop == 0 && aopcde == 9 && HL == 0 && s == 0)
  2859. {
  2860. OUTS (outf, "A0.L = ");
  2861. OUTS (outf, dregs_lo (src0));
  2862. }
  2863. else if (aop == 2 && aopcde == 9 && HL == 1 && s == 0)
  2864. {
  2865. OUTS (outf, "A1.H = ");
  2866. OUTS (outf, dregs_hi (src0));
  2867. }
  2868. else if (aop == 2 && aopcde == 9 && HL == 0 && s == 0)
  2869. {
  2870. OUTS (outf, "A1.L = ");
  2871. OUTS (outf, dregs_lo (src0));
  2872. }
  2873. else if (aop == 0 && aopcde == 9 && HL == 1 && s == 0)
  2874. {
  2875. OUTS (outf, "A0.H = ");
  2876. OUTS (outf, dregs_hi (src0));
  2877. }
  2878. else if (x == 1 && HL == 1 && aop == 3 && aopcde == 5)
  2879. {
  2880. OUTS (outf, dregs_hi (dst0));
  2881. OUTS (outf, " = ");
  2882. OUTS (outf, dregs (src0));
  2883. OUTS (outf, " - ");
  2884. OUTS (outf, dregs (src1));
  2885. OUTS (outf, " (RND20)");
  2886. }
  2887. else if (x == 1 && HL == 1 && aop == 2 && aopcde == 5)
  2888. {
  2889. OUTS (outf, dregs_hi (dst0));
  2890. OUTS (outf, " = ");
  2891. OUTS (outf, dregs (src0));
  2892. OUTS (outf, " + ");
  2893. OUTS (outf, dregs (src1));
  2894. OUTS (outf, " (RND20)");
  2895. }
  2896. else if (x == 0 && HL == 0 && aop == 1 && aopcde == 5)
  2897. {
  2898. OUTS (outf, dregs_lo (dst0));
  2899. OUTS (outf, " = ");
  2900. OUTS (outf, dregs (src0));
  2901. OUTS (outf, " - ");
  2902. OUTS (outf, dregs (src1));
  2903. OUTS (outf, " (RND12)");
  2904. }
  2905. else if (x == 0 && HL == 0 && aop == 0 && aopcde == 5)
  2906. {
  2907. OUTS (outf, dregs_lo (dst0));
  2908. OUTS (outf, " = ");
  2909. OUTS (outf, dregs (src0));
  2910. OUTS (outf, " + ");
  2911. OUTS (outf, dregs (src1));
  2912. OUTS (outf, " (RND12)");
  2913. }
  2914. else if (x == 1 && HL == 0 && aop == 3 && aopcde == 5)
  2915. {
  2916. OUTS (outf, dregs_lo (dst0));
  2917. OUTS (outf, " = ");
  2918. OUTS (outf, dregs (src0));
  2919. OUTS (outf, " - ");
  2920. OUTS (outf, dregs (src1));
  2921. OUTS (outf, " (RND20)");
  2922. }
  2923. else if (x == 0 && HL == 1 && aop == 0 && aopcde == 5)
  2924. {
  2925. OUTS (outf, dregs_hi (dst0));
  2926. OUTS (outf, " = ");
  2927. OUTS (outf, dregs (src0));
  2928. OUTS (outf, " + ");
  2929. OUTS (outf, dregs (src1));
  2930. OUTS (outf, " (RND12)");
  2931. }
  2932. else if (x == 1 && HL == 0 && aop == 2 && aopcde == 5)
  2933. {
  2934. OUTS (outf, dregs_lo (dst0));
  2935. OUTS (outf, " = ");
  2936. OUTS (outf, dregs (src0));
  2937. OUTS (outf, " + ");
  2938. OUTS (outf, dregs (src1));
  2939. OUTS (outf, " (RND20)");
  2940. }
  2941. else if (x == 0 && HL == 1 && aop == 1 && aopcde == 5)
  2942. {
  2943. OUTS (outf, dregs_hi (dst0));
  2944. OUTS (outf, " = ");
  2945. OUTS (outf, dregs (src0));
  2946. OUTS (outf, " - ");
  2947. OUTS (outf, dregs (src1));
  2948. OUTS (outf, " (RND12)");
  2949. }
  2950. else if (HL == 1 && aop == 0 && aopcde == 2)
  2951. {
  2952. OUTS (outf, dregs_hi (dst0));
  2953. OUTS (outf, " = ");
  2954. OUTS (outf, dregs_lo (src0));
  2955. OUTS (outf, " + ");
  2956. OUTS (outf, dregs_lo (src1));
  2957. amod1 (s, x, outf);
  2958. }
  2959. else if (HL == 1 && aop == 1 && aopcde == 2)
  2960. {
  2961. OUTS (outf, dregs_hi (dst0));
  2962. OUTS (outf, " = ");
  2963. OUTS (outf, dregs_lo (src0));
  2964. OUTS (outf, " + ");
  2965. OUTS (outf, dregs_hi (src1));
  2966. amod1 (s, x, outf);
  2967. }
  2968. else if (HL == 1 && aop == 2 && aopcde == 2)
  2969. {
  2970. OUTS (outf, dregs_hi (dst0));
  2971. OUTS (outf, " = ");
  2972. OUTS (outf, dregs_hi (src0));
  2973. OUTS (outf, " + ");
  2974. OUTS (outf, dregs_lo (src1));
  2975. amod1 (s, x, outf);
  2976. }
  2977. else if (HL == 1 && aop == 3 && aopcde == 2)
  2978. {
  2979. OUTS (outf, dregs_hi (dst0));
  2980. OUTS (outf, " = ");
  2981. OUTS (outf, dregs_hi (src0));
  2982. OUTS (outf, " + ");
  2983. OUTS (outf, dregs_hi (src1));
  2984. amod1 (s, x, outf);
  2985. }
  2986. else if (HL == 0 && aop == 0 && aopcde == 3)
  2987. {
  2988. OUTS (outf, dregs_lo (dst0));
  2989. OUTS (outf, " = ");
  2990. OUTS (outf, dregs_lo (src0));
  2991. OUTS (outf, " - ");
  2992. OUTS (outf, dregs_lo (src1));
  2993. amod1 (s, x, outf);
  2994. }
  2995. else if (HL == 0 && aop == 1 && aopcde == 3)
  2996. {
  2997. OUTS (outf, dregs_lo (dst0));
  2998. OUTS (outf, " = ");
  2999. OUTS (outf, dregs_lo (src0));
  3000. OUTS (outf, " - ");
  3001. OUTS (outf, dregs_hi (src1));
  3002. amod1 (s, x, outf);
  3003. }
  3004. else if (HL == 0 && aop == 3 && aopcde == 2)
  3005. {
  3006. OUTS (outf, dregs_lo (dst0));
  3007. OUTS (outf, " = ");
  3008. OUTS (outf, dregs_hi (src0));
  3009. OUTS (outf, " + ");
  3010. OUTS (outf, dregs_hi (src1));
  3011. amod1 (s, x, outf);
  3012. }
  3013. else if (HL == 1 && aop == 0 && aopcde == 3)
  3014. {
  3015. OUTS (outf, dregs_hi (dst0));
  3016. OUTS (outf, " = ");
  3017. OUTS (outf, dregs_lo (src0));
  3018. OUTS (outf, " - ");
  3019. OUTS (outf, dregs_lo (src1));
  3020. amod1 (s, x, outf);
  3021. }
  3022. else if (HL == 1 && aop == 1 && aopcde == 3)
  3023. {
  3024. OUTS (outf, dregs_hi (dst0));
  3025. OUTS (outf, " = ");
  3026. OUTS (outf, dregs_lo (src0));
  3027. OUTS (outf, " - ");
  3028. OUTS (outf, dregs_hi (src1));
  3029. amod1 (s, x, outf);
  3030. }
  3031. else if (HL == 1 && aop == 2 && aopcde == 3)
  3032. {
  3033. OUTS (outf, dregs_hi (dst0));
  3034. OUTS (outf, " = ");
  3035. OUTS (outf, dregs_hi (src0));
  3036. OUTS (outf, " - ");
  3037. OUTS (outf, dregs_lo (src1));
  3038. amod1 (s, x, outf);
  3039. }
  3040. else if (HL == 1 && aop == 3 && aopcde == 3)
  3041. {
  3042. OUTS (outf, dregs_hi (dst0));
  3043. OUTS (outf, " = ");
  3044. OUTS (outf, dregs_hi (src0));
  3045. OUTS (outf, " - ");
  3046. OUTS (outf, dregs_hi (src1));
  3047. amod1 (s, x, outf);
  3048. }
  3049. else if (HL == 0 && aop == 2 && aopcde == 2)
  3050. {
  3051. OUTS (outf, dregs_lo (dst0));
  3052. OUTS (outf, " = ");
  3053. OUTS (outf, dregs_hi (src0));
  3054. OUTS (outf, " + ");
  3055. OUTS (outf, dregs_lo (src1));
  3056. amod1 (s, x, outf);
  3057. }
  3058. else if (HL == 0 && aop == 1 && aopcde == 2)
  3059. {
  3060. OUTS (outf, dregs_lo (dst0));
  3061. OUTS (outf, " = ");
  3062. OUTS (outf, dregs_lo (src0));
  3063. OUTS (outf, " + ");
  3064. OUTS (outf, dregs_hi (src1));
  3065. amod1 (s, x, outf);
  3066. }
  3067. else if (HL == 0 && aop == 2 && aopcde == 3)
  3068. {
  3069. OUTS (outf, dregs_lo (dst0));
  3070. OUTS (outf, " = ");
  3071. OUTS (outf, dregs_hi (src0));
  3072. OUTS (outf, " - ");
  3073. OUTS (outf, dregs_lo (src1));
  3074. amod1 (s, x, outf);
  3075. }
  3076. else if (HL == 0 && aop == 3 && aopcde == 3)
  3077. {
  3078. OUTS (outf, dregs_lo (dst0));
  3079. OUTS (outf, " = ");
  3080. OUTS (outf, dregs_hi (src0));
  3081. OUTS (outf, " - ");
  3082. OUTS (outf, dregs_hi (src1));
  3083. amod1 (s, x, outf);
  3084. }
  3085. else if (HL == 0 && aop == 0 && aopcde == 2)
  3086. {
  3087. OUTS (outf, dregs_lo (dst0));
  3088. OUTS (outf, " = ");
  3089. OUTS (outf, dregs_lo (src0));
  3090. OUTS (outf, " + ");
  3091. OUTS (outf, dregs_lo (src1));
  3092. amod1 (s, x, outf);
  3093. }
  3094. else if (aop == 0 && aopcde == 9 && s == 1)
  3095. {
  3096. OUTS (outf, "A0 = ");
  3097. OUTS (outf, dregs (src0));
  3098. }
  3099. else if (aop == 3 && aopcde == 11 && s == 0)
  3100. OUTS (outf, "A0 -= A1");
  3101. else if (aop == 3 && aopcde == 11 && s == 1)
  3102. OUTS (outf, "A0 -= A1 (W32)");
  3103. else if (aop == 1 && aopcde == 22 && HL == 1)
  3104. {
  3105. OUTS (outf, dregs (dst0));
  3106. OUTS (outf, " = BYTEOP2P (");
  3107. OUTS (outf, dregs (src0 + 1));
  3108. OUTS (outf, ":");
  3109. OUTS (outf, imm5d (src0));
  3110. OUTS (outf, ", ");
  3111. OUTS (outf, dregs (src1 + 1));
  3112. OUTS (outf, ":");
  3113. OUTS (outf, imm5d (src1));
  3114. OUTS (outf, ") (TH");
  3115. if (s == 1)
  3116. OUTS (outf, ", R)");
  3117. else
  3118. OUTS (outf, ")");
  3119. }
  3120. else if (aop == 1 && aopcde == 22 && HL == 0)
  3121. {
  3122. OUTS (outf, dregs (dst0));
  3123. OUTS (outf, " = BYTEOP2P (");
  3124. OUTS (outf, dregs (src0 + 1));
  3125. OUTS (outf, ":");
  3126. OUTS (outf, imm5d (src0));
  3127. OUTS (outf, ", ");
  3128. OUTS (outf, dregs (src1 + 1));
  3129. OUTS (outf, ":");
  3130. OUTS (outf, imm5d (src1));
  3131. OUTS (outf, ") (TL");
  3132. if (s == 1)
  3133. OUTS (outf, ", R)");
  3134. else
  3135. OUTS (outf, ")");
  3136. }
  3137. else if (aop == 0 && aopcde == 22 && HL == 1)
  3138. {
  3139. OUTS (outf, dregs (dst0));
  3140. OUTS (outf, " = BYTEOP2P (");
  3141. OUTS (outf, dregs (src0 + 1));
  3142. OUTS (outf, ":");
  3143. OUTS (outf, imm5d (src0));
  3144. OUTS (outf, ", ");
  3145. OUTS (outf, dregs (src1 + 1));
  3146. OUTS (outf, ":");
  3147. OUTS (outf, imm5d (src1));
  3148. OUTS (outf, ") (RNDH");
  3149. if (s == 1)
  3150. OUTS (outf, ", R)");
  3151. else
  3152. OUTS (outf, ")");
  3153. }
  3154. else if (aop == 0 && aopcde == 22 && HL == 0)
  3155. {
  3156. OUTS (outf, dregs (dst0));
  3157. OUTS (outf, " = BYTEOP2P (");
  3158. OUTS (outf, dregs (src0 + 1));
  3159. OUTS (outf, ":");
  3160. OUTS (outf, imm5d (src0));
  3161. OUTS (outf, ", ");
  3162. OUTS (outf, dregs (src1 + 1));
  3163. OUTS (outf, ":");
  3164. OUTS (outf, imm5d (src1));
  3165. OUTS (outf, ") (RNDL");
  3166. if (s == 1)
  3167. OUTS (outf, ", R)");
  3168. else
  3169. OUTS (outf, ")");
  3170. }
  3171. else if (aop == 0 && s == 0 && aopcde == 8)
  3172. OUTS (outf, "A0 = 0");
  3173. else if (aop == 0 && s == 1 && aopcde == 8)
  3174. OUTS (outf, "A0 = A0 (S)");
  3175. else if (aop == 1 && s == 0 && aopcde == 8)
  3176. OUTS (outf, "A1 = 0");
  3177. else if (aop == 1 && s == 1 && aopcde == 8)
  3178. OUTS (outf, "A1 = A1 (S)");
  3179. else if (aop == 2 && s == 0 && aopcde == 8)
  3180. OUTS (outf, "A1 = A0 = 0");
  3181. else if (aop == 2 && s == 1 && aopcde == 8)
  3182. OUTS (outf, "A1 = A1 (S), A0 = A0 (S)");
  3183. else if (aop == 3 && s == 0 && aopcde == 8)
  3184. OUTS (outf, "A0 = A1");
  3185. else if (aop == 3 && s == 1 && aopcde == 8)
  3186. OUTS (outf, "A1 = A0");
  3187. else if (aop == 1 && aopcde == 9 && s == 0)
  3188. {
  3189. OUTS (outf, "A0.X = ");
  3190. OUTS (outf, dregs_lo (src0));
  3191. }
  3192. else if (aop == 1 && HL == 0 && aopcde == 11)
  3193. {
  3194. OUTS (outf, dregs_lo (dst0));
  3195. OUTS (outf, " = (A0 += A1)");
  3196. }
  3197. else if (aop == 3 && HL == 0 && aopcde == 16)
  3198. OUTS (outf, "A1 = ABS A1, A0 = ABS A0");
  3199. else if (aop == 0 && aopcde == 23 && HL == 1)
  3200. {
  3201. OUTS (outf, dregs (dst0));
  3202. OUTS (outf, " = BYTEOP3P (");
  3203. OUTS (outf, dregs (src0 + 1));
  3204. OUTS (outf, ":");
  3205. OUTS (outf, imm5d (src0));
  3206. OUTS (outf, ", ");
  3207. OUTS (outf, dregs (src1 + 1));
  3208. OUTS (outf, ":");
  3209. OUTS (outf, imm5d (src1));
  3210. OUTS (outf, ") (HI");
  3211. if (s == 1)
  3212. OUTS (outf, ", R)");
  3213. else
  3214. OUTS (outf, ")");
  3215. }
  3216. else if (aop == 3 && aopcde == 9 && s == 0)
  3217. {
  3218. OUTS (outf, "A1.X = ");
  3219. OUTS (outf, dregs_lo (src0));
  3220. }
  3221. else if (aop == 1 && HL == 1 && aopcde == 16)
  3222. OUTS (outf, "A1 = ABS A1");
  3223. else if (aop == 0 && HL == 1 && aopcde == 16)
  3224. OUTS (outf, "A1 = ABS A0");
  3225. else if (aop == 2 && aopcde == 9 && s == 1)
  3226. {
  3227. OUTS (outf, "A1 = ");
  3228. OUTS (outf, dregs (src0));
  3229. }
  3230. else if (HL == 0 && aop == 3 && aopcde == 12)
  3231. {
  3232. OUTS (outf, dregs_lo (dst0));
  3233. OUTS (outf, " = ");
  3234. OUTS (outf, dregs (src0));
  3235. OUTS (outf, " (RND)");
  3236. }
  3237. else if (aop == 1 && HL == 0 && aopcde == 16)
  3238. OUTS (outf, "A0 = ABS A1");
  3239. else if (aop == 0 && HL == 0 && aopcde == 16)
  3240. OUTS (outf, "A0 = ABS A0");
  3241. else if (aop == 3 && HL == 0 && aopcde == 15)
  3242. {
  3243. OUTS (outf, dregs (dst0));
  3244. OUTS (outf, " = -");
  3245. OUTS (outf, dregs (src0));
  3246. OUTS (outf, " (V)");
  3247. }
  3248. else if (aop == 3 && s == 1 && HL == 0 && aopcde == 7)
  3249. {
  3250. OUTS (outf, dregs (dst0));
  3251. OUTS (outf, " = -");
  3252. OUTS (outf, dregs (src0));
  3253. OUTS (outf, " (S)");
  3254. }
  3255. else if (aop == 3 && s == 0 && HL == 0 && aopcde == 7)
  3256. {
  3257. OUTS (outf, dregs (dst0));
  3258. OUTS (outf, " = -");
  3259. OUTS (outf, dregs (src0));
  3260. OUTS (outf, " (NS)");
  3261. }
  3262. else if (aop == 1 && HL == 1 && aopcde == 11)
  3263. {
  3264. OUTS (outf, dregs_hi (dst0));
  3265. OUTS (outf, " = (A0 += A1)");
  3266. }
  3267. else if (aop == 2 && aopcde == 11 && s == 0)
  3268. OUTS (outf, "A0 += A1");
  3269. else if (aop == 2 && aopcde == 11 && s == 1)
  3270. OUTS (outf, "A0 += A1 (W32)");
  3271. else if (aop == 3 && HL == 0 && aopcde == 14)
  3272. OUTS (outf, "A1 = -A1, A0 = -A0");
  3273. else if (HL == 1 && aop == 3 && aopcde == 12)
  3274. {
  3275. OUTS (outf, dregs_hi (dst0));
  3276. OUTS (outf, " = ");
  3277. OUTS (outf, dregs (src0));
  3278. OUTS (outf, " (RND)");
  3279. }
  3280. else if (aop == 0 && aopcde == 23 && HL == 0)
  3281. {
  3282. OUTS (outf, dregs (dst0));
  3283. OUTS (outf, " = BYTEOP3P (");
  3284. OUTS (outf, dregs (src0 + 1));
  3285. OUTS (outf, ":");
  3286. OUTS (outf, imm5d (src0));
  3287. OUTS (outf, ", ");
  3288. OUTS (outf, dregs (src1 + 1));
  3289. OUTS (outf, ":");
  3290. OUTS (outf, imm5d (src1));
  3291. OUTS (outf, ") (LO");
  3292. if (s == 1)
  3293. OUTS (outf, ", R)");
  3294. else
  3295. OUTS (outf, ")");
  3296. }
  3297. else if (aop == 0 && HL == 0 && aopcde == 14)
  3298. OUTS (outf, "A0 = -A0");
  3299. else if (aop == 1 && HL == 0 && aopcde == 14)
  3300. OUTS (outf, "A0 = -A1");
  3301. else if (aop == 0 && HL == 1 && aopcde == 14)
  3302. OUTS (outf, "A1 = -A0");
  3303. else if (aop == 1 && HL == 1 && aopcde == 14)
  3304. OUTS (outf, "A1 = -A1");
  3305. else if (aop == 0 && aopcde == 12)
  3306. {
  3307. OUTS (outf, dregs_hi (dst0));
  3308. OUTS (outf, " = ");
  3309. OUTS (outf, dregs_lo (dst0));
  3310. OUTS (outf, " = SIGN (");
  3311. OUTS (outf, dregs_hi (src0));
  3312. OUTS (outf, ") * ");
  3313. OUTS (outf, dregs_hi (src1));
  3314. OUTS (outf, " + SIGN (");
  3315. OUTS (outf, dregs_lo (src0));
  3316. OUTS (outf, ") * ");
  3317. OUTS (outf, dregs_lo (src1));
  3318. }
  3319. else if (aop == 2 && aopcde == 0)
  3320. {
  3321. OUTS (outf, dregs (dst0));
  3322. OUTS (outf, " = ");
  3323. OUTS (outf, dregs (src0));
  3324. OUTS (outf, " -|+ ");
  3325. OUTS (outf, dregs (src1));
  3326. amod0 (s, x, outf);
  3327. }
  3328. else if (aop == 1 && aopcde == 12)
  3329. {
  3330. OUTS (outf, dregs (dst1));
  3331. OUTS (outf, " = A1.L + A1.H, ");
  3332. OUTS (outf, dregs (dst0));
  3333. OUTS (outf, " = A0.L + A0.H");
  3334. }
  3335. else if (aop == 2 && aopcde == 4)
  3336. {
  3337. OUTS (outf, dregs (dst1));
  3338. OUTS (outf, " = ");
  3339. OUTS (outf, dregs (src0));
  3340. OUTS (outf, " + ");
  3341. OUTS (outf, dregs (src1));
  3342. OUTS (outf, ", ");
  3343. OUTS (outf, dregs (dst0));
  3344. OUTS (outf, " = ");
  3345. OUTS (outf, dregs (src0));
  3346. OUTS (outf, " - ");
  3347. OUTS (outf, dregs (src1));
  3348. amod1 (s, x, outf);
  3349. }
  3350. else if (HL == 0 && aopcde == 1)
  3351. {
  3352. OUTS (outf, dregs (dst1));
  3353. OUTS (outf, " = ");
  3354. OUTS (outf, dregs (src0));
  3355. OUTS (outf, " +|+ ");
  3356. OUTS (outf, dregs (src1));
  3357. OUTS (outf, ", ");
  3358. OUTS (outf, dregs (dst0));
  3359. OUTS (outf, " = ");
  3360. OUTS (outf, dregs (src0));
  3361. OUTS (outf, " -|- ");
  3362. OUTS (outf, dregs (src1));
  3363. amod0amod2 (s, x, aop, outf);
  3364. }
  3365. else if (aop == 0 && aopcde == 11)
  3366. {
  3367. OUTS (outf, dregs (dst0));
  3368. OUTS (outf, " = (A0 += A1)");
  3369. }
  3370. else if (aop == 0 && aopcde == 10)
  3371. {
  3372. OUTS (outf, dregs_lo (dst0));
  3373. OUTS (outf, " = A0.X");
  3374. }
  3375. else if (aop == 1 && aopcde == 10)
  3376. {
  3377. OUTS (outf, dregs_lo (dst0));
  3378. OUTS (outf, " = A1.X");
  3379. }
  3380. else if (aop == 1 && aopcde == 0)
  3381. {
  3382. OUTS (outf, dregs (dst0));
  3383. OUTS (outf, " = ");
  3384. OUTS (outf, dregs (src0));
  3385. OUTS (outf, " +|- ");
  3386. OUTS (outf, dregs (src1));
  3387. amod0 (s, x, outf);
  3388. }
  3389. else if (aop == 3 && aopcde == 0)
  3390. {
  3391. OUTS (outf, dregs (dst0));
  3392. OUTS (outf, " = ");
  3393. OUTS (outf, dregs (src0));
  3394. OUTS (outf, " -|- ");
  3395. OUTS (outf, dregs (src1));
  3396. amod0 (s, x, outf);
  3397. }
  3398. else if (aop == 1 && aopcde == 4)
  3399. {
  3400. OUTS (outf, dregs (dst0));
  3401. OUTS (outf, " = ");
  3402. OUTS (outf, dregs (src0));
  3403. OUTS (outf, " - ");
  3404. OUTS (outf, dregs (src1));
  3405. amod1 (s, x, outf);
  3406. }
  3407. else if (aop == 0 && aopcde == 17)
  3408. {
  3409. OUTS (outf, dregs (dst1));
  3410. OUTS (outf, " = A1 + A0, ");
  3411. OUTS (outf, dregs (dst0));
  3412. OUTS (outf, " = A1 - A0");
  3413. amod1 (s, x, outf);
  3414. }
  3415. else if (aop == 1 && aopcde == 17)
  3416. {
  3417. OUTS (outf, dregs (dst1));
  3418. OUTS (outf, " = A0 + A1, ");
  3419. OUTS (outf, dregs (dst0));
  3420. OUTS (outf, " = A0 - A1");
  3421. amod1 (s, x, outf);
  3422. }
  3423. else if (aop == 0 && aopcde == 18)
  3424. {
  3425. OUTS (outf, "SAA (");
  3426. OUTS (outf, dregs (src0 + 1));
  3427. OUTS (outf, ":");
  3428. OUTS (outf, imm5d (src0));
  3429. OUTS (outf, ", ");
  3430. OUTS (outf, dregs (src1 + 1));
  3431. OUTS (outf, ":");
  3432. OUTS (outf, imm5d (src1));
  3433. OUTS (outf, ")");
  3434. aligndir (s, outf);
  3435. }
  3436. else if (aop == 3 && aopcde == 18)
  3437. OUTS (outf, "DISALGNEXCPT");
  3438. else if (aop == 0 && aopcde == 20)
  3439. {
  3440. OUTS (outf, dregs (dst0));
  3441. OUTS (outf, " = BYTEOP1P (");
  3442. OUTS (outf, dregs (src0 + 1));
  3443. OUTS (outf, ":");
  3444. OUTS (outf, imm5d (src0));
  3445. OUTS (outf, ", ");
  3446. OUTS (outf, dregs (src1 + 1));
  3447. OUTS (outf, ":");
  3448. OUTS (outf, imm5d (src1));
  3449. OUTS (outf, ")");
  3450. aligndir (s, outf);
  3451. }
  3452. else if (aop == 1 && aopcde == 20)
  3453. {
  3454. OUTS (outf, dregs (dst0));
  3455. OUTS (outf, " = BYTEOP1P (");
  3456. OUTS (outf, dregs (src0 + 1));
  3457. OUTS (outf, ":");
  3458. OUTS (outf, imm5d (src0));
  3459. OUTS (outf, ", ");
  3460. OUTS (outf, dregs (src1 + 1));
  3461. OUTS (outf, ":");
  3462. OUTS (outf, imm5d (src1));
  3463. OUTS (outf, ") (T");
  3464. if (s == 1)
  3465. OUTS (outf, ", R)");
  3466. else
  3467. OUTS (outf, ")");
  3468. }
  3469. else if (aop == 0 && aopcde == 21)
  3470. {
  3471. OUTS (outf, "(");
  3472. OUTS (outf, dregs (dst1));
  3473. OUTS (outf, ", ");
  3474. OUTS (outf, dregs (dst0));
  3475. OUTS (outf, ") = BYTEOP16P (");
  3476. OUTS (outf, dregs (src0 + 1));
  3477. OUTS (outf, ":");
  3478. OUTS (outf, imm5d (src0));
  3479. OUTS (outf, ", ");
  3480. OUTS (outf, dregs (src1 + 1));
  3481. OUTS (outf, ":");
  3482. OUTS (outf, imm5d (src1));
  3483. OUTS (outf, ")");
  3484. aligndir (s, outf);
  3485. }
  3486. else if (aop == 1 && aopcde == 21)
  3487. {
  3488. OUTS (outf, "(");
  3489. OUTS (outf, dregs (dst1));
  3490. OUTS (outf, ", ");
  3491. OUTS (outf, dregs (dst0));
  3492. OUTS (outf, ") = BYTEOP16M (");
  3493. OUTS (outf, dregs (src0 + 1));
  3494. OUTS (outf, ":");
  3495. OUTS (outf, imm5d (src0));
  3496. OUTS (outf, ", ");
  3497. OUTS (outf, dregs (src1 + 1));
  3498. OUTS (outf, ":");
  3499. OUTS (outf, imm5d (src1));
  3500. OUTS (outf, ")");
  3501. aligndir (s, outf);
  3502. }
  3503. else if (aop == 2 && aopcde == 7)
  3504. {
  3505. OUTS (outf, dregs (dst0));
  3506. OUTS (outf, " = ABS ");
  3507. OUTS (outf, dregs (src0));
  3508. }
  3509. else if (aop == 1 && aopcde == 7)
  3510. {
  3511. OUTS (outf, dregs (dst0));
  3512. OUTS (outf, " = MIN (");
  3513. OUTS (outf, dregs (src0));
  3514. OUTS (outf, ", ");
  3515. OUTS (outf, dregs (src1));
  3516. OUTS (outf, ")");
  3517. }
  3518. else if (aop == 0 && aopcde == 7)
  3519. {
  3520. OUTS (outf, dregs (dst0));
  3521. OUTS (outf, " = MAX (");
  3522. OUTS (outf, dregs (src0));
  3523. OUTS (outf, ", ");
  3524. OUTS (outf, dregs (src1));
  3525. OUTS (outf, ")");
  3526. }
  3527. else if (aop == 2 && aopcde == 6)
  3528. {
  3529. OUTS (outf, dregs (dst0));
  3530. OUTS (outf, " = ABS ");
  3531. OUTS (outf, dregs (src0));
  3532. OUTS (outf, " (V)");
  3533. }
  3534. else if (aop == 1 && aopcde == 6)
  3535. {
  3536. OUTS (outf, dregs (dst0));
  3537. OUTS (outf, " = MIN (");
  3538. OUTS (outf, dregs (src0));
  3539. OUTS (outf, ", ");
  3540. OUTS (outf, dregs (src1));
  3541. OUTS (outf, ") (V)");
  3542. }
  3543. else if (aop == 0 && aopcde == 6)
  3544. {
  3545. OUTS (outf, dregs (dst0));
  3546. OUTS (outf, " = MAX (");
  3547. OUTS (outf, dregs (src0));
  3548. OUTS (outf, ", ");
  3549. OUTS (outf, dregs (src1));
  3550. OUTS (outf, ") (V)");
  3551. }
  3552. else if (HL == 1 && aopcde == 1)
  3553. {
  3554. OUTS (outf, dregs (dst1));
  3555. OUTS (outf, " = ");
  3556. OUTS (outf, dregs (src0));
  3557. OUTS (outf, " +|- ");
  3558. OUTS (outf, dregs (src1));
  3559. OUTS (outf, ", ");
  3560. OUTS (outf, dregs (dst0));
  3561. OUTS (outf, " = ");
  3562. OUTS (outf, dregs (src0));
  3563. OUTS (outf, " -|+ ");
  3564. OUTS (outf, dregs (src1));
  3565. amod0amod2 (s, x, aop, outf);
  3566. }
  3567. else if (aop == 0 && aopcde == 4)
  3568. {
  3569. OUTS (outf, dregs (dst0));
  3570. OUTS (outf, " = ");
  3571. OUTS (outf, dregs (src0));
  3572. OUTS (outf, " + ");
  3573. OUTS (outf, dregs (src1));
  3574. amod1 (s, x, outf);
  3575. }
  3576. else if (aop == 0 && aopcde == 0)
  3577. {
  3578. OUTS (outf, dregs (dst0));
  3579. OUTS (outf, " = ");
  3580. OUTS (outf, dregs (src0));
  3581. OUTS (outf, " +|+ ");
  3582. OUTS (outf, dregs (src1));
  3583. amod0 (s, x, outf);
  3584. }
  3585. else if (aop == 0 && aopcde == 24)
  3586. {
  3587. OUTS (outf, dregs (dst0));
  3588. OUTS (outf, " = BYTEPACK (");
  3589. OUTS (outf, dregs (src0));
  3590. OUTS (outf, ", ");
  3591. OUTS (outf, dregs (src1));
  3592. OUTS (outf, ")");
  3593. }
  3594. else if (aop == 1 && aopcde == 24)
  3595. {
  3596. OUTS (outf, "(");
  3597. OUTS (outf, dregs (dst1));
  3598. OUTS (outf, ", ");
  3599. OUTS (outf, dregs (dst0));
  3600. OUTS (outf, ") = BYTEUNPACK ");
  3601. OUTS (outf, dregs (src0 + 1));
  3602. OUTS (outf, ":");
  3603. OUTS (outf, imm5d (src0));
  3604. aligndir (s, outf);
  3605. }
  3606. else if (aopcde == 13)
  3607. {
  3608. OUTS (outf, "(");
  3609. OUTS (outf, dregs (dst1));
  3610. OUTS (outf, ", ");
  3611. OUTS (outf, dregs (dst0));
  3612. OUTS (outf, ") = SEARCH ");
  3613. OUTS (outf, dregs (src0));
  3614. OUTS (outf, " (");
  3615. searchmod (aop, outf);
  3616. OUTS (outf, ")");
  3617. }
  3618. else
  3619. return 0;
  3620. return 4;
  3621. }
  3622. static int
  3623. decode_dsp32shift_0 (TIword iw0, TIword iw1, disassemble_info *outf)
  3624. {
  3625. /* dsp32shift
  3626. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  3627. | 1 | 1 | 0 | 0 |.M.| 1 | 1 | 0 | 0 | - | - |.sopcde............|
  3628. |.sop...|.HLs...|.dst0......| - | - | - |.src0......|.src1......|
  3629. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  3630. int HLs = ((iw1 >> DSP32Shift_HLs_bits) & DSP32Shift_HLs_mask);
  3631. int sop = ((iw1 >> DSP32Shift_sop_bits) & DSP32Shift_sop_mask);
  3632. int src0 = ((iw1 >> DSP32Shift_src0_bits) & DSP32Shift_src0_mask);
  3633. int src1 = ((iw1 >> DSP32Shift_src1_bits) & DSP32Shift_src1_mask);
  3634. int dst0 = ((iw1 >> DSP32Shift_dst0_bits) & DSP32Shift_dst0_mask);
  3635. int sopcde = ((iw0 >> (DSP32Shift_sopcde_bits - 16)) & DSP32Shift_sopcde_mask);
  3636. const char *acc01 = (HLs & 1) == 0 ? "A0" : "A1";
  3637. if (HLs == 0 && sop == 0 && sopcde == 0)
  3638. {
  3639. OUTS (outf, dregs_lo (dst0));
  3640. OUTS (outf, " = ASHIFT ");
  3641. OUTS (outf, dregs_lo (src1));
  3642. OUTS (outf, " BY ");
  3643. OUTS (outf, dregs_lo (src0));
  3644. }
  3645. else if (HLs == 1 && sop == 0 && sopcde == 0)
  3646. {
  3647. OUTS (outf, dregs_lo (dst0));
  3648. OUTS (outf, " = ASHIFT ");
  3649. OUTS (outf, dregs_hi (src1));
  3650. OUTS (outf, " BY ");
  3651. OUTS (outf, dregs_lo (src0));
  3652. }
  3653. else if (HLs == 2 && sop == 0 && sopcde == 0)
  3654. {
  3655. OUTS (outf, dregs_hi (dst0));
  3656. OUTS (outf, " = ASHIFT ");
  3657. OUTS (outf, dregs_lo (src1));
  3658. OUTS (outf, " BY ");
  3659. OUTS (outf, dregs_lo (src0));
  3660. }
  3661. else if (HLs == 3 && sop == 0 && sopcde == 0)
  3662. {
  3663. OUTS (outf, dregs_hi (dst0));
  3664. OUTS (outf, " = ASHIFT ");
  3665. OUTS (outf, dregs_hi (src1));
  3666. OUTS (outf, " BY ");
  3667. OUTS (outf, dregs_lo (src0));
  3668. }
  3669. else if (HLs == 0 && sop == 1 && sopcde == 0)
  3670. {
  3671. OUTS (outf, dregs_lo (dst0));
  3672. OUTS (outf, " = ASHIFT ");
  3673. OUTS (outf, dregs_lo (src1));
  3674. OUTS (outf, " BY ");
  3675. OUTS (outf, dregs_lo (src0));
  3676. OUTS (outf, " (S)");
  3677. }
  3678. else if (HLs == 1 && sop == 1 && sopcde == 0)
  3679. {
  3680. OUTS (outf, dregs_lo (dst0));
  3681. OUTS (outf, " = ASHIFT ");
  3682. OUTS (outf, dregs_hi (src1));
  3683. OUTS (outf, " BY ");
  3684. OUTS (outf, dregs_lo (src0));
  3685. OUTS (outf, " (S)");
  3686. }
  3687. else if (HLs == 2 && sop == 1 && sopcde == 0)
  3688. {
  3689. OUTS (outf, dregs_hi (dst0));
  3690. OUTS (outf, " = ASHIFT ");
  3691. OUTS (outf, dregs_lo (src1));
  3692. OUTS (outf, " BY ");
  3693. OUTS (outf, dregs_lo (src0));
  3694. OUTS (outf, " (S)");
  3695. }
  3696. else if (HLs == 3 && sop == 1 && sopcde == 0)
  3697. {
  3698. OUTS (outf, dregs_hi (dst0));
  3699. OUTS (outf, " = ASHIFT ");
  3700. OUTS (outf, dregs_hi (src1));
  3701. OUTS (outf, " BY ");
  3702. OUTS (outf, dregs_lo (src0));
  3703. OUTS (outf, " (S)");
  3704. }
  3705. else if (sop == 2 && sopcde == 0)
  3706. {
  3707. OUTS (outf, (HLs & 2) == 0 ? dregs_lo (dst0) : dregs_hi (dst0));
  3708. OUTS (outf, " = LSHIFT ");
  3709. OUTS (outf, (HLs & 1) == 0 ? dregs_lo (src1) : dregs_hi (src1));
  3710. OUTS (outf, " BY ");
  3711. OUTS (outf, dregs_lo (src0));
  3712. }
  3713. else if (sop == 0 && sopcde == 3)
  3714. {
  3715. OUTS (outf, acc01);
  3716. OUTS (outf, " = ASHIFT ");
  3717. OUTS (outf, acc01);
  3718. OUTS (outf, " BY ");
  3719. OUTS (outf, dregs_lo (src0));
  3720. }
  3721. else if (sop == 1 && sopcde == 3)
  3722. {
  3723. OUTS (outf, acc01);
  3724. OUTS (outf, " = LSHIFT ");
  3725. OUTS (outf, acc01);
  3726. OUTS (outf, " BY ");
  3727. OUTS (outf, dregs_lo (src0));
  3728. }
  3729. else if (sop == 2 && sopcde == 3)
  3730. {
  3731. OUTS (outf, acc01);
  3732. OUTS (outf, " = ROT ");
  3733. OUTS (outf, acc01);
  3734. OUTS (outf, " BY ");
  3735. OUTS (outf, dregs_lo (src0));
  3736. }
  3737. else if (sop == 3 && sopcde == 3)
  3738. {
  3739. OUTS (outf, dregs (dst0));
  3740. OUTS (outf, " = ROT ");
  3741. OUTS (outf, dregs (src1));
  3742. OUTS (outf, " BY ");
  3743. OUTS (outf, dregs_lo (src0));
  3744. }
  3745. else if (sop == 1 && sopcde == 1)
  3746. {
  3747. OUTS (outf, dregs (dst0));
  3748. OUTS (outf, " = ASHIFT ");
  3749. OUTS (outf, dregs (src1));
  3750. OUTS (outf, " BY ");
  3751. OUTS (outf, dregs_lo (src0));
  3752. OUTS (outf, " (V, S)");
  3753. }
  3754. else if (sop == 0 && sopcde == 1)
  3755. {
  3756. OUTS (outf, dregs (dst0));
  3757. OUTS (outf, " = ASHIFT ");
  3758. OUTS (outf, dregs (src1));
  3759. OUTS (outf, " BY ");
  3760. OUTS (outf, dregs_lo (src0));
  3761. OUTS (outf, " (V)");
  3762. }
  3763. else if (sop == 0 && sopcde == 2)
  3764. {
  3765. OUTS (outf, dregs (dst0));
  3766. OUTS (outf, " = ASHIFT ");
  3767. OUTS (outf, dregs (src1));
  3768. OUTS (outf, " BY ");
  3769. OUTS (outf, dregs_lo (src0));
  3770. }
  3771. else if (sop == 1 && sopcde == 2)
  3772. {
  3773. OUTS (outf, dregs (dst0));
  3774. OUTS (outf, " = ASHIFT ");
  3775. OUTS (outf, dregs (src1));
  3776. OUTS (outf, " BY ");
  3777. OUTS (outf, dregs_lo (src0));
  3778. OUTS (outf, " (S)");
  3779. }
  3780. else if (sop == 2 && sopcde == 2)
  3781. {
  3782. OUTS (outf, dregs (dst0));
  3783. OUTS (outf, " = LSHIFT ");
  3784. OUTS (outf, dregs (src1));
  3785. OUTS (outf, " BY ");
  3786. OUTS (outf, dregs_lo (src0));
  3787. }
  3788. else if (sop == 3 && sopcde == 2)
  3789. {
  3790. OUTS (outf, dregs (dst0));
  3791. OUTS (outf, " = ROT ");
  3792. OUTS (outf, dregs (src1));
  3793. OUTS (outf, " BY ");
  3794. OUTS (outf, dregs_lo (src0));
  3795. }
  3796. else if (sop == 2 && sopcde == 1)
  3797. {
  3798. OUTS (outf, dregs (dst0));
  3799. OUTS (outf, " = LSHIFT ");
  3800. OUTS (outf, dregs (src1));
  3801. OUTS (outf, " BY ");
  3802. OUTS (outf, dregs_lo (src0));
  3803. OUTS (outf, " (V)");
  3804. }
  3805. else if (sop == 0 && sopcde == 4)
  3806. {
  3807. OUTS (outf, dregs (dst0));
  3808. OUTS (outf, " = PACK (");
  3809. OUTS (outf, dregs_lo (src1));
  3810. OUTS (outf, ", ");
  3811. OUTS (outf, dregs_lo (src0));
  3812. OUTS (outf, ")");
  3813. }
  3814. else if (sop == 1 && sopcde == 4)
  3815. {
  3816. OUTS (outf, dregs (dst0));
  3817. OUTS (outf, " = PACK (");
  3818. OUTS (outf, dregs_lo (src1));
  3819. OUTS (outf, ", ");
  3820. OUTS (outf, dregs_hi (src0));
  3821. OUTS (outf, ")");
  3822. }
  3823. else if (sop == 2 && sopcde == 4)
  3824. {
  3825. OUTS (outf, dregs (dst0));
  3826. OUTS (outf, " = PACK (");
  3827. OUTS (outf, dregs_hi (src1));
  3828. OUTS (outf, ", ");
  3829. OUTS (outf, dregs_lo (src0));
  3830. OUTS (outf, ")");
  3831. }
  3832. else if (sop == 3 && sopcde == 4)
  3833. {
  3834. OUTS (outf, dregs (dst0));
  3835. OUTS (outf, " = PACK (");
  3836. OUTS (outf, dregs_hi (src1));
  3837. OUTS (outf, ", ");
  3838. OUTS (outf, dregs_hi (src0));
  3839. OUTS (outf, ")");
  3840. }
  3841. else if (sop == 0 && sopcde == 5)
  3842. {
  3843. OUTS (outf, dregs_lo (dst0));
  3844. OUTS (outf, " = SIGNBITS ");
  3845. OUTS (outf, dregs (src1));
  3846. }
  3847. else if (sop == 1 && sopcde == 5)
  3848. {
  3849. OUTS (outf, dregs_lo (dst0));
  3850. OUTS (outf, " = SIGNBITS ");
  3851. OUTS (outf, dregs_lo (src1));
  3852. }
  3853. else if (sop == 2 && sopcde == 5)
  3854. {
  3855. OUTS (outf, dregs_lo (dst0));
  3856. OUTS (outf, " = SIGNBITS ");
  3857. OUTS (outf, dregs_hi (src1));
  3858. }
  3859. else if (sop == 0 && sopcde == 6)
  3860. {
  3861. OUTS (outf, dregs_lo (dst0));
  3862. OUTS (outf, " = SIGNBITS A0");
  3863. }
  3864. else if (sop == 1 && sopcde == 6)
  3865. {
  3866. OUTS (outf, dregs_lo (dst0));
  3867. OUTS (outf, " = SIGNBITS A1");
  3868. }
  3869. else if (sop == 3 && sopcde == 6)
  3870. {
  3871. OUTS (outf, dregs_lo (dst0));
  3872. OUTS (outf, " = ONES ");
  3873. OUTS (outf, dregs (src1));
  3874. }
  3875. else if (sop == 0 && sopcde == 7)
  3876. {
  3877. OUTS (outf, dregs_lo (dst0));
  3878. OUTS (outf, " = EXPADJ (");
  3879. OUTS (outf, dregs (src1));
  3880. OUTS (outf, ", ");
  3881. OUTS (outf, dregs_lo (src0));
  3882. OUTS (outf, ")");
  3883. }
  3884. else if (sop == 1 && sopcde == 7)
  3885. {
  3886. OUTS (outf, dregs_lo (dst0));
  3887. OUTS (outf, " = EXPADJ (");
  3888. OUTS (outf, dregs (src1));
  3889. OUTS (outf, ", ");
  3890. OUTS (outf, dregs_lo (src0));
  3891. OUTS (outf, ") (V)");
  3892. }
  3893. else if (sop == 2 && sopcde == 7)
  3894. {
  3895. OUTS (outf, dregs_lo (dst0));
  3896. OUTS (outf, " = EXPADJ (");
  3897. OUTS (outf, dregs_lo (src1));
  3898. OUTS (outf, ", ");
  3899. OUTS (outf, dregs_lo (src0));
  3900. OUTS (outf, ")");
  3901. }
  3902. else if (sop == 3 && sopcde == 7)
  3903. {
  3904. OUTS (outf, dregs_lo (dst0));
  3905. OUTS (outf, " = EXPADJ (");
  3906. OUTS (outf, dregs_hi (src1));
  3907. OUTS (outf, ", ");
  3908. OUTS (outf, dregs_lo (src0));
  3909. OUTS (outf, ")");
  3910. }
  3911. else if (sop == 0 && sopcde == 8)
  3912. {
  3913. OUTS (outf, "BITMUX (");
  3914. OUTS (outf, dregs (src0));
  3915. OUTS (outf, ", ");
  3916. OUTS (outf, dregs (src1));
  3917. OUTS (outf, ", A0) (ASR)");
  3918. }
  3919. else if (sop == 1 && sopcde == 8)
  3920. {
  3921. OUTS (outf, "BITMUX (");
  3922. OUTS (outf, dregs (src0));
  3923. OUTS (outf, ", ");
  3924. OUTS (outf, dregs (src1));
  3925. OUTS (outf, ", A0) (ASL)");
  3926. }
  3927. else if (sop == 0 && sopcde == 9)
  3928. {
  3929. OUTS (outf, dregs_lo (dst0));
  3930. OUTS (outf, " = VIT_MAX (");
  3931. OUTS (outf, dregs (src1));
  3932. OUTS (outf, ") (ASL)");
  3933. }
  3934. else if (sop == 1 && sopcde == 9)
  3935. {
  3936. OUTS (outf, dregs_lo (dst0));
  3937. OUTS (outf, " = VIT_MAX (");
  3938. OUTS (outf, dregs (src1));
  3939. OUTS (outf, ") (ASR)");
  3940. }
  3941. else if (sop == 2 && sopcde == 9)
  3942. {
  3943. OUTS (outf, dregs (dst0));
  3944. OUTS (outf, " = VIT_MAX (");
  3945. OUTS (outf, dregs (src1));
  3946. OUTS (outf, ", ");
  3947. OUTS (outf, dregs (src0));
  3948. OUTS (outf, ") (ASL)");
  3949. }
  3950. else if (sop == 3 && sopcde == 9)
  3951. {
  3952. OUTS (outf, dregs (dst0));
  3953. OUTS (outf, " = VIT_MAX (");
  3954. OUTS (outf, dregs (src1));
  3955. OUTS (outf, ", ");
  3956. OUTS (outf, dregs (src0));
  3957. OUTS (outf, ") (ASR)");
  3958. }
  3959. else if (sop == 0 && sopcde == 10)
  3960. {
  3961. OUTS (outf, dregs (dst0));
  3962. OUTS (outf, " = EXTRACT (");
  3963. OUTS (outf, dregs (src1));
  3964. OUTS (outf, ", ");
  3965. OUTS (outf, dregs_lo (src0));
  3966. OUTS (outf, ") (Z)");
  3967. }
  3968. else if (sop == 1 && sopcde == 10)
  3969. {
  3970. OUTS (outf, dregs (dst0));
  3971. OUTS (outf, " = EXTRACT (");
  3972. OUTS (outf, dregs (src1));
  3973. OUTS (outf, ", ");
  3974. OUTS (outf, dregs_lo (src0));
  3975. OUTS (outf, ") (X)");
  3976. }
  3977. else if (sop == 2 && sopcde == 10)
  3978. {
  3979. OUTS (outf, dregs (dst0));
  3980. OUTS (outf, " = DEPOSIT (");
  3981. OUTS (outf, dregs (src1));
  3982. OUTS (outf, ", ");
  3983. OUTS (outf, dregs (src0));
  3984. OUTS (outf, ")");
  3985. }
  3986. else if (sop == 3 && sopcde == 10)
  3987. {
  3988. OUTS (outf, dregs (dst0));
  3989. OUTS (outf, " = DEPOSIT (");
  3990. OUTS (outf, dregs (src1));
  3991. OUTS (outf, ", ");
  3992. OUTS (outf, dregs (src0));
  3993. OUTS (outf, ") (X)");
  3994. }
  3995. else if (sop == 0 && sopcde == 11)
  3996. {
  3997. OUTS (outf, dregs_lo (dst0));
  3998. OUTS (outf, " = CC = BXORSHIFT (A0, ");
  3999. OUTS (outf, dregs (src0));
  4000. OUTS (outf, ")");
  4001. }
  4002. else if (sop == 1 && sopcde == 11)
  4003. {
  4004. OUTS (outf, dregs_lo (dst0));
  4005. OUTS (outf, " = CC = BXOR (A0, ");
  4006. OUTS (outf, dregs (src0));
  4007. OUTS (outf, ")");
  4008. }
  4009. else if (sop == 0 && sopcde == 12)
  4010. OUTS (outf, "A0 = BXORSHIFT (A0, A1, CC)");
  4011. else if (sop == 1 && sopcde == 12)
  4012. {
  4013. OUTS (outf, dregs_lo (dst0));
  4014. OUTS (outf, " = CC = BXOR (A0, A1, CC)");
  4015. }
  4016. else if (sop == 0 && sopcde == 13)
  4017. {
  4018. OUTS (outf, dregs (dst0));
  4019. OUTS (outf, " = ALIGN8 (");
  4020. OUTS (outf, dregs (src1));
  4021. OUTS (outf, ", ");
  4022. OUTS (outf, dregs (src0));
  4023. OUTS (outf, ")");
  4024. }
  4025. else if (sop == 1 && sopcde == 13)
  4026. {
  4027. OUTS (outf, dregs (dst0));
  4028. OUTS (outf, " = ALIGN16 (");
  4029. OUTS (outf, dregs (src1));
  4030. OUTS (outf, ", ");
  4031. OUTS (outf, dregs (src0));
  4032. OUTS (outf, ")");
  4033. }
  4034. else if (sop == 2 && sopcde == 13)
  4035. {
  4036. OUTS (outf, dregs (dst0));
  4037. OUTS (outf, " = ALIGN24 (");
  4038. OUTS (outf, dregs (src1));
  4039. OUTS (outf, ", ");
  4040. OUTS (outf, dregs (src0));
  4041. OUTS (outf, ")");
  4042. }
  4043. else
  4044. return 0;
  4045. return 4;
  4046. }
  4047. static int
  4048. decode_dsp32shiftimm_0 (TIword iw0, TIword iw1, disassemble_info *outf)
  4049. {
  4050. /* dsp32shiftimm
  4051. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  4052. | 1 | 1 | 0 | 0 |.M.| 1 | 1 | 0 | 1 | - | - |.sopcde............|
  4053. |.sop...|.HLs...|.dst0......|.immag.................|.src1......|
  4054. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  4055. int src1 = ((iw1 >> DSP32ShiftImm_src1_bits) & DSP32ShiftImm_src1_mask);
  4056. int sop = ((iw1 >> DSP32ShiftImm_sop_bits) & DSP32ShiftImm_sop_mask);
  4057. int bit8 = ((iw1 >> 8) & 0x1);
  4058. int immag = ((iw1 >> DSP32ShiftImm_immag_bits) & DSP32ShiftImm_immag_mask);
  4059. int newimmag = (-(iw1 >> DSP32ShiftImm_immag_bits) & DSP32ShiftImm_immag_mask);
  4060. int dst0 = ((iw1 >> DSP32ShiftImm_dst0_bits) & DSP32ShiftImm_dst0_mask);
  4061. int sopcde = ((iw0 >> (DSP32ShiftImm_sopcde_bits - 16)) & DSP32ShiftImm_sopcde_mask);
  4062. int HLs = ((iw1 >> DSP32ShiftImm_HLs_bits) & DSP32ShiftImm_HLs_mask);
  4063. if (sop == 0 && sopcde == 0)
  4064. {
  4065. OUTS (outf, (HLs & 2) ? dregs_hi (dst0) : dregs_lo (dst0));
  4066. OUTS (outf, " = ");
  4067. OUTS (outf, (HLs & 1) ? dregs_hi (src1) : dregs_lo (src1));
  4068. OUTS (outf, " >>> ");
  4069. OUTS (outf, uimm4 (newimmag));
  4070. }
  4071. else if (sop == 1 && sopcde == 0 && bit8 == 0)
  4072. {
  4073. OUTS (outf, (HLs & 2) ? dregs_hi (dst0) : dregs_lo (dst0));
  4074. OUTS (outf, " = ");
  4075. OUTS (outf, (HLs & 1) ? dregs_hi (src1) : dregs_lo (src1));
  4076. OUTS (outf, " << ");
  4077. OUTS (outf, uimm4 (immag));
  4078. OUTS (outf, " (S)");
  4079. }
  4080. else if (sop == 1 && sopcde == 0 && bit8 == 1)
  4081. {
  4082. OUTS (outf, (HLs & 2) ? dregs_hi (dst0) : dregs_lo (dst0));
  4083. OUTS (outf, " = ");
  4084. OUTS (outf, (HLs & 1) ? dregs_hi (src1) : dregs_lo (src1));
  4085. OUTS (outf, " >>> ");
  4086. OUTS (outf, uimm4 (newimmag));
  4087. OUTS (outf, " (S)");
  4088. }
  4089. else if (sop == 2 && sopcde == 0 && bit8 == 0)
  4090. {
  4091. OUTS (outf, (HLs & 2) ? dregs_hi (dst0) : dregs_lo (dst0));
  4092. OUTS (outf, " = ");
  4093. OUTS (outf, (HLs & 1) ? dregs_hi (src1) : dregs_lo (src1));
  4094. OUTS (outf, " << ");
  4095. OUTS (outf, uimm4 (immag));
  4096. }
  4097. else if (sop == 2 && sopcde == 0 && bit8 == 1)
  4098. {
  4099. OUTS (outf, (HLs & 2) ? dregs_hi (dst0) : dregs_lo (dst0));
  4100. OUTS (outf, " = ");
  4101. OUTS (outf, (HLs & 1) ? dregs_hi (src1) : dregs_lo (src1));
  4102. OUTS (outf, " >> ");
  4103. OUTS (outf, uimm4 (newimmag));
  4104. }
  4105. else if (sop == 2 && sopcde == 3 && HLs == 1)
  4106. {
  4107. OUTS (outf, "A1 = ROT A1 BY ");
  4108. OUTS (outf, imm6 (immag));
  4109. }
  4110. else if (sop == 0 && sopcde == 3 && HLs == 0 && bit8 == 0)
  4111. {
  4112. OUTS (outf, "A0 = A0 << ");
  4113. OUTS (outf, uimm5 (immag));
  4114. }
  4115. else if (sop == 0 && sopcde == 3 && HLs == 0 && bit8 == 1)
  4116. {
  4117. OUTS (outf, "A0 = A0 >>> ");
  4118. OUTS (outf, uimm5 (newimmag));
  4119. }
  4120. else if (sop == 0 && sopcde == 3 && HLs == 1 && bit8 == 0)
  4121. {
  4122. OUTS (outf, "A1 = A1 << ");
  4123. OUTS (outf, uimm5 (immag));
  4124. }
  4125. else if (sop == 0 && sopcde == 3 && HLs == 1 && bit8 == 1)
  4126. {
  4127. OUTS (outf, "A1 = A1 >>> ");
  4128. OUTS (outf, uimm5 (newimmag));
  4129. }
  4130. else if (sop == 1 && sopcde == 3 && HLs == 0)
  4131. {
  4132. OUTS (outf, "A0 = A0 >> ");
  4133. OUTS (outf, uimm5 (newimmag));
  4134. }
  4135. else if (sop == 1 && sopcde == 3 && HLs == 1)
  4136. {
  4137. OUTS (outf, "A1 = A1 >> ");
  4138. OUTS (outf, uimm5 (newimmag));
  4139. }
  4140. else if (sop == 2 && sopcde == 3 && HLs == 0)
  4141. {
  4142. OUTS (outf, "A0 = ROT A0 BY ");
  4143. OUTS (outf, imm6 (immag));
  4144. }
  4145. else if (sop == 1 && sopcde == 1 && bit8 == 0)
  4146. {
  4147. OUTS (outf, dregs (dst0));
  4148. OUTS (outf, " = ");
  4149. OUTS (outf, dregs (src1));
  4150. OUTS (outf, " << ");
  4151. OUTS (outf, uimm5 (immag));
  4152. OUTS (outf, " (V, S)");
  4153. }
  4154. else if (sop == 1 && sopcde == 1 && bit8 == 1)
  4155. {
  4156. OUTS (outf, dregs (dst0));
  4157. OUTS (outf, " = ");
  4158. OUTS (outf, dregs (src1));
  4159. OUTS (outf, " >>> ");
  4160. OUTS (outf, imm5 (-immag));
  4161. OUTS (outf, " (V, S)");
  4162. }
  4163. else if (sop == 2 && sopcde == 1 && bit8 == 1)
  4164. {
  4165. OUTS (outf, dregs (dst0));
  4166. OUTS (outf, " = ");
  4167. OUTS (outf, dregs (src1));
  4168. OUTS (outf, " >> ");
  4169. OUTS (outf, uimm5 (newimmag));
  4170. OUTS (outf, " (V)");
  4171. }
  4172. else if (sop == 2 && sopcde == 1 && bit8 == 0)
  4173. {
  4174. OUTS (outf, dregs (dst0));
  4175. OUTS (outf, " = ");
  4176. OUTS (outf, dregs (src1));
  4177. OUTS (outf, " << ");
  4178. OUTS (outf, imm5 (immag));
  4179. OUTS (outf, " (V)");
  4180. }
  4181. else if (sop == 0 && sopcde == 1)
  4182. {
  4183. OUTS (outf, dregs (dst0));
  4184. OUTS (outf, " = ");
  4185. OUTS (outf, dregs (src1));
  4186. OUTS (outf, " >>> ");
  4187. OUTS (outf, uimm5 (newimmag));
  4188. OUTS (outf, " (V)");
  4189. }
  4190. else if (sop == 1 && sopcde == 2)
  4191. {
  4192. OUTS (outf, dregs (dst0));
  4193. OUTS (outf, " = ");
  4194. OUTS (outf, dregs (src1));
  4195. OUTS (outf, " << ");
  4196. OUTS (outf, uimm5 (immag));
  4197. OUTS (outf, " (S)");
  4198. }
  4199. else if (sop == 2 && sopcde == 2 && bit8 == 1)
  4200. {
  4201. OUTS (outf, dregs (dst0));
  4202. OUTS (outf, " = ");
  4203. OUTS (outf, dregs (src1));
  4204. OUTS (outf, " >> ");
  4205. OUTS (outf, uimm5 (newimmag));
  4206. }
  4207. else if (sop == 2 && sopcde == 2 && bit8 == 0)
  4208. {
  4209. OUTS (outf, dregs (dst0));
  4210. OUTS (outf, " = ");
  4211. OUTS (outf, dregs (src1));
  4212. OUTS (outf, " << ");
  4213. OUTS (outf, uimm5 (immag));
  4214. }
  4215. else if (sop == 3 && sopcde == 2)
  4216. {
  4217. OUTS (outf, dregs (dst0));
  4218. OUTS (outf, " = ROT ");
  4219. OUTS (outf, dregs (src1));
  4220. OUTS (outf, " BY ");
  4221. OUTS (outf, imm6 (immag));
  4222. }
  4223. else if (sop == 0 && sopcde == 2)
  4224. {
  4225. OUTS (outf, dregs (dst0));
  4226. OUTS (outf, " = ");
  4227. OUTS (outf, dregs (src1));
  4228. OUTS (outf, " >>> ");
  4229. OUTS (outf, uimm5 (newimmag));
  4230. }
  4231. else
  4232. return 0;
  4233. return 4;
  4234. }
  4235. static int
  4236. decode_pseudoDEBUG_0 (TIword iw0, disassemble_info *outf)
  4237. {
  4238. struct private *priv = outf->private_data;
  4239. /* pseudoDEBUG
  4240. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  4241. | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 |.fn....|.grp.......|.reg.......|
  4242. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  4243. int fn = ((iw0 >> PseudoDbg_fn_bits) & PseudoDbg_fn_mask);
  4244. int grp = ((iw0 >> PseudoDbg_grp_bits) & PseudoDbg_grp_mask);
  4245. int reg = ((iw0 >> PseudoDbg_reg_bits) & PseudoDbg_reg_mask);
  4246. if (priv->parallel)
  4247. return 0;
  4248. if (reg == 0 && fn == 3)
  4249. OUTS (outf, "DBG A0");
  4250. else if (reg == 1 && fn == 3)
  4251. OUTS (outf, "DBG A1");
  4252. else if (reg == 3 && fn == 3)
  4253. OUTS (outf, "ABORT");
  4254. else if (reg == 4 && fn == 3)
  4255. OUTS (outf, "HLT");
  4256. else if (reg == 5 && fn == 3)
  4257. OUTS (outf, "DBGHALT");
  4258. else if (reg == 6 && fn == 3)
  4259. {
  4260. OUTS (outf, "DBGCMPLX (");
  4261. OUTS (outf, dregs (grp));
  4262. OUTS (outf, ")");
  4263. }
  4264. else if (reg == 7 && fn == 3)
  4265. OUTS (outf, "DBG");
  4266. else if (grp == 0 && fn == 2)
  4267. {
  4268. OUTS (outf, "OUTC ");
  4269. OUTS (outf, dregs (reg));
  4270. }
  4271. else if (fn == 0)
  4272. {
  4273. OUTS (outf, "DBG ");
  4274. OUTS (outf, allregs (reg, grp));
  4275. }
  4276. else if (fn == 1)
  4277. {
  4278. OUTS (outf, "PRNT ");
  4279. OUTS (outf, allregs (reg, grp));
  4280. }
  4281. else
  4282. return 0;
  4283. return 2;
  4284. }
  4285. static int
  4286. decode_pseudoOChar_0 (TIword iw0, disassemble_info *outf)
  4287. {
  4288. struct private *priv = outf->private_data;
  4289. /* psedoOChar
  4290. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  4291. | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 1 |.ch............................|
  4292. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  4293. int ch = ((iw0 >> PseudoChr_ch_bits) & PseudoChr_ch_mask);
  4294. if (priv->parallel)
  4295. return 0;
  4296. OUTS (outf, "OUTC ");
  4297. OUTS (outf, uimm8 (ch));
  4298. return 2;
  4299. }
  4300. static int
  4301. decode_pseudodbg_assert_0 (TIword iw0, TIword iw1, disassemble_info *outf)
  4302. {
  4303. struct private *priv = outf->private_data;
  4304. /* pseudodbg_assert
  4305. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
  4306. | 1 | 1 | 1 | 1 | 0 | - | - | - | dbgop |.grp.......|.regtest...|
  4307. |.expected......................................................|
  4308. +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
  4309. int expected = ((iw1 >> PseudoDbg_Assert_expected_bits) & PseudoDbg_Assert_expected_mask);
  4310. int dbgop = ((iw0 >> (PseudoDbg_Assert_dbgop_bits - 16)) & PseudoDbg_Assert_dbgop_mask);
  4311. int grp = ((iw0 >> (PseudoDbg_Assert_grp_bits - 16)) & PseudoDbg_Assert_grp_mask);
  4312. int regtest = ((iw0 >> (PseudoDbg_Assert_regtest_bits - 16)) & PseudoDbg_Assert_regtest_mask);
  4313. if (priv->parallel)
  4314. return 0;
  4315. if (dbgop == 0)
  4316. {
  4317. OUTS (outf, "DBGA (");
  4318. OUTS (outf, regs_lo (regtest, grp));
  4319. OUTS (outf, ", ");
  4320. OUTS (outf, uimm16 (expected));
  4321. OUTS (outf, ")");
  4322. }
  4323. else if (dbgop == 1)
  4324. {
  4325. OUTS (outf, "DBGA (");
  4326. OUTS (outf, regs_hi (regtest, grp));
  4327. OUTS (outf, ", ");
  4328. OUTS (outf, uimm16 (expected));
  4329. OUTS (outf, ")");
  4330. }
  4331. else if (dbgop == 2)
  4332. {
  4333. OUTS (outf, "DBGAL (");
  4334. OUTS (outf, allregs (regtest, grp));
  4335. OUTS (outf, ", ");
  4336. OUTS (outf, uimm16 (expected));
  4337. OUTS (outf, ")");
  4338. }
  4339. else if (dbgop == 3)
  4340. {
  4341. OUTS (outf, "DBGAH (");
  4342. OUTS (outf, allregs (regtest, grp));
  4343. OUTS (outf, ", ");
  4344. OUTS (outf, uimm16 (expected));
  4345. OUTS (outf, ")");
  4346. }
  4347. else
  4348. return 0;
  4349. return 4;
  4350. }
  4351. static int
  4352. ifetch (bfd_vma pc, disassemble_info *outf, TIword *iw)
  4353. {
  4354. bfd_byte buf[2];
  4355. int status;
  4356. status = (*outf->read_memory_func) (pc, buf, 2, outf);
  4357. if (status != 0)
  4358. {
  4359. (*outf->memory_error_func) (status, pc, outf);
  4360. return -1;
  4361. }
  4362. *iw = bfd_getl16 (buf);
  4363. return 0;
  4364. }
  4365. static int
  4366. _print_insn_bfin (bfd_vma pc, disassemble_info *outf)
  4367. {
  4368. struct private *priv = outf->private_data;
  4369. TIword iw0;
  4370. TIword iw1;
  4371. int rv = 0;
  4372. /* The PC must be 16-bit aligned. */
  4373. if (pc & 1)
  4374. {
  4375. OUTS (outf, "ILLEGAL (UNALIGNED)");
  4376. /* For people dumping data, just re-align the return value. */
  4377. return 1;
  4378. }
  4379. if (ifetch (pc, outf, &iw0))
  4380. return -1;
  4381. priv->iw0 = iw0;
  4382. if (((iw0 & 0xc000) == 0xc000) && ((iw0 & 0xff00) != 0xf800))
  4383. {
  4384. /* 32-bit insn. */
  4385. if (ifetch (pc + 2, outf, &iw1))
  4386. return -1;
  4387. }
  4388. else
  4389. /* 16-bit insn. */
  4390. iw1 = 0;
  4391. if ((iw0 & 0xf7ff) == 0xc003 && iw1 == 0x1800)
  4392. {
  4393. if (priv->parallel)
  4394. {
  4395. OUTS (outf, "ILLEGAL");
  4396. return 0;
  4397. }
  4398. OUTS (outf, "MNOP");
  4399. return 4;
  4400. }
  4401. else if ((iw0 & 0xff00) == 0x0000)
  4402. rv = decode_ProgCtrl_0 (iw0, outf);
  4403. else if ((iw0 & 0xffc0) == 0x0240)
  4404. rv = decode_CaCTRL_0 (iw0, outf);
  4405. else if ((iw0 & 0xff80) == 0x0100)
  4406. rv = decode_PushPopReg_0 (iw0, outf);
  4407. else if ((iw0 & 0xfe00) == 0x0400)
  4408. rv = decode_PushPopMultiple_0 (iw0, outf);
  4409. else if ((iw0 & 0xfe00) == 0x0600)
  4410. rv = decode_ccMV_0 (iw0, outf);
  4411. else if ((iw0 & 0xf800) == 0x0800)
  4412. rv = decode_CCflag_0 (iw0, outf);
  4413. else if ((iw0 & 0xffe0) == 0x0200)
  4414. rv = decode_CC2dreg_0 (iw0, outf);
  4415. else if ((iw0 & 0xff00) == 0x0300)
  4416. rv = decode_CC2stat_0 (iw0, outf);
  4417. else if ((iw0 & 0xf000) == 0x1000)
  4418. rv = decode_BRCC_0 (iw0, pc, outf);
  4419. else if ((iw0 & 0xf000) == 0x2000)
  4420. rv = decode_UJUMP_0 (iw0, pc, outf);
  4421. else if ((iw0 & 0xf000) == 0x3000)
  4422. rv = decode_REGMV_0 (iw0, outf);
  4423. else if ((iw0 & 0xfc00) == 0x4000)
  4424. rv = decode_ALU2op_0 (iw0, outf);
  4425. else if ((iw0 & 0xfe00) == 0x4400)
  4426. rv = decode_PTR2op_0 (iw0, outf);
  4427. else if ((iw0 & 0xf800) == 0x4800)
  4428. rv = decode_LOGI2op_0 (iw0, outf);
  4429. else if ((iw0 & 0xf000) == 0x5000)
  4430. rv = decode_COMP3op_0 (iw0, outf);
  4431. else if ((iw0 & 0xf800) == 0x6000)
  4432. rv = decode_COMPI2opD_0 (iw0, outf);
  4433. else if ((iw0 & 0xf800) == 0x6800)
  4434. rv = decode_COMPI2opP_0 (iw0, outf);
  4435. else if ((iw0 & 0xf000) == 0x8000)
  4436. rv = decode_LDSTpmod_0 (iw0, outf);
  4437. else if ((iw0 & 0xff60) == 0x9e60)
  4438. rv = decode_dagMODim_0 (iw0, outf);
  4439. else if ((iw0 & 0xfff0) == 0x9f60)
  4440. rv = decode_dagMODik_0 (iw0, outf);
  4441. else if ((iw0 & 0xfc00) == 0x9c00)
  4442. rv = decode_dspLDST_0 (iw0, outf);
  4443. else if ((iw0 & 0xf000) == 0x9000)
  4444. rv = decode_LDST_0 (iw0, outf);
  4445. else if ((iw0 & 0xfc00) == 0xb800)
  4446. rv = decode_LDSTiiFP_0 (iw0, outf);
  4447. else if ((iw0 & 0xe000) == 0xA000)
  4448. rv = decode_LDSTii_0 (iw0, outf);
  4449. else if ((iw0 & 0xff80) == 0xe080 && (iw1 & 0x0C00) == 0x0000)
  4450. rv = decode_LoopSetup_0 (iw0, iw1, pc, outf);
  4451. else if ((iw0 & 0xff00) == 0xe100 && (iw1 & 0x0000) == 0x0000)
  4452. rv = decode_LDIMMhalf_0 (iw0, iw1, outf);
  4453. else if ((iw0 & 0xfe00) == 0xe200 && (iw1 & 0x0000) == 0x0000)
  4454. rv = decode_CALLa_0 (iw0, iw1, pc, outf);
  4455. else if ((iw0 & 0xfc00) == 0xe400 && (iw1 & 0x0000) == 0x0000)
  4456. rv = decode_LDSTidxI_0 (iw0, iw1, outf);
  4457. else if ((iw0 & 0xfffe) == 0xe800 && (iw1 & 0x0000) == 0x0000)
  4458. rv = decode_linkage_0 (iw0, iw1, outf);
  4459. else if ((iw0 & 0xf600) == 0xc000 && (iw1 & 0x0000) == 0x0000)
  4460. rv = decode_dsp32mac_0 (iw0, iw1, outf);
  4461. else if ((iw0 & 0xf600) == 0xc200 && (iw1 & 0x0000) == 0x0000)
  4462. rv = decode_dsp32mult_0 (iw0, iw1, outf);
  4463. else if ((iw0 & 0xf7c0) == 0xc400 && (iw1 & 0x0000) == 0x0000)
  4464. rv = decode_dsp32alu_0 (iw0, iw1, outf);
  4465. else if ((iw0 & 0xf780) == 0xc600 && (iw1 & 0x01c0) == 0x0000)
  4466. rv = decode_dsp32shift_0 (iw0, iw1, outf);
  4467. else if ((iw0 & 0xf780) == 0xc680 && (iw1 & 0x0000) == 0x0000)
  4468. rv = decode_dsp32shiftimm_0 (iw0, iw1, outf);
  4469. else if ((iw0 & 0xff00) == 0xf800)
  4470. rv = decode_pseudoDEBUG_0 (iw0, outf);
  4471. else if ((iw0 & 0xFF00) == 0xF900)
  4472. rv = decode_pseudoOChar_0 (iw0, outf);
  4473. else if ((iw0 & 0xFF00) == 0xf000 && (iw1 & 0x0000) == 0x0000)
  4474. rv = decode_pseudodbg_assert_0 (iw0, iw1, outf);
  4475. if (rv == 0)
  4476. OUTS (outf, "ILLEGAL");
  4477. return rv;
  4478. }
  4479. int
  4480. print_insn_bfin (bfd_vma pc, disassemble_info *outf)
  4481. {
  4482. struct private priv;
  4483. int count;
  4484. priv.parallel = false;
  4485. priv.comment = false;
  4486. outf->private_data = &priv;
  4487. count = _print_insn_bfin (pc, outf);
  4488. if (count == -1)
  4489. return -1;
  4490. /* Proper display of multiple issue instructions. */
  4491. if (count == 4 && (priv.iw0 & 0xc000) == 0xc000 && (priv.iw0 & BIT_MULTI_INS)
  4492. && ((priv.iw0 & 0xe800) != 0xe800 /* Not Linkage. */ ))
  4493. {
  4494. bool legal = true;
  4495. int len;
  4496. priv.parallel = true;
  4497. OUTS (outf, " || ");
  4498. len = _print_insn_bfin (pc + 4, outf);
  4499. if (len == -1)
  4500. return -1;
  4501. OUTS (outf, " || ");
  4502. if (len != 2)
  4503. legal = false;
  4504. len = _print_insn_bfin (pc + 6, outf);
  4505. if (len == -1)
  4506. return -1;
  4507. if (len != 2)
  4508. legal = false;
  4509. if (legal)
  4510. count = 8;
  4511. else
  4512. {
  4513. OUTS (outf, ";\t\t/* ILLEGAL PARALLEL INSTRUCTION */");
  4514. priv.comment = true;
  4515. count = 0;
  4516. }
  4517. }
  4518. if (!priv.comment)
  4519. OUTS (outf, ";");
  4520. if (count == 0)
  4521. return 2;
  4522. return count;
  4523. }