1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019 |
- /* Simulation code for the CR16 processor.
- Copyright (C) 2008-2015 Free Software Foundation, Inc.
- Contributed by M Ranga Swami Reddy <MR.Swami.Reddy@nsc.com>
- This file is part of GDB, the GNU debugger.
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3, or (at your option)
- any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
- #include "config.h"
- #include <signal.h>
- #include <errno.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #ifdef HAVE_UNISTD_H
- #include <unistd.h>
- #endif
- #ifdef HAVE_STRING_H
- #include <string.h>
- #endif
- #ifdef HAVE_TIME_H
- #include <time.h>
- #endif
- #ifdef HAVE_SYS_TIME_H
- #include <sys/time.h>
- #endif
- #include "sim-main.h"
- #include "simops.h"
- #include "targ-vals.h"
- #ifdef TARGET_SYS_utime
- #include <utime.h>
- #endif
- #ifdef TARGET_SYS_wait
- #include <sys/wait.h>
- #endif
- enum op_types {
- OP_VOID,
- OP_CONSTANT3,
- OP_UCONSTANT3,
- OP_CONSTANT4,
- OP_CONSTANT4_1,
- OP_CONSTANT5,
- OP_CONSTANT6,
- OP_CONSTANT16,
- OP_UCONSTANT16,
- OP_CONSTANT20,
- OP_UCONSTANT20,
- OP_CONSTANT32,
- OP_UCONSTANT32,
- OP_MEMREF,
- OP_MEMREF2,
- OP_MEMREF3,
- OP_DISP5,
- OP_DISP17,
- OP_DISP25,
- OP_DISPE9,
- //OP_ABS20,
- OP_ABS20_OUTPUT,
- //OP_ABS24,
- OP_ABS24_OUTPUT,
- OP_R_BASE_DISPS16,
- OP_R_BASE_DISP20,
- OP_R_BASE_DISPS20,
- OP_R_BASE_DISPE20,
- OP_RP_BASE_DISPE0,
- OP_RP_BASE_DISP4,
- OP_RP_BASE_DISPE4,
- OP_RP_BASE_DISP14,
- OP_RP_BASE_DISP16,
- OP_RP_BASE_DISP20,
- OP_RP_BASE_DISPS20,
- OP_RP_BASE_DISPE20,
- OP_R_INDEX7_ABS20,
- OP_R_INDEX8_ABS20,
- OP_RP_INDEX_DISP0,
- OP_RP_INDEX_DISP14,
- OP_RP_INDEX_DISP20,
- OP_RP_INDEX_DISPS20,
- OP_REG,
- OP_REGP,
- OP_PROC_REG,
- OP_PROC_REGP,
- OP_COND,
- OP_RA
- };
- enum {
- PSR_MASK = (PSR_I_BIT
- | PSR_P_BIT
- | PSR_E_BIT
- | PSR_N_BIT
- | PSR_Z_BIT
- | PSR_F_BIT
- | PSR_U_BIT
- | PSR_L_BIT
- | PSR_T_BIT
- | PSR_C_BIT),
- /* The following bits in the PSR _can't_ be set by instructions such
- as mvtc. */
- PSR_HW_MASK = (PSR_MASK)
- };
- /* cond Code Condition True State
- * EQ Equal Z flag is 1
- * NE Not Equal Z flag is 0
- * CS Carry Set C flag is 1
- * CC Carry Clear C flag is 0
- * HI Higher L flag is 1
- * LS Lower or Same L flag is 0
- * GT Greater Than N flag is 1
- * LE Less Than or Equal To N flag is 0
- * FS Flag Set F flag is 1
- * FC Flag Clear F flag is 0
- * LO Lower Z and L flags are 0
- * HS Higher or Same Z or L flag is 1
- * LT Less Than Z and N flags are 0
- * GE Greater Than or Equal To Z or N flag is 1. */
- static int cond_stat(int cc)
- {
- switch (cc)
- {
- case 0: return PSR_Z; break;
- case 1: return !PSR_Z; break;
- case 2: return PSR_C; break;
- case 3: return !PSR_C; break;
- case 4: return PSR_L; break;
- case 5: return !PSR_L; break;
- case 6: return PSR_N; break;
- case 7: return !PSR_N; break;
- case 8: return PSR_F; break;
- case 9: return !PSR_F; break;
- case 10: return !PSR_Z && !PSR_L; break;
- case 11: return PSR_Z || PSR_L; break;
- case 12: return !PSR_Z && !PSR_N; break;
- case 13: return PSR_Z || PSR_N; break;
- case 14: return 1; break; /*ALWAYS. */
- default:
- // case NEVER: return false; break;
- //case NO_COND_CODE:
- //panic("Shouldn't have NO_COND_CODE in an actual instruction!");
- return 0; break;
- }
- return 0;
- }
- creg_t
- move_to_cr (int cr, creg_t mask, creg_t val, int psw_hw_p)
- {
- /* A MASK bit is set when the corresponding bit in the CR should
- be left alone. */
- /* This assumes that (VAL & MASK) == 0. */
- switch (cr)
- {
- case PSR_CR:
- if (psw_hw_p)
- val &= PSR_HW_MASK;
- #if 0
- else
- val &= PSR_MASK;
- (*cr16_callback->printf_filtered)
- (cr16_callback,
- "ERROR at PC 0x%x: ST can only be set when FX is set.\n", PC);
- State.exception = SIGILL;
- #endif
- /* keep an up-to-date psw around for tracing. */
- State.trace.psw = (State.trace.psw & mask) | val;
- break;
- default:
- break;
- }
- /* only issue an update if the register is being changed. */
- if ((State.cregs[cr] & ~mask) != val)
- SLOT_PEND_MASK (State.cregs[cr], mask, val);
- return val;
- }
- #ifdef DEBUG
- static void trace_input_func (const char *name,
- enum op_types in1,
- enum op_types in2,
- enum op_types in3);
- #define trace_input(name, in1, in2, in3) do { if (cr16_debug) trace_input_func (name, in1, in2, in3); } while (0)
- #ifndef SIZE_INSTRUCTION
- #define SIZE_INSTRUCTION 8
- #endif
- #ifndef SIZE_OPERANDS
- #define SIZE_OPERANDS 18
- #endif
- #ifndef SIZE_VALUES
- #define SIZE_VALUES 13
- #endif
- #ifndef SIZE_LOCATION
- #define SIZE_LOCATION 20
- #endif
- #ifndef SIZE_PC
- #define SIZE_PC 4
- #endif
- #ifndef SIZE_LINE_NUMBER
- #define SIZE_LINE_NUMBER 2
- #endif
- static void
- trace_input_func (const char *name, enum op_types in1, enum op_types in2, enum op_types in3)
- {
- char *comma;
- enum op_types in[3];
- int i;
- char buf[1024];
- char *p;
- long tmp;
- char *type;
- const char *filename;
- const char *functionname;
- unsigned int linenumber;
- bfd_vma byte_pc;
- if ((cr16_debug & DEBUG_TRACE) == 0)
- return;
- switch (State.ins_type)
- {
- default:
- case INS_UNKNOWN: type = " ?"; break;
- }
- if ((cr16_debug & DEBUG_LINE_NUMBER) == 0)
- (*cr16_callback->printf_filtered) (cr16_callback,
- "0x%.*x %s: %-*s ",
- SIZE_PC, (unsigned)PC,
- type,
- SIZE_INSTRUCTION, name);
- else
- {
- extern SIM_DESC trace_sd;
- buf[0] = '\0';
- byte_pc = PC;
- if (STATE_TEXT_SECTION (trace_sd)
- && byte_pc >= STATE_TEXT_START (trace_sd)
- && byte_pc < STATE_TEXT_END (trace_sd))
- {
- filename = (const char *)0;
- functionname = (const char *)0;
- linenumber = 0;
- if (bfd_find_nearest_line (STATE_PROG_BFD (trace_sd),
- STATE_TEXT_SECTION (trace_sd),
- (struct bfd_symbol **)0,
- byte_pc - STATE_TEXT_START (trace_sd),
- &filename, &functionname, &linenumber))
- {
- p = buf;
- if (linenumber)
- {
- sprintf (p, "#%-*d ", SIZE_LINE_NUMBER, linenumber);
- p += strlen (p);
- }
- else
- {
- sprintf (p, "%-*s ", SIZE_LINE_NUMBER+1, "---");
- p += SIZE_LINE_NUMBER+2;
- }
- if (functionname)
- {
- sprintf (p, "%s ", functionname);
- p += strlen (p);
- }
- else if (filename)
- {
- char *q = strrchr (filename, '/');
- sprintf (p, "%s ", (q) ? q+1 : filename);
- p += strlen (p);
- }
- if (*p == ' ')
- *p = '\0';
- }
- }
- (*cr16_callback->printf_filtered) (cr16_callback,
- "0x%.*x %s: %-*.*s %-*s ",
- SIZE_PC, (unsigned)PC,
- type,
- SIZE_LOCATION, SIZE_LOCATION, buf,
- SIZE_INSTRUCTION, name);
- }
- in[0] = in1;
- in[1] = in2;
- in[2] = in3;
- comma = "";
- p = buf;
- for (i = 0; i < 3; i++)
- {
- switch (in[i])
- {
- case OP_VOID:
- break;
- case OP_REG:
- case OP_REGP:
- sprintf (p, "%sr%d", comma, OP[i]);
- p += strlen (p);
- comma = ",";
- break;
- case OP_PROC_REG:
- sprintf (p, "%scr%d", comma, OP[i]);
- p += strlen (p);
- comma = ",";
- break;
- case OP_CONSTANT16:
- sprintf (p, "%s%d", comma, OP[i]);
- p += strlen (p);
- comma = ",";
- break;
- case OP_CONSTANT4:
- sprintf (p, "%s%d", comma, SEXT4(OP[i]));
- p += strlen (p);
- comma = ",";
- break;
- case OP_CONSTANT3:
- sprintf (p, "%s%d", comma, SEXT3(OP[i]));
- p += strlen (p);
- comma = ",";
- break;
- case OP_MEMREF:
- sprintf (p, "%s@r%d", comma, OP[i]);
- p += strlen (p);
- comma = ",";
- break;
- case OP_MEMREF2:
- sprintf (p, "%s@(%d,r%d)", comma, (int16)OP[i], OP[i+1]);
- p += strlen (p);
- comma = ",";
- break;
- case OP_MEMREF3:
- sprintf (p, "%s@%d", comma, OP[i]);
- p += strlen (p);
- comma = ",";
- break;
- }
- }
- if ((cr16_debug & DEBUG_VALUES) == 0)
- {
- *p++ = '\n';
- *p = '\0';
- (*cr16_callback->printf_filtered) (cr16_callback, "%s", buf);
- }
- else
- {
- *p = '\0';
- (*cr16_callback->printf_filtered) (cr16_callback, "%-*s", SIZE_OPERANDS, buf);
- p = buf;
- for (i = 0; i < 3; i++)
- {
- buf[0] = '\0';
- switch (in[i])
- {
- case OP_VOID:
- (*cr16_callback->printf_filtered) (cr16_callback, "%*s", SIZE_VALUES, "");
- break;
- case OP_REG:
- (*cr16_callback->printf_filtered) (cr16_callback, "%*s0x%.4x", SIZE_VALUES-6, "",
- (uint16) GPR (OP[i]));
- break;
- case OP_REGP:
- tmp = (long)((((uint32) GPR (OP[i])) << 16) | ((uint32) GPR (OP[i] + 1)));
- (*cr16_callback->printf_filtered) (cr16_callback, "%*s0x%.8lx", SIZE_VALUES-10, "", tmp);
- break;
- case OP_PROC_REG:
- (*cr16_callback->printf_filtered) (cr16_callback, "%*s0x%.4x", SIZE_VALUES-6, "",
- (uint16) CREG (OP[i]));
- break;
- case OP_CONSTANT16:
- (*cr16_callback->printf_filtered) (cr16_callback, "%*s0x%.4x", SIZE_VALUES-6, "",
- (uint16)OP[i]);
- break;
- case OP_CONSTANT4:
- (*cr16_callback->printf_filtered) (cr16_callback, "%*s0x%.4x", SIZE_VALUES-6, "",
- (uint16)SEXT4(OP[i]));
- break;
- case OP_CONSTANT3:
- (*cr16_callback->printf_filtered) (cr16_callback, "%*s0x%.4x", SIZE_VALUES-6, "",
- (uint16)SEXT3(OP[i]));
- break;
- case OP_MEMREF2:
- (*cr16_callback->printf_filtered) (cr16_callback, "%*s0x%.4x", SIZE_VALUES-6, "",
- (uint16)OP[i]);
- (*cr16_callback->printf_filtered) (cr16_callback, "%*s0x%.4x", SIZE_VALUES-6, "",
- (uint16)GPR (OP[i + 1]));
- i++;
- break;
- }
- }
- }
- (*cr16_callback->flush_stdout) (cr16_callback);
- }
- static void
- do_trace_output_flush (void)
- {
- (*cr16_callback->flush_stdout) (cr16_callback);
- }
- static void
- do_trace_output_finish (void)
- {
- (*cr16_callback->printf_filtered) (cr16_callback,
- " F0=%d F1=%d C=%d\n",
- (State.trace.psw & PSR_F_BIT) != 0,
- (State.trace.psw & PSR_F_BIT) != 0,
- (State.trace.psw & PSR_C_BIT) != 0);
- (*cr16_callback->flush_stdout) (cr16_callback);
- }
- #if 0
- static void
- trace_output_40 (uint64 val)
- {
- if ((cr16_debug & (DEBUG_TRACE | DEBUG_VALUES)) == (DEBUG_TRACE | DEBUG_VALUES))
- {
- (*cr16_callback->printf_filtered) (cr16_callback,
- " :: %*s0x%.2x%.8lx",
- SIZE_VALUES - 12,
- "",
- ((int)(val >> 32) & 0xff),
- ((unsigned long) val) & 0xffffffff);
- do_trace_output_finish ();
- }
- }
- #endif
- static void
- trace_output_32 (uint32 val)
- {
- if ((cr16_debug & (DEBUG_TRACE | DEBUG_VALUES)) == (DEBUG_TRACE | DEBUG_VALUES))
- {
- (*cr16_callback->printf_filtered) (cr16_callback,
- " :: %*s0x%.8x",
- SIZE_VALUES - 10,
- "",
- (int) val);
- do_trace_output_finish ();
- }
- }
- static void
- trace_output_16 (uint16 val)
- {
- if ((cr16_debug & (DEBUG_TRACE | DEBUG_VALUES)) == (DEBUG_TRACE | DEBUG_VALUES))
- {
- (*cr16_callback->printf_filtered) (cr16_callback,
- " :: %*s0x%.4x",
- SIZE_VALUES - 6,
- "",
- (int) val);
- do_trace_output_finish ();
- }
- }
- static void
- trace_output_void (void)
- {
- if ((cr16_debug & (DEBUG_TRACE | DEBUG_VALUES)) == (DEBUG_TRACE | DEBUG_VALUES))
- {
- (*cr16_callback->printf_filtered) (cr16_callback, "\n");
- do_trace_output_flush ();
- }
- }
- static void
- trace_output_flag (void)
- {
- if ((cr16_debug & (DEBUG_TRACE | DEBUG_VALUES)) == (DEBUG_TRACE | DEBUG_VALUES))
- {
- (*cr16_callback->printf_filtered) (cr16_callback,
- " :: %*s",
- SIZE_VALUES,
- "");
- do_trace_output_finish ();
- }
- }
- #else
- #define trace_input(NAME, IN1, IN2, IN3)
- #define trace_output(RESULT)
- #endif
- /* addub. */
- void
- OP_2C_8 (void)
- {
- uint8 tmp;
- uint8 a = OP[0] & 0xff;
- uint16 b = (GPR (OP[1])) & 0xff;
- trace_input ("addub", OP_CONSTANT4_1, OP_REG, OP_VOID);
- tmp = (a + b) & 0xff;
- SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
- trace_output_16 (tmp);
- }
- /* addub. */
- void
- OP_2CB_C (void)
- {
- uint16 tmp;
- uint8 a = ((OP[0]) & 0xff), b = (GPR (OP[1])) & 0xff;
- trace_input ("addub", OP_CONSTANT16, OP_REG, OP_VOID);
- tmp = (a + b) & 0xff;
- SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
- trace_output_16 (tmp);
- }
- /* addub. */
- void
- OP_2D_8 (void)
- {
- uint8 a = (GPR (OP[0])) & 0xff;
- uint8 b = (GPR (OP[1])) & 0xff;
- uint16 tmp = (a + b) & 0xff;
- trace_input ("addub", OP_REG, OP_REG, OP_VOID);
- SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
- trace_output_16 (tmp);
- }
- /* adduw. */
- void
- OP_2E_8 (void)
- {
- uint16 a = OP[0];
- uint16 b = GPR (OP[1]);
- uint16 tmp = (a + b);
- trace_input ("adduw", OP_CONSTANT4_1, OP_REG, OP_VOID);
- SET_GPR (OP[1], tmp);
- trace_output_16 (tmp);
- }
- /* adduw. */
- void
- OP_2EB_C (void)
- {
- uint16 a = OP[0];
- uint16 b = GPR (OP[1]);
- uint16 tmp = (a + b);
- trace_input ("adduw", OP_CONSTANT16, OP_REG, OP_VOID);
- SET_GPR (OP[1], tmp);
- trace_output_16 (tmp);
- }
- /* adduw. */
- void
- OP_2F_8 (void)
- {
- uint16 a = GPR (OP[0]);
- uint16 b = GPR (OP[1]);
- uint16 tmp = (a + b);
- trace_input ("adduw", OP_REG, OP_REG, OP_VOID);
- SET_GPR (OP[1], tmp);
- trace_output_16 (tmp);
- }
- /* addb. */
- void
- OP_30_8 (void)
- {
- uint8 a = OP[0];
- uint8 b = (GPR (OP[1]) & 0xff);
- uint16 tmp = (a + b) & 0xff;
- trace_input ("addb", OP_CONSTANT4_1, OP_REG, OP_VOID);
- SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
- SET_PSR_C (tmp > 0xFF);
- SET_PSR_F (((a & 0x80) == (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
- trace_output_16 (tmp);
- }
- /* addb. */
- void
- OP_30B_C (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint8 b = (GPR (OP[1]) & 0xff);
- uint16 tmp = (a + b) & 0xff;
- trace_input ("addb", OP_CONSTANT16, OP_REG, OP_VOID);
- SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
- SET_PSR_C (tmp > 0xFF);
- SET_PSR_F (((a & 0x80) == (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
- trace_output_16 (tmp);
- }
- /* addb. */
- void
- OP_31_8 (void)
- {
- uint8 a = (GPR (OP[0]) & 0xff);
- uint8 b = (GPR (OP[1]) & 0xff);
- uint16 tmp = (a + b) & 0xff;
- trace_input ("addb", OP_REG, OP_REG, OP_VOID);
- SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
- SET_PSR_C (tmp > 0xFF);
- SET_PSR_F (((a & 0x80) == (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
- trace_output_16 (tmp);
- }
- /* addw. */
- void
- OP_32_8 (void)
- {
- int16 a = OP[0];
- uint16 tmp, b = GPR (OP[1]);
- tmp = (a + b);
- trace_input ("addw", OP_CONSTANT4_1, OP_REG, OP_VOID);
- SET_GPR (OP[1], tmp);
- SET_PSR_C (tmp > 0xFFFF);
- SET_PSR_F (((a & 0x8000) == (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
- trace_output_16 (tmp);
- }
- /* addw. */
- void
- OP_32B_C (void)
- {
- int16 a = OP[0];
- uint16 tmp, b = GPR (OP[1]);
- tmp = (a + b);
- trace_input ("addw", OP_CONSTANT16, OP_REG, OP_VOID);
- SET_GPR (OP[1], tmp);
- SET_PSR_C (tmp > 0xFFFF);
- SET_PSR_F (((a & 0x8000) == (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
- trace_output_16 (tmp);
- }
- /* addw. */
- void
- OP_33_8 (void)
- {
- uint16 tmp, a = (GPR (OP[0])), b = (GPR (OP[1]));
- trace_input ("addw", OP_REG, OP_REG, OP_VOID);
- tmp = (a + b);
- SET_GPR (OP[1], tmp);
- SET_PSR_C (tmp > 0xFFFF);
- SET_PSR_F (((a & 0x8000) == (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
- trace_output_16 (tmp);
- }
- /* addcb. */
- void
- OP_34_8 (void)
- {
- uint8 tmp, a = OP[0] & 0xff, b = (GPR (OP[1])) & 0xff;
- trace_input ("addcb", OP_CONSTANT4_1, OP_REG, OP_REG);
- tmp = (a + b + PSR_C) & 0xff;
- SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
- SET_PSR_C (tmp > 0xFF);
- SET_PSR_F (((a & 0x80) == (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
- trace_output_16 (tmp);
- }
- /* addcb. */
- void
- OP_34B_C (void)
- {
- int8 a = OP[0] & 0xff;
- uint8 b = (GPR (OP[1])) & 0xff;
- uint8 tmp = (a + b + PSR_C) & 0xff;
- trace_input ("addcb", OP_CONSTANT16, OP_REG, OP_VOID);
- SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
- SET_PSR_C (tmp > 0xFF);
- SET_PSR_F (((a & 0x80) == (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
- trace_output_16 (tmp);
- }
- /* addcb. */
- void
- OP_35_8 (void)
- {
- uint8 a = (GPR (OP[0])) & 0xff;
- uint8 b = (GPR (OP[1])) & 0xff;
- uint8 tmp = (a + b + PSR_C) & 0xff;
- trace_input ("addcb", OP_REG, OP_REG, OP_VOID);
- SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
- SET_PSR_C (tmp > 0xFF);
- SET_PSR_F (((a & 0x80) == (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
- trace_output_16 (tmp);
- }
- /* addcw. */
- void
- OP_36_8 (void)
- {
- uint16 a = OP[0];
- uint16 b = GPR (OP[1]);
- uint16 tmp = (a + b + PSR_C);
- trace_input ("addcw", OP_CONSTANT4_1, OP_REG, OP_VOID);
- SET_GPR (OP[1], tmp);
- SET_PSR_C (tmp > 0xFFFF);
- SET_PSR_F (((a & 0x8000) == (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
- trace_output_16 (tmp);
- }
- /* addcw. */
- void
- OP_36B_C (void)
- {
- int16 a = OP[0];
- uint16 b = GPR (OP[1]);
- uint16 tmp = (a + b + PSR_C);
- trace_input ("addcw", OP_CONSTANT16, OP_REG, OP_VOID);
- SET_GPR (OP[1], tmp);
- SET_PSR_C (tmp > 0xFFFF);
- SET_PSR_F (((a & 0x8000) == (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
- trace_output_16 (tmp);
- }
- /* addcw. */
- void
- OP_37_8 (void)
- {
- uint16 a = GPR (OP[1]);
- uint16 b = GPR (OP[1]);
- uint16 tmp = (a + b + PSR_C);
- trace_input ("addcw", OP_REG, OP_REG, OP_VOID);
- SET_GPR (OP[1], tmp);
- SET_PSR_C (tmp > 0xFFFF);
- SET_PSR_F (((a & 0x8000) == (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
- trace_output_16 (tmp);
- }
- /* addd. */
- void
- OP_60_8 (void)
- {
- int16 a = (OP[0]);
- uint32 b = GPR32 (OP[1]);
- uint32 tmp = (a + b);
- trace_input ("addd", OP_CONSTANT4_1, OP_REGP, OP_VOID);
- SET_GPR32 (OP[1], tmp);
- SET_PSR_C (tmp > 0xFFFFFFFF);
- SET_PSR_F (((a & 0x80000000) == (b & 0x80000000)) && ((b & 0x80000000) != (tmp & 0x80000000)));
- trace_output_32 (tmp);
- }
- /* addd. */
- void
- OP_60B_C (void)
- {
- int32 a = (SEXT16(OP[0]));
- uint32 b = GPR32 (OP[1]);
- uint32 tmp = (a + b);
- trace_input ("addd", OP_CONSTANT16, OP_REGP, OP_VOID);
- SET_GPR32 (OP[1], tmp);
- SET_PSR_C (tmp > 0xFFFFFFFF);
- SET_PSR_F (((a & 0x80000000) == (b & 0x80000000)) && ((b & 0x80000000) != (tmp & 0x80000000)));
- trace_output_32 (tmp);
- }
- /* addd. */
- void
- OP_61_8 (void)
- {
- uint32 a = GPR32 (OP[0]);
- uint32 b = GPR32 (OP[1]);
- uint32 tmp = (a + b);
- trace_input ("addd", OP_REGP, OP_REGP, OP_VOID);
- SET_GPR32 (OP[1], tmp);
- trace_output_32 (tmp);
- SET_PSR_C (tmp > 0xFFFFFFFF);
- SET_PSR_F (((a & 0x80000000) == (b & 0x80000000)) && ((b & 0x80000000) != (tmp & 0x80000000)));
- }
- /* addd. */
- void
- OP_4_8 (void)
- {
- uint32 a = OP[0];
- uint32 b = GPR32 (OP[1]);
- uint32 tmp;
- trace_input ("addd", OP_CONSTANT20, OP_REGP, OP_VOID);
- tmp = (a + b);
- SET_GPR32 (OP[1], tmp);
- SET_PSR_C (tmp > 0xFFFFFFFF);
- SET_PSR_F (((a & 0x80000000) == (b & 0x80000000)) && ((b & 0x80000000) != (tmp & 0x80000000)));
- trace_output_32 (tmp);
- }
- /* addd. */
- void
- OP_2_C (void)
- {
- int32 a = OP[0];
- uint32 b = GPR32 (OP[1]);
- uint32 tmp;
- trace_input ("addd", OP_CONSTANT32, OP_REGP, OP_VOID);
- tmp = (a + b);
- SET_GPR32 (OP[1], tmp);
- SET_PSR_C (tmp > 0xFFFFFFFF);
- SET_PSR_F (((a & 0x80000000) == (b & 0x80000000)) && ((b & 0x80000000) != (tmp & 0x80000000)));
- trace_output_32 (tmp);
- }
- /* andb. */
- void
- OP_20_8 (void)
- {
- uint8 tmp, a = (OP[0]) & 0xff, b = (GPR (OP[1])) & 0xff;
- trace_input ("andb", OP_CONSTANT4, OP_REG, OP_VOID);
- tmp = a & b;
- SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
- trace_output_16 (tmp);
- }
- /* andb. */
- void
- OP_20B_C (void)
- {
- uint8 tmp, a = (OP[0]) & 0xff, b = (GPR (OP[1])) & 0xff;
- trace_input ("andb", OP_CONSTANT16, OP_REG, OP_VOID);
- tmp = a & b;
- SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
- trace_output_16 (tmp);
- }
- /* andb. */
- void
- OP_21_8 (void)
- {
- uint8 tmp, a = (GPR (OP[0])) & 0xff, b = (GPR (OP[1])) & 0xff;
- trace_input ("andb", OP_REG, OP_REG, OP_VOID);
- tmp = a & b;
- SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
- trace_output_16 (tmp);
- }
- /* andw. */
- void
- OP_22_8 (void)
- {
- uint16 tmp, a = OP[0], b = GPR (OP[1]);
- trace_input ("andw", OP_CONSTANT4, OP_REG, OP_VOID);
- tmp = a & b;
- SET_GPR (OP[1], tmp);
- trace_output_16 (tmp);
- }
- /* andw. */
- void
- OP_22B_C (void)
- {
- uint16 tmp, a = OP[0], b = GPR (OP[1]);
- trace_input ("andw", OP_CONSTANT16, OP_REG, OP_VOID);
- tmp = a & b;
- SET_GPR (OP[1], tmp);
- trace_output_16 (tmp);
- }
- /* andw. */
- void
- OP_23_8 (void)
- {
- uint16 tmp, a = GPR (OP[0]), b = GPR (OP[1]);
- trace_input ("andw", OP_REG, OP_REG, OP_VOID);
- tmp = a & b;
- SET_GPR (OP[1], tmp);
- trace_output_16 (tmp);
- }
- /* andd. */
- void
- OP_4_C (void)
- {
- uint32 tmp, a = OP[0], b = GPR32 (OP[1]);
- trace_input ("andd", OP_CONSTANT32, OP_REGP, OP_VOID);
- tmp = a & b;
- SET_GPR32 (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* andd. */
- void
- OP_14B_14 (void)
- {
- uint32 tmp, a = (GPR32 (OP[0])), b = (GPR32 (OP[1]));
- trace_input ("andd", OP_REGP, OP_REGP, OP_VOID);
- tmp = a & b;
- SET_GPR32 (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* ord. */
- void
- OP_5_C (void)
- {
- uint32 tmp, a = (OP[0]), b = GPR32 (OP[1]);
- trace_input ("ord", OP_CONSTANT32, OP_REG, OP_VOID);
- tmp = a | b;
- SET_GPR32 (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* ord. */
- void
- OP_149_14 (void)
- {
- uint32 tmp, a = GPR32 (OP[0]), b = GPR32 (OP[1]);
- trace_input ("ord", OP_REGP, OP_REGP, OP_VOID);
- tmp = a | b;
- SET_GPR32 (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* xord. */
- void
- OP_6_C (void)
- {
- uint32 tmp, a = (OP[0]), b = GPR32 (OP[1]);
- trace_input ("xord", OP_CONSTANT32, OP_REG, OP_VOID);
- tmp = a ^ b;
- SET_GPR32 (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* xord. */
- void
- OP_14A_14 (void)
- {
- uint32 tmp, a = GPR32 (OP[0]), b = GPR32 (OP[1]);
- trace_input ("xord", OP_REGP, OP_REGP, OP_VOID);
- tmp = a ^ b;
- SET_GPR32 (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* b. */
- void
- OP_1_4 (void)
- {
- uint32 tmp = 0, cc = cond_stat (OP[0]);
- trace_input ("b", OP_CONSTANT4, OP_DISPE9, OP_VOID);
- if (cc)
- {
- if (sign_flag)
- tmp = (PC - (OP[1]));
- else
- tmp = (PC + (OP[1]));
- /* If the resulting PC value is less than 0x00_0000 or greater
- than 0xFF_FFFF, this instruction causes an IAD trap.*/
- if ((tmp < 0x000000) || (tmp > 0xFFFFFF))
- {
- State.exception = SIG_CR16_BUS;
- State.pc_changed = 1; /* Don't increment the PC. */
- trace_output_void ();
- return;
- }
- else
- JMP (tmp);
- }
- sign_flag = 0; /* Reset sign_flag. */
- trace_output_32 (tmp);
- }
- /* b. */
- void
- OP_18_8 (void)
- {
- uint32 tmp = 0, cc = cond_stat (OP[0]);
- trace_input ("b", OP_CONSTANT4, OP_DISP17, OP_VOID);
- if (cc)
- {
- if (sign_flag)
- tmp = (PC - OP[1]);
- else
- tmp = (PC + OP[1]);
- /* If the resulting PC value is less than 0x00_0000 or greater
- than 0xFF_FFFF, this instruction causes an IAD trap.*/
- if ((tmp < 0x000000) || (tmp > 0xFFFFFF))
- {
- State.exception = SIG_CR16_BUS;
- State.pc_changed = 1; /* Don't increment the PC. */
- trace_output_void ();
- return;
- }
- else
- JMP (tmp);
- }
- sign_flag = 0; /* Reset sign_flag. */
- trace_output_32 (tmp);
- }
- /* b. */
- void
- OP_10_10 (void)
- {
- uint32 tmp = 0, cc = cond_stat (OP[0]);
- trace_input ("b", OP_CONSTANT4, OP_DISP25, OP_VOID);
- if (cc)
- {
- if (sign_flag)
- tmp = (PC - (OP[1]));
- else
- tmp = (PC + (OP[1]));
- /* If the resulting PC value is less than 0x00_0000 or greater
- than 0xFF_FFFF, this instruction causes an IAD trap.*/
- if ((tmp < 0x000000) || (tmp > 0xFFFFFF))
- {
- State.exception = SIG_CR16_BUS;
- State.pc_changed = 1; /* Don't increment the PC. */
- trace_output_void ();
- return;
- }
- else
- JMP (tmp);
- }
- sign_flag = 0; /* Reset sign_flag. */
- trace_output_32 (tmp);
- }
- /* bal. */
- void
- OP_C0_8 (void)
- {
- uint32 tmp;
- trace_input ("bal", OP_REG, OP_DISP17, OP_VOID);
- tmp = ((PC + 4) >> 1); /* Store PC in RA register. */
- SET_GPR32 (14, tmp);
- if (sign_flag)
- tmp = (PC - (OP[1]));
- else
- tmp = (PC + (OP[1]));
- /* If the resulting PC value is less than 0x00_0000 or greater
- than 0xFF_FFFF, this instruction causes an IAD trap. */
- if ((tmp < 0x000000) || (tmp > 0xFFFFFF))
- {
- State.exception = SIG_CR16_BUS;
- State.pc_changed = 1; /* Don't increment the PC. */
- trace_output_void ();
- return;
- }
- else
- JMP (tmp);
- sign_flag = 0; /* Reset sign_flag. */
- trace_output_32 (tmp);
- }
- /* bal. */
- void
- OP_102_14 (void)
- {
- uint32 tmp;
- trace_input ("bal", OP_REGP, OP_DISP25, OP_VOID);
- tmp = (((PC) + 4) >> 1); /* Store PC in reg pair. */
- SET_GPR32 (OP[0], tmp);
- if (sign_flag)
- tmp = ((PC) - (OP[1]));
- else
- tmp = ((PC) + (OP[1]));
- /* If the resulting PC value is less than 0x00_0000 or greater
- than 0xFF_FFFF, this instruction causes an IAD trap.*/
- if ((tmp < 0x000000) || (tmp > 0xFFFFFF))
- {
- State.exception = SIG_CR16_BUS;
- State.pc_changed = 1; /* Don't increment the PC. */
- trace_output_void ();
- return;
- }
- else
- JMP (tmp);
- sign_flag = 0; /* Reset sign_flag. */
- trace_output_32 (tmp);
- }
- /* jal. */
- void
- OP_148_14 (void)
- {
- uint32 tmp;
- trace_input ("jal", OP_REGP, OP_REGP, OP_VOID);
- SET_GPR32 (OP[0], (((PC) + 4) >> 1)); /* Store next PC in RA */
- tmp = GPR32 (OP[1]);
- tmp = SEXT24(tmp << 1);
- /* If the resulting PC value is less than 0x00_0000 or greater
- than 0xFF_FFFF, this instruction causes an IAD trap.*/
- if ((tmp < 0x0) || (tmp > 0xFFFFFF))
- {
- State.exception = SIG_CR16_BUS;
- State.pc_changed = 1; /* Don't increment the PC. */
- trace_output_void ();
- return;
- }
- else
- JMP (tmp);
- trace_output_32 (tmp);
- }
- /* jal. */
- void
- OP_D_C (void)
- {
- uint32 tmp;
- trace_input ("jal", OP_REGP, OP_VOID, OP_VOID);
- SET_GPR32 (14, (((PC) + 2) >> 1)); /* Store next PC in RA */
- tmp = GPR32 (OP[0]);
- tmp = SEXT24(tmp << 1);
- /* If the resulting PC value is less than 0x00_0000 or greater
- than 0xFF_FFFF, this instruction causes an IAD trap.*/
- if ((tmp < 0x0) || (tmp > 0xFFFFFF))
- {
- State.exception = SIG_CR16_BUS;
- State.pc_changed = 1; /* Don't increment the PC. */
- trace_output_void ();
- return;
- }
- else
- JMP (tmp);
- trace_output_32 (tmp);
- }
- /* beq0b. */
- void
- OP_C_8 (void)
- {
- uint32 addr;
- uint8 a = (GPR (OP[0]) & 0xFF);
- trace_input ("beq0b", OP_REG, OP_DISP5, OP_VOID);
- addr = OP[1];
- if (a == 0)
- {
- if (sign_flag)
- addr = (PC - OP[1]);
- else
- addr = (PC + OP[1]);
- JMP (addr);
- }
- sign_flag = 0; /* Reset sign_flag. */
- trace_output_void ();
- }
- /* bne0b. */
- void
- OP_D_8 (void)
- {
- uint32 addr;
- uint8 a = (GPR (OP[0]) & 0xFF);
- trace_input ("bne0b", OP_REG, OP_DISP5, OP_VOID);
- addr = OP[1];
- if (a != 0)
- {
- if (sign_flag)
- addr = (PC - OP[1]);
- else
- addr = (PC + OP[1]);
- JMP (addr);
- }
- sign_flag = 0; /* Reset sign_flag. */
- trace_output_void ();
- }
- /* beq0w. */
- void
- OP_E_8 (void)
- {
- uint32 addr;
- uint16 a = GPR (OP[0]);
- trace_input ("beq0w", OP_REG, OP_DISP5, OP_VOID);
- addr = OP[1];
- if (a == 0)
- {
- if (sign_flag)
- addr = (PC - OP[1]);
- else
- addr = (PC + OP[1]);
- JMP (addr);
- }
- sign_flag = 0; /* Reset sign_flag. */
- trace_output_void ();
- }
- /* bne0w. */
- void
- OP_F_8 (void)
- {
- uint32 addr;
- uint16 a = GPR (OP[0]);
- trace_input ("bne0w", OP_REG, OP_DISP5, OP_VOID);
- addr = OP[1];
- if (a != 0)
- {
- if (sign_flag)
- addr = (PC - OP[1]);
- else
- addr = (PC + OP[1]);
- JMP (addr);
- }
- sign_flag = 0; /* Reset sign_flag. */
- trace_output_void ();
- }
- /* jeq. */
- void
- OP_A0_C (void)
- {
- uint32 tmp = 0;
- trace_input ("jeq", OP_REGP, OP_VOID, OP_VOID);
- if ((PSR_Z) == 1)
- {
- tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits. */
- JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit. */
- }
- trace_output_32 (tmp);
- }
- /* jne. */
- void
- OP_A1_C (void)
- {
- uint32 tmp = 0;
- trace_input ("jne", OP_REGP, OP_VOID, OP_VOID);
- if ((PSR_Z) == 0)
- {
- tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits. */
- JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit. */
- }
- trace_output_32 (tmp);
- }
- /* jcs. */
- void
- OP_A2_C (void)
- {
- uint32 tmp = 0;
- trace_input ("jcs", OP_REGP, OP_VOID, OP_VOID);
- if ((PSR_C) == 1)
- {
- tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
- JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
- }
- trace_output_32 (tmp);
- }
- /* jcc. */
- void
- OP_A3_C (void)
- {
- uint32 tmp = 0;
- trace_input ("jcc", OP_REGP, OP_VOID, OP_VOID);
- if ((PSR_C) == 0)
- {
- tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
- JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
- }
- trace_output_32 (tmp);
- }
- /* jhi. */
- void
- OP_A4_C (void)
- {
- uint32 tmp = 0;
- trace_input ("jhi", OP_REGP, OP_VOID, OP_VOID);
- if ((PSR_L) == 1)
- {
- tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
- JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
- }
- trace_output_32 (tmp);
- }
- /* jls. */
- void
- OP_A5_C (void)
- {
- uint32 tmp = 0;
- trace_input ("jls", OP_REGP, OP_VOID, OP_VOID);
- if ((PSR_L) == 0)
- {
- tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
- JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
- }
- trace_output_32 (tmp);
- }
- /* jgt. */
- void
- OP_A6_C (void)
- {
- uint32 tmp = 0;
- trace_input ("jgt", OP_REGP, OP_VOID, OP_VOID);
- if ((PSR_N) == 1)
- {
- tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
- JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
- }
- trace_output_32 (tmp);
- }
- /* jle. */
- void
- OP_A7_C (void)
- {
- uint32 tmp = 0;
- trace_input ("jle", OP_REGP, OP_VOID, OP_VOID);
- if ((PSR_N) == 0)
- {
- tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
- JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
- }
- trace_output_32 (tmp);
- }
- /* jfs. */
- void
- OP_A8_C (void)
- {
- uint32 tmp = 0;
- trace_input ("jfs", OP_REGP, OP_VOID, OP_VOID);
- if ((PSR_F) == 1)
- {
- tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
- JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
- }
- trace_output_32 (tmp);
- }
- /* jfc. */
- void
- OP_A9_C (void)
- {
- uint32 tmp = 0;
- trace_input ("jfc", OP_REGP, OP_VOID, OP_VOID);
- if ((PSR_F) == 0)
- {
- tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
- JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
- }
- trace_output_32 (tmp);
- }
- /* jlo. */
- void
- OP_AA_C (void)
- {
- uint32 tmp = 0;
- trace_input ("jlo", OP_REGP, OP_VOID, OP_VOID);
- if (((PSR_Z) == 0) & ((PSR_L) == 0))
- {
- tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
- JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
- }
- trace_output_32 (tmp);
- }
- /* jhs. */
- void
- OP_AB_C (void)
- {
- uint32 tmp = 0;
- trace_input ("jhs", OP_REGP, OP_VOID, OP_VOID);
- if (((PSR_Z) == 1) | ((PSR_L) == 1))
- {
- tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
- JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
- }
- trace_output_32 (tmp);
- }
- /* jlt. */
- void
- OP_AC_C (void)
- {
- uint32 tmp = 0;
- trace_input ("jlt", OP_REGP, OP_VOID, OP_VOID);
- if (((PSR_Z) == 0) & ((PSR_N) == 0))
- {
- tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
- JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
- }
- trace_output_32 (tmp);
- }
- /* jge. */
- void
- OP_AD_C (void)
- {
- uint32 tmp = 0;
- trace_input ("jge", OP_REGP, OP_VOID, OP_VOID);
- if (((PSR_Z) == 1) | ((PSR_N) == 1))
- {
- tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
- JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
- }
- trace_output_32 (tmp);
- }
- /* jump. */
- void
- OP_AE_C (void)
- {
- uint32 tmp;
- trace_input ("jump", OP_REGP, OP_VOID, OP_VOID);
- tmp = GPR32 (OP[0]) /*& 0x3fffff*/; /* Use only 0 - 22 bits */
- JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
- trace_output_32 (tmp);
- }
- /* jusr. */
- void
- OP_AF_C (void)
- {
- uint32 tmp;
- trace_input ("jusr", OP_REGP, OP_VOID, OP_VOID);
- tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
- JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
- SET_PSR_U(1);
- trace_output_32 (tmp);
- }
- /* seq. */
- void
- OP_80_C (void)
- {
- trace_input ("seq", OP_REG, OP_VOID, OP_VOID);
- if ((PSR_Z) == 1)
- SET_GPR (OP[0], 1);
- else
- SET_GPR (OP[0], 0);
- trace_output_void ();
- }
- /* sne. */
- void
- OP_81_C (void)
- {
- trace_input ("sne", OP_REG, OP_VOID, OP_VOID);
- if ((PSR_Z) == 0)
- SET_GPR (OP[0], 1);
- else
- SET_GPR (OP[0], 0);
- trace_output_void ();
- }
- /* scs. */
- void
- OP_82_C (void)
- {
- trace_input ("scs", OP_REG, OP_VOID, OP_VOID);
- if ((PSR_C) == 1)
- SET_GPR (OP[0], 1);
- else
- SET_GPR (OP[0], 0);
- trace_output_void ();
- }
- /* scc. */
- void
- OP_83_C (void)
- {
- trace_input ("scc", OP_REG, OP_VOID, OP_VOID);
- if ((PSR_C) == 0)
- SET_GPR (OP[0], 1);
- else
- SET_GPR (OP[0], 0);
- trace_output_void ();
- }
- /* shi. */
- void
- OP_84_C (void)
- {
- trace_input ("shi", OP_REG, OP_VOID, OP_VOID);
- if ((PSR_L) == 1)
- SET_GPR (OP[0], 1);
- else
- SET_GPR (OP[0], 0);
- trace_output_void ();
- }
- /* sls. */
- void
- OP_85_C (void)
- {
- trace_input ("sls", OP_REG, OP_VOID, OP_VOID);
- if ((PSR_L) == 0)
- SET_GPR (OP[0], 1);
- else
- SET_GPR (OP[0], 0);
- trace_output_void ();
- }
- /* sgt. */
- void
- OP_86_C (void)
- {
- trace_input ("sgt", OP_REG, OP_VOID, OP_VOID);
- if ((PSR_N) == 1)
- SET_GPR (OP[0], 1);
- else
- SET_GPR (OP[0], 0);
- trace_output_void ();
- }
- /* sle. */
- void
- OP_87_C (void)
- {
- trace_input ("sle", OP_REG, OP_VOID, OP_VOID);
- if ((PSR_N) == 0)
- SET_GPR (OP[0], 1);
- else
- SET_GPR (OP[0], 0);
- trace_output_void ();
- }
- /* sfs. */
- void
- OP_88_C (void)
- {
- trace_input ("sfs", OP_REG, OP_VOID, OP_VOID);
- if ((PSR_F) == 1)
- SET_GPR (OP[0], 1);
- else
- SET_GPR (OP[0], 0);
- trace_output_void ();
- }
- /* sfc. */
- void
- OP_89_C (void)
- {
- trace_input ("sfc", OP_REG, OP_VOID, OP_VOID);
- if ((PSR_F) == 0)
- SET_GPR (OP[0], 1);
- else
- SET_GPR (OP[0], 0);
- trace_output_void ();
- }
- /* slo. */
- void
- OP_8A_C (void)
- {
- trace_input ("slo", OP_REG, OP_VOID, OP_VOID);
- if (((PSR_Z) == 0) & ((PSR_L) == 0))
- SET_GPR (OP[0], 1);
- else
- SET_GPR (OP[0], 0);
- trace_output_void ();
- }
- /* shs. */
- void
- OP_8B_C (void)
- {
- trace_input ("shs", OP_REG, OP_VOID, OP_VOID);
- if ( ((PSR_Z) == 1) | ((PSR_L) == 1))
- SET_GPR (OP[0], 1);
- else
- SET_GPR (OP[0], 0);
- trace_output_void ();
- }
- /* slt. */
- void
- OP_8C_C (void)
- {
- trace_input ("slt", OP_REG, OP_VOID, OP_VOID);
- if (((PSR_Z) == 0) & ((PSR_N) == 0))
- SET_GPR (OP[0], 1);
- else
- SET_GPR (OP[0], 0);
- trace_output_void ();
- }
- /* sge. */
- void
- OP_8D_C (void)
- {
- trace_input ("sge", OP_REG, OP_VOID, OP_VOID);
- if (((PSR_Z) == 1) | ((PSR_N) == 1))
- SET_GPR (OP[0], 1);
- else
- SET_GPR (OP[0], 0);
- trace_output_void ();
- }
- /* cbitb. */
- void
- OP_D7_9 (void)
- {
- uint8 a = OP[0] & 0xff;
- uint32 addr = OP[1], tmp;
- trace_input ("cbitb", OP_CONSTANT4, OP_ABS20_OUTPUT, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp & ~(1 << a);
- SB (addr, tmp);
- trace_output_32 (tmp);
- }
- /* cbitb. */
- void
- OP_107_14 (void)
- {
- uint8 a = OP[0] & 0xff;
- uint32 addr = OP[1], tmp;
- trace_input ("cbitb", OP_CONSTANT4, OP_ABS24_OUTPUT, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp & ~(1 << a);
- SB (addr, tmp);
- trace_output_32 (tmp);
- }
- /* cbitb. */
- void
- OP_68_8 (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint32 addr = (GPR (OP[2])) + OP[1], tmp;
- trace_input ("cbitb", OP_CONSTANT4, OP_R_INDEX7_ABS20, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp & ~(1 << a);
- SB (addr, tmp);
- trace_output_32 (addr);
- }
- /* cbitb. */
- void
- OP_1AA_A (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("cbitb", OP_CONSTANT4, OP_RP_INDEX_DISP14, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp & ~(1 << a);
- SB (addr, tmp);
- trace_output_32 (addr);
- }
- /* cbitb. */
- void
- OP_104_14 (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint32 addr = (GPR (OP[2])) + OP[1], tmp;
- trace_input ("cbitb", OP_CONSTANT4, OP_R_BASE_DISPS20, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp & ~(1 << a);
- SB (addr, tmp);
- trace_output_32 (addr);
- }
- /* cbitb. */
- void
- OP_D4_9 (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("cbitb", OP_CONSTANT4, OP_RP_INDEX_DISP0, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp & ~(1 << a);
- SB (addr, tmp);
- trace_output_32 (addr);
- }
- /* cbitb. */
- void
- OP_D6_9 (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("cbitb", OP_CONSTANT4, OP_RP_BASE_DISP16, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp & ~(1 << a);
- SB (addr, tmp);
- trace_output_32 (addr);
- }
- /* cbitb. */
- void
- OP_105_14 (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("cbitb", OP_CONSTANT4, OP_RP_BASE_DISPS20, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp & ~(1 << a);
- SB (addr, tmp);
- trace_output_32 (addr);
- }
- /* cbitb. */
- void
- OP_106_14 (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("cbitb", OP_CONSTANT4, OP_RP_INDEX_DISPS20, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp & ~(1 << a);
- SB (addr, tmp);
- trace_output_32 (addr);
- }
- /* cbitw. */
- void
- OP_6F_8 (void)
- {
- uint16 a = OP[0];
- uint32 addr = OP[1], tmp;
- trace_input ("cbitw", OP_CONSTANT4, OP_ABS20_OUTPUT, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp & ~(1 << a);
- SW (addr, tmp);
- trace_output_32 (tmp);
- }
- /* cbitw. */
- void
- OP_117_14 (void)
- {
- uint16 a = OP[0];
- uint32 addr = OP[1], tmp;
- trace_input ("cbitw", OP_CONSTANT4, OP_ABS24_OUTPUT, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp & ~(1 << a);
- SW (addr, tmp);
- trace_output_32 (tmp);
- }
- /* cbitw. */
- void
- OP_36_7 (void)
- {
- uint32 addr;
- uint16 a = (OP[0]), tmp;
- trace_input ("cbitw", OP_CONSTANT4, OP_R_INDEX8_ABS20, OP_VOID);
- if (OP[1] == 0)
- addr = (GPR32 (12)) + OP[2];
- else
- addr = (GPR32 (13)) + OP[2];
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp & ~(1 << a);
- SW (addr, tmp);
- trace_output_32 (addr);
- }
- /* cbitw. */
- void
- OP_1AB_A (void)
- {
- uint16 a = (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("cbitw", OP_CONSTANT4, OP_RP_INDEX_DISP14, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp & ~(1 << a);
- SW (addr, tmp);
- trace_output_32 (addr);
- }
- /* cbitw. */
- void
- OP_114_14 (void)
- {
- uint16 a = (OP[0]);
- uint32 addr = (GPR (OP[2])) + OP[1], tmp;
- trace_input ("cbitw", OP_CONSTANT4, OP_R_BASE_DISPS20, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp & ~(1 << a);
- SW (addr, tmp);
- trace_output_32 (addr);
- }
- /* cbitw. */
- void
- OP_6E_8 (void)
- {
- uint16 a = (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("cbitw", OP_CONSTANT4, OP_RP_INDEX_DISP0, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp & ~(1 << a);
- SW (addr, tmp);
- trace_output_32 (addr);
- }
- /* cbitw. */
- void
- OP_69_8 (void)
- {
- uint16 a = (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("cbitw", OP_CONSTANT4, OP_RP_BASE_DISP16, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp & ~(1 << a);
- SW (addr, tmp);
- trace_output_32 (addr);
- }
- /* cbitw. */
- void
- OP_115_14 (void)
- {
- uint16 a = (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("cbitw", OP_CONSTANT4, OP_RP_BASE_DISPS20, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp & ~(1 << a);
- SW (addr, tmp);
- trace_output_32 (addr);
- }
- /* cbitw. */
- void
- OP_116_14 (void)
- {
- uint16 a = (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("cbitw", OP_CONSTANT4, OP_RP_INDEX_DISPS20, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp & ~(1 << a);
- SW (addr, tmp);
- trace_output_32 (addr);
- }
- /* sbitb. */
- void
- OP_E7_9 (void)
- {
- uint8 a = OP[0] & 0xff;
- uint32 addr = OP[1], tmp;
- trace_input ("sbitb", OP_CONSTANT4, OP_ABS20_OUTPUT, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp | (1 << a);
- SB (addr, tmp);
- trace_output_32 (tmp);
- }
- /* sbitb. */
- void
- OP_10B_14 (void)
- {
- uint8 a = OP[0] & 0xff;
- uint32 addr = OP[1], tmp;
- trace_input ("sbitb", OP_CONSTANT4, OP_ABS24_OUTPUT, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp | (1 << a);
- SB (addr, tmp);
- trace_output_32 (tmp);
- }
- /* sbitb. */
- void
- OP_70_8 (void)
- {
- uint8 a = OP[0] & 0xff;
- uint32 addr = (GPR (OP[2])) + OP[1], tmp;
- trace_input ("sbitb", OP_CONSTANT4, OP_R_INDEX7_ABS20, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp | (1 << a);
- SB (addr, tmp);
- trace_output_32 (tmp);
- }
- /* sbitb. */
- void
- OP_1CA_A (void)
- {
- uint8 a = OP[0] & 0xff;
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("sbitb", OP_CONSTANT4, OP_RP_INDEX_DISP14, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp | (1 << a);
- SB (addr, tmp);
- trace_output_32 (tmp);
- }
- /* sbitb. */
- void
- OP_108_14 (void)
- {
- uint8 a = OP[0] & 0xff;
- uint32 addr = (GPR (OP[2])) + OP[1], tmp;
- trace_input ("sbitb", OP_CONSTANT4, OP_R_BASE_DISPS20, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp | (1 << a);
- SB (addr, tmp);
- trace_output_32 (tmp);
- }
- /* sbitb. */
- void
- OP_E4_9 (void)
- {
- uint8 a = OP[0] & 0xff;
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("sbitb", OP_CONSTANT4, OP_RP_INDEX_DISP0, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp | (1 << a);
- SB (addr, tmp);
- trace_output_32 (tmp);
- }
- /* sbitb. */
- void
- OP_E6_9 (void)
- {
- uint8 a = OP[0] & 0xff;
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("sbitb", OP_CONSTANT4, OP_RP_BASE_DISP16, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp | (1 << a);
- SB (addr, tmp);
- trace_output_32 (tmp);
- }
- /* sbitb. */
- void
- OP_109_14 (void)
- {
- uint8 a = OP[0] & 0xff;
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("sbitb", OP_CONSTANT4, OP_RP_BASE_DISPS20, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp | (1 << a);
- SB (addr, tmp);
- trace_output_32 (tmp);
- }
- /* sbitb. */
- void
- OP_10A_14 (void)
- {
- uint8 a = OP[0] & 0xff;
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("sbitb", OP_CONSTANT4, OP_RP_INDEX_DISPS20, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp | (1 << a);
- SB (addr, tmp);
- trace_output_32 (tmp);
- }
- /* sbitw. */
- void
- OP_77_8 (void)
- {
- uint16 a = OP[0];
- uint32 addr = OP[1], tmp;
- trace_input ("sbitw", OP_CONSTANT4, OP_ABS20_OUTPUT, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp | (1 << a);
- SW (addr, tmp);
- trace_output_32 (tmp);
- }
- /* sbitw. */
- void
- OP_11B_14 (void)
- {
- uint16 a = OP[0];
- uint32 addr = OP[1], tmp;
- trace_input ("sbitw", OP_CONSTANT4, OP_ABS24_OUTPUT, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp | (1 << a);
- SW (addr, tmp);
- trace_output_32 (tmp);
- }
- /* sbitw. */
- void
- OP_3A_7 (void)
- {
- uint32 addr;
- uint16 a = (OP[0]), tmp;
- trace_input ("sbitw", OP_CONSTANT4, OP_R_INDEX8_ABS20, OP_VOID);
- if (OP[1] == 0)
- addr = (GPR32 (12)) + OP[2];
- else
- addr = (GPR32 (13)) + OP[2];
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp | (1 << a);
- SW (addr, tmp);
- trace_output_32 (addr);
- }
- /* sbitw. */
- void
- OP_1CB_A (void)
- {
- uint16 a = (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("sbitw", OP_CONSTANT4, OP_RP_INDEX_DISP14, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp | (1 << a);
- SW (addr, tmp);
- trace_output_32 (addr);
- }
- /* sbitw. */
- void
- OP_118_14 (void)
- {
- uint16 a = (OP[0]);
- uint32 addr = (GPR (OP[2])) + OP[1], tmp;
- trace_input ("sbitw", OP_CONSTANT4, OP_R_BASE_DISPS20, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp | (1 << a);
- SW (addr, tmp);
- trace_output_32 (addr);
- }
- /* sbitw. */
- void
- OP_76_8 (void)
- {
- uint16 a = (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("sbitw", OP_CONSTANT4, OP_RP_INDEX_DISP0, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp | (1 << a);
- SW (addr, tmp);
- trace_output_32 (addr);
- }
- /* sbitw. */
- void
- OP_71_8 (void)
- {
- uint16 a = (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("sbitw", OP_CONSTANT4, OP_RP_BASE_DISP16, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp | (1 << a);
- SW (addr, tmp);
- trace_output_32 (addr);
- }
- /* sbitw. */
- void
- OP_119_14 (void)
- {
- uint16 a = (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("sbitw", OP_CONSTANT4, OP_RP_BASE_DISPS20, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp | (1 << a);
- SW (addr, tmp);
- trace_output_32 (addr);
- }
- /* sbitw. */
- void
- OP_11A_14 (void)
- {
- uint16 a = (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("sbitw", OP_CONSTANT4, OP_RP_INDEX_DISPS20, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- tmp = tmp | (1 << a);
- SW (addr, tmp);
- trace_output_32 (addr);
- }
- /* tbitb. */
- void
- OP_F7_9 (void)
- {
- uint8 a = OP[0] & 0xff;
- uint32 addr = OP[1], tmp;
- trace_input ("tbitb", OP_CONSTANT4, OP_ABS20_OUTPUT, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- trace_output_32 (tmp);
- }
- /* tbitb. */
- void
- OP_10F_14 (void)
- {
- uint8 a = OP[0] & 0xff;
- uint32 addr = OP[1], tmp;
- trace_input ("tbitb", OP_CONSTANT4, OP_ABS24_OUTPUT, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- trace_output_32 (tmp);
- }
- /* tbitb. */
- void
- OP_78_8 (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint32 addr = (GPR (OP[2])) + OP[1], tmp;
- trace_input ("tbitb", OP_CONSTANT4, OP_R_INDEX7_ABS20, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- trace_output_32 (addr);
- }
- /* tbitb. */
- void
- OP_1EA_A (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("tbitb", OP_CONSTANT4, OP_RP_INDEX_DISP14, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- trace_output_32 (addr);
- }
- /* tbitb. */
- void
- OP_10C_14 (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint32 addr = (GPR (OP[2])) + OP[1], tmp;
- trace_input ("tbitb", OP_CONSTANT4, OP_R_BASE_DISPS20, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- trace_output_32 (addr);
- }
- /* tbitb. */
- void
- OP_F4_9 (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("tbitb", OP_CONSTANT4, OP_RP_INDEX_DISP0, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- trace_output_32 (addr);
- }
- /* tbitb. */
- void
- OP_F6_9 (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("tbitb", OP_CONSTANT4, OP_RP_BASE_DISP16, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- trace_output_32 (addr);
- }
- /* tbitb. */
- void
- OP_10D_14 (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("tbitb", OP_CONSTANT4, OP_RP_BASE_DISPS20, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- trace_output_32 (addr);
- }
- /* tbitb. */
- void
- OP_10E_14 (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("tbitb", OP_CONSTANT4, OP_RP_INDEX_DISPS20, OP_VOID);
- tmp = RB (addr);
- SET_PSR_F (tmp & (1 << a));
- trace_output_32 (addr);
- }
- /* tbitw. */
- void
- OP_7F_8 (void)
- {
- uint16 a = OP[0];
- uint32 addr = OP[1], tmp;
- trace_input ("tbitw", OP_CONSTANT4, OP_ABS20_OUTPUT, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- trace_output_32 (tmp);
- }
- /* tbitw. */
- void
- OP_11F_14 (void)
- {
- uint16 a = OP[0];
- uint32 addr = OP[1], tmp;
- trace_input ("tbitw", OP_CONSTANT4, OP_ABS24_OUTPUT, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- trace_output_32 (tmp);
- }
- /* tbitw. */
- void
- OP_3E_7 (void)
- {
- uint32 addr;
- uint16 a = (OP[0]), tmp;
- trace_input ("tbitw", OP_CONSTANT4, OP_R_INDEX8_ABS20, OP_VOID);
- if (OP[1] == 0)
- addr = (GPR32 (12)) + OP[2];
- else
- addr = (GPR32 (13)) + OP[2];
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- trace_output_32 (addr);
- }
- /* tbitw. */
- void
- OP_1EB_A (void)
- {
- uint16 a = (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("tbitw", OP_CONSTANT4, OP_RP_INDEX_DISP14, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- trace_output_32 (addr);
- }
- /* tbitw. */
- void
- OP_11C_14 (void)
- {
- uint16 a = (OP[0]);
- uint32 addr = (GPR (OP[2])) + OP[1], tmp;
- trace_input ("tbitw", OP_CONSTANT4, OP_R_BASE_DISPS20, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- trace_output_32 (addr);
- }
- /* tbitw. */
- void
- OP_7E_8 (void)
- {
- uint16 a = (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("tbitw", OP_CONSTANT4, OP_RP_INDEX_DISP0, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- trace_output_32 (addr);
- }
- /* tbitw. */
- void
- OP_79_8 (void)
- {
- uint16 a = (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("tbitw", OP_CONSTANT4, OP_RP_BASE_DISP16, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- trace_output_32 (addr);
- }
- /* tbitw. */
- void
- OP_11D_14 (void)
- {
- uint16 a = (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("tbitw", OP_CONSTANT4, OP_RP_BASE_DISPS20, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- trace_output_32 (addr);
- }
- /* tbitw. */
- void
- OP_11E_14 (void)
- {
- uint16 a = (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1], tmp;
- trace_input ("tbitw", OP_CONSTANT4, OP_RP_INDEX_DISPS20, OP_VOID);
- tmp = RW (addr);
- SET_PSR_F (tmp & (1 << a));
- trace_output_32 (addr);
- }
- /* tbit. */
- void
- OP_6_8 (void)
- {
- uint16 a = OP[0];
- uint16 b = (GPR (OP[1]));
- trace_input ("tbit", OP_CONSTANT4, OP_REG, OP_VOID);
- SET_PSR_F (b & (1 << a));
- trace_output_16 (b);
- }
- /* tbit. */
- void
- OP_7_8 (void)
- {
- uint16 a = GPR (OP[0]);
- uint16 b = (GPR (OP[1]));
- trace_input ("tbit", OP_REG, OP_REG, OP_VOID);
- SET_PSR_F (b & (1 << a));
- trace_output_16 (b);
- }
- /* cmpb. */
- void
- OP_50_8 (void)
- {
- uint8 a = (OP[0]) & 0xFF;
- uint8 b = (GPR (OP[1])) & 0xFF;
- trace_input ("cmpb", OP_CONSTANT4, OP_REG, OP_VOID);
- SET_PSR_Z (a == b);
- SET_PSR_N ((int8)a > (int8)b);
- SET_PSR_L (a > b);
- trace_output_flag ();
- }
- /* cmpb. */
- void
- OP_50B_C (void)
- {
- uint8 a = (OP[0]) & 0xFF;
- uint8 b = (GPR (OP[1])) & 0xFF;
- trace_input ("cmpb", OP_CONSTANT16, OP_REG, OP_VOID);
- SET_PSR_Z (a == b);
- SET_PSR_N ((int8)a > (int8)b);
- SET_PSR_L (a > b);
- trace_output_flag ();
- }
- /* cmpb. */
- void
- OP_51_8 (void)
- {
- uint8 a = (GPR (OP[0])) & 0xFF;
- uint8 b = (GPR (OP[1])) & 0xFF;
- trace_input ("cmpb", OP_REG, OP_REG, OP_VOID);
- SET_PSR_Z (a == b);
- SET_PSR_N ((int8)a > (int8)b);
- SET_PSR_L (a > b);
- trace_output_flag ();
- }
- /* cmpw. */
- void
- OP_52_8 (void)
- {
- uint16 a = (OP[0]);
- uint16 b = GPR (OP[1]);
- trace_input ("cmpw", OP_CONSTANT4, OP_REG, OP_VOID);
- SET_PSR_Z (a == b);
- SET_PSR_N ((int16)a > (int16)b);
- SET_PSR_L (a > b);
- trace_output_flag ();
- }
- /* cmpw. */
- void
- OP_52B_C (void)
- {
- uint16 a = (OP[0]);
- uint16 b = GPR (OP[1]);
- trace_input ("cmpw", OP_CONSTANT16, OP_REG, OP_VOID);
- SET_PSR_Z (a == b);
- SET_PSR_N ((int16)a > (int16)b);
- SET_PSR_L (a > b);
- trace_output_flag ();
- }
- /* cmpw. */
- void
- OP_53_8 (void)
- {
- uint16 a = GPR (OP[0]) ;
- uint16 b = GPR (OP[1]) ;
- trace_input ("cmpw", OP_REG, OP_REG, OP_VOID);
- SET_PSR_Z (a == b);
- SET_PSR_N ((int16)a > (int16)b);
- SET_PSR_L (a > b);
- trace_output_flag ();
- }
- /* cmpd. */
- void
- OP_56_8 (void)
- {
- uint32 a = (OP[0]);
- uint32 b = GPR32 (OP[1]);
- trace_input ("cmpd", OP_CONSTANT4, OP_REGP, OP_VOID);
- SET_PSR_Z (a == b);
- SET_PSR_N ((int32)a > (int32)b);
- SET_PSR_L (a > b);
- trace_output_flag ();
- }
- /* cmpd. */
- void
- OP_56B_C (void)
- {
- uint32 a = (SEXT16(OP[0]));
- uint32 b = GPR32 (OP[1]);
- trace_input ("cmpd", OP_CONSTANT16, OP_REGP, OP_VOID);
- SET_PSR_Z (a == b);
- SET_PSR_N ((int32)a > (int32)b);
- SET_PSR_L (a > b);
- trace_output_flag ();
- }
- /* cmpd. */
- void
- OP_57_8 (void)
- {
- uint32 a = GPR32 (OP[0]) ;
- uint32 b = GPR32 (OP[1]) ;
- trace_input ("cmpd", OP_REGP, OP_REGP, OP_VOID);
- SET_PSR_Z (a == b);
- SET_PSR_N ((int32)a > (int32)b);
- SET_PSR_L (a > b);
- trace_output_flag ();
- }
- /* cmpd. */
- void
- OP_9_C (void)
- {
- uint32 a = (OP[0]);
- uint32 b = GPR32 (OP[1]);
- trace_input ("cmpd", OP_CONSTANT32, OP_REGP, OP_VOID);
- SET_PSR_Z (a == b);
- SET_PSR_N ((int32)a > (int32)b);
- SET_PSR_L (a > b);
- trace_output_flag ();
- }
- /* movb. */
- void
- OP_58_8 (void)
- {
- uint8 tmp = OP[0] & 0xFF;
- uint16 a = (GPR (OP[1])) & 0xFF00;
- trace_input ("movb", OP_CONSTANT4, OP_REG, OP_VOID);
- SET_GPR (OP[1], (a | tmp));
- trace_output_16 (tmp);
- }
- /* movb. */
- void
- OP_58B_C (void)
- {
- uint8 tmp = OP[0] & 0xFF;
- uint16 a = (GPR (OP[1])) & 0xFF00;
- trace_input ("movb", OP_CONSTANT16, OP_REG, OP_VOID);
- SET_GPR (OP[1], (a | tmp));
- trace_output_16 (tmp);
- }
- /* movb. */
- void
- OP_59_8 (void)
- {
- uint8 tmp = (GPR (OP[0])) & 0xFF;
- uint16 a = (GPR (OP[1])) & 0xFF00;
- trace_input ("movb", OP_REG, OP_REG, OP_VOID);
- SET_GPR (OP[1], (a | tmp));
- trace_output_16 (tmp);
- }
- /* movw. */
- void
- OP_5A_8 (void)
- {
- uint16 tmp = OP[0];
- trace_input ("movw", OP_CONSTANT4_1, OP_REG, OP_VOID);
- SET_GPR (OP[1], (tmp & 0xffff));
- trace_output_16 (tmp);
- }
- /* movw. */
- void
- OP_5AB_C (void)
- {
- int16 tmp = OP[0];
- trace_input ("movw", OP_CONSTANT16, OP_REG, OP_VOID);
- SET_GPR (OP[1], (tmp & 0xffff));
- trace_output_16 (tmp);
- }
- /* movw. */
- void
- OP_5B_8 (void)
- {
- uint16 tmp = GPR (OP[0]);
- uint32 a = GPR32 (OP[1]);
- trace_input ("movw", OP_REG, OP_REGP, OP_VOID);
- a = (a & 0xffff0000) | tmp;
- SET_GPR32 (OP[1], a);
- trace_output_16 (tmp);
- }
- /* movxb. */
- void
- OP_5C_8 (void)
- {
- uint8 tmp = (GPR (OP[0])) & 0xFF;
- trace_input ("movxb", OP_REG, OP_REG, OP_VOID);
- SET_GPR (OP[1], ((SEXT8(tmp)) & 0xffff));
- trace_output_16 (tmp);
- }
- /* movzb. */
- void
- OP_5D_8 (void)
- {
- uint8 tmp = (GPR (OP[0])) & 0xFF;
- trace_input ("movzb", OP_REG, OP_REG, OP_VOID);
- SET_GPR (OP[1], tmp);
- trace_output_16 (tmp);
- }
- /* movxw. */
- void
- OP_5E_8 (void)
- {
- uint16 tmp = GPR (OP[0]);
- trace_input ("movxw", OP_REG, OP_REGP, OP_VOID);
- SET_GPR32 (OP[1], SEXT16(tmp));
- trace_output_16 (tmp);
- }
- /* movzw. */
- void
- OP_5F_8 (void)
- {
- uint16 tmp = GPR (OP[0]);
- trace_input ("movzw", OP_REG, OP_REGP, OP_VOID);
- SET_GPR32 (OP[1], (tmp & 0x0000FFFF));
- trace_output_16 (tmp);
- }
- /* movd. */
- void
- OP_54_8 (void)
- {
- int32 tmp = OP[0];
- trace_input ("movd", OP_CONSTANT4, OP_REGP, OP_VOID);
- SET_GPR32 (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* movd. */
- void
- OP_54B_C (void)
- {
- int32 tmp = SEXT16(OP[0]);
- trace_input ("movd", OP_CONSTANT16, OP_REGP, OP_VOID);
- SET_GPR32 (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* movd. */
- void
- OP_55_8 (void)
- {
- uint32 tmp = GPR32 (OP[0]);
- trace_input ("movd", OP_REGP, OP_REGP, OP_VOID);
- SET_GPR32 (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* movd. */
- void
- OP_5_8 (void)
- {
- uint32 tmp = OP[0];
- trace_input ("movd", OP_CONSTANT20, OP_REGP, OP_VOID);
- SET_GPR32 (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* movd. */
- void
- OP_7_C (void)
- {
- int32 tmp = OP[0];
- trace_input ("movd", OP_CONSTANT32, OP_REGP, OP_VOID);
- SET_GPR32 (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* loadm. */
- void
- OP_14_D (void)
- {
- uint32 addr = GPR (0);
- uint16 count = OP[0], reg = 2, tmp;
- trace_input ("loadm", OP_CONSTANT4, OP_VOID, OP_VOID);
- if ((addr & 1))
- {
- State.exception = SIG_CR16_BUS;
- State.pc_changed = 1; /* Don't increment the PC. */
- trace_output_void ();
- return;
- }
- while (count)
- {
- tmp = RW (addr);
- SET_GPR (reg, tmp);
- addr +=2;
- --count;
- reg++;
- if (reg == 6) reg = 8;
- };
- SET_GPR (0, addr);
- trace_output_void ();
- }
- /* loadmp. */
- void
- OP_15_D (void)
- {
- uint32 addr = GPR32 (0);
- uint16 count = OP[0], reg = 2, tmp;
- trace_input ("loadm", OP_CONSTANT4, OP_VOID, OP_VOID);
- if ((addr & 1))
- {
- State.exception = SIG_CR16_BUS;
- State.pc_changed = 1; /* Don't increment the PC. */
- trace_output_void ();
- return;
- }
- while (count)
- {
- tmp = RW (addr);
- SET_GPR (reg, tmp);
- addr +=2;
- --count;
- reg++;
- if (reg == 6) reg = 8;
- };
- SET_GPR32 (0, addr);
- trace_output_void ();
- }
- /* loadb. */
- void
- OP_88_8 (void)
- {
- /* loadb ABS20, REG
- * ADDR = zext24(abs20) | remap (ie 0xF00000)
- * REG = [ADDR]
- * NOTE: remap is
- * If (abs20 > 0xEFFFF) the resulting address is logically ORed
- * with 0xF00000 i.e. addresses from 1M-64k to 1M are re-mapped
- * by the core to 16M-64k to 16M. */
- uint16 tmp, a = (GPR (OP[1])) & 0xFF00;
- uint32 addr = OP[0];
- trace_input ("loadb", OP_ABS20, OP_REG, OP_VOID);
- if (addr > 0xEFFFF) addr |= 0xF00000;
- tmp = (RB (addr));
- SET_GPR (OP[1], (a | tmp));
- trace_output_16 (tmp);
- }
- /* loadb. */
- void
- OP_127_14 (void)
- {
- /* loadb ABS24, REG
- * ADDR = abs24
- * REGR = [ADDR]. */
- uint16 tmp, a = (GPR (OP[1])) & 0xFF00;
- uint32 addr = OP[0];
- trace_input ("loadb", OP_ABS24, OP_REG, OP_VOID);
- tmp = (RB (addr));
- SET_GPR (OP[1], (a | tmp));
- trace_output_16 (tmp);
- }
- /* loadb. */
- void
- OP_45_7 (void)
- {
- /* loadb [Rindex]ABS20 REG
- * ADDR = Rindex + zext24(disp20)
- * REGR = [ADDR]. */
- uint32 addr;
- uint16 tmp, a = (GPR (OP[2])) & 0xFF00;
- trace_input ("loadb", OP_R_INDEX8_ABS20, OP_REG, OP_VOID);
- if (OP[0] == 0)
- addr = (GPR32 (12)) + OP[1];
- else
- addr = (GPR32 (13)) + OP[1];
- tmp = (RB (addr));
- SET_GPR (OP[2], (a | tmp));
- trace_output_16 (tmp);
- }
- /* loadb. */
- void
- OP_B_4 (void)
- {
- /* loadb DIPS4(REGP) REG
- * ADDR = RPBASE + zext24(DISP4)
- * REG = [ADDR]. */
- uint16 tmp, a = (GPR (OP[2])) & 0xFF00;
- uint32 addr = (GPR32 (OP[1])) + OP[0];
- trace_input ("loadb", OP_RP_BASE_DISP4, OP_REG, OP_VOID);
- tmp = (RB (addr));
- SET_GPR (OP[2], (a | tmp));
- trace_output_16 (tmp);
- }
- /* loadb. */
- void
- OP_BE_8 (void)
- {
- /* loadb [Rindex]disp0(RPbasex) REG
- * ADDR = Rpbasex + Rindex
- * REGR = [ADDR] */
- uint32 addr;
- uint16 tmp, a = (GPR (OP[3])) & 0xFF00;
- trace_input ("loadb", OP_RP_INDEX_DISP0, OP_REG, OP_VOID);
- addr = (GPR32 (OP[2])) + OP[1];
- if (OP[0] == 0)
- addr = (GPR32 (12)) + addr;
- else
- addr = (GPR32 (13)) + addr;
- tmp = (RB (addr));
- SET_GPR (OP[3], (a | tmp));
- trace_output_16 (tmp);
- }
- /* loadb. */
- void
- OP_219_A (void)
- {
- /* loadb [Rindex]disp14(RPbasex) REG
- * ADDR = Rpbasex + Rindex + zext24(disp14)
- * REGR = [ADDR] */
- uint32 addr;
- uint16 tmp, a = (GPR (OP[3])) & 0xFF00;
- addr = (GPR32 (OP[2])) + OP[1];
- if (OP[0] == 0)
- addr = (GPR32 (12)) + addr;
- else
- addr = (GPR32 (13)) + addr;
- trace_input ("loadb", OP_RP_INDEX_DISP14, OP_REG, OP_VOID);
- tmp = (RB (addr));
- SET_GPR (OP[3], (a | tmp));
- trace_output_16 (tmp);
- }
- /* loadb. */
- void
- OP_184_14 (void)
- {
- /* loadb DISPE20(REG) REG
- * zext24(Rbase) + zext24(dispe20)
- * REG = [ADDR] */
- uint16 tmp,a = (GPR (OP[2])) & 0xFF00;
- uint32 addr = OP[0] + (GPR (OP[1]));
- trace_input ("loadb", OP_R_BASE_DISPE20, OP_REG, OP_VOID);
- tmp = (RB (addr));
- SET_GPR (OP[2], (a | tmp));
- trace_output_16 (tmp);
- }
- /* loadb. */
- void
- OP_124_14 (void)
- {
- /* loadb DISP20(REG) REG
- * ADDR = zext24(Rbase) + zext24(disp20)
- * REG = [ADDR] */
- uint16 tmp,a = (GPR (OP[2])) & 0xFF00;
- uint32 addr = OP[0] + (GPR (OP[1]));
- trace_input ("loadb", OP_R_BASE_DISP20, OP_REG, OP_VOID);
- tmp = (RB (addr));
- SET_GPR (OP[2], (a | tmp));
- trace_output_16 (tmp);
- }
- /* loadb. */
- void
- OP_BF_8 (void)
- {
- /* loadb disp16(REGP) REG
- * ADDR = RPbase + zext24(disp16)
- * REGR = [ADDR] */
- uint16 tmp,a = (GPR (OP[2])) & 0xFF00;
- uint32 addr = (GPR32 (OP[1])) + OP[0];
- trace_input ("loadb", OP_RP_BASE_DISP16, OP_REG, OP_VOID);
- tmp = (RB (addr));
- SET_GPR (OP[2], (a | tmp));
- trace_output_16 (tmp);
- }
- /* loadb. */
- void
- OP_125_14 (void)
- {
- /* loadb disp20(REGP) REG
- * ADDR = RPbase + zext24(disp20)
- * REGR = [ADDR] */
- uint16 tmp,a = (GPR (OP[2])) & 0xFF00;
- uint32 addr = (GPR32 (OP[1])) + OP[0];
- trace_input ("loadb", OP_RP_BASE_DISP20, OP_REG, OP_VOID);
- tmp = (RB (addr));
- SET_GPR (OP[2], (a | tmp));
- trace_output_16 (tmp);
- }
- /* loadb. */
- void
- OP_185_14 (void)
- {
- /* loadb -disp20(REGP) REG
- * ADDR = RPbase + zext24(-disp20)
- * REGR = [ADDR] */
- uint16 tmp,a = (GPR (OP[2])) & 0xFF00;
- uint32 addr = (GPR32 (OP[1])) + OP[1];
- trace_input ("loadb", OP_RP_BASE_DISPE20, OP_REG, OP_VOID);
- tmp = (RB (addr));
- SET_GPR (OP[2], (a | tmp));
- trace_output_16 (tmp);
- }
- /* loadb. */
- void
- OP_126_14 (void)
- {
- /* loadb [Rindex]disp20(RPbasexb) REG
- * ADDR = RPbasex + Rindex + zext24(disp20)
- * REGR = [ADDR] */
- uint32 addr;
- uint16 tmp, a = (GPR (OP[3])) & 0xFF00;
- trace_input ("loadb", OP_RP_INDEX_DISP20, OP_REG, OP_VOID);
- addr = (GPR32 (OP[2])) + OP[1];
- if (OP[0] == 0)
- addr = (GPR32 (12)) + addr;
- else
- addr = (GPR32 (13)) + addr;
- tmp = (RB (addr));
- SET_GPR (OP[3], (a | tmp));
- trace_output_16 (tmp);
- }
- /* loadw. */
- void
- OP_89_8 (void)
- {
- /* loadw ABS20, REG
- * ADDR = zext24(abs20) | remap
- * REGR = [ADDR]
- * NOTE: remap is
- * If (abs20 > 0xEFFFF) the resulting address is logically ORed
- * with 0xF00000 i.e. addresses from 1M-64k to 1M are re-mapped
- * by the core to 16M-64k to 16M. */
- uint16 tmp;
- uint32 addr = OP[0];
- trace_input ("loadw", OP_ABS20, OP_REG, OP_VOID);
- if (addr > 0xEFFFF) addr |= 0xF00000;
- tmp = (RW (addr));
- SET_GPR (OP[1], tmp);
- trace_output_16 (tmp);
- }
- /* loadw. */
- void
- OP_12F_14 (void)
- {
- /* loadw ABS24, REG
- * ADDR = abs24
- * REGR = [ADDR] */
- uint16 tmp;
- uint32 addr = OP[0];
- trace_input ("loadw", OP_ABS24, OP_REG, OP_VOID);
- tmp = (RW (addr));
- SET_GPR (OP[1], tmp);
- trace_output_16 (tmp);
- }
- /* loadw. */
- void
- OP_47_7 (void)
- {
- /* loadw [Rindex]ABS20 REG
- * ADDR = Rindex + zext24(disp20)
- * REGR = [ADDR] */
- uint32 addr;
- uint16 tmp;
- trace_input ("loadw", OP_R_INDEX8_ABS20, OP_REG, OP_VOID);
- if (OP[0] == 0)
- addr = (GPR32 (12)) + OP[1];
- else
- addr = (GPR32 (13)) + OP[1];
- tmp = (RW (addr));
- SET_GPR (OP[2], tmp);
- trace_output_16 (tmp);
- }
- /* loadw. */
- void
- OP_9_4 (void)
- {
- /* loadw DIPS4(REGP) REGP
- * ADDR = RPBASE + zext24(DISP4)
- * REGP = [ADDR]. */
- uint16 tmp;
- uint32 addr, a;
- trace_input ("loadw", OP_RP_BASE_DISP4, OP_REG, OP_VOID);
- addr = (GPR32 (OP[1])) + OP[0];
- tmp = (RW (addr));
- if (OP[2] > 11)
- {
- a = (GPR32 (OP[2])) & 0xffff0000;
- SET_GPR32 (OP[2], (a | tmp));
- }
- else
- SET_GPR (OP[2], tmp);
- trace_output_16 (tmp);
- }
- /* loadw. */
- void
- OP_9E_8 (void)
- {
- /* loadw [Rindex]disp0(RPbasex) REG
- * ADDR = Rpbasex + Rindex
- * REGR = [ADDR] */
- uint32 addr;
- uint16 tmp;
- trace_input ("loadw", OP_RP_INDEX_DISP0, OP_REG, OP_VOID);
- addr = (GPR32 (OP[2])) + OP[1];
- if (OP[0] == 0)
- addr = (GPR32 (12)) + addr;
- else
- addr = (GPR32 (13)) + addr;
- tmp = RW (addr);
- SET_GPR (OP[3], tmp);
- trace_output_16 (tmp);
- }
- /* loadw. */
- void
- OP_21B_A (void)
- {
- /* loadw [Rindex]disp14(RPbasex) REG
- * ADDR = Rpbasex + Rindex + zext24(disp14)
- * REGR = [ADDR] */
- uint32 addr;
- uint16 tmp;
- trace_input ("loadw", OP_RP_INDEX_DISP14, OP_REG, OP_VOID);
- addr = (GPR32 (OP[2])) + OP[1];
- if (OP[0] == 0)
- addr = (GPR32 (12)) + addr;
- else
- addr = (GPR32 (13)) + addr;
- tmp = (RW (addr));
- SET_GPR (OP[3], tmp);
- trace_output_16 (tmp);
- }
- /* loadw. */
- void
- OP_18C_14 (void)
- {
- /* loadw dispe20(REG) REGP
- * REGP = [DISPE20+[REG]] */
- uint16 tmp;
- uint32 addr, a;
- trace_input ("loadw", OP_R_BASE_DISPE20, OP_REGP, OP_VOID);
- addr = OP[0] + (GPR (OP[1]));
- tmp = (RW (addr));
- if (OP[2] > 11)
- {
- a = (GPR32 (OP[2])) & 0xffff0000;
- SET_GPR32 (OP[2], (a | tmp));
- }
- else
- SET_GPR (OP[2], tmp);
-
- trace_output_16 (tmp);
- }
- /* loadw. */
- void
- OP_12C_14 (void)
- {
- /* loadw DISP20(REG) REGP
- * ADDR = zext24(Rbase) + zext24(disp20)
- * REGP = [ADDR] */
- uint16 tmp;
- uint32 addr, a;
- trace_input ("loadw", OP_R_BASE_DISP20, OP_REGP, OP_VOID);
- addr = OP[0] + (GPR (OP[1]));
- tmp = (RW (addr));
- if (OP[2] > 11)
- {
- a = (GPR32 (OP[2])) & 0xffff0000;
- SET_GPR32 (OP[2], (a | tmp));
- }
- else
- SET_GPR (OP[2], tmp);
- trace_output_16 (tmp);
- }
- /* loadw. */
- void
- OP_9F_8 (void)
- {
- /* loadw disp16(REGP) REGP
- * ADDR = RPbase + zext24(disp16)
- * REGP = [ADDR] */
- uint16 tmp;
- uint32 addr, a;
- trace_input ("loadw", OP_RP_BASE_DISP16, OP_REGP, OP_VOID);
- addr = (GPR32 (OP[1])) + OP[0];
- tmp = (RW (addr));
- if (OP[2] > 11)
- {
- a = (GPR32 (OP[2])) & 0xffff0000;
- SET_GPR32 (OP[2], (a | tmp));
- }
- else
- SET_GPR (OP[2], tmp);
- trace_output_16 (tmp);
- }
- /* loadw. */
- void
- OP_12D_14 (void)
- {
- /* loadw disp20(REGP) REGP
- * ADDR = RPbase + zext24(disp20)
- * REGP = [ADDR] */
- uint16 tmp;
- uint32 addr, a;
- trace_input ("loadw", OP_RP_BASE_DISP20, OP_REG, OP_VOID);
- addr = (GPR32 (OP[1])) + OP[0];
- tmp = (RW (addr));
- if (OP[2] > 11)
- {
- a = (GPR32 (OP[2])) & 0xffff0000;
- SET_GPR32 (OP[2], (a | tmp));
- }
- else
- SET_GPR (OP[2], tmp);
- trace_output_16 (tmp);
- }
- /* loadw. */
- void
- OP_18D_14 (void)
- {
- /* loadw -disp20(REGP) REG
- * ADDR = RPbase + zext24(-disp20)
- * REGR = [ADDR] */
- uint16 tmp;
- uint32 addr, a;
- trace_input ("loadw", OP_RP_BASE_DISPE20, OP_REG, OP_VOID);
- addr = (GPR32 (OP[1])) + OP[0];
- tmp = (RB (addr));
- if (OP[2] > 11)
- {
- a = (GPR32 (OP[2])) & 0xffff0000;
- SET_GPR32 (OP[2], (a | tmp));
- }
- else
- SET_GPR (OP[2], tmp);
- trace_output_16 (tmp);
- }
- /* loadw. */
- void
- OP_12E_14 (void)
- {
- /* loadw [Rindex]disp20(RPbasexb) REG
- * ADDR = RPbasex + Rindex + zext24(disp20)
- * REGR = [ADDR] */
- uint32 addr;
- uint16 tmp;
- trace_input ("loadw", OP_RP_INDEX_DISP20, OP_REG, OP_VOID);
- if (OP[0] == 0)
- addr = (GPR32 (12)) + OP[1] + (GPR32 (OP[2]));
- else
- addr = (GPR32 (13)) + OP[1] + (GPR32 (OP[2]));
- tmp = (RW (addr));
- SET_GPR (OP[3], tmp);
- trace_output_16 (tmp);
- }
- /* loadd. */
- void
- OP_87_8 (void)
- {
- /* loadd ABS20, REGP
- * ADDR = zext24(abs20) | remap
- * REGP = [ADDR]
- * NOTE: remap is
- * If (abs20 > 0xEFFFF) the resulting address is logically ORed
- * with 0xF00000 i.e. addresses from 1M-64k to 1M are re-mapped
- * by the core to 16M-64k to 16M. */
- uint32 addr, tmp;
- addr = OP[0];
- trace_input ("loadd", OP_ABS20, OP_REGP, OP_VOID);
- if (addr > 0xEFFFF) addr |= 0xF00000;
- tmp = RLW (addr);
- tmp = ((tmp << 16) & 0xffff)| ((tmp >> 16) & 0xffff);
- SET_GPR32 (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* loadd. */
- void
- OP_12B_14 (void)
- {
- /* loadd ABS24, REGP
- * ADDR = abs24
- * REGP = [ADDR] */
- uint32 addr = OP[0];
- uint32 tmp;
- trace_input ("loadd", OP_ABS24, OP_REGP, OP_VOID);
- tmp = RLW (addr);
- tmp = ((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff);
- SET_GPR32 (OP[1],tmp);
- trace_output_32 (tmp);
- }
- /* loadd. */
- void
- OP_46_7 (void)
- {
- /* loadd [Rindex]ABS20 REGP
- * ADDR = Rindex + zext24(disp20)
- * REGP = [ADDR] */
- uint32 addr, tmp;
- trace_input ("loadd", OP_R_INDEX8_ABS20, OP_REGP, OP_VOID);
- if (OP[0] == 0)
- addr = (GPR32 (12)) + OP[1];
- else
- addr = (GPR32 (13)) + OP[1];
- tmp = RLW (addr);
- tmp = ((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff);
- SET_GPR32 (OP[2], tmp);
- trace_output_32 (tmp);
- }
- /* loadd. */
- void
- OP_A_4 (void)
- {
- /* loadd dips4(regp) REGP
- * ADDR = Rpbase + zext24(disp4)
- * REGP = [ADDR] */
- uint32 tmp, addr = (GPR32 (OP[1])) + OP[0];
- trace_input ("loadd", OP_RP_BASE_DISP4, OP_REGP, OP_VOID);
- tmp = RLW (addr);
- tmp = ((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff);
- SET_GPR32 (OP[2], tmp);
- trace_output_32 (tmp);
- }
- /* loadd. */
- void
- OP_AE_8 (void)
- {
- /* loadd [Rindex]disp0(RPbasex) REGP
- * ADDR = Rpbasex + Rindex
- * REGP = [ADDR] */
- uint32 addr, tmp;
- trace_input ("loadd", OP_RP_INDEX_DISP0, OP_REGP, OP_VOID);
- if (OP[0] == 0)
- addr = (GPR32 (12)) + (GPR32 (OP[2])) + OP[1];
- else
- addr = (GPR32 (13)) + (GPR32 (OP[2])) + OP[1];
- tmp = RLW (addr);
- tmp = ((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff);
- SET_GPR32 (OP[3], tmp);
- trace_output_32 (tmp);
- }
- /* loadd. */
- void
- OP_21A_A (void)
- {
- /* loadd [Rindex]disp14(RPbasex) REGP
- * ADDR = Rpbasex + Rindex + zext24(disp14)
- * REGR = [ADDR] */
- uint32 addr, tmp;
- trace_input ("loadd", OP_RP_INDEX_DISP14, OP_REGP, OP_VOID);
- if (OP[0] == 0)
- addr = (GPR32 (12)) + OP[1] + (GPR32 (OP[2]));
- else
- addr = (GPR32 (13)) + OP[1] + (GPR32 (OP[2]));
- tmp = RLW (addr);
- tmp = ((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff);
- SET_GPR (OP[3],tmp);
- trace_output_32 (tmp);
- }
- /* loadd. */
- void
- OP_188_14 (void)
- {
- /* loadd dispe20(REG) REG
- * zext24(Rbase) + zext24(dispe20)
- * REG = [ADDR] */
- uint32 tmp, addr = OP[0] + (GPR (OP[1]));
- trace_input ("loadd", OP_R_BASE_DISPE20, OP_REGP, OP_VOID);
- tmp = RLW (addr);
- tmp = ((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff);
- SET_GPR32 (OP[2], tmp);
- trace_output_32 (tmp);
- }
- /* loadd. */
- void
- OP_128_14 (void)
- {
- /* loadd DISP20(REG) REG
- * ADDR = zext24(Rbase) + zext24(disp20)
- * REG = [ADDR] */
- uint32 tmp, addr = OP[0] + (GPR (OP[1]));
- trace_input ("loadd", OP_R_BASE_DISP20, OP_REGP, OP_VOID);
- tmp = RLW (addr);
- tmp = ((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff);
- SET_GPR32 (OP[2], tmp);
- trace_output_32 (tmp);
- }
- /* loadd. */
- void
- OP_AF_8 (void)
- {
- /* loadd disp16(REGP) REGP
- * ADDR = RPbase + zext24(disp16)
- * REGR = [ADDR] */
- uint32 tmp, addr = OP[0] + (GPR32 (OP[1]));
- trace_input ("loadd", OP_RP_BASE_DISP16, OP_REGP, OP_VOID);
- tmp = RLW (addr);
- tmp = ((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff);
- SET_GPR32 (OP[2], tmp);
- trace_output_32 (tmp);
- }
- /* loadd. */
- void
- OP_129_14 (void)
- {
- /* loadd disp20(REGP) REGP
- * ADDR = RPbase + zext24(disp20)
- * REGP = [ADDR] */
- uint32 tmp, addr = OP[0] + (GPR32 (OP[1]));
- trace_input ("loadd", OP_RP_BASE_DISP20, OP_REGP, OP_VOID);
- tmp = RLW (addr);
- tmp = ((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff);
- SET_GPR32 (OP[2], tmp);
- trace_output_32 (tmp);
- }
- /* loadd. */
- void
- OP_189_14 (void)
- {
- /* loadd -disp20(REGP) REGP
- * ADDR = RPbase + zext24(-disp20)
- * REGP = [ADDR] */
- uint32 tmp, addr = OP[0] + (GPR32 (OP[1]));
- trace_input ("loadd", OP_RP_BASE_DISPE20, OP_REGP, OP_VOID);
- tmp = RLW (addr);
- tmp = ((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff);
- SET_GPR32 (OP[2], tmp);
- trace_output_32 (tmp);
- }
- /* loadd. */
- void
- OP_12A_14 (void)
- {
- /* loadd [Rindex]disp20(RPbasexb) REGP
- * ADDR = RPbasex + Rindex + zext24(disp20)
- * REGP = [ADDR] */
- uint32 addr, tmp;
- trace_input ("loadd", OP_RP_INDEX_DISP20, OP_REGP, OP_VOID);
- if (OP[0] == 0)
- addr = (GPR32 (12)) + OP[1] + (GPR32 (OP[2]));
- else
- addr = (GPR32 (13)) + OP[1] + (GPR32 (OP[2]));
- tmp = RLW (addr);
- tmp = ((tmp << 16) & 0xffff)| ((tmp >> 16) & 0xffff);
- SET_GPR32 (OP[3], tmp);
- trace_output_32 (tmp);
- }
- /* storb. */
- void
- OP_C8_8 (void)
- {
- /* storb REG, ABS20
- * ADDR = zext24(abs20) | remap
- * [ADDR] = REGR
- * NOTE: remap is
- * If (abs20 > 0xEFFFF) the resulting address is logically ORed
- * with 0xF00000 i.e. addresses from 1M-64k to 1M are re-mapped
- * by the core to 16M-64k to 16M. */
- uint8 a = ((GPR (OP[0])) & 0xff);
- uint32 addr = OP[1];
- trace_input ("storb", OP_REG, OP_ABS20_OUTPUT, OP_VOID);
- SB (addr, a);
- trace_output_32 (addr);
- }
- /* storb. */
- void
- OP_137_14 (void)
- {
- /* storb REG, ABS24
- * ADDR = abs24
- * [ADDR] = REGR. */
- uint8 a = ((GPR (OP[0])) & 0xff);
- uint32 addr = OP[1];
- trace_input ("storb", OP_REG, OP_ABS24_OUTPUT, OP_VOID);
- SB (addr, a);
- trace_output_32 (addr);
- }
- /* storb. */
- void
- OP_65_7 (void)
- {
- /* storb REG, [Rindex]ABS20
- * ADDR = Rindex + zext24(disp20)
- * [ADDR] = REGR */
- uint32 addr;
- uint8 a = ((GPR (OP[0])) & 0xff);
- trace_input ("storb", OP_REG, OP_R_INDEX8_ABS20, OP_VOID);
- if (OP[1] == 0)
- addr = (GPR32 (12)) + OP[2];
- else
- addr = (GPR32 (13)) + OP[2];
- SB (addr, a);
- trace_output_32 (addr);
- }
- /* storb. */
- void
- OP_F_4 (void)
- {
- /* storb REG, DIPS4(REGP)
- * ADDR = RPBASE + zext24(DISP4)
- * [ADDR] = REG. */
- uint16 a = ((GPR (OP[0])) & 0xff);
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storb", OP_REG, OP_RP_BASE_DISPE4, OP_VOID);
- SB (addr, a);
- trace_output_32 (addr);
- }
- /* storb. */
- void
- OP_FE_8 (void)
- {
- /* storb [Rindex]disp0(RPbasex) REG
- * ADDR = Rpbasex + Rindex
- * [ADDR] = REGR */
- uint32 addr;
- uint8 a = ((GPR (OP[0])) & 0xff);
- trace_input ("storb", OP_REG, OP_RP_INDEX_DISP0, OP_VOID);
- if (OP[1] == 0)
- addr = (GPR32 (12)) + (GPR32 (OP[3])) + OP[2];
- else
- addr = (GPR32 (13)) + (GPR32 (OP[3])) + OP[2];
- SB (addr, a);
- trace_output_32 (addr);
- }
- /* storb. */
- void
- OP_319_A (void)
- {
- /* storb REG, [Rindex]disp14(RPbasex)
- * ADDR = Rpbasex + Rindex + zext24(disp14)
- * [ADDR] = REGR */
- uint8 a = ((GPR (OP[0])) & 0xff);
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storb", OP_REG, OP_RP_INDEX_DISP14, OP_VOID);
- SB (addr, a);
- trace_output_32 (addr);
- }
- /* storb. */
- void
- OP_194_14 (void)
- {
- /* storb REG, DISPE20(REG)
- * zext24(Rbase) + zext24(dispe20)
- * [ADDR] = REG */
- uint8 a = ((GPR (OP[0])) & 0xff);
- uint32 addr = OP[1] + (GPR (OP[2]));
- trace_input ("storb", OP_REG, OP_R_BASE_DISPE20, OP_VOID);
- SB (addr, a);
- trace_output_32 (addr);
- }
- /* storb. */
- void
- OP_134_14 (void)
- {
- /* storb REG, DISP20(REG)
- * ADDR = zext24(Rbase) + zext24(disp20)
- * [ADDR] = REG */
- uint8 a = (GPR (OP[0]) & 0xff);
- uint32 addr = OP[1] + (GPR (OP[2]));
- trace_input ("storb", OP_REG, OP_R_BASE_DISPS20, OP_VOID);
- SB (addr, a);
- trace_output_32 (addr);
- }
- /* storb. */
- void
- OP_FF_8 (void)
- {
- /* storb REG, disp16(REGP)
- * ADDR = RPbase + zext24(disp16)
- * [ADDR] = REGP */
- uint8 a = ((GPR (OP[0])) & 0xff);
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storb", OP_REG, OP_RP_BASE_DISP16, OP_VOID);
- SB (addr, a);
- trace_output_32 (addr);
- }
- /* storb. */
- void
- OP_135_14 (void)
- {
- /* storb REG, disp20(REGP)
- * ADDR = RPbase + zext24(disp20)
- * [ADDR] = REGP */
- uint8 a = ((GPR (OP[0])) & 0xff);
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storb", OP_REG, OP_RP_BASE_DISPS20, OP_VOID);
- SB (addr, a);
- trace_output_32 (addr);
- }
- /* storb. */
- void
- OP_195_14 (void)
- {
- /* storb REG, -disp20(REGP)
- * ADDR = RPbase + zext24(-disp20)
- * [ADDR] = REGP */
- uint8 a = (GPR (OP[0]) & 0xff);
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storb", OP_REG, OP_RP_BASE_DISPE20, OP_VOID);
- SB (addr, a);
- trace_output_32 (addr);
- }
- /* storb. */
- void
- OP_136_14 (void)
- {
- /* storb REG, [Rindex]disp20(RPbase)
- * ADDR = RPbasex + Rindex + zext24(disp20)
- * [ADDR] = REGP */
- uint8 a = (GPR (OP[0])) & 0xff;
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storb", OP_REG, OP_RP_INDEX_DISPS20, OP_VOID);
- SB (addr, a);
- trace_output_32 (addr);
- }
- /* STR_IMM instructions. */
- /* storb . */
- void
- OP_81_8 (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint32 addr = OP[1];
- trace_input ("storb", OP_CONSTANT4, OP_ABS20_OUTPUT, OP_VOID);
- SB (addr, a);
- trace_output_32 (addr);
- }
- /* storb. */
- void
- OP_123_14 (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint32 addr = OP[1];
- trace_input ("storb", OP_CONSTANT4, OP_ABS24_OUTPUT, OP_VOID);
- SB (addr, a);
- trace_output_32 (addr);
- }
- /* storb. */
- void
- OP_42_7 (void)
- {
- uint32 addr;
- uint8 a = (OP[0]) & 0xff;
- trace_input ("storb", OP_CONSTANT4, OP_R_INDEX8_ABS20, OP_VOID);
- if (OP[1] == 0)
- addr = (GPR32 (12)) + OP[2];
- else
- addr = (GPR32 (13)) + OP[2];
- SB (addr, a);
- trace_output_32 (addr);
- }
- /* storb. */
- void
- OP_218_A (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storb", OP_CONSTANT4, OP_RP_BASE_DISP14, OP_VOID);
- SB (addr, a);
- trace_output_32 (addr);
- }
- /* storb. */
- void
- OP_82_8 (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storb", OP_CONSTANT4, OP_RP_INDEX_DISP0, OP_VOID);
- SB (addr, a);
- trace_output_32 (addr);
- }
- /* storb. */
- void
- OP_120_14 (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint32 addr = (GPR (OP[2])) + OP[1];
- trace_input ("storb", OP_CONSTANT4, OP_R_BASE_DISPS20, OP_VOID);
- SB (addr, a);
- trace_output_32 (addr);
- }
- /* storb. */
- void
- OP_83_8 (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storb", OP_CONSTANT4, OP_RP_BASE_DISP16, OP_VOID);
- SB (addr, a);
- trace_output_32 (addr);
- }
- /* storb. */
- void
- OP_121_14 (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storb", OP_CONSTANT4, OP_RP_BASE_DISPS20, OP_VOID);
- SB (addr, a);
- trace_output_32 (addr);
- }
- /* storb. */
- void
- OP_122_14 (void)
- {
- uint8 a = (OP[0]) & 0xff;
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storb", OP_CONSTANT4, OP_RP_INDEX_DISPS20, OP_VOID);
- SB (addr, a);
- trace_output_32 (addr);
- }
- /* endif for STR_IMM. */
- /* storw . */
- void
- OP_C9_8 (void)
- {
- uint16 a = GPR (OP[0]);
- uint32 addr = OP[1];
- trace_input ("storw", OP_REG, OP_ABS20_OUTPUT, OP_VOID);
- SW (addr, a);
- trace_output_32 (addr);
- }
- /* storw. */
- void
- OP_13F_14 (void)
- {
- uint16 a = GPR (OP[0]);
- uint32 addr = OP[1];
- trace_input ("storw", OP_REG, OP_ABS24_OUTPUT, OP_VOID);
- SW (addr, a);
- trace_output_32 (addr);
- }
- /* storw. */
- void
- OP_67_7 (void)
- {
- uint32 addr;
- uint16 a = GPR (OP[0]);
- trace_input ("storw", OP_REG, OP_R_INDEX8_ABS20, OP_VOID);
- if (OP[1] == 0)
- addr = (GPR32 (12)) + OP[2];
- else
- addr = (GPR32 (13)) + OP[2];
- SW (addr, a);
- trace_output_32 (addr);
- }
- /* storw. */
- void
- OP_D_4 (void)
- {
- uint16 a = (GPR (OP[0]));
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storw", OP_REGP, OP_RP_BASE_DISPE4, OP_VOID);
- SW (addr, a);
- trace_output_32 (addr);
- }
- /* storw. */
- void
- OP_DE_8 (void)
- {
- uint16 a = GPR (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storw", OP_REG, OP_RP_INDEX_DISP0, OP_VOID);
- SW (addr, a);
- trace_output_32 (addr);
- }
- /* storw. */
- void
- OP_31B_A (void)
- {
- uint16 a = GPR (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storw", OP_REG, OP_RP_INDEX_DISP14, OP_VOID);
- SW (addr, a);
- trace_output_32 (addr);
- }
- /* storw. */
- void
- OP_19C_14 (void)
- {
- uint16 a = (GPR (OP[0]));
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storw", OP_REGP, OP_RP_BASE_DISPE20, OP_VOID);
- SW (addr, a);
- trace_output_32 (addr);
- }
- /* storw. */
- void
- OP_13C_14 (void)
- {
- uint16 a = (GPR (OP[0]));
- uint32 addr = (GPR (OP[2])) + OP[1];
- trace_input ("storw", OP_REG, OP_R_BASE_DISPS20, OP_VOID);
- SW (addr, a);
- trace_output_32 (addr);
- }
- /* storw. */
- void
- OP_DF_8 (void)
- {
- uint16 a = (GPR (OP[0]));
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storw", OP_REG, OP_RP_BASE_DISP16, OP_VOID);
- SW (addr, a);
- trace_output_32 (addr);
- }
- /* storw. */
- void
- OP_13D_14 (void)
- {
- uint16 a = (GPR (OP[0]));
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storw", OP_REG, OP_RP_BASE_DISPS20, OP_VOID);
- SW (addr, a);
- trace_output_32 (addr);
- }
- /* storw. */
- void
- OP_19D_14 (void)
- {
- uint16 a = (GPR (OP[0]));
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storw", OP_REG, OP_RP_BASE_DISPE20, OP_VOID);
- SW (addr, a);
- trace_output_32 (addr);
- }
- /* storw. */
- void
- OP_13E_14 (void)
- {
- uint16 a = (GPR (OP[0]));
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storw", OP_REG, OP_RP_INDEX_DISPS20, OP_VOID);
- SW (addr, a);
- trace_output_32 (addr);
- }
- /* STORE-w IMM instruction *****/
- /* storw . */
- void
- OP_C1_8 (void)
- {
- uint16 a = OP[0];
- uint32 addr = OP[1];
- trace_input ("storw", OP_CONSTANT4, OP_ABS20_OUTPUT, OP_VOID);
- SW (addr, a);
- trace_output_32 (addr);
- }
- /* storw. */
- void
- OP_133_14 (void)
- {
- uint16 a = OP[0];
- uint32 addr = OP[1];
- trace_input ("storw", OP_CONSTANT4, OP_ABS24_OUTPUT, OP_VOID);
- SW (addr, a);
- trace_output_32 (addr);
- }
- /* storw. */
- void
- OP_62_7 (void)
- {
- uint32 addr;
- uint16 a = OP[0];
- trace_input ("storw", OP_CONSTANT4, OP_R_INDEX8_ABS20, OP_VOID);
- if (OP[1] == 0)
- addr = (GPR32 (12)) + OP[2];
- else
- addr = (GPR32 (13)) + OP[2];
- SW (addr, a);
- trace_output_32 (addr);
- }
- /* storw. */
- void
- OP_318_A (void)
- {
- uint16 a = OP[0];
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storw", OP_CONSTANT4, OP_RP_BASE_DISP14, OP_VOID);
- SW (addr, a);
- trace_output_32 (addr);
- }
- /* storw. */
- void
- OP_C2_8 (void)
- {
- uint16 a = OP[0];
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storw", OP_CONSTANT4, OP_RP_INDEX_DISP0, OP_VOID);
- SW (addr, a);
- trace_output_32 (addr);
- }
- /* storw. */
- void
- OP_130_14 (void)
- {
- uint16 a = OP[0];
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storw", OP_CONSTANT4, OP_R_BASE_DISPS20, OP_VOID);
- SW (addr, a);
- trace_output_32 (addr);
- }
- /* storw. */
- void
- OP_C3_8 (void)
- {
- uint16 a = OP[0];
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storw", OP_CONSTANT4, OP_RP_BASE_DISP16, OP_VOID);
- SW (addr, a);
- trace_output_32 (addr);
- }
- /* storw. */
- void
- OP_131_14 (void)
- {
- uint16 a = OP[0];
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storw", OP_CONSTANT4, OP_RP_BASE_DISPS20, OP_VOID);
- SW (addr, a);
- trace_output_32 (addr);
- }
- /* storw. */
- void
- OP_132_14 (void)
- {
- uint16 a = OP[0];
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("storw", OP_CONSTANT4, OP_RP_INDEX_DISPS20, OP_VOID);
- SW (addr, a);
- trace_output_32 (addr);
- }
- /* stord. */
- void
- OP_C7_8 (void)
- {
- uint32 a = GPR32 (OP[0]);
- uint32 addr = OP[1];
- trace_input ("stord", OP_REGP, OP_ABS20_OUTPUT, OP_VOID);
- SLW (addr, a);
- trace_output_32 (addr);
- }
- /* stord. */
- void
- OP_13B_14 (void)
- {
- uint32 a = GPR32 (OP[0]);
- uint32 addr = OP[1];
- trace_input ("stord", OP_REGP, OP_ABS24_OUTPUT, OP_VOID);
- SLW (addr, a);
- trace_output_32 (addr);
- }
- /* stord. */
- void
- OP_66_7 (void)
- {
- uint32 addr, a = GPR32 (OP[0]);
- trace_input ("stord", OP_REGP, OP_R_INDEX8_ABS20, OP_VOID);
- if (OP[1] == 0)
- addr = (GPR32 (12)) + OP[2];
- else
- addr = (GPR32 (13)) + OP[2];
- SLW (addr, a);
- trace_output_32 (addr);
- }
- /* stord. */
- void
- OP_E_4 (void)
- {
- uint32 a = GPR32 (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("stord", OP_REGP, OP_RP_BASE_DISPE4, OP_VOID);
- SLW (addr, a);
- trace_output_32 (addr);
- }
- /* stord. */
- void
- OP_EE_8 (void)
- {
- uint32 a = GPR32 (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("stord", OP_REGP, OP_RP_INDEX_DISP0, OP_VOID);
- SLW (addr, a);
- trace_output_32 (addr);
- }
- /* stord. */
- void
- OP_31A_A (void)
- {
- uint32 a = GPR32 (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("stord", OP_REGP, OP_RP_INDEX_DISP14, OP_VOID);
- SLW (addr, a);
- trace_output_32 (addr);
- }
- /* stord. */
- void
- OP_198_14 (void)
- {
- uint32 a = GPR32 (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("stord", OP_REGP, OP_R_BASE_DISPE20, OP_VOID);
- SLW (addr, a);
- trace_output_32 (addr);
- }
- /* stord. */
- void
- OP_138_14 (void)
- {
- uint32 a = GPR32 (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("stord", OP_REGP, OP_R_BASE_DISPS20, OP_VOID);
- SLW (addr, a);
- trace_output_32 (addr);
- }
- /* stord. */
- void
- OP_EF_8 (void)
- {
- uint32 a = GPR32 (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("stord", OP_REGP, OP_RP_BASE_DISP16, OP_VOID);
- SLW (addr, a);
- trace_output_32 (addr);
- }
- /* stord. */
- void
- OP_139_14 (void)
- {
- uint32 a = GPR32 (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("stord", OP_REGP, OP_RP_BASE_DISPS20, OP_VOID);
- SLW (addr, a);
- trace_output_32 (addr);
- }
- /* stord. */
- void
- OP_199_14 (void)
- {
- uint32 a = GPR32 (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("stord", OP_REGP, OP_RP_BASE_DISPE20, OP_VOID);
- SLW (addr, a);
- trace_output_32 (addr);
- }
- /* stord. */
- void
- OP_13A_14 (void)
- {
- uint32 a = GPR32 (OP[0]);
- uint32 addr = (GPR32 (OP[2])) + OP[1];
- trace_input ("stord", OP_REGP, OP_RP_INDEX_DISPS20, OP_VOID);
- SLW (addr, a);
- trace_output_32 (addr);
- }
- /* macqu. */
- void
- OP_14D_14 (void)
- {
- int32 tmp;
- int16 src1, src2;
- trace_input ("macuw", OP_REG, OP_REG, OP_REGP);
- src1 = GPR (OP[0]);
- src2 = GPR (OP[1]);
- tmp = src1 * src2;
- /*REVISIT FOR SATURATION and Q FORMAT. */
- SET_GPR32 (OP[2], tmp);
- trace_output_32 (tmp);
- }
- /* macuw. */
- void
- OP_14E_14 (void)
- {
- uint32 tmp;
- uint16 src1, src2;
- trace_input ("macuw", OP_REG, OP_REG, OP_REGP);
- src1 = GPR (OP[0]);
- src2 = GPR (OP[1]);
- tmp = src1 * src2;
- /*REVISIT FOR SATURATION. */
- SET_GPR32 (OP[2], tmp);
- trace_output_32 (tmp);
- }
- /* macsw. */
- void
- OP_14F_14 (void)
- {
- int32 tmp;
- int16 src1, src2;
- trace_input ("macsw", OP_REG, OP_REG, OP_REGP);
- src1 = GPR (OP[0]);
- src2 = GPR (OP[1]);
- tmp = src1 * src2;
- /*REVISIT FOR SATURATION. */
- SET_GPR32 (OP[2], tmp);
- trace_output_32 (tmp);
- }
- /* mulb. */
- void
- OP_64_8 (void)
- {
- int16 tmp;
- int8 a = (OP[0]) & 0xff;
- int8 b = (GPR (OP[1])) & 0xff;
- trace_input ("mulb", OP_CONSTANT4_1, OP_REG, OP_VOID);
- tmp = (a * b) & 0xff;
- SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
- trace_output_16 (tmp);
- }
- /* mulb. */
- void
- OP_64B_C (void)
- {
- int16 tmp;
- int8 a = (OP[0]) & 0xff, b = (GPR (OP[1])) & 0xff;
- trace_input ("mulb", OP_CONSTANT4, OP_REG, OP_VOID);
- tmp = (a * b) & 0xff;
- SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
- trace_output_16 (tmp);
- }
- /* mulb. */
- void
- OP_65_8 (void)
- {
- int16 tmp;
- int8 a = (GPR (OP[0])) & 0xff, b = (GPR (OP[1])) & 0xff;
- trace_input ("mulb", OP_REG, OP_REG, OP_VOID);
- tmp = (a * b) & 0xff;
- SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
- trace_output_16 (tmp);
- }
- /* mulw. */
- void
- OP_66_8 (void)
- {
- int32 tmp;
- uint16 a = OP[0];
- int16 b = (GPR (OP[1]));
- trace_input ("mulw", OP_CONSTANT4_1, OP_REG, OP_VOID);
- tmp = (a * b) & 0xffff;
- SET_GPR (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* mulw. */
- void
- OP_66B_C (void)
- {
- int32 tmp;
- int16 a = OP[0], b = (GPR (OP[1]));
- trace_input ("mulw", OP_CONSTANT4, OP_REG, OP_VOID);
- tmp = (a * b) & 0xffff;
- SET_GPR (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* mulw. */
- void
- OP_67_8 (void)
- {
- int32 tmp;
- int16 a = (GPR (OP[0])), b = (GPR (OP[1]));
- trace_input ("mulw", OP_REG, OP_REG, OP_VOID);
- tmp = (a * b) & 0xffff;
- SET_GPR (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* mulsb. */
- void
- OP_B_8 (void)
- {
- int16 tmp;
- int8 a = (GPR (OP[0])) & 0xff, b = (GPR (OP[1])) & 0xff;
- trace_input ("mulsb", OP_REG, OP_REG, OP_VOID);
- tmp = a * b;
- SET_GPR (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* mulsw. */
- void
- OP_62_8 (void)
- {
- int32 tmp;
- int16 a = (GPR (OP[0])), b = (GPR (OP[1]));
- trace_input ("mulsw", OP_REG, OP_REGP, OP_VOID);
- tmp = a * b;
- SET_GPR32 (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* muluw. */
- void
- OP_63_8 (void)
- {
- uint32 tmp;
- uint16 a = (GPR (OP[0])), b = (GPR (OP[1]));
- trace_input ("muluw", OP_REG, OP_REGP, OP_VOID);
- tmp = a * b;
- SET_GPR32 (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* nop. */
- void
- OP_2C00_10 (void)
- {
- trace_input ("nop", OP_VOID, OP_VOID, OP_VOID);
- #if 0
- State.exception = SIGTRAP;
- ins_type_counters[ (int)State.ins_type ]--; /* don't count nops as normal instructions */
- switch (State.ins_type)
- {
- default:
- ins_type_counters[ (int)INS_UNKNOWN ]++;
- break;
- }
- #endif
- trace_output_void ();
- }
- /* orb. */
- void
- OP_24_8 (void)
- {
- uint8 tmp, a = (OP[0]) & 0xff, b = (GPR (OP[1])) & 0xff;
- trace_input ("orb", OP_CONSTANT4, OP_REG, OP_VOID);
- tmp = a | b;
- SET_GPR (OP[1], ((GPR (OP[1]) | tmp)));
- trace_output_16 (tmp);
- }
- /* orb. */
- void
- OP_24B_C (void)
- {
- uint8 tmp, a = (OP[0]) & 0xff, b = (GPR (OP[1])) & 0xff;
- trace_input ("orb", OP_CONSTANT16, OP_REG, OP_VOID);
- tmp = a | b;
- SET_GPR (OP[1], ((GPR (OP[1]) | tmp)));
- trace_output_16 (tmp);
- }
- /* orb. */
- void
- OP_25_8 (void)
- {
- uint8 tmp, a = (GPR (OP[0])) & 0xff, b = (GPR (OP[1])) & 0xff;
- trace_input ("orb", OP_REG, OP_REG, OP_VOID);
- tmp = a | b;
- SET_GPR (OP[1], ((GPR (OP[1]) | tmp)));
- trace_output_16 (tmp);
- }
- /* orw. */
- void
- OP_26_8 (void)
- {
- uint16 tmp, a = (OP[0]), b = (GPR (OP[1]));
- trace_input ("orw", OP_CONSTANT4, OP_REG, OP_VOID);
- tmp = a | b;
- SET_GPR (OP[1], tmp);
- trace_output_16 (tmp);
- }
- /* orw. */
- void
- OP_26B_C (void)
- {
- uint16 tmp, a = (OP[0]), b = (GPR (OP[1]));
- trace_input ("orw", OP_CONSTANT16, OP_REG, OP_VOID);
- tmp = a | b;
- SET_GPR (OP[1], tmp);
- trace_output_16 (tmp);
- }
- /* orw. */
- void
- OP_27_8 (void)
- {
- uint16 tmp, a = (GPR (OP[0])), b = (GPR (OP[1]));
- trace_input ("orw", OP_REG, OP_REG, OP_VOID);
- tmp = a | b;
- SET_GPR (OP[1], tmp);
- trace_output_16 (tmp);
- }
- /* lshb. */
- void
- OP_13_9 (void)
- {
- uint16 a = OP[0];
- uint16 tmp, b = (GPR (OP[1])) & 0xFF;
- trace_input ("lshb", OP_CONSTANT4, OP_REG, OP_VOID);
- /* A positive count specifies a shift to the left;
- * A negative count specifies a shift to the right. */
- if (sign_flag)
- tmp = b >> a;
- else
- tmp = b << a;
- sign_flag = 0; /* Reset sign_flag. */
- SET_GPR (OP[1], ((tmp & 0xFF) | ((GPR (OP[1])) & 0xFF00)));
- trace_output_16 (tmp);
- }
- /* lshb. */
- void
- OP_44_8 (void)
- {
- uint16 a = (GPR (OP[0])) & 0xff;
- uint16 tmp, b = (GPR (OP[1])) & 0xFF;
- trace_input ("lshb", OP_REG, OP_REG, OP_VOID);
- if (a & ((long)1 << 3))
- {
- sign_flag = 1;
- a = ~(a) + 1;
- }
- a = (unsigned int) (a & 0x7);
- /* A positive count specifies a shift to the left;
- * A negative count specifies a shift to the right. */
- if (sign_flag)
- tmp = b >> a;
- else
- tmp = b << a;
- sign_flag = 0; /* Reset sign_flag. */
- SET_GPR (OP[1], ((tmp & 0xFF) | ((GPR (OP[1])) & 0xFF00)));
- trace_output_16 (tmp);
- }
- /* lshw. */
- void
- OP_46_8 (void)
- {
- uint16 tmp, b = GPR (OP[1]);
- int16 a = GPR (OP[0]);
- trace_input ("lshw", OP_REG, OP_REG, OP_VOID);
- if (a & ((long)1 << 4))
- {
- sign_flag = 1;
- a = ~(a) + 1;
- }
- a = (unsigned int) (a & 0xf);
- /* A positive count specifies a shift to the left;
- * A negative count specifies a shift to the right. */
- if (sign_flag)
- tmp = b >> a;
- else
- tmp = b << a;
- sign_flag = 0; /* Reset sign_flag. */
- SET_GPR (OP[1], (tmp & 0xffff));
- trace_output_16 (tmp);
- }
- /* lshw. */
- void
- OP_49_8 (void)
- {
- uint16 tmp, b = GPR (OP[1]);
- uint16 a = OP[0];
- trace_input ("lshw", OP_CONSTANT5, OP_REG, OP_VOID);
- /* A positive count specifies a shift to the left;
- * A negative count specifies a shift to the right. */
- if (sign_flag)
- tmp = b >> a;
- else
- tmp = b << a;
- sign_flag = 0; /* Reset sign_flag. */
- SET_GPR (OP[1], (tmp & 0xffff));
- trace_output_16 (tmp);
- }
- /* lshd. */
- void
- OP_25_7 (void)
- {
- uint32 tmp, b = GPR32 (OP[1]);
- uint16 a = OP[0];
- trace_input ("lshd", OP_CONSTANT6, OP_REGP, OP_VOID);
- /* A positive count specifies a shift to the left;
- * A negative count specifies a shift to the right. */
- if (sign_flag)
- tmp = b >> a;
- else
- tmp = b << a;
- sign_flag = 0; /* Reset sign flag. */
- SET_GPR32 (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* lshd. */
- void
- OP_47_8 (void)
- {
- uint32 tmp, b = GPR32 (OP[1]);
- uint16 a = GPR (OP[0]);
- trace_input ("lshd", OP_REG, OP_REGP, OP_VOID);
- if (a & ((long)1 << 5))
- {
- sign_flag = 1;
- a = ~(a) + 1;
- }
- a = (unsigned int) (a & 0x1f);
- /* A positive count specifies a shift to the left;
- * A negative count specifies a shift to the right. */
- if (sign_flag)
- tmp = b >> a;
- else
- tmp = b << a;
- sign_flag = 0; /* Reset sign flag. */
- SET_GPR32 (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* ashub. */
- void
- OP_80_9 (void)
- {
- uint16 a = OP[0];
- int8 tmp, b = (GPR (OP[1])) & 0xFF;
- trace_input ("ashub", OP_CONSTANT4, OP_REG, OP_VOID);
- /* A positive count specifies a shift to the left;
- * A negative count specifies a shift to the right. */
- if (sign_flag)
- tmp = b >> a;
- else
- tmp = b << a;
- sign_flag = 0; /* Reset sign flag. */
- SET_GPR (OP[1], ((tmp & 0xFF) | ((GPR (OP[1])) & 0xff00)));
- trace_output_16 (tmp);
- }
- /* ashub. */
- void
- OP_81_9 (void)
- {
- uint16 a = OP[0];
- int8 tmp, b = (GPR (OP[1])) & 0xFF;
- trace_input ("ashub", OP_CONSTANT4, OP_REG, OP_VOID);
- /* A positive count specifies a shift to the left;
- * A negative count specifies a shift to the right. */
- if (sign_flag)
- tmp = b >> a;
- else
- tmp = b << a;
- sign_flag = 0; /* Reset sign flag. */
- SET_GPR (OP[1], ((tmp & 0xFF) | ((GPR (OP[1])) & 0xFF00)));
- trace_output_16 (tmp);
- }
- /* ashub. */
- void
- OP_41_8 (void)
- {
- int16 a = (GPR (OP[0]));
- int8 tmp, b = (GPR (OP[1])) & 0xFF;
- trace_input ("ashub", OP_REG, OP_REG, OP_VOID);
- if (a & ((long)1 << 3))
- {
- sign_flag = 1;
- a = ~(a) + 1;
- }
- a = (unsigned int) (a & 0x7);
- /* A positive count specifies a shift to the left;
- * A negative count specifies a shift to the right. */
- if (sign_flag)
- tmp = b >> a;
- else
- tmp = b << a;
- sign_flag = 0; /* Reset sign flag. */
- SET_GPR (OP[1], ((tmp & 0xFF) | ((GPR (OP[1])) & 0xFF00)));
- trace_output_16 (tmp);
- }
- /* ashuw. */
- void
- OP_42_8 (void)
- {
- int16 tmp, b = GPR (OP[1]);
- uint16 a = OP[0];
- trace_input ("ashuw", OP_CONSTANT5, OP_REG, OP_VOID);
- /* A positive count specifies a shift to the left;
- * A negative count specifies a shift to the right. */
- if (sign_flag)
- tmp = b >> a;
- else
- tmp = b << a;
- sign_flag = 0; /* Reset sign flag. */
- SET_GPR (OP[1], (tmp & 0xffff));
- trace_output_16 (tmp);
- }
- /* ashuw. */
- void
- OP_43_8 (void)
- {
- int16 tmp, b = GPR (OP[1]);
- uint16 a = OP[0];
- trace_input ("ashuw", OP_CONSTANT5, OP_REG, OP_VOID);
- /* A positive count specifies a shift to the left;
- * A negative count specifies a shift to the right. */
- if (sign_flag)
- tmp = b >> a;
- else
- tmp = b << a;
- sign_flag = 0; /* Reset sign flag. */
- SET_GPR (OP[1], (tmp & 0xffff));
- trace_output_16 (tmp);
- }
- /* ashuw. */
- void
- OP_45_8 (void)
- {
- int16 tmp;
- int16 a = GPR (OP[0]), b = GPR (OP[1]);
- trace_input ("ashuw", OP_REG, OP_REG, OP_VOID);
- if (a & ((long)1 << 4))
- {
- sign_flag = 1;
- a = ~(a) + 1;
- }
- a = (unsigned int) (a & 0xf);
- /* A positive count specifies a shift to the left;
- * A negative count specifies a shift to the right. */
- if (sign_flag)
- tmp = b >> a;
- else
- tmp = b << a;
- sign_flag = 0; /* Reset sign flag. */
- SET_GPR (OP[1], (tmp & 0xffff));
- trace_output_16 (tmp);
- }
- /* ashud. */
- void
- OP_26_7 (void)
- {
- int32 tmp,b = GPR32 (OP[1]);
- uint32 a = OP[0];
- trace_input ("ashud", OP_CONSTANT6, OP_REGP, OP_VOID);
- /* A positive count specifies a shift to the left;
- * A negative count specifies a shift to the right. */
- if (sign_flag)
- tmp = b >> a;
- else
- tmp = b << a;
- sign_flag = 0; /* Reset sign flag. */
- SET_GPR32 (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* ashud. */
- void
- OP_27_7 (void)
- {
- int32 tmp;
- int32 a = OP[0], b = GPR32 (OP[1]);
- trace_input ("ashud", OP_CONSTANT6, OP_REGP, OP_VOID);
- /* A positive count specifies a shift to the left;
- * A negative count specifies a shift to the right. */
- if (sign_flag)
- tmp = b >> a;
- else
- tmp = b << a;
- sign_flag = 0; /* Reset sign flag. */
- SET_GPR32 (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* ashud. */
- void
- OP_48_8 (void)
- {
- int32 tmp;
- int32 a = GPR32 (OP[0]), b = GPR32 (OP[1]);
- trace_input ("ashud", OP_REGP, OP_REGP, OP_VOID);
- if (a & ((long)1 << 5))
- {
- sign_flag = 1;
- a = ~(a) + 1;
- }
- a = (unsigned int) (a & 0x1f);
- /* A positive count specifies a shift to the left;
- * A negative count specifies a shift to the right. */
- if (sign_flag)
- tmp = b >> a;
- else
- tmp = b << a;
- sign_flag = 0; /* Reset sign flag. */
- SET_GPR32 (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* storm. */
- void
- OP_16_D (void)
- {
- uint32 addr = GPR (1);
- uint16 count = OP[0], reg = 2;
- trace_input ("storm", OP_CONSTANT4, OP_VOID, OP_VOID);
- if ((addr & 1))
- {
- State.exception = SIG_CR16_BUS;
- State.pc_changed = 1; /* Don't increment the PC. */
- trace_output_void ();
- return;
- }
- while (count)
- {
- SW (addr, (GPR (reg)));
- addr +=2;
- --count;
- reg++;
- if (reg == 6) reg = 8;
- };
- SET_GPR (1, addr);
- trace_output_void ();
- }
- /* stormp. */
- void
- OP_17_D (void)
- {
- uint32 addr = GPR32 (6);
- uint16 count = OP[0], reg = 2;
- trace_input ("stormp", OP_CONSTANT4, OP_VOID, OP_VOID);
- if ((addr & 1))
- {
- State.exception = SIG_CR16_BUS;
- State.pc_changed = 1; /* Don't increment the PC. */
- trace_output_void ();
- return;
- }
- while (count)
- {
- SW (addr, (GPR (reg)));
- addr +=2;
- --count;
- reg++;
- if (reg == 6) reg = 8;
- };
- SET_GPR32 (6, addr);
- trace_output_void ();
- }
- /* subb. */
- void
- OP_38_8 (void)
- {
- uint8 a = OP[0];
- uint8 b = (GPR (OP[1])) & 0xff;
- uint16 tmp = (~a + 1 + b) & 0xff;
- trace_input ("subb", OP_CONSTANT4, OP_REG, OP_VOID);
- /* see ../common/sim-alu.h for a more extensive discussion on how to
- compute the carry/overflow bits. */
- SET_PSR_C (tmp > 0xff);
- SET_PSR_F (((a & 0x80) != (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
- SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
- trace_output_16 (tmp);
- }
- /* subb. */
- void
- OP_38B_C (void)
- {
- uint8 a = OP[0] & 0xFF;
- uint8 b = (GPR (OP[1])) & 0xFF;
- uint16 tmp = (~a + 1 + b) & 0xFF;
- trace_input ("subb", OP_CONSTANT16, OP_REG, OP_VOID);
- /* see ../common/sim-alu.h for a more extensive discussion on how to
- compute the carry/overflow bits. */
- SET_PSR_C (tmp > 0xff);
- SET_PSR_F (((a & 0x80) != (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
- SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
- trace_output_16 (tmp);
- }
- /* subb. */
- void
- OP_39_8 (void)
- {
- uint8 a = (GPR (OP[0])) & 0xFF;
- uint8 b = (GPR (OP[1])) & 0xFF;
- uint16 tmp = (~a + 1 + b) & 0xff;
- trace_input ("subb", OP_REG, OP_REG, OP_VOID);
- /* see ../common/sim-alu.h for a more extensive discussion on how to
- compute the carry/overflow bits. */
- SET_PSR_C (tmp > 0xff);
- SET_PSR_F (((a & 0x80) != (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
- SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
- trace_output_16 (tmp);
- }
- /* subw. */
- void
- OP_3A_8 (void)
- {
- uint16 a = OP[0];
- uint16 b = GPR (OP[1]);
- uint16 tmp = (~a + 1 + b);
- trace_input ("subw", OP_CONSTANT4, OP_REG, OP_VOID);
- /* see ../common/sim-alu.h for a more extensive discussion on how to
- compute the carry/overflow bits. */
- SET_PSR_C (tmp > 0xffff);
- SET_PSR_F (((a & 0x8000) != (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
- SET_GPR (OP[1], tmp);
- trace_output_16 (tmp);
- }
- /* subw. */
- void
- OP_3AB_C (void)
- {
- uint16 a = OP[0];
- uint16 b = GPR (OP[1]);
- uint32 tmp = (~a + 1 + b);
- trace_input ("subw", OP_CONSTANT16, OP_REG, OP_VOID);
- /* see ../common/sim-alu.h for a more extensive discussion on how to
- compute the carry/overflow bits. */
- SET_PSR_C (tmp > 0xffff);
- SET_PSR_F (((a & 0x8000) != (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
- SET_GPR (OP[1], tmp & 0xffff);
- trace_output_16 (tmp);
- }
- /* subw. */
- void
- OP_3B_8 (void)
- {
- uint16 a = GPR (OP[0]);
- uint16 b = GPR (OP[1]);
- uint32 tmp = (~a + 1 + b);
- trace_input ("subw", OP_REG, OP_REG, OP_VOID);
- /* see ../common/sim-alu.h for a more extensive discussion on how to
- compute the carry/overflow bits. */
- SET_PSR_C (tmp > 0xffff);
- SET_PSR_F (((a & 0x8000) != (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
- SET_GPR (OP[1], tmp & 0xffff);
- trace_output_16 (tmp);
- }
- /* subcb. */
- void
- OP_3C_8 (void)
- {
- uint8 a = OP[0];
- uint8 b = (GPR (OP[1])) & 0xff;
- //uint16 tmp1 = a + 1;
- uint16 tmp1 = a + (PSR_C);
- uint16 tmp = (~tmp1 + 1 + b);
- trace_input ("subcb", OP_CONSTANT4, OP_REG, OP_VOID);
- /* see ../common/sim-alu.h for a more extensive discussion on how to
- compute the carry/overflow bits. */
- SET_PSR_C (tmp > 0xff);
- SET_PSR_F (((a & 0x80) != (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
- SET_GPR (OP[1], tmp);
- trace_output_16 (tmp);
- }
- /* subcb. */
- void
- OP_3CB_C (void)
- {
- uint16 a = OP[0];
- uint16 b = (GPR (OP[1])) & 0xff;
- //uint16 tmp1 = a + 1;
- uint16 tmp1 = a + (PSR_C);
- uint16 tmp = (~tmp1 + 1 + b);
- trace_input ("subcb", OP_CONSTANT16, OP_REG, OP_VOID);
- /* see ../common/sim-alu.h for a more extensive discussion on how to
- compute the carry/overflow bits. */
- SET_PSR_C (tmp > 0xff);
- SET_PSR_F (((a & 0x80) != (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
- SET_GPR (OP[1], tmp);
- trace_output_16 (tmp);
- }
- /* subcb. */
- void
- OP_3D_8 (void)
- {
- uint16 a = (GPR (OP[0])) & 0xff;
- uint16 b = (GPR (OP[1])) & 0xff;
- uint16 tmp1 = a + (PSR_C);
- uint16 tmp = (~tmp1 + 1 + b);
- trace_input ("subcb", OP_REG, OP_REG, OP_VOID);
- /* see ../common/sim-alu.h for a more extensive discussion on how to
- compute the carry/overflow bits. */
- SET_PSR_C (tmp > 0xff);
- SET_PSR_F (((a & 0x80) != (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
- SET_GPR (OP[1], tmp);
- trace_output_16 (tmp);
- }
- /* subcw. */
- void
- OP_3E_8 (void)
- {
- uint16 a = OP[0], b = (GPR (OP[1]));
- uint16 tmp1 = a + (PSR_C);
- uint16 tmp = (~tmp1 + 1 + b);
- trace_input ("subcw", OP_CONSTANT4, OP_REG, OP_VOID);
- /* see ../common/sim-alu.h for a more extensive discussion on how to
- compute the carry/overflow bits. */
- SET_PSR_C (tmp > 0xffff);
- SET_PSR_F (((a & 0x8000) != (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
- SET_GPR (OP[1], tmp);
- trace_output_16 (tmp);
- }
- /* subcw. */
- void
- OP_3EB_C (void)
- {
- int16 a = OP[0];
- uint16 b = GPR (OP[1]);
- uint16 tmp1 = a + (PSR_C);
- uint16 tmp = (~tmp1 + 1 + b);
- trace_input ("subcw", OP_CONSTANT16, OP_REG, OP_VOID);
- /* see ../common/sim-alu.h for a more extensive discussion on how to
- compute the carry/overflow bits. */
- SET_PSR_C (tmp > 0xffff);
- SET_PSR_F (((a & 0x8000) != (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
- SET_GPR (OP[1], tmp);
- trace_output_16 (tmp);
- }
- /* subcw. */
- void
- OP_3F_8 (void)
- {
- uint16 a = (GPR (OP[0])), b = (GPR (OP[1]));
- uint16 tmp1 = a + (PSR_C);
- uint16 tmp = (~tmp1 + 1 + b);
- trace_input ("subcw", OP_REG, OP_REG, OP_VOID);
- /* see ../common/sim-alu.h for a more extensive discussion on how to
- compute the carry/overflow bits. */
- SET_PSR_C (tmp > 0xffff);
- SET_PSR_F (((a & 0x8000) != (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
- SET_GPR (OP[1], tmp);
- trace_output_16 (tmp);
- }
- /* subd. */
- void
- OP_3_C (void)
- {
- int32 a = OP[0];
- uint32 b = GPR32 (OP[1]);
- uint32 tmp = (~a + 1 + b);
- trace_input ("subd", OP_CONSTANT32, OP_REGP, OP_VOID);
- /* see ../common/sim-alu.h for a more extensive discussion on how to
- compute the carry/overflow bits. */
- SET_PSR_C (tmp > 0xffffffff);
- SET_PSR_F (((a & 0x80000000) != (b & 0x80000000)) &&
- ((b & 0x80000000) != (tmp & 0x80000000)));
- SET_GPR32 (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* subd. */
- void
- OP_14C_14 (void)
- {
- uint32 a = GPR32 (OP[0]);
- uint32 b = GPR32 (OP[1]);
- uint32 tmp = (~a + 1 + b);
- trace_input ("subd", OP_REGP, OP_REGP, OP_VOID);
- /* see ../common/sim-alu.h for a more extensive discussion on how to
- compute the carry/overflow bits. */
- SET_PSR_C (tmp > 0xffffffff);
- SET_PSR_F (((a & 0x80000000) != (b & 0x80000000)) &&
- ((b & 0x80000000) != (tmp & 0x80000000)));
- SET_GPR32 (OP[1], tmp);
- trace_output_32 (tmp);
- }
- /* excp. */
- void
- OP_C_C (void)
- {
- uint32 tmp;
- uint16 a;
- trace_input ("excp", OP_CONSTANT4, OP_VOID, OP_VOID);
- switch (OP[0])
- {
- default:
- #if (DEBUG & DEBUG_TRAP) == 0
- {
- #if 0
- uint16 vec = OP[0] + TRAP_VECTOR_START;
- SET_BPC (PC + 1);
- SET_BPSR (PSR);
- SET_PSR (PSR & PSR_SM_BIT);
- JMP (vec);
- break;
- #endif
- }
- #else /* if debugging use trap to print registers */
- {
- int i;
- static int first_time = 1;
- if (first_time)
- {
- first_time = 0;
- (*cr16_callback->printf_filtered) (cr16_callback, "Trap # PC ");
- for (i = 0; i < 16; i++)
- (*cr16_callback->printf_filtered) (cr16_callback, " %sr%d", (i > 9) ? "" : " ", i);
- (*cr16_callback->printf_filtered) (cr16_callback, " a0 a1 f0 f1 c\n");
- }
- (*cr16_callback->printf_filtered) (cr16_callback, "Trap %2d 0x%.4x:", (int)OP[0], (int)PC);
- for (i = 0; i < 16; i++)
- (*cr16_callback->printf_filtered) (cr16_callback, " %.4x", (int) GPR (i));
- for (i = 0; i < 2; i++)
- (*cr16_callback->printf_filtered) (cr16_callback, " %.2x%.8lx",
- ((int)(ACC (i) >> 32) & 0xff),
- ((unsigned long) ACC (i)) & 0xffffffff);
- (*cr16_callback->printf_filtered) (cr16_callback, " %d %d %d\n",
- PSR_F != 0, PSR_F != 0, PSR_C != 0);
- (*cr16_callback->flush_stdout) (cr16_callback);
- break;
- }
- #endif
- case 8: /* new system call trap */
- /* Trap 8 is used for simulating low-level I/O */
- {
- unsigned32 result = 0;
- errno = 0;
- /* Registers passed to trap 0. */
- #define FUNC GPR (0) /* function number. */
- #define PARM1 GPR (2) /* optional parm 1. */
- #define PARM2 GPR (3) /* optional parm 2. */
- #define PARM3 GPR (4) /* optional parm 3. */
- #define PARM4 GPR (5) /* optional parm 4. */
- /* Registers set by trap 0 */
- #define RETVAL(X) do { result = (0xffff & (X));SET_GPR (0, result);} while (0)
- #define RETVAL32(X) do { result = (X); SET_GPR32 (0, result);} while (0)
- #define RETERR(X) SET_GPR (4, (X)) /* return error code. */
- /* Turn a pointer in a register into a pointer into real memory. */
- #define MEMPTR(x) ((char *)(dmem_addr(x)))
- switch (FUNC)
- {
- #if !defined(__GO32__) && !defined(_WIN32)
- #ifdef TARGET_SYS_fork
- case TARGET_SYS_fork:
- trace_input ("<fork>", OP_VOID, OP_VOID, OP_VOID);
- RETVAL (fork ());
- trace_output_16 (result);
- break;
- #endif
- #define getpid() 47
- case TARGET_SYS_getpid:
- trace_input ("<getpid>", OP_VOID, OP_VOID, OP_VOID);
- RETVAL (getpid ());
- trace_output_16 (result);
- break;
- case TARGET_SYS_kill:
- trace_input ("<kill>", OP_REG, OP_REG, OP_VOID);
- if (PARM1 == getpid ())
- {
- trace_output_void ();
- State.exception = PARM2;
- }
- else
- {
- int os_sig = -1;
- switch (PARM2)
- {
- #ifdef SIGHUP
- case 1: os_sig = SIGHUP; break;
- #endif
- #ifdef SIGINT
- case 2: os_sig = SIGINT; break;
- #endif
- #ifdef SIGQUIT
- case 3: os_sig = SIGQUIT; break;
- #endif
- #ifdef SIGILL
- case 4: os_sig = SIGILL; break;
- #endif
- #ifdef SIGTRAP
- case 5: os_sig = SIGTRAP; break;
- #endif
- #ifdef SIGABRT
- case 6: os_sig = SIGABRT; break;
- #elif defined(SIGIOT)
- case 6: os_sig = SIGIOT; break;
- #endif
- #ifdef SIGEMT
- case 7: os_sig = SIGEMT; break;
- #endif
- #ifdef SIGFPE
- case 8: os_sig = SIGFPE; break;
- #endif
- #ifdef SIGKILL
- case 9: os_sig = SIGKILL; break;
- #endif
- #ifdef SIGBUS
- case 10: os_sig = SIGBUS; break;
- #endif
- #ifdef SIGSEGV
- case 11: os_sig = SIGSEGV; break;
- #endif
- #ifdef SIGSYS
- case 12: os_sig = SIGSYS; break;
- #endif
- #ifdef SIGPIPE
- case 13: os_sig = SIGPIPE; break;
- #endif
- #ifdef SIGALRM
- case 14: os_sig = SIGALRM; break;
- #endif
- #ifdef SIGTERM
- case 15: os_sig = SIGTERM; break;
- #endif
- #ifdef SIGURG
- case 16: os_sig = SIGURG; break;
- #endif
- #ifdef SIGSTOP
- case 17: os_sig = SIGSTOP; break;
- #endif
- #ifdef SIGTSTP
- case 18: os_sig = SIGTSTP; break;
- #endif
- #ifdef SIGCONT
- case 19: os_sig = SIGCONT; break;
- #endif
- #ifdef SIGCHLD
- case 20: os_sig = SIGCHLD; break;
- #elif defined(SIGCLD)
- case 20: os_sig = SIGCLD; break;
- #endif
- #ifdef SIGTTIN
- case 21: os_sig = SIGTTIN; break;
- #endif
- #ifdef SIGTTOU
- case 22: os_sig = SIGTTOU; break;
- #endif
- #ifdef SIGIO
- case 23: os_sig = SIGIO; break;
- #elif defined (SIGPOLL)
- case 23: os_sig = SIGPOLL; break;
- #endif
- #ifdef SIGXCPU
- case 24: os_sig = SIGXCPU; break;
- #endif
- #ifdef SIGXFSZ
- case 25: os_sig = SIGXFSZ; break;
- #endif
- #ifdef SIGVTALRM
- case 26: os_sig = SIGVTALRM; break;
- #endif
- #ifdef SIGPROF
- case 27: os_sig = SIGPROF; break;
- #endif
- #ifdef SIGWINCH
- case 28: os_sig = SIGWINCH; break;
- #endif
- #ifdef SIGLOST
- case 29: os_sig = SIGLOST; break;
- #endif
- #ifdef SIGUSR1
- case 30: os_sig = SIGUSR1; break;
- #endif
- #ifdef SIGUSR2
- case 31: os_sig = SIGUSR2; break;
- #endif
- }
- if (os_sig == -1)
- {
- trace_output_void ();
- (*cr16_callback->printf_filtered) (cr16_callback, "Unknown signal %d\n", PARM2);
- (*cr16_callback->flush_stdout) (cr16_callback);
- State.exception = SIGILL;
- }
- else
- {
- RETVAL (kill (PARM1, PARM2));
- trace_output_16 (result);
- }
- }
- break;
- #ifdef TARGET_SYS_execve
- case TARGET_SYS_execve:
- trace_input ("<execve>", OP_VOID, OP_VOID, OP_VOID);
- RETVAL (execve (MEMPTR (PARM1), (char **) MEMPTR (PARM2<<16|PARM3),
- (char **)MEMPTR (PARM4)));
- trace_output_16 (result);
- break;
- #endif
- #ifdef TARGET_SYS_execv
- case TARGET_SYS_execv:
- trace_input ("<execv>", OP_VOID, OP_VOID, OP_VOID);
- RETVAL (execve (MEMPTR (PARM1), (char **) MEMPTR (PARM2), NULL));
- trace_output_16 (result);
- break;
- #endif
- #ifdef TARGET_SYS_pipe
- case TARGET_SYS_pipe:
- {
- reg_t buf;
- int host_fd[2];
- trace_input ("<pipe>", OP_VOID, OP_VOID, OP_VOID);
- buf = PARM1;
- RETVAL (pipe (host_fd));
- SW (buf, host_fd[0]);
- buf += sizeof(uint16);
- SW (buf, host_fd[1]);
- trace_output_16 (result);
- }
- break;
- #endif
- #ifdef TARGET_SYS_wait
- case TARGET_SYS_wait:
- {
- int status;
- trace_input ("<wait>", OP_REG, OP_VOID, OP_VOID);
- RETVAL (wait (&status));
- if (PARM1)
- SW (PARM1, status);
- trace_output_16 (result);
- }
- break;
- #endif
- #else
- case TARGET_SYS_getpid:
- trace_input ("<getpid>", OP_VOID, OP_VOID, OP_VOID);
- RETVAL (1);
- trace_output_16 (result);
- break;
- case TARGET_SYS_kill:
- trace_input ("<kill>", OP_REG, OP_REG, OP_VOID);
- trace_output_void ();
- State.exception = PARM2;
- break;
- #endif
- case TARGET_SYS_read:
- trace_input ("<read>", OP_REG, OP_MEMREF, OP_REG);
- RETVAL (cr16_callback->read (cr16_callback, PARM1,
- MEMPTR (((unsigned long)PARM3 << 16)
- |((unsigned long)PARM2)), PARM4));
- trace_output_16 (result);
- break;
- case TARGET_SYS_write:
- trace_input ("<write>", OP_REG, OP_MEMREF, OP_REG);
- RETVAL ((int)cr16_callback->write (cr16_callback, PARM1,
- MEMPTR (((unsigned long)PARM3 << 16) | PARM2), PARM4));
- trace_output_16 (result);
- break;
- case TARGET_SYS_lseek:
- trace_input ("<lseek>", OP_REG, OP_REGP, OP_REG);
- RETVAL32 (cr16_callback->lseek (cr16_callback, PARM1,
- ((((long) PARM3) << 16) | PARM2),
- PARM4));
- trace_output_32 (result);
- break;
- case TARGET_SYS_close:
- trace_input ("<close>", OP_REG, OP_VOID, OP_VOID);
- RETVAL (cr16_callback->close (cr16_callback, PARM1));
- trace_output_16 (result);
- break;
- case TARGET_SYS_open:
- trace_input ("<open>", OP_MEMREF, OP_REG, OP_VOID);
- RETVAL32 (cr16_callback->open (cr16_callback,
- MEMPTR ((((unsigned long)PARM2)<<16)|PARM1),
- PARM3));
- trace_output_32 (result);
- break;
- #ifdef TARGET_SYS_rename
- case TARGET_SYS_rename:
- trace_input ("<rename>", OP_MEMREF, OP_MEMREF, OP_VOID);
- RETVAL (cr16_callback->rename (cr16_callback,
- MEMPTR ((((unsigned long)PARM2)<<16) |PARM1),
- MEMPTR ((((unsigned long)PARM4)<<16) |PARM3)));
- trace_output_16 (result);
- break;
- #endif
- case 0x408: /* REVISIT: Added a dummy getenv call. */
- trace_input ("<getenv>", OP_MEMREF, OP_MEMREF, OP_VOID);
- RETVAL32 (0);
- trace_output_32 (result);
- break;
- case TARGET_SYS_exit:
- trace_input ("<exit>", OP_VOID, OP_VOID, OP_VOID);
- State.exception = SIG_CR16_EXIT;
- trace_output_void ();
- break;
- case TARGET_SYS_unlink:
- trace_input ("<unlink>", OP_MEMREF, OP_VOID, OP_VOID);
- RETVAL (cr16_callback->unlink (cr16_callback,
- MEMPTR (((unsigned long)PARM2<<16)|PARM1)));
- trace_output_16 (result);
- break;
- #ifdef TARGET_SYS_stat
- case TARGET_SYS_stat:
- trace_input ("<stat>", OP_VOID, OP_VOID, OP_VOID);
- /* stat system call. */
- {
- struct stat host_stat;
- reg_t buf;
- RETVAL (stat (MEMPTR ((((unsigned long)PARM2) << 16)|PARM1), &host_stat));
- buf = PARM2;
- /* The hard-coded offsets and sizes were determined by using
- * the CR16 compiler on a test program that used struct stat.
- */
- SW (buf, host_stat.st_dev);
- SW (buf+2, host_stat.st_ino);
- SW (buf+4, host_stat.st_mode);
- SW (buf+6, host_stat.st_nlink);
- SW (buf+8, host_stat.st_uid);
- SW (buf+10, host_stat.st_gid);
- SW (buf+12, host_stat.st_rdev);
- SLW (buf+16, host_stat.st_size);
- SLW (buf+20, host_stat.st_atime);
- SLW (buf+28, host_stat.st_mtime);
- SLW (buf+36, host_stat.st_ctime);
- }
- trace_output_16 (result);
- break;
- #endif
- #ifdef TARGET_SYS_chown
- case TARGET_SYS_chown:
- trace_input ("<chown>", OP_VOID, OP_VOID, OP_VOID);
- RETVAL (chown (MEMPTR (PARM1), PARM2, PARM3));
- trace_output_16 (result);
- break;
- #endif
- case TARGET_SYS_chmod:
- trace_input ("<chmod>", OP_VOID, OP_VOID, OP_VOID);
- RETVAL (chmod (MEMPTR (PARM1), PARM2));
- trace_output_16 (result);
- break;
- #ifdef TARGET_SYS_utime
- case TARGET_SYS_utime:
- trace_input ("<utime>", OP_REG, OP_REG, OP_REG);
- /* Cast the second argument to void *, to avoid type mismatch
- if a prototype is present. */
- RETVAL (utime (MEMPTR (PARM1), (void *) MEMPTR (PARM2)));
- trace_output_16 (result);
- break;
- #endif
- #ifdef TARGET_SYS_time
- case TARGET_SYS_time:
- trace_input ("<time>", OP_VOID, OP_VOID, OP_REG);
- RETVAL32 (time (NULL));
- trace_output_32 (result);
- break;
- #endif
-
- default:
- a = OP[0];
- switch (a)
- {
- case TRAP_BREAKPOINT:
- State.exception = SIGTRAP;
- tmp = (PC);
- JMP(tmp);
- trace_output_void ();
- break;
- case SIGTRAP: /* supervisor call ? */
- State.exception = SIG_CR16_EXIT;
- trace_output_void ();
- break;
- default:
- cr16_callback->error (cr16_callback, "Unknown syscall %d", FUNC);
- break;
- }
- }
- if ((uint16) result == (uint16) -1)
- RETERR (cr16_callback->get_errno(cr16_callback));
- else
- RETERR (0);
- break;
- }
- }
- }
- /* push. */
- void
- OP_3_9 (void)
- {
- uint16 a = OP[0] + 1, b = OP[1], c = OP[2], i = 0;
- uint32 tmp, sp_addr = (GPR32 (15)) - (a * 2) - 4, is_regp = 0;
- trace_input ("push", OP_CONSTANT3, OP_REG, OP_REG);
- for (; i < a; ++i)
- {
- if ((b+i) <= 11)
- {
- SW (sp_addr, (GPR (b+i)));
- sp_addr +=2;
- }
- else
- {
- if (is_regp == 0)
- tmp = (GPR32 (b+i));
- else
- tmp = (GPR32 (b+i-1));
- if ((a-i) > 1)
- {
- SLW (sp_addr, tmp);
- sp_addr +=4;
- }
- else
- {
- SW (sp_addr, tmp);
- sp_addr +=2;
- }
- ++i;
- is_regp = 1;
- }
- }
- sp_addr +=4;
- /* Store RA address. */
- tmp = (GPR32 (14));
- SLW(sp_addr,tmp);
- sp_addr = (GPR32 (15)) - (a * 2) - 4;
- SET_GPR32 (15, sp_addr); /* Update SP address. */
- trace_output_void ();
- }
- /* push. */
- void
- OP_1_8 (void)
- {
- uint32 sp_addr, tmp, is_regp = 0;
- uint16 a = OP[0] + 1, b = OP[1], c = OP[2], i = 0;
- trace_input ("push", OP_CONSTANT3, OP_REG, OP_VOID);
- if (c == 1)
- sp_addr = (GPR32 (15)) - (a * 2) - 4;
- else
- sp_addr = (GPR32 (15)) - (a * 2);
- for (; i < a; ++i)
- {
- if ((b+i) <= 11)
- {
- SW (sp_addr, (GPR (b+i)));
- sp_addr +=2;
- }
- else
- {
- if (is_regp == 0)
- tmp = (GPR32 (b+i));
- else
- tmp = (GPR32 (b+i-1));
- if ((a-i) > 1)
- {
- SLW (sp_addr, tmp);
- sp_addr +=4;
- }
- else
- {
- SW (sp_addr, tmp);
- sp_addr +=2;
- }
- ++i;
- is_regp = 1;
- }
- }
- if (c == 1)
- {
- /* Store RA address. */
- tmp = (GPR32 (14));
- SLW(sp_addr,tmp);
- sp_addr = (GPR32 (15)) - (a * 2) - 4;
- }
- else
- sp_addr = (GPR32 (15)) - (a * 2);
- SET_GPR32 (15, sp_addr); /* Update SP address. */
- trace_output_void ();
- }
- /* push. */
- void
- OP_11E_10 (void)
- {
- uint32 sp_addr = (GPR32 (15)), tmp;
- trace_input ("push", OP_VOID, OP_VOID, OP_VOID);
- tmp = (GPR32 (14));
- SLW(sp_addr-4,tmp); /* Store RA address. */
- SET_GPR32 (15, (sp_addr - 4)); /* Update SP address. */
- trace_output_void ();
- }
- /* pop. */
- void
- OP_5_9 (void)
- {
- uint16 a = OP[0] + 1, b = OP[1], c = OP[2], i = 0;
- uint32 tmp, sp_addr = (GPR32 (15)), is_regp = 0;;
- trace_input ("pop", OP_CONSTANT3, OP_REG, OP_REG);
- for (; i < a; ++i)
- {
- if ((b+i) <= 11)
- {
- SET_GPR ((b+i), RW(sp_addr));
- sp_addr +=2;
- }
- else
- {
- if ((a-i) > 1)
- {
- tmp = RLW(sp_addr);
- sp_addr +=4;
- }
- else
- {
- tmp = RW(sp_addr);
- sp_addr +=2;
- if (is_regp == 0)
- tmp = (tmp << 16) | (GPR32 (b+i));
- else
- tmp = (tmp << 16) | (GPR32 (b+i-1));
- }
- if (is_regp == 0)
- SET_GPR32 ((b+i), (((tmp & 0xffff) << 16)
- | ((tmp >> 16) & 0xffff)));
- else
- SET_GPR32 ((b+i-1), (((tmp & 0xffff) << 16)
- | ((tmp >> 16) & 0xffff)));
- ++i;
- is_regp = 1;
- }
- }
- tmp = RLW(sp_addr); /* store RA also. */
- SET_GPR32 (14, (((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff)));
- SET_GPR32 (15, (sp_addr + 4)); /* Update SP address. */
- trace_output_void ();
- }
- /* pop. */
- void
- OP_2_8 (void)
- {
- uint16 a = OP[0] + 1, b = OP[1], c = OP[2], i = 0;
- uint32 tmp, sp_addr = (GPR32 (15)), is_regp = 0;
- trace_input ("pop", OP_CONSTANT3, OP_REG, OP_VOID);
- for (; i < a; ++i)
- {
- if ((b+i) <= 11)
- {
- SET_GPR ((b+i), RW(sp_addr));
- sp_addr +=2;
- }
- else
- {
- if ((a-i) > 1)
- {
- tmp = RLW(sp_addr);
- sp_addr +=4;
- }
- else
- {
- tmp = RW(sp_addr);
- sp_addr +=2;
- if (is_regp == 0)
- tmp = ((tmp << 16) & 0xffffffff) | (GPR32 (b+i));
- else
- tmp = ((tmp << 16) & 0xffffffff) | (GPR32 (b+i-1));
- }
- if (is_regp == 0)
- SET_GPR32 ((b+i), (((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff)));
- else
- SET_GPR32 ((b+i-1), (((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff)));
- ++i;
- is_regp = 1;
- }
- }
- if (c == 1)
- {
- tmp = RLW(sp_addr); /* Store RA Reg. */
- SET_GPR32 (14, (((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff)));
- sp_addr +=4;
- }
- SET_GPR32 (15, sp_addr); /* Update SP address. */
- trace_output_void ();
- }
- /* pop. */
- void
- OP_21E_10 (void)
- {
- uint32 sp_addr = GPR32 (15);
- uint32 tmp;
- trace_input ("pop", OP_VOID, OP_VOID, OP_VOID);
- tmp = RLW(sp_addr);
- SET_GPR32 (14, (((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff)));
- SET_GPR32 (15, (sp_addr+4)); /* Update SP address. */
- trace_output_void ();
- }
- /* popret. */
- void
- OP_7_9 (void)
- {
- uint16 a = OP[0], b = OP[1];
- trace_input ("popret", OP_CONSTANT3, OP_REG, OP_REG);
- OP_5_9 ();
- JMP(((GPR32(14)) << 1) & 0xffffff);
- trace_output_void ();
- }
- /* popret. */
- void
- OP_3_8 (void)
- {
- uint16 a = OP[0], b = OP[1];
- trace_input ("popret", OP_CONSTANT3, OP_REG, OP_VOID);
- OP_2_8 ();
- JMP(((GPR32(14)) << 1) & 0xffffff);
- trace_output_void ();
- }
- /* popret. */
- void
- OP_31E_10 (void)
- {
- uint32 tmp;
- trace_input ("popret", OP_VOID, OP_VOID, OP_VOID);
- OP_21E_10 ();
- tmp = (((GPR32(14)) << 1) & 0xffffff);
- /* If the resulting PC value is less than 0x00_0000 or greater
- than 0xFF_FFFF, this instruction causes an IAD trap.*/
- if ((tmp < 0x0) || (tmp > 0xFFFFFF))
- {
- State.exception = SIG_CR16_BUS;
- State.pc_changed = 1; /* Don't increment the PC. */
- trace_output_void ();
- return;
- }
- else
- JMP (tmp);
- trace_output_32 (tmp);
- }
- /* cinv[i]. */
- void
- OP_A_10 (void)
- {
- trace_input ("cinv[i]", OP_VOID, OP_VOID, OP_VOID);
- SET_PSR_I (1);
- trace_output_void ();
- }
- /* cinv[i,u]. */
- void
- OP_B_10 (void)
- {
- trace_input ("cinv[i,u]", OP_VOID, OP_VOID, OP_VOID);
- SET_PSR_I (1);
- trace_output_void ();
- }
- /* cinv[d]. */
- void
- OP_C_10 (void)
- {
- trace_input ("cinv[d]", OP_VOID, OP_VOID, OP_VOID);
- SET_PSR_I (1);
- trace_output_void ();
- }
- /* cinv[d,u]. */
- void
- OP_D_10 (void)
- {
- trace_input ("cinv[i,u]", OP_VOID, OP_VOID, OP_VOID);
- SET_PSR_I (1);
- trace_output_void ();
- }
- /* cinv[d,i]. */
- void
- OP_E_10 (void)
- {
- trace_input ("cinv[d,i]", OP_VOID, OP_VOID, OP_VOID);
- SET_PSR_I (1);
- trace_output_void ();
- }
- /* cinv[d,i,u]. */
- void
- OP_F_10 (void)
- {
- trace_input ("cinv[d,i,u]", OP_VOID, OP_VOID, OP_VOID);
- SET_PSR_I (1);
- trace_output_void ();
- }
- /* retx. */
- void
- OP_3_10 (void)
- {
- trace_input ("retx", OP_VOID, OP_VOID, OP_VOID);
- SET_PSR_I (1);
- trace_output_void ();
- }
- /* di. */
- void
- OP_4_10 (void)
- {
- trace_input ("di", OP_VOID, OP_VOID, OP_VOID);
- SET_PSR_I (1);
- trace_output_void ();
- }
- /* ei. */
- void
- OP_5_10 (void)
- {
- trace_input ("ei", OP_VOID, OP_VOID, OP_VOID);
- SET_PSR_I (1);
- trace_output_void ();
- }
- /* wait. */
- void
- OP_6_10 (void)
- {
- trace_input ("wait", OP_VOID, OP_VOID, OP_VOID);
- State.exception = SIGTRAP;
- trace_output_void ();
- }
- /* ewait. */
- void
- OP_7_10 (void)
- {
- trace_input ("ewait", OP_VOID, OP_VOID, OP_VOID);
- SET_PSR_I (1);
- trace_output_void ();
- }
- /* xorb. */
- void
- OP_28_8 (void)
- {
- uint8 tmp, a = (OP[0]) & 0xff, b = (GPR (OP[1])) & 0xff;
- trace_input ("xorb", OP_CONSTANT4, OP_REG, OP_VOID);
- tmp = a ^ b;
- SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
- trace_output_16 (tmp);
- }
- /* xorb. */
- void
- OP_28B_C (void)
- {
- uint8 tmp, a = (OP[0]) & 0xff, b = (GPR (OP[1])) & 0xff;
- trace_input ("xorb", OP_CONSTANT16, OP_REG, OP_VOID);
- tmp = a ^ b;
- SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
- trace_output_16 (tmp);
- }
- /* xorb. */
- void
- OP_29_8 (void)
- {
- uint8 tmp, a = (GPR (OP[0])) & 0xff, b = (GPR (OP[1])) & 0xff;
- trace_input ("xorb", OP_REG, OP_REG, OP_VOID);
- tmp = a ^ b;
- SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
- trace_output_16 (tmp);
- }
- /* xorw. */
- void
- OP_2A_8 (void)
- {
- uint16 tmp, a = (OP[0]), b = (GPR (OP[1]));
- trace_input ("xorw", OP_CONSTANT4, OP_REG, OP_VOID);
- tmp = a ^ b;
- SET_GPR (OP[1], tmp);
- trace_output_16 (tmp);
- }
- /* xorw. */
- void
- OP_2AB_C (void)
- {
- uint16 tmp, a = (OP[0]), b = (GPR (OP[1]));
- trace_input ("xorw", OP_CONSTANT16, OP_REG, OP_VOID);
- tmp = a ^ b;
- SET_GPR (OP[1], tmp);
- trace_output_16 (tmp);
- }
- /* xorw. */
- void
- OP_2B_8 (void)
- {
- uint16 tmp, a = (GPR (OP[0])), b = (GPR (OP[1]));
- trace_input ("xorw", OP_REG, OP_REG, OP_VOID);
- tmp = a ^ b;
- SET_GPR (OP[1], tmp);
- trace_output_16 (tmp);
- }
- /*REVISIT FOR LPR/SPR . */
- /* lpr. */
- void
- OP_140_14 (void)
- {
- uint16 a = GPR (OP[0]);
- trace_input ("lpr", OP_REG, OP_REG, OP_VOID);
- SET_CREG (OP[1], a);
- trace_output_16 (a);
- }
- /* lprd. */
- void
- OP_141_14 (void)
- {
- uint32 a = GPR32 (OP[0]);
- trace_input ("lprd", OP_REGP, OP_REG, OP_VOID);
- SET_CREG (OP[1], a);
- trace_output_flag ();
- }
- /* spr. */
- void
- OP_142_14 (void)
- {
- uint16 a = CREG (OP[0]);
- trace_input ("spr", OP_REG, OP_REG, OP_VOID);
- SET_GPR (OP[1], a);
- trace_output_16 (a);
- }
- /* sprd. */
- void
- OP_143_14 (void)
- {
- uint32 a = CREG (OP[0]);
- trace_input ("sprd", OP_REGP, OP_REGP, OP_VOID);
- SET_GPR32 (OP[1], a);
- trace_output_32 (a);
- }
- /* null. */
- void
- OP_0_20 (void)
- {
- trace_input ("null", OP_VOID, OP_VOID, OP_VOID);
- State.exception = SIG_CR16_STOP;
- }
|