m32c.cpu 369 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522
  1. ; Renesas M32C CPU description. -*- Scheme -*-
  2. ;
  3. ; Copyright 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
  4. ;
  5. ; Contributed by Red Hat Inc; developed under contract from Renesas.
  6. ;
  7. ; This file is part of the GNU Binutils.
  8. ;
  9. ; This program is free software; you can redistribute it and/or modify
  10. ; it under the terms of the GNU General Public License as published by
  11. ; the Free Software Foundation; either version 3 of the License, or
  12. ; (at your option) any later version.
  13. ;
  14. ; This program is distributed in the hope that it will be useful,
  15. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ; GNU General Public License for more details.
  18. ;
  19. ; You should have received a copy of the GNU General Public License
  20. ; along with this program; if not, write to the Free Software
  21. ; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  22. ; MA 02110-1301, USA.
  23. (include "simplify.inc")
  24. (define-arch
  25. (name m32c)
  26. (comment "Renesas M32C")
  27. (default-alignment forced)
  28. (insn-lsb0? #f)
  29. (machs m16c m32c)
  30. (isas m16c m32c)
  31. )
  32. (define-isa
  33. (name m16c)
  34. (default-insn-bitsize 32)
  35. ; Number of bytes of insn we can initially fetch.
  36. (base-insn-bitsize 32)
  37. ; Used in computing bit numbers.
  38. (default-insn-word-bitsize 32)
  39. (decode-assist (0 1 2 3 4 5 6 7)) ; Initial bitnumbers to decode insns by.
  40. ; fetches 1 insn at a time.
  41. (liw-insns 1)
  42. ; executes 1 insn at a time.
  43. (parallel-insns 1)
  44. )
  45. (define-isa
  46. (name m32c)
  47. (default-insn-bitsize 32)
  48. ; Number of bytes of insn we can initially fetch.
  49. (base-insn-bitsize 32)
  50. ; Used in computing bit numbers.
  51. (default-insn-word-bitsize 32)
  52. (decode-assist (0 1 2 3 4 5 6 7)) ; Initial bitnumbers to decode insns by.
  53. ; fetches 1 insn at a time.
  54. (liw-insns 1)
  55. ; executes 1 insn at a time.
  56. (parallel-insns 1)
  57. )
  58. (define-cpu
  59. ; cpu names must be distinct from the architecture name and machine names.
  60. ; The "b" suffix stands for "base" and is the convention.
  61. ; The "f" suffix stands for "family" and is the convention.
  62. (name m16cbf)
  63. (comment "Renesas M16C base family")
  64. (insn-endian big)
  65. (data-endian little)
  66. (word-bitsize 16)
  67. )
  68. (define-cpu
  69. ; cpu names must be distinct from the architecture name and machine names.
  70. ; The "b" suffix stands for "base" and is the convention.
  71. ; The "f" suffix stands for "family" and is the convention.
  72. (name m32cbf)
  73. (comment "Renesas M32C base family")
  74. (insn-endian big)
  75. (data-endian little)
  76. (word-bitsize 16)
  77. )
  78. (define-mach
  79. (name m16c)
  80. (comment "Generic M16C cpu")
  81. (cpu m32cbf)
  82. )
  83. (define-mach
  84. (name m32c)
  85. (comment "Generic M32C cpu")
  86. (cpu m32cbf)
  87. )
  88. ; Model descriptions.
  89. (define-model
  90. (name m16c)
  91. (comment "m16c") (attrs)
  92. (mach m16c)
  93. ; `state' is a list of variables for recording model state
  94. ; (state)
  95. (unit u-exec "Execution Unit" ()
  96. 1 1 ; issue done
  97. () ; state
  98. () ; inputs
  99. () ; outputs
  100. () ; profile action (default)
  101. )
  102. )
  103. (define-model
  104. (name m32c)
  105. (comment "m32c") (attrs)
  106. (mach m32c)
  107. ; `state' is a list of variables for recording model state
  108. ; (state)
  109. (unit u-exec "Execution Unit" ()
  110. 1 1 ; issue done
  111. () ; state
  112. () ; inputs
  113. () ; outputs
  114. () ; profile action (default)
  115. )
  116. )
  117. (define-attr
  118. (type enum)
  119. (name RL_TYPE)
  120. (values NONE JUMP 1ADDR 2ADDR)
  121. (default NONE)
  122. )
  123. ; Macros to simplify MACH attribute specification.
  124. (define-pmacro all-isas () (ISA m16c,m32c))
  125. (define-pmacro m16c-isa () (ISA m16c))
  126. (define-pmacro m32c-isa () (ISA m32c))
  127. (define-pmacro MACH16 (MACH m16c))
  128. (define-pmacro MACH32 (MACH m32c))
  129. (define-pmacro (machine size)
  130. (MACH (.sym m size c)) (ISA (.sym m size c)))
  131. (define-pmacro RL_JUMP (RL_TYPE JUMP))
  132. (define-pmacro RL_1ADDR (RL_TYPE 1ADDR))
  133. (define-pmacro RL_2ADDR (RL_TYPE 2ADDR))
  134. ;=============================================================
  135. ; Fields
  136. ;-------------------------------------------------------------
  137. ; Main opcodes
  138. ;
  139. (dnf f-0-1 "opcode" (all-isas) 0 1)
  140. (dnf f-0-2 "opcode" (all-isas) 0 2)
  141. (dnf f-0-3 "opcode" (all-isas) 0 3)
  142. (dnf f-0-4 "opcode" (all-isas) 0 4)
  143. (dnf f-1-3 "opcode" (all-isas) 1 3)
  144. (dnf f-2-2 "opcode" (all-isas) 2 2)
  145. (dnf f-3-4 "opcode" (all-isas) 3 4)
  146. (dnf f-3-1 "opcode" (all-isas) 3 1)
  147. (dnf f-4-1 "opcode" (all-isas) 4 1)
  148. (dnf f-4-3 "opcode" (all-isas) 4 3)
  149. (dnf f-4-4 "opcode" (all-isas) 4 4)
  150. (dnf f-4-6 "opcode" (all-isas) 4 6)
  151. (dnf f-5-1 "opcode" (all-isas) 5 1)
  152. (dnf f-5-3 "opcode" (all-isas) 5 3)
  153. (dnf f-6-2 "opcode" (all-isas) 6 2)
  154. (dnf f-7-1 "opcode" (all-isas) 7 1)
  155. (dnf f-8-1 "opcode" (all-isas) 8 1)
  156. (dnf f-8-2 "opcode" (all-isas) 8 2)
  157. (dnf f-8-3 "opcode" (all-isas) 8 3)
  158. (dnf f-8-4 "opcode" (all-isas) 8 4)
  159. (dnf f-8-8 "opcode" (all-isas) 8 8)
  160. (dnf f-9-3 "opcode" (all-isas) 9 3)
  161. (dnf f-9-1 "opcode" (all-isas) 9 1)
  162. (dnf f-10-1 "opcode" (all-isas) 10 1)
  163. (dnf f-10-2 "opcode" (all-isas) 10 2)
  164. (dnf f-10-3 "opcode" (all-isas) 10 3)
  165. (dnf f-11-1 "opcode" (all-isas) 11 1)
  166. (dnf f-12-1 "opcode" (all-isas) 12 1)
  167. (dnf f-12-2 "opcode" (all-isas) 12 2)
  168. (dnf f-12-3 "opcode" (all-isas) 12 3)
  169. (dnf f-12-4 "opcode" (all-isas) 12 4)
  170. (dnf f-12-6 "opcode" (all-isas) 12 6)
  171. (dnf f-13-3 "opcode" (all-isas) 13 3)
  172. (dnf f-14-1 "opcode" (all-isas) 14 1)
  173. (dnf f-14-2 "opcode" (all-isas) 14 2)
  174. (dnf f-15-1 "opcode" (all-isas) 15 1)
  175. (dnf f-16-1 "opcode" (all-isas) 16 1)
  176. (dnf f-16-2 "opcode" (all-isas) 16 2)
  177. (dnf f-16-4 "opcode" (all-isas) 16 4)
  178. (dnf f-16-8 "opcode" (all-isas) 16 8)
  179. (dnf f-18-1 "opcode" (all-isas) 18 1)
  180. (dnf f-18-2 "opcode" (all-isas) 18 2)
  181. (dnf f-18-3 "opcode" (all-isas) 18 3)
  182. (dnf f-20-1 "opcode" (all-isas) 20 1)
  183. (dnf f-20-3 "opcode" (all-isas) 20 3)
  184. (dnf f-20-2 "opcode" (all-isas) 20 2)
  185. (dnf f-20-4 "opcode" (all-isas) 20 4)
  186. (dnf f-21-3 "opcode" (all-isas) 21 3)
  187. (dnf f-24-2 "opcode" (all-isas) 24 2)
  188. (dnf f-24-8 "opcode" (all-isas) 24 8)
  189. (dnf f-32-16 "opcode" (all-isas) 32 16)
  190. ;-------------------------------------------------------------
  191. ; Registers
  192. ;-------------------------------------------------------------
  193. (dnf f-src16-rn "source Rn for m16c" (MACH16 m16c-isa) 10 2)
  194. (dnf f-src16-an "source An for m16c" (MACH16 m16c-isa) 11 1)
  195. (dnf f-src32-an-unprefixed "destination An for m32c" (MACH32 m32c-isa) 11 1)
  196. (dnf f-src32-an-prefixed "destination An for m32c" (MACH32 m32c-isa) 19 1)
  197. ; QI mode gr encoding for m32c is different than for m16c. The hardware
  198. ; is indexed using the m16c encoding, so perform the transformation here.
  199. ; register m16c m32c
  200. ; ----------------------
  201. ; r0l 00'b 10'b
  202. ; r0h 01'b 00'b
  203. ; r1l 10'b 11'b
  204. ; r1h 11'b 01'b
  205. (df f-src32-rn-unprefixed-QI "source Rn QI for m32c" (MACH32 m32c-isa) 10 2 UINT
  206. ((value pc) (or USI (and (sll (inv value) 1) 2) (and (srl value 1) 1))) ; insert
  207. ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract
  208. )
  209. ; QI mode gr encoding for m32c is different than for m16c. The hardware
  210. ; is indexed using the m16c encoding, so perform the transformation here.
  211. ; register m16c m32c
  212. ; ----------------------
  213. ; r0l 00'b 10'b
  214. ; r0h 01'b 00'b
  215. ; r1l 10'b 11'b
  216. ; r1h 11'b 01'b
  217. (df f-src32-rn-prefixed-QI "source Rn QI for m32c" (MACH32 m32c-isa) 18 2 UINT
  218. ((value pc) (or USI (and (sll (inv value) 1) 2) (and (srl value 1) 1))) ; insert
  219. ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract
  220. )
  221. ; HI mode gr encoding for m32c is different than for m16c. The hardware
  222. ; is indexed using the m16c encoding, so perform the transformation here.
  223. ; register m16c m32c
  224. ; ----------------------
  225. ; r0 00'b 10'b
  226. ; r1 01'b 11'b
  227. ; r2 10'b 00'b
  228. ; r3 11'b 01'b
  229. (df f-src32-rn-unprefixed-HI "source Rn HI for m32c" (MACH32 m32c-isa) 10 2 UINT
  230. ((value pc) (mod USI (add value 2) 4)) ; insert
  231. ((value pc) (mod USI (add value 2) 4)) ; extract
  232. )
  233. ; HI mode gr encoding for m32c is different than for m16c. The hardware
  234. ; is indexed using the m16c encoding, so perform the transformation here.
  235. ; register m16c m32c
  236. ; ----------------------
  237. ; r0 00'b 10'b
  238. ; r1 01'b 11'b
  239. ; r2 10'b 00'b
  240. ; r3 11'b 01'b
  241. (df f-src32-rn-prefixed-HI "source Rn HI for m32c" (MACH32 m32c-isa) 18 2 UINT
  242. ((value pc) (mod USI (add value 2) 4)) ; insert
  243. ((value pc) (mod USI (add value 2) 4)) ; extract
  244. )
  245. ; SI mode gr encoding for m32c is as follows:
  246. ; register encoding index
  247. ; -------------------------
  248. ; r2r0 10'b 0
  249. ; r3r1 11'b 1
  250. (df f-src32-rn-unprefixed-SI "source Rn SI for m32c" (MACH32 m32c-isa) 10 2 UINT
  251. ((value pc) (add USI value 2)) ; insert
  252. ((value pc) (sub USI value 2)) ; extract
  253. )
  254. (df f-src32-rn-prefixed-SI "source Rn SI for m32c" (MACH32 m32c-isa) 18 2 UINT
  255. ((value pc) (add USI value 2)) ; insert
  256. ((value pc) (sub USI value 2)) ; extract
  257. )
  258. (dnf f-dst32-rn-ext-unprefixed "destination Rn for m32c" (MACH32 m32c-isa) 9 1)
  259. (dnf f-dst16-rn "destination Rn for m16c" (MACH16 m16c-isa) 14 2)
  260. (dnf f-dst16-rn-ext "destination Rn for m16c" (MACH16 m16c-isa) 14 1)
  261. (dnf f-dst16-rn-QI-s "destination Rn for m16c" (MACH16 m16c-isa) 5 1)
  262. (dnf f-dst16-an "destination An for m16c" (MACH16 m16c-isa) 15 1)
  263. (dnf f-dst16-an-s "destination An for m16c" (MACH16 m16c-isa) 4 1)
  264. (dnf f-dst32-an-unprefixed "destination An for m32c" (MACH32 m32c-isa) 9 1)
  265. (dnf f-dst32-an-prefixed "destination An for m32c" (MACH32 m32c-isa) 17 1)
  266. ; QI mode gr encoding for m32c is different than for m16c. The hardware
  267. ; is indexed using the m16c encoding, so perform the transformation here.
  268. ; register m16c m32c
  269. ; ----------------------
  270. ; r0l 00'b 10'b
  271. ; r0h 01'b 00'b
  272. ; r1l 10'b 11'b
  273. ; r1h 11'b 01'b
  274. (df f-dst32-rn-unprefixed-QI "destination Rn QI for m32c" (MACH32 m32c-isa) 8 2 UINT
  275. ((value pc) (or USI (and (sll (inv value) 1) 2) (and (srl value 1) 1))) ; insert
  276. ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract
  277. )
  278. (df f-dst32-rn-prefixed-QI "destination Rn QI for m32c" (MACH32 m32c-isa) 16 2 UINT
  279. ((value pc) (or USI (and (sll (inv value) 1) 2) (and (srl value 1) 1))) ; insert
  280. ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract
  281. )
  282. ; HI mode gr encoding for m32c is different than for m16c. The hardware
  283. ; is indexed using the m16c encoding, so perform the transformation here.
  284. ; register m16c m32c
  285. ; ----------------------
  286. ; r0 00'b 10'b
  287. ; r1 01'b 11'b
  288. ; r2 10'b 00'b
  289. ; r3 11'b 01'b
  290. (df f-dst32-rn-unprefixed-HI "destination Rn HI for m32c" (MACH32 m32c-isa) 8 2 UINT
  291. ((value pc) (mod USI (add value 2) 4)) ; insert
  292. ((value pc) (mod USI (add value 2) 4)) ; extract
  293. )
  294. (df f-dst32-rn-prefixed-HI "destination Rn HI for m32c" (MACH32 m32c-isa) 16 2 UINT
  295. ((value pc) (mod USI (add value 2) 4)) ; insert
  296. ((value pc) (mod USI (add value 2) 4)) ; extract
  297. )
  298. ; SI mode gr encoding for m32c is as follows:
  299. ; register encoding index
  300. ; -------------------------
  301. ; r2r0 10'b 0
  302. ; r3r1 11'b 1
  303. (df f-dst32-rn-unprefixed-SI "destination Rn SI for m32c" (MACH32 m32c-isa) 8 2 UINT
  304. ((value pc) (add USI value 2)) ; insert
  305. ((value pc) (sub USI value 2)) ; extract
  306. )
  307. (df f-dst32-rn-prefixed-SI "destination Rn SI for m32c" (MACH32 m32c-isa) 16 2 UINT
  308. ((value pc) (add USI value 2)) ; insert
  309. ((value pc) (sub USI value 2)) ; extract
  310. )
  311. (dnf f-dst16-1-S "destination R0[hl] for m16c" (MACH16 m16c-isa) 5 1)
  312. ;-------------------------------------------------------------
  313. ; Immediates embedded in the base insn
  314. ;-------------------------------------------------------------
  315. (df f-imm-8-s4 "4 bit signed" (all-isas) 8 4 INT #f #f)
  316. (df f-imm-12-s4 "4 bit signed" (all-isas) 12 4 INT #f #f)
  317. (df f-imm-13-u3 "3 bit unsigned" (all-isas) 13 3 UINT #f #f)
  318. (df f-imm-20-s4 "4 bit signed" (all-isas) 20 4 INT #f #f)
  319. (df f-imm1-S "1 bit immediate for short format binary insns" (MACH32 m32c-isa) 2 1 UINT
  320. ((value pc) (sub USI value 1)) ; insert
  321. ((value pc) (add USI value 1)) ; extract
  322. )
  323. (dnmf f-imm3-S "3 bit unsigned for short format insns" (all-isas) UINT
  324. (f-2-2 f-7-1)
  325. (sequence () ; insert
  326. (set (ifield f-7-1) (and (sub (ifield f-imm3-S) 1) 1))
  327. (set (ifield f-2-2) (and (srl (sub (ifield f-imm3-S) 1) 1) #x3))
  328. )
  329. (sequence () ; extract
  330. (set (ifield f-imm3-S) (add (or (sll (ifield f-2-2) 1)
  331. (ifield f-7-1))
  332. 1))
  333. )
  334. )
  335. ;-------------------------------------------------------------
  336. ; Immediates and displacements beyond the base insn
  337. ;-------------------------------------------------------------
  338. (df f-dsp-8-u6 "6 bit unsigned" (all-isas) 8 6 UINT #f #f)
  339. (df f-dsp-8-u8 "8 bit unsigned" (all-isas) 8 8 UINT #f #f)
  340. (df f-dsp-8-s8 "8 bit signed" (all-isas) 8 8 INT #f #f)
  341. (df f-dsp-10-u6 "6 bit unsigned" (all-isas) 10 6 UINT #f #f)
  342. (df f-dsp-16-u8 "8 bit unsigned" (all-isas) 16 8 UINT #f #f)
  343. (df f-dsp-16-s8 "8 bit signed" (all-isas) 16 8 INT #f #f)
  344. (df f-dsp-24-u8 "8 bit unsigned" (all-isas) 24 8 UINT #f #f)
  345. (df f-dsp-24-s8 "8 bit signed" (all-isas) 24 8 INT #f #f)
  346. (df f-dsp-32-u8 "8 bit unsigned" (all-isas) 32 8 UINT #f #f)
  347. (df f-dsp-32-s8 "8 bit signed" (all-isas) 32 8 INT #f #f)
  348. (df f-dsp-40-u8 "8 bit unsigned" (all-isas) 40 8 UINT #f #f)
  349. (df f-dsp-40-s8 "8 bit signed" (all-isas) 40 8 INT #f #f)
  350. (df f-dsp-48-u8 "8 bit unsigned" (all-isas) 48 8 UINT #f #f)
  351. (df f-dsp-48-s8 "8 bit signed" (all-isas) 48 8 INT #f #f)
  352. (df f-dsp-56-u8 "8 bit unsigned" (all-isas) 56 8 UINT #f #f)
  353. (df f-dsp-56-s8 "8 bit signed" (all-isas) 56 8 INT #f #f)
  354. (df f-dsp-64-u8 "8 bit unsigned" (all-isas) 64 8 UINT #f #f)
  355. (df f-dsp-64-s8 "8 bit signed" (all-isas) 64 8 INT #f #f)
  356. ; Insn opcode endianness is big, but the immediate fields are stored
  357. ; in little endian. Handle this here at the field level for all immediate
  358. ; fields longer that 1 byte.
  359. ;
  360. ; CGEN can't handle a field which spans a 32 bit word boundary, so
  361. ; handle those as multi ifields.
  362. ;
  363. ; Take care in expressions using 'srl' or 'sll' as part of some larger
  364. ; expression meant to yield sign-extended values. CGEN translates
  365. ; uses of those operators into C expressions whose type is 'unsigned
  366. ; int', which tends to make the whole expression 'unsigned int'.
  367. ; Expressions like (set (ifield foo) X), however, just take X and
  368. ; store it in some member of 'struct cgen_fields', all of whose
  369. ; members are 'long'. On machines where 'long' is larger than
  370. ; 'unsigned int', assigning a "sign-extended" unsigned int to a long
  371. ; just produces a very large positive value. insert_normal will
  372. ; range-check the field's value and produce odd error messages like
  373. ; this:
  374. ;
  375. ; Error: operand out of range (4160684031 not between -2147483648 and 2147483647) `add.l #-265,-270[fb]'
  376. ;
  377. ; Annoyingly, the code will work fine on machines where 'long' and
  378. ; 'unsigned int' are the same size: the assignment will produce a
  379. ; negative number.
  380. ;
  381. ; Just tell yourself over and over: overflow detection is expensive,
  382. ; and you're glad C doesn't do it, because it never happens in real
  383. ; life.
  384. (df f-dsp-8-u16 "16 bit unsigned" (all-isas) 8 16 UINT
  385. ((value pc) (or UHI
  386. (and (srl value 8) #x00ff)
  387. (and (sll value 8) #xff00))) ; insert
  388. ((value pc) (or UHI
  389. (and UHI (srl UHI value 8) #x00ff)
  390. (and UHI (sll UHI value 8) #xff00))) ; extract
  391. )
  392. (df f-dsp-8-s16 "8 bit signed" (all-isas) 8 16 INT
  393. ((value pc) (ext INT
  394. (trunc HI
  395. (or (and (srl value 8) #x00ff)
  396. (and (sll value 8) #xff00))))) ; insert
  397. ((value pc) (ext INT
  398. (trunc HI
  399. (or (and (srl value 8) #x00ff)
  400. (and (sll value 8) #xff00))))) ; extract
  401. )
  402. (df f-dsp-16-u16 "16 bit unsigned" (all-isas) 16 16 UINT
  403. ((value pc) (or UHI
  404. (and (srl value 8) #x00ff)
  405. (and (sll value 8) #xff00))) ; insert
  406. ((value pc) (or UHI
  407. (and UHI (srl UHI value 8) #x00ff)
  408. (and UHI (sll UHI value 8) #xff00))) ; extract
  409. )
  410. (df f-dsp-16-s16 "16 bit signed" (all-isas) 16 16 INT
  411. ((value pc) (ext INT
  412. (trunc HI
  413. (or (and (srl value 8) #x00ff)
  414. (and (sll value 8) #xff00))))) ; insert
  415. ((value pc) (ext INT
  416. (trunc HI
  417. (or (and (srl value 8) #x00ff)
  418. (and (sll value 8) #xff00))))) ; extract
  419. )
  420. (dnmf f-dsp-24-u16 "16 bit unsigned" (all-isas) UINT
  421. (f-dsp-24-u8 f-dsp-32-u8)
  422. (sequence () ; insert
  423. (set (ifield f-dsp-24-u8) (and (ifield f-dsp-24-u16) #xff))
  424. (set (ifield f-dsp-32-u8) (and (srl (ifield f-dsp-24-u16) 8) #xff))
  425. )
  426. (sequence () ; extract
  427. (set (ifield f-dsp-24-u16) (or (sll (ifield f-dsp-32-u8) 8)
  428. (ifield f-dsp-24-u8)))
  429. )
  430. )
  431. (dnmf f-dsp-24-s16 "16 bit signed" (all-isas) INT
  432. (f-dsp-24-u8 f-dsp-32-u8)
  433. (sequence () ; insert
  434. (set (ifield f-dsp-24-u8)
  435. (and (ifield f-dsp-24-s16) #xff))
  436. (set (ifield f-dsp-32-u8)
  437. (and (srl (ifield f-dsp-24-s16) 8) #xff))
  438. )
  439. (sequence () ; extract
  440. (set (ifield f-dsp-24-s16)
  441. (ext INT
  442. (trunc HI (or (sll (ifield f-dsp-32-u8) 8)
  443. (ifield f-dsp-24-u8)))))
  444. )
  445. )
  446. (df f-dsp-32-u16 "16 bit unsigned" (all-isas) 32 16 UINT
  447. ((value pc) (or UHI
  448. (and (srl value 8) #x00ff)
  449. (and (sll value 8) #xff00))) ; insert
  450. ((value pc) (or UHI
  451. (and UHI (srl UHI value 8) #x00ff)
  452. (and UHI (sll UHI value 8) #xff00))) ; extract
  453. )
  454. (df f-dsp-32-s16 "16 bit signed" (all-isas) 32 16 INT
  455. ((value pc) (ext INT
  456. (trunc HI
  457. (or (and (srl value 8) #x00ff)
  458. (and (sll value 8) #xff00))))) ; insert
  459. ((value pc) (ext INT
  460. (trunc HI
  461. (or (and (srl value 8) #x00ff)
  462. (and (sll value 8) #xff00))))) ; extract
  463. )
  464. (df f-dsp-40-u16 "16 bit unsigned" (all-isas) 40 16 UINT
  465. ((value pc) (or UHI
  466. (and (srl value 8) #x00ff)
  467. (and (sll value 8) #xff00))) ; insert
  468. ((value pc) (or UHI
  469. (and UHI (srl UHI value 8) #x00ff)
  470. (and UHI (sll UHI value 8) #xff00))) ; extract
  471. )
  472. (df f-dsp-40-s16 "16 bit signed" (all-isas) 40 16 INT
  473. ((value pc) (ext INT
  474. (trunc HI
  475. (or (and (srl value 8) #x00ff)
  476. (and (sll value 8) #xff00))))) ; insert
  477. ((value pc) (ext INT
  478. (trunc HI
  479. (or (and (srl value 8) #x00ff)
  480. (and (sll value 8) #xff00))))) ; extract
  481. )
  482. (df f-dsp-48-u16 "16 bit unsigned" (all-isas) 48 16 UINT
  483. ((value pc) (or UHI
  484. (and (srl value 8) #x00ff)
  485. (and (sll value 8) #xff00))) ; insert
  486. ((value pc) (or UHI
  487. (and UHI (srl UHI value 8) #x00ff)
  488. (and UHI (sll UHI value 8) #xff00))) ; extract
  489. )
  490. (df f-dsp-48-s16 "16 bit signed" (all-isas) 48 16 INT
  491. ((value pc) (ext INT
  492. (trunc HI
  493. (or (and (srl value 8) #x00ff)
  494. (and (sll value 8) #xff00))))) ; insert
  495. ((value pc) (ext INT
  496. (trunc HI
  497. (or (and (srl value 8) #x00ff)
  498. (and (sll value 8) #xff00))))) ; extract
  499. )
  500. (df f-dsp-64-u16 "16 bit unsigned" (all-isas) 64 16 UINT
  501. ((value pc) (or UHI
  502. (and (srl value 8) #x00ff)
  503. (and (sll value 8) #xff00))) ; insert
  504. ((value pc) (or UHI
  505. (and UHI (srl UHI value 8) #x00ff)
  506. (and UHI (sll UHI value 8) #xff00))) ; extract
  507. )
  508. (df f-dsp-8-s24 "24 bit signed" (all-isas) 8 24 INT
  509. ((value pc) (or SI
  510. (or (and (srl value 16) #xff) (and value #xff00))
  511. (sll (ext INT (trunc QI (and value #xff))) 16)))
  512. ((value pc) (or SI
  513. (or (and (srl value 16) #xff) (and value #xff00))
  514. (sll (ext INT (trunc QI (and value #xff))) 16)))
  515. )
  516. (df f-dsp-8-u24 "24 bit unsigned" (all-isas) 8 24 UINT
  517. ((value pc) (or SI
  518. (or (srl value 16) (and value #xff00))
  519. (sll (and value #xff) 16)))
  520. ((value pc) (or SI
  521. (or (srl value 16) (and value #xff00))
  522. (sll (and value #xff) 16)))
  523. )
  524. (dnmf f-dsp-16-u24 "24 bit unsigned" (all-isas) UINT
  525. (f-dsp-16-u16 f-dsp-32-u8)
  526. (sequence () ; insert
  527. (set (ifield f-dsp-16-u16) (and (ifield f-dsp-16-u24) #xffff))
  528. (set (ifield f-dsp-32-u8) (and (srl (ifield f-dsp-16-u24) 16) #xff))
  529. )
  530. (sequence () ; extract
  531. (set (ifield f-dsp-16-u24) (or (sll (ifield f-dsp-32-u8) 16)
  532. (ifield f-dsp-16-u16)))
  533. )
  534. )
  535. (dnmf f-dsp-24-u24 "24 bit unsigned" (all-isas) UINT
  536. (f-dsp-24-u8 f-dsp-32-u16)
  537. (sequence () ; insert
  538. (set (ifield f-dsp-24-u8) (and (ifield f-dsp-24-u24) #xff))
  539. (set (ifield f-dsp-32-u16) (and (srl (ifield f-dsp-24-u24) 8) #xffff))
  540. )
  541. (sequence () ; extract
  542. (set (ifield f-dsp-24-u24) (or (sll (ifield f-dsp-32-u16) 8)
  543. (ifield f-dsp-24-u8)))
  544. )
  545. )
  546. (df f-dsp-32-u24 "24 bit unsigned" (all-isas) 32 24 UINT
  547. ((value pc) (or USI
  548. (or USI
  549. (and (srl value 16) #x0000ff)
  550. (and value #x00ff00))
  551. (and (sll value 16) #xff0000))) ; insert
  552. ((value pc) (or USI
  553. (or USI
  554. (and USI (srl value 16) #x0000ff)
  555. (and USI value #x00ff00))
  556. (and USI (sll value 16) #xff0000))) ; extract
  557. )
  558. (df f-dsp-40-u20 "20 bit unsigned" (all-isas) 40 20 UINT
  559. ((value pc) (or USI
  560. (or USI
  561. (and (srl value 16) #x0000ff)
  562. (and value #x00ff00))
  563. (and (sll value 16) #x0f0000))) ; insert
  564. ((value pc) (or USI
  565. (or USI
  566. (and USI (srl value 16) #x0000ff)
  567. (and USI value #x00ff00))
  568. (and USI (sll value 16) #x0f0000))) ; extract
  569. )
  570. (df f-dsp-40-u24 "24 bit unsigned" (all-isas) 40 24 UINT
  571. ((value pc) (or USI
  572. (or USI
  573. (and (srl value 16) #x0000ff)
  574. (and value #x00ff00))
  575. (and (sll value 16) #xff0000))) ; insert
  576. ((value pc) (or USI
  577. (or USI
  578. (and USI (srl value 16) #x0000ff)
  579. (and USI value #x00ff00))
  580. (and USI (sll value 16) #xff0000))) ; extract
  581. )
  582. (dnmf f-dsp-40-s32 "32 bit signed" (all-isas) INT
  583. (f-dsp-40-u24 f-dsp-64-u8)
  584. (sequence () ; insert
  585. (set (ifield f-dsp-64-u8) (and (srl (ifield f-dsp-40-s32) 24) #xff))
  586. (set (ifield f-dsp-40-u24) (and (ifield f-dsp-40-s32) #xffffff))
  587. )
  588. (sequence () ; extract
  589. (set (ifield f-dsp-40-s32) (or (and (ifield f-dsp-40-u24) #xffffff)
  590. (and (sll (ifield f-dsp-64-u8) 24) #xff000000)))
  591. )
  592. )
  593. (dnmf f-dsp-48-u20 "20 bit unsigned" (all-isas) UINT
  594. (f-dsp-48-u16 f-dsp-64-u8)
  595. (sequence () ; insert
  596. (set (ifield f-dsp-64-u8) (and (srl (ifield f-dsp-48-u20) 16) #x0f))
  597. (set (ifield f-dsp-48-u16) (and (ifield f-dsp-48-u20) #xffff))
  598. )
  599. (sequence () ; extract
  600. (set (ifield f-dsp-48-u20) (or (and (ifield f-dsp-48-u16) #xffff)
  601. (and (sll (ifield f-dsp-64-u8) 16) #x0f0000)))
  602. )
  603. )
  604. (dnmf f-dsp-48-u24 "24 bit unsigned" (all-isas) UINT
  605. (f-dsp-48-u16 f-dsp-64-u8)
  606. (sequence () ; insert
  607. (set (ifield f-dsp-64-u8) (and (srl (ifield f-dsp-48-u24) 16) #xff))
  608. (set (ifield f-dsp-48-u16) (and (ifield f-dsp-48-u24) #xffff))
  609. )
  610. (sequence () ; extract
  611. (set (ifield f-dsp-48-u24) (or (and (ifield f-dsp-48-u16) #xffff)
  612. (and (sll (ifield f-dsp-64-u8) 16) #xff0000)))
  613. )
  614. )
  615. (dnmf f-dsp-16-s32 "32 bit signed" (all-isas) INT
  616. (f-dsp-16-u16 f-dsp-32-u16)
  617. (sequence () ; insert
  618. (set (ifield f-dsp-32-u16) (and (srl (ifield f-dsp-16-s32) 16) #xffff))
  619. (set (ifield f-dsp-16-u16) (and (ifield f-dsp-16-s32) #xffff))
  620. )
  621. (sequence () ; extract
  622. (set (ifield f-dsp-16-s32) (or (and (ifield f-dsp-16-u16) #xffff)
  623. (and (sll (ifield f-dsp-32-u16) 16) #xffff0000)))
  624. )
  625. )
  626. (dnmf f-dsp-24-s32 "32 bit signed" (all-isas) INT
  627. (f-dsp-24-u8 f-dsp-32-u24)
  628. (sequence () ; insert
  629. (set (ifield f-dsp-32-u24) (and (srl (ifield f-dsp-24-s32) 8) #xffffff))
  630. (set (ifield f-dsp-24-u8) (and (ifield f-dsp-24-s32) #xff))
  631. )
  632. (sequence () ; extract
  633. (set (ifield f-dsp-24-s32) (or (and (ifield f-dsp-24-u8) #xff)
  634. (and (sll (ifield f-dsp-32-u24) 8) #xffffff00)))
  635. )
  636. )
  637. (df f-dsp-32-s32 "32 bit signed" (all-isas) 32 32 INT
  638. ((value pc)
  639. ;; insert
  640. (ext INT
  641. (or SI
  642. (or SI
  643. (and (srl value 24) #x000000ff)
  644. (and (srl value 8) #x0000ff00))
  645. (or SI
  646. (and (sll value 8) #x00ff0000)
  647. (and (sll value 24) #xff000000)))))
  648. ;; extract
  649. ((value pc)
  650. (ext INT
  651. (or SI
  652. (or SI
  653. (and (srl value 24) #x000000ff)
  654. (and (srl value 8) #x0000ff00))
  655. (or SI
  656. (and (sll value 8) #x00ff0000)
  657. (and (sll value 24) #xff000000)))))
  658. )
  659. (dnmf f-dsp-48-u32 "32 bit unsigned" (all-isas) UINT
  660. (f-dsp-48-u16 f-dsp-64-u16)
  661. (sequence () ; insert
  662. (set (ifield f-dsp-64-u16) (and (srl (ifield f-dsp-48-u32) 16) #xffff))
  663. (set (ifield f-dsp-48-u16) (and (ifield f-dsp-48-u32) #xffff))
  664. )
  665. (sequence () ; extract
  666. (set (ifield f-dsp-48-u32) (or (and (ifield f-dsp-48-u16) #xffff)
  667. (and (sll (ifield f-dsp-64-u16) 16) #xffff0000)))
  668. )
  669. )
  670. (dnmf f-dsp-48-s32 "32 bit signed" (all-isas) INT
  671. (f-dsp-48-u16 f-dsp-64-u16)
  672. (sequence () ; insert
  673. (set (ifield f-dsp-64-u16) (and (srl (ifield f-dsp-48-s32) 16) #xffff))
  674. (set (ifield f-dsp-48-u16) (and (ifield f-dsp-48-s32) #xffff))
  675. )
  676. (sequence () ; extract
  677. (set (ifield f-dsp-48-s32) (or (and (ifield f-dsp-48-u16) #xffff)
  678. (and (sll (ifield f-dsp-64-u16) 16) #xffff0000)))
  679. )
  680. )
  681. (dnmf f-dsp-56-s16 "16 bit signed" (all-isas) INT
  682. (f-dsp-56-u8 f-dsp-64-u8)
  683. (sequence () ; insert
  684. (set (ifield f-dsp-56-u8)
  685. (and (ifield f-dsp-56-s16) #xff))
  686. (set (ifield f-dsp-64-u8)
  687. (and (srl (ifield f-dsp-56-s16) 8) #xff))
  688. )
  689. (sequence () ; extract
  690. (set (ifield f-dsp-56-s16)
  691. (ext INT
  692. (trunc HI (or (sll (ifield f-dsp-64-u8) 8)
  693. (ifield f-dsp-56-u8)))))
  694. )
  695. )
  696. (df f-dsp-64-s16 " 16 bit signed" (all-isas) 64 16 INT
  697. ((value pc) (ext INT
  698. (trunc HI
  699. (or (and (srl value 8) #x00ff)
  700. (and (sll value 8) #xff00))))) ; insert
  701. ((value pc) (ext INT
  702. (trunc HI
  703. (or (and (srl value 8) #x00ff)
  704. (and (sll value 8) #xff00))))) ; extract
  705. )
  706. ;-------------------------------------------------------------
  707. ; Bit indices
  708. ;-------------------------------------------------------------
  709. (dnf f-bitno16-S "bit index for m16c" (all-isas) 5 3)
  710. (dnf f-bitno32-prefixed "bit index for m32c" (all-isas) 21 3)
  711. (dnf f-bitno32-unprefixed "bit index for m32c" (all-isas) 13 3)
  712. (dnmf f-bitbase16-u11-S "unsigned bit,base:11" (all-isas) UINT
  713. (f-bitno16-S f-dsp-8-u8)
  714. (sequence () ; insert
  715. (set (ifield f-bitno16-S) (and f-bitbase16-u11-S #x7))
  716. (set (ifield f-dsp-8-u8) (and (srl (ifield f-bitbase16-u11-S) 3) #xff))
  717. )
  718. (sequence () ; extract
  719. (set (ifield f-bitbase16-u11-S) (or (sll (ifield f-dsp-8-u8) 3)
  720. (ifield f-bitno16-S)))
  721. )
  722. )
  723. (dnmf f-bitbase32-16-u11-unprefixed "unsigned bit,base:11" (all-isas) UINT
  724. (f-bitno32-unprefixed f-dsp-16-u8)
  725. (sequence () ; insert
  726. (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-u11-unprefixed #x7))
  727. (set (ifield f-dsp-16-u8) (and (srl (ifield f-bitbase32-16-u11-unprefixed) 3) #xff))
  728. )
  729. (sequence () ; extract
  730. (set (ifield f-bitbase32-16-u11-unprefixed) (or (sll (ifield f-dsp-16-u8) 3)
  731. (ifield f-bitno32-unprefixed)))
  732. )
  733. )
  734. (dnmf f-bitbase32-16-s11-unprefixed "signed bit,base:11" (all-isas) INT
  735. (f-bitno32-unprefixed f-dsp-16-s8)
  736. (sequence () ; insert
  737. (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-s11-unprefixed #x7))
  738. (set (ifield f-dsp-16-s8) (sra INT (ifield f-bitbase32-16-s11-unprefixed) 3))
  739. )
  740. (sequence () ; extract
  741. (set (ifield f-bitbase32-16-s11-unprefixed) (or (sll (ifield f-dsp-16-s8) 3)
  742. (ifield f-bitno32-unprefixed)))
  743. )
  744. )
  745. (dnmf f-bitbase32-16-u19-unprefixed "unsigned bit,base:19" (all-isas) UINT
  746. (f-bitno32-unprefixed f-dsp-16-u16)
  747. (sequence () ; insert
  748. (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-u19-unprefixed #x7))
  749. (set (ifield f-dsp-16-u16) (and (srl (ifield f-bitbase32-16-u19-unprefixed) 3) #xffff))
  750. )
  751. (sequence () ; extract
  752. (set (ifield f-bitbase32-16-u19-unprefixed) (or (sll (ifield f-dsp-16-u16) 3)
  753. (ifield f-bitno32-unprefixed)))
  754. )
  755. )
  756. (dnmf f-bitbase32-16-s19-unprefixed "signed bit,base:11" (all-isas) INT
  757. (f-bitno32-unprefixed f-dsp-16-s16)
  758. (sequence () ; insert
  759. (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-s19-unprefixed #x7))
  760. (set (ifield f-dsp-16-s16) (sra INT (ifield f-bitbase32-16-s19-unprefixed) 3))
  761. )
  762. (sequence () ; extract
  763. (set (ifield f-bitbase32-16-s19-unprefixed) (or (sll (ifield f-dsp-16-s16) 3)
  764. (ifield f-bitno32-unprefixed)))
  765. )
  766. )
  767. ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-(
  768. (dnmf f-bitbase32-16-u27-unprefixed "unsigned bit,base:27" (all-isas) UINT
  769. (f-bitno32-unprefixed f-dsp-16-u16 f-dsp-32-u8)
  770. (sequence () ; insert
  771. (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-u27-unprefixed #x7))
  772. (set (ifield f-dsp-16-u16) (and (srl (ifield f-bitbase32-16-u27-unprefixed) 3) #xffff))
  773. (set (ifield f-dsp-32-u8) (and (srl (ifield f-bitbase32-16-u27-unprefixed) 19) #xff))
  774. )
  775. (sequence () ; extract
  776. (set (ifield f-bitbase32-16-u27-unprefixed) (or (sll (ifield f-dsp-16-u16) 3)
  777. (or (sll (ifield f-dsp-32-u8) 19)
  778. (ifield f-bitno32-unprefixed))))
  779. )
  780. )
  781. (dnmf f-bitbase32-24-u11-prefixed "unsigned bit,base:11" (all-isas) UINT
  782. (f-bitno32-prefixed f-dsp-24-u8)
  783. (sequence () ; insert
  784. (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-u11-prefixed #x7))
  785. (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-u11-prefixed) 3) #xff))
  786. )
  787. (sequence () ; extract
  788. (set (ifield f-bitbase32-24-u11-prefixed) (or (sll (ifield f-dsp-24-u8) 3)
  789. (ifield f-bitno32-prefixed)))
  790. )
  791. )
  792. (dnmf f-bitbase32-24-s11-prefixed "signed bit,base:11" (all-isas) INT
  793. (f-bitno32-prefixed f-dsp-24-s8)
  794. (sequence () ; insert
  795. (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-s11-prefixed #x7))
  796. (set (ifield f-dsp-24-s8) (sra INT (ifield f-bitbase32-24-s11-prefixed) 3))
  797. )
  798. (sequence () ; extract
  799. (set (ifield f-bitbase32-24-s11-prefixed) (or (sll (ifield f-dsp-24-s8) 3)
  800. (ifield f-bitno32-prefixed)))
  801. )
  802. )
  803. ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-(
  804. (dnmf f-bitbase32-24-u19-prefixed "unsigned bit,base:19" (all-isas) UINT
  805. (f-bitno32-prefixed f-dsp-24-u8 f-dsp-32-u8)
  806. (sequence () ; insert
  807. (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-u19-prefixed #x7))
  808. (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-u19-prefixed) 3) #xff))
  809. (set (ifield f-dsp-32-u8) (and (srl (ifield f-bitbase32-24-u19-prefixed) 11) #xff))
  810. )
  811. (sequence () ; extract
  812. (set (ifield f-bitbase32-24-u19-prefixed) (or (sll (ifield f-dsp-24-u8) 3)
  813. (or (sll (ifield f-dsp-32-u8) 11)
  814. (ifield f-bitno32-prefixed))))
  815. )
  816. )
  817. ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-(
  818. (dnmf f-bitbase32-24-s19-prefixed "signed bit,base:11" (all-isas) INT
  819. (f-bitno32-prefixed f-dsp-24-u8 f-dsp-32-s8)
  820. (sequence () ; insert
  821. (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-s19-prefixed #x7))
  822. (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-s19-prefixed) 3) #xff))
  823. (set (ifield f-dsp-32-s8) (sra INT (ifield f-bitbase32-24-s19-prefixed) 11))
  824. )
  825. (sequence () ; extract
  826. (set (ifield f-bitbase32-24-s19-prefixed) (or (sll (ifield f-dsp-24-u8) 3)
  827. (or (sll (ifield f-dsp-32-s8) 11)
  828. (ifield f-bitno32-prefixed))))
  829. )
  830. )
  831. ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-(
  832. (dnmf f-bitbase32-24-u27-prefixed "unsigned bit,base:27" (all-isas) UINT
  833. (f-bitno32-prefixed f-dsp-24-u8 f-dsp-32-u16)
  834. (sequence () ; insert
  835. (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-u27-prefixed #x7))
  836. (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-u27-prefixed) 3) #xff))
  837. (set (ifield f-dsp-32-u16) (and (srl (ifield f-bitbase32-24-u27-prefixed) 11) #xffff))
  838. )
  839. (sequence () ; extract
  840. (set (ifield f-bitbase32-24-u27-prefixed) (or (sll (ifield f-dsp-24-u8) 3)
  841. (or (sll (ifield f-dsp-32-u16) 11)
  842. (ifield f-bitno32-prefixed))))
  843. )
  844. )
  845. ;-------------------------------------------------------------
  846. ; Labels
  847. ;-------------------------------------------------------------
  848. (df f-lab-5-3 "3 bit pc relative unsigned offset" (PCREL-ADDR all-isas) 5 3 UINT
  849. ((value pc) (sub SI value (add SI pc 2))) ; insert
  850. ((value pc) (add SI value (add SI pc 2))) ; extract
  851. )
  852. (dnmf f-lab32-jmp-s "unsigned 3 bit pc relative offset" (PCREL-ADDR all-isas) UINT
  853. (f-2-2 f-7-1)
  854. (sequence ((SI val)) ; insert
  855. (set val (sub (sub (ifield f-lab32-jmp-s) pc) 2))
  856. (set (ifield f-7-1) (and val #x1))
  857. (set (ifield f-2-2) (srl val 1))
  858. )
  859. (sequence () ; extract
  860. (set (ifield f-lab32-jmp-s) (add pc (add (or (sll (ifield f-2-2) 1)
  861. (ifield f-7-1))
  862. 2)))
  863. )
  864. )
  865. (df f-lab-8-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 8 8 INT
  866. ((value pc) (sub SI value (add SI pc 1))) ; insert
  867. ((value pc) (add SI value (add SI pc 1))) ; extract
  868. )
  869. (df f-lab-8-16 "16 bit pc relative signed offset" (PCREL-ADDR SIGN-OPT all-isas) 8 16 UINT
  870. ((value pc) (or SI (sll (and (sub value (add pc 1)) #xff) 8)
  871. (srl (and (sub value (add pc 1)) #xffff) 8)))
  872. ((value pc) (add SI (or (srl (and value #xffff) 8)
  873. (sra (sll (and value #xff) 24) 16)) (add pc 1)))
  874. )
  875. (df f-lab-8-24 "24 bit absolute" (all-isas ABS-ADDR) 8 24 UINT
  876. ((value pc) (or SI
  877. (or (srl value 16) (and value #xff00))
  878. (sll (and value #xff) 16)))
  879. ((value pc) (or SI
  880. (or (srl value 16) (and value #xff00))
  881. (sll (and value #xff) 16)))
  882. )
  883. (df f-lab-16-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 16 8 INT
  884. ((value pc) (sub SI value (add SI pc 2))) ; insert
  885. ((value pc) (add SI value (add SI pc 2))) ; extract
  886. )
  887. (df f-lab-24-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 24 8 INT
  888. ((value pc) (sub SI value (add SI pc 2))) ; insert
  889. ((value pc) (add SI value (add SI pc 2))) ; extract
  890. )
  891. (df f-lab-32-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 32 8 INT
  892. ((value pc) (sub SI value (add SI pc 2))) ; insert
  893. ((value pc) (add SI value (add SI pc 2))) ; extract
  894. )
  895. (df f-lab-40-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 40 8 INT
  896. ((value pc) (sub SI value (add SI pc 2))) ; insert
  897. ((value pc) (add SI value (add SI pc 2))) ; extract
  898. )
  899. ;-------------------------------------------------------------
  900. ; Condition codes
  901. ;-------------------------------------------------------------
  902. (dnf f-cond16 "condition code" (all-isas) 12 4)
  903. (dnf f-cond16j-5 "condition code" (all-isas) 5 3)
  904. (dnmf f-cond32 "condition code" (all-isas) UINT
  905. (f-9-1 f-13-3)
  906. (sequence () ; insert
  907. (set (ifield f-9-1) (and (srl (ifield f-cond32) 3) 1))
  908. (set (ifield f-13-3) (and (ifield f-cond32) #x7))
  909. )
  910. (sequence () ; extract
  911. (set (ifield f-cond32) (or (sll (ifield f-9-1) 3)
  912. (ifield f-13-3)))
  913. )
  914. )
  915. (dnmf f-cond32j "condition code" (all-isas) UINT
  916. (f-1-3 f-7-1)
  917. (sequence () ; insert
  918. (set (ifield f-1-3) (and (srl (ifield f-cond32j) 1) #x7))
  919. (set (ifield f-7-1) (and (ifield f-cond32j) #x1))
  920. )
  921. (sequence () ; extract
  922. (set (ifield f-cond32j) (or (sll (ifield f-1-3) 1)
  923. (ifield f-7-1)))
  924. )
  925. )
  926. ;=============================================================
  927. ; Hardware
  928. ;
  929. (dnh h-pc "program counter" (PC all-isas) (pc USI) () () ())
  930. ;-------------------------------------------------------------
  931. ; General registers
  932. ; The actual registers are 16 bits
  933. ;-------------------------------------------------------------
  934. (define-hardware
  935. (name h-gr)
  936. (comment "general 16 bit registers")
  937. (attrs all-isas CACHE-ADDR)
  938. (type register HI (4))
  939. (indices keyword "" (("r0" 0) ("r1" 1) ("r2" 2) ("r3" 3))))
  940. ; Define different views of the grs as VIRTUAL with getter/setter specs
  941. ;
  942. (define-hardware
  943. (name h-gr-QI)
  944. (comment "general 8 bit registers")
  945. (attrs all-isas VIRTUAL)
  946. (type register QI (4))
  947. (indices keyword "" (("r0l" 0) ("r0h" 1) ("r1l" 2) ("r1h" 3)))
  948. (get (index) (and (if SI (mod index 2)
  949. (srl (reg h-gr (div index 2)) 8)
  950. (reg h-gr (div index 2)))
  951. #xff))
  952. (set (index newval) (set (reg h-gr (div index 2))
  953. (if SI (mod index 2)
  954. (or (and (reg h-gr (div index 2)) #xff)
  955. (sll (and newval #xff) 8))
  956. (or (and (reg h-gr (div index 2)) #xff00)
  957. (and newval #xff))))))
  958. (define-hardware
  959. (name h-gr-HI)
  960. (comment "general 16 bit registers")
  961. (attrs all-isas VIRTUAL)
  962. (type register HI (4))
  963. (indices keyword "" (("r0" 0) ("r1" 1) ("r2" 2) ("r3" 3)))
  964. (get (index) (reg h-gr index))
  965. (set (index newval) (set (reg h-gr index) newval)))
  966. (define-hardware
  967. (name h-gr-SI)
  968. (comment "general 32 bit registers")
  969. (attrs all-isas VIRTUAL)
  970. (type register SI (2))
  971. (indices keyword "" (("r2r0" 0) ("r3r1" 1)))
  972. (get (index) (or SI
  973. (and (reg h-gr index) #xffff)
  974. (and (sll (reg h-gr (add index 2)) 16) #xffff0000)))
  975. (set (index newval) (sequence ()
  976. (set (reg h-gr index) (and newval #xffff))
  977. (set (reg h-gr (add index 2)) (srl newval 16)))))
  978. (define-hardware
  979. (name h-gr-ext-QI)
  980. (comment "general 16 bit registers")
  981. (attrs all-isas VIRTUAL)
  982. (type register HI (2))
  983. (indices keyword "" (("r0l" 0) ("r1l" 1)))
  984. (get (index) (reg h-gr-QI (mul index 2)))
  985. (set (index newval) (set (reg h-gr (mul index 2)) newval)))
  986. (define-hardware
  987. (name h-gr-ext-HI)
  988. (comment "general 16 bit registers")
  989. (attrs all-isas VIRTUAL)
  990. (type register SI (2))
  991. (indices keyword "" (("r0" 0) ("r1" 1)))
  992. (get (index) (reg h-gr (mul index 2)))
  993. (set (index newval) (set (reg h-gr-SI index) newval)))
  994. (define-hardware
  995. (name h-r0l)
  996. (comment "r0l register")
  997. (attrs all-isas VIRTUAL)
  998. (type register QI)
  999. (indices keyword "" (("r0l" 0)))
  1000. (get () (reg h-gr-QI 0))
  1001. (set (newval) (set (reg h-gr-QI 0) newval)))
  1002. (define-hardware
  1003. (name h-r0h)
  1004. (comment "r0h register")
  1005. (attrs all-isas VIRTUAL)
  1006. (type register QI)
  1007. (indices keyword "" (("r0h" 0)))
  1008. (get () (reg h-gr-QI 1))
  1009. (set (newval) (set (reg h-gr-QI 1) newval)))
  1010. (define-hardware
  1011. (name h-r1l)
  1012. (comment "r1l register")
  1013. (attrs all-isas VIRTUAL)
  1014. (type register QI)
  1015. (indices keyword "" (("r1l" 0)))
  1016. (get () (reg h-gr-QI 2))
  1017. (set (newval) (set (reg h-gr-QI 2) newval)))
  1018. (define-hardware
  1019. (name h-r1h)
  1020. (comment "r1h register")
  1021. (attrs all-isas VIRTUAL)
  1022. (type register QI)
  1023. (indices keyword "" (("r1h" 0)))
  1024. (get () (reg h-gr-QI 3))
  1025. (set (newval) (set (reg h-gr-QI 3) newval)))
  1026. (define-hardware
  1027. (name h-r0)
  1028. (comment "r0 register")
  1029. (attrs all-isas VIRTUAL)
  1030. (type register HI)
  1031. (indices keyword "" (("r0" 0)))
  1032. (get () (reg h-gr 0))
  1033. (set (newval) (set (reg h-gr 0) newval)))
  1034. (define-hardware
  1035. (name h-r1)
  1036. (comment "r1 register")
  1037. (attrs all-isas VIRTUAL)
  1038. (type register HI)
  1039. (indices keyword "" (("r1" 0)))
  1040. (get () (reg h-gr 1))
  1041. (set (newval) (set (reg h-gr 1) newval)))
  1042. (define-hardware
  1043. (name h-r2)
  1044. (comment "r2 register")
  1045. (attrs all-isas VIRTUAL)
  1046. (type register HI)
  1047. (indices keyword "" (("r2" 0)))
  1048. (get () (reg h-gr 2))
  1049. (set (newval) (set (reg h-gr 2) newval)))
  1050. (define-hardware
  1051. (name h-r3)
  1052. (comment "r3 register")
  1053. (attrs all-isas VIRTUAL)
  1054. (type register HI)
  1055. (indices keyword "" (("r3" 0)))
  1056. (get () (reg h-gr 3))
  1057. (set (newval) (set (reg h-gr 3) newval)))
  1058. (define-hardware
  1059. (name h-r0l-r0h)
  1060. (comment "r0l or r0h")
  1061. (attrs all-isas VIRTUAL)
  1062. (type register QI (2))
  1063. (indices keyword "" (("r0l" 0) ("r0h" 1)))
  1064. (get (index) (reg h-gr-QI index))
  1065. (set (index newval) (set (reg h-gr-QI index) newval)))
  1066. (define-hardware
  1067. (name h-r2r0)
  1068. (comment "r2r0 register")
  1069. (attrs all-isas VIRTUAL)
  1070. (type register SI)
  1071. (indices keyword "" (("r2r0" 0)))
  1072. (get () (or (sll (reg h-gr 2) 16) (reg h-gr 0)))
  1073. (set (newval)
  1074. (sequence ()
  1075. (set (reg h-gr 0) newval)
  1076. (set (reg h-gr 2) (sra newval 16)))))
  1077. (define-hardware
  1078. (name h-r3r1)
  1079. (comment "r3r1 register")
  1080. (attrs all-isas VIRTUAL)
  1081. (type register SI)
  1082. (indices keyword "" (("r3r1" 0)))
  1083. (get () (or (sll (reg h-gr 3) 16) (reg h-gr 1)))
  1084. (set (newval)
  1085. (sequence ()
  1086. (set (reg h-gr 1) newval)
  1087. (set (reg h-gr 3) (sra newval 16)))))
  1088. (define-hardware
  1089. (name h-r1r2r0)
  1090. (comment "r1r2r0 register")
  1091. (attrs all-isas VIRTUAL)
  1092. (type register DI)
  1093. (indices keyword "" (("r1r2r0" 0)))
  1094. (get () (or DI (sll DI (reg h-gr 1) 32) (or (sll (reg h-gr 2) 16) (reg h-gr 0))))
  1095. (set (newval)
  1096. (sequence ()
  1097. (set (reg h-gr 0) newval)
  1098. (set (reg h-gr 2) (sra newval 16))
  1099. (set (reg h-gr 1) (sra newval 32)))))
  1100. ;-------------------------------------------------------------
  1101. ; Address registers
  1102. ;-------------------------------------------------------------
  1103. (define-hardware
  1104. (name h-ar)
  1105. (comment "address registers")
  1106. (attrs all-isas)
  1107. (type register USI (2))
  1108. (indices keyword "" (("a0" 0) ("a1" 1)))
  1109. (get (index) (c-call USI "h_ar_get_handler" index))
  1110. (set (index newval) (c-call VOID "h_ar_set_handler" index newval)))
  1111. ; Define different views of the ars as VIRTUAL with getter/setter specs
  1112. (define-hardware
  1113. (name h-ar-QI)
  1114. (comment "8 bit view of address register")
  1115. (attrs all-isas VIRTUAL)
  1116. (type register QI (2))
  1117. (indices keyword "" (("a0" 0) ("a1" 1)))
  1118. (get (index) (reg h-ar index))
  1119. (set (index newval) (set (reg h-ar index) newval)))
  1120. (define-hardware
  1121. (name h-ar-HI)
  1122. (comment "16 bit view of address register")
  1123. (attrs all-isas VIRTUAL)
  1124. (type register HI (2))
  1125. (indices keyword "" (("a0" 0) ("a1" 1)))
  1126. (get (index) (reg h-ar index))
  1127. (set (index newval) (set (reg h-ar index) newval)))
  1128. (define-hardware
  1129. (name h-ar-SI)
  1130. (comment "32 bit view of address register")
  1131. (attrs all-isas VIRTUAL)
  1132. (type register SI)
  1133. (indices keyword "" (("a1a0" 0)))
  1134. (get () (or SI (sll SI (ext SI (reg h-ar 1)) 16) (ext SI (reg h-ar 0))))
  1135. (set (newval) (sequence ()
  1136. (set (reg h-ar 0) (and newval #xffff))
  1137. (set (reg h-ar 1) (and (srl newval 16) #xffff)))))
  1138. (define-hardware
  1139. (name h-a0)
  1140. (comment "16 bit view of address register")
  1141. (attrs all-isas VIRTUAL)
  1142. (type register HI)
  1143. (indices keyword "" (("a0" 0)))
  1144. (get () (reg h-ar 0))
  1145. (set (newval) (set (reg h-ar 0) newval)))
  1146. (define-hardware
  1147. (name h-a1)
  1148. (comment "16 bit view of address register")
  1149. (attrs all-isas VIRTUAL)
  1150. (type register HI)
  1151. (indices keyword "" (("a1" 1)))
  1152. (get () (reg h-ar 1))
  1153. (set (newval) (set (reg h-ar 1) newval)))
  1154. ; SB Register
  1155. (define-hardware
  1156. (name h-sb)
  1157. (comment "SB register")
  1158. (attrs all-isas)
  1159. (type register USI)
  1160. (get () (c-call USI "h_sb_get_handler"))
  1161. (set (newval) (c-call VOID "h_sb_set_handler" newval))
  1162. )
  1163. ; FB Register
  1164. (define-hardware
  1165. (name h-fb)
  1166. (comment "FB register")
  1167. (attrs all-isas)
  1168. (type register USI)
  1169. (get () (c-call USI "h_fb_get_handler"))
  1170. (set (newval) (c-call VOID "h_fb_set_handler" newval))
  1171. )
  1172. ; SP Register
  1173. (define-hardware
  1174. (name h-sp)
  1175. (comment "SP register")
  1176. (attrs all-isas)
  1177. (type register USI)
  1178. (get () (c-call USI "h_sp_get_handler"))
  1179. (set (newval) (c-call VOID "h_sp_set_handler" newval))
  1180. )
  1181. ;-------------------------------------------------------------
  1182. ; condition-code bits
  1183. ;-------------------------------------------------------------
  1184. (define-hardware
  1185. (name h-sbit)
  1186. (comment "sign bit")
  1187. (attrs all-isas)
  1188. (type register BI)
  1189. )
  1190. (define-hardware
  1191. (name h-zbit)
  1192. (comment "zero bit")
  1193. (attrs all-isas)
  1194. (type register BI)
  1195. )
  1196. (define-hardware
  1197. (name h-obit)
  1198. (comment "overflow bit")
  1199. (attrs all-isas)
  1200. (type register BI)
  1201. )
  1202. (define-hardware
  1203. (name h-cbit)
  1204. (comment "carry bit")
  1205. (attrs all-isas)
  1206. (type register BI)
  1207. )
  1208. (define-hardware
  1209. (name h-ubit)
  1210. (comment "stack pointer select bit")
  1211. (attrs all-isas)
  1212. (type register BI)
  1213. )
  1214. (define-hardware
  1215. (name h-ibit)
  1216. (comment "interrupt enable bit")
  1217. (attrs all-isas)
  1218. (type register BI)
  1219. )
  1220. (define-hardware
  1221. (name h-bbit)
  1222. (comment "register bank select bit")
  1223. (attrs all-isas)
  1224. (type register BI)
  1225. )
  1226. (define-hardware
  1227. (name h-dbit)
  1228. (comment "debug bit")
  1229. (attrs all-isas)
  1230. (type register BI)
  1231. )
  1232. (define-hardware
  1233. (name h-dct0)
  1234. (comment "dma transfer count 000")
  1235. (attrs all-isas)
  1236. (type register UHI)
  1237. )
  1238. (define-hardware
  1239. (name h-dct1)
  1240. (comment "dma transfer count 001")
  1241. (attrs all-isas)
  1242. (type register UHI)
  1243. )
  1244. (define-hardware
  1245. (name h-svf)
  1246. (comment "save flag 011")
  1247. (attrs all-isas)
  1248. (type register UHI)
  1249. )
  1250. (define-hardware
  1251. (name h-drc0)
  1252. (comment "dma transfer count reload 100")
  1253. (attrs all-isas)
  1254. (type register UHI)
  1255. )
  1256. (define-hardware
  1257. (name h-drc1)
  1258. (comment "dma transfer count reload 101")
  1259. (attrs all-isas)
  1260. (type register UHI)
  1261. )
  1262. (define-hardware
  1263. (name h-dmd0)
  1264. (comment "dma mode 110")
  1265. (attrs all-isas)
  1266. (type register UQI)
  1267. )
  1268. (define-hardware
  1269. (name h-dmd1)
  1270. (comment "dma mode 111")
  1271. (attrs all-isas)
  1272. (type register UQI)
  1273. )
  1274. (define-hardware
  1275. (name h-intb)
  1276. (comment "interrupt table 000")
  1277. (attrs all-isas)
  1278. (type register USI)
  1279. )
  1280. (define-hardware
  1281. (name h-svp)
  1282. (comment "save pc 100")
  1283. (attrs all-isas)
  1284. (type register UHI)
  1285. )
  1286. (define-hardware
  1287. (name h-vct)
  1288. (comment "vector 101")
  1289. (attrs all-isas)
  1290. (type register USI)
  1291. )
  1292. (define-hardware
  1293. (name h-isp)
  1294. (comment "interrupt stack ptr 111")
  1295. (attrs all-isas)
  1296. (type register USI)
  1297. )
  1298. (define-hardware
  1299. (name h-dma0)
  1300. (comment "dma mem addr 010")
  1301. (attrs all-isas)
  1302. (type register USI)
  1303. )
  1304. (define-hardware
  1305. (name h-dma1)
  1306. (comment "dma mem addr 011")
  1307. (attrs all-isas)
  1308. (type register USI)
  1309. )
  1310. (define-hardware
  1311. (name h-dra0)
  1312. (comment "dma mem addr reload 100")
  1313. (attrs all-isas)
  1314. (type register USI)
  1315. )
  1316. (define-hardware
  1317. (name h-dra1)
  1318. (comment "dma mem addr reload 101")
  1319. (attrs all-isas)
  1320. (type register USI)
  1321. )
  1322. (define-hardware
  1323. (name h-dsa0)
  1324. (comment "dma sfr addr 110")
  1325. (attrs all-isas)
  1326. (type register USI)
  1327. )
  1328. (define-hardware
  1329. (name h-dsa1)
  1330. (comment "dma sfr addr 111")
  1331. (attrs all-isas)
  1332. (type register USI)
  1333. )
  1334. ;-------------------------------------------------------------
  1335. ; Condition code operand hardware
  1336. ;-------------------------------------------------------------
  1337. (define-hardware
  1338. (name h-cond16)
  1339. (comment "condition code hardware for m16c")
  1340. (attrs m16c-isa MACH16)
  1341. (type immediate UQI)
  1342. (values keyword ""
  1343. (("geu" #x00) ("c" #x00)
  1344. ("gtu" #x01)
  1345. ("eq" #x02) ("z" #x02)
  1346. ("n" #x03)
  1347. ("le" #x04)
  1348. ("o" #x05)
  1349. ("ge" #x06)
  1350. ("ltu" #xf8) ("nc" #xf8)
  1351. ("leu" #xf9)
  1352. ("ne" #xfa) ("nz" #xfa)
  1353. ("pz" #xfb)
  1354. ("gt" #xfc)
  1355. ("no" #xfd)
  1356. ("lt" #xfe)
  1357. )
  1358. )
  1359. )
  1360. (define-hardware
  1361. (name h-cond16c)
  1362. (comment "condition code hardware for m16c")
  1363. (attrs m16c-isa MACH16)
  1364. (type immediate UQI)
  1365. (values keyword ""
  1366. (("geu" #x00) ("c" #x00)
  1367. ("gtu" #x01)
  1368. ("eq" #x02) ("z" #x02)
  1369. ("n" #x03)
  1370. ("ltu" #x04) ("nc" #x04)
  1371. ("leu" #x05)
  1372. ("ne" #x06) ("nz" #x06)
  1373. ("pz" #x07)
  1374. ("le" #x08)
  1375. ("o" #x09)
  1376. ("ge" #x0a)
  1377. ("gt" #x0c)
  1378. ("no" #x0d)
  1379. ("lt" #x0e)
  1380. )
  1381. )
  1382. )
  1383. (define-hardware
  1384. (name h-cond16j)
  1385. (comment "condition code hardware for m16c")
  1386. (attrs m16c-isa MACH16)
  1387. (type immediate UQI)
  1388. (values keyword ""
  1389. (("le" #x08)
  1390. ("o" #x09)
  1391. ("ge" #x0a)
  1392. ("gt" #x0c)
  1393. ("no" #x0d)
  1394. ("lt" #x0e)
  1395. )
  1396. )
  1397. )
  1398. (define-hardware
  1399. (name h-cond16j-5)
  1400. (comment "condition code hardware for m16c")
  1401. (attrs m16c-isa MACH16)
  1402. (type immediate UQI)
  1403. (values keyword ""
  1404. (("geu" #x00) ("c" #x00)
  1405. ("gtu" #x01)
  1406. ("eq" #x02) ("z" #x02)
  1407. ("n" #x03)
  1408. ("ltu" #x04) ("nc" #x04)
  1409. ("leu" #x05)
  1410. ("ne" #x06) ("nz" #x06)
  1411. ("pz" #x07)
  1412. )
  1413. )
  1414. )
  1415. (define-hardware
  1416. (name h-cond32)
  1417. (comment "condition code hardware for m32c")
  1418. (attrs m32c-isa MACH32)
  1419. (type immediate UQI)
  1420. (values keyword ""
  1421. (("ltu" #x00) ("nc" #x00)
  1422. ("leu" #x01)
  1423. ("ne" #x02) ("nz" #x02)
  1424. ("pz" #x03)
  1425. ("no" #x04)
  1426. ("gt" #x05)
  1427. ("ge" #x06)
  1428. ("geu" #x08) ("c" #x08)
  1429. ("gtu" #x09)
  1430. ("eq" #x0a) ("z" #x0a)
  1431. ("n" #x0b)
  1432. ("o" #x0c)
  1433. ("le" #x0d)
  1434. ("lt" #x0e)
  1435. )
  1436. )
  1437. )
  1438. (define-hardware
  1439. (name h-cr1-32)
  1440. (comment "control registers")
  1441. (attrs m32c-isa MACH32)
  1442. (type immediate UQI)
  1443. (values keyword "" (("dct0" 0) ("dct1" 1) ("flg" 2) ("svf" 3) ("drc0" 4)
  1444. ("drc1" 5) ("dmd0" 6) ("dmd1" 7))))
  1445. (define-hardware
  1446. (name h-cr2-32)
  1447. (comment "control registers")
  1448. (attrs m32c-isa MACH32)
  1449. (type immediate UQI)
  1450. (values keyword "" (("intb" 0) ("sp" 1) ("sb" 2) ("fb" 3) ("svp" 4)
  1451. ("vct" 5) ("isp" 7))))
  1452. (define-hardware
  1453. (name h-cr3-32)
  1454. (comment "control registers")
  1455. (attrs m32c-isa MACH32)
  1456. (type immediate UQI)
  1457. (values keyword "" (("dma0" 2) ("dma1" 3) ("dra0" 4)
  1458. ("dra1" 5) ("dsa0" 6) ("dsa1" 7))))
  1459. (define-hardware
  1460. (name h-cr-16)
  1461. (comment "control registers")
  1462. (attrs m16c-isa MACH16)
  1463. (type immediate UQI)
  1464. (values keyword "" (("intbl" 1) ("intbh" 2) ("flg" 3) ("isp" 4)
  1465. ("sp" 5) ("sb" 6) ("fb" 7))))
  1466. (define-hardware
  1467. (name h-flags)
  1468. (comment "flag hardware for m32c")
  1469. (attrs all-isas)
  1470. (type immediate UQI)
  1471. (values keyword ""
  1472. (("c" #x0)
  1473. ("d" #x1)
  1474. ("z" #x2)
  1475. ("s" #x3)
  1476. ("b" #x4)
  1477. ("o" #x5)
  1478. ("i" #x6)
  1479. ("u" #x7)
  1480. )
  1481. )
  1482. )
  1483. ;-------------------------------------------------------------
  1484. ; Misc helper hardware
  1485. ;-------------------------------------------------------------
  1486. (define-hardware
  1487. (name h-shimm)
  1488. (comment "shift immediate")
  1489. (attrs all-isas)
  1490. (type immediate (INT 4))
  1491. (values keyword "" (("1" 0) ("2" 1) ("3" 2) ("4" 3) ("5" 4) ("6" 5) ("7" 6)
  1492. ("8" 7) ("-1" -8) ("-2" -7) ("-3" -6) ("-4" -5) ("-5" -4)
  1493. ("-6" -3) ("-7" -2) ("-8" -1)
  1494. )))
  1495. (define-hardware
  1496. (name h-bit-index)
  1497. (comment "bit index for the next insn")
  1498. (attrs m32c-isa MACH32)
  1499. (type register UHI)
  1500. )
  1501. (define-hardware
  1502. (name h-src-index)
  1503. (comment "source index for the next insn")
  1504. (attrs m32c-isa MACH32)
  1505. (type register UHI)
  1506. )
  1507. (define-hardware
  1508. (name h-dst-index)
  1509. (comment "destination index for the next insn")
  1510. (attrs m32c-isa MACH32)
  1511. (type register UHI)
  1512. )
  1513. (define-hardware
  1514. (name h-src-indirect)
  1515. (comment "indirect src for the next insn")
  1516. (attrs all-isas)
  1517. (type register UHI)
  1518. )
  1519. (define-hardware
  1520. (name h-dst-indirect)
  1521. (comment "indirect dst for the next insn")
  1522. (attrs all-isas)
  1523. (type register UHI)
  1524. )
  1525. (define-hardware
  1526. (name h-none)
  1527. (comment "for storing unused values")
  1528. (attrs m32c-isa MACH32)
  1529. (type register SI)
  1530. )
  1531. ;=============================================================
  1532. ; Operands
  1533. ;-------------------------------------------------------------
  1534. ; Source Registers
  1535. ;-------------------------------------------------------------
  1536. (dnop Src16RnQI "general register QI view" (MACH16 m16c-isa) h-gr-QI f-src16-rn)
  1537. (dnop Src16RnHI "general register QH view" (MACH16 m16c-isa) h-gr-HI f-src16-rn)
  1538. (dnop Src32RnUnprefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-src32-rn-unprefixed-QI)
  1539. (dnop Src32RnUnprefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-src32-rn-unprefixed-HI)
  1540. (dnop Src32RnUnprefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-src32-rn-unprefixed-SI)
  1541. (dnop Src32RnPrefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-src32-rn-prefixed-QI)
  1542. (dnop Src32RnPrefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-src32-rn-prefixed-HI)
  1543. (dnop Src32RnPrefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-src32-rn-prefixed-SI)
  1544. (dnop Src16An "address register" (MACH16 m16c-isa) h-ar f-src16-an)
  1545. (dnop Src16AnQI "address register QI view" (MACH16 m16c-isa) h-ar-QI f-src16-an)
  1546. (dnop Src16AnHI "address register HI view" (MACH16 m16c-isa) h-ar-HI f-src16-an)
  1547. (dnop Src32AnUnprefixed "address register" (MACH32 m32c-isa) h-ar f-src32-an-unprefixed)
  1548. (dnop Src32AnUnprefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-src32-an-unprefixed)
  1549. (dnop Src32AnUnprefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-src32-an-unprefixed)
  1550. (dnop Src32AnUnprefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-src32-an-unprefixed)
  1551. (dnop Src32AnPrefixed "address register" (MACH32 m32c-isa) h-ar f-src32-an-prefixed)
  1552. (dnop Src32AnPrefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-src32-an-prefixed)
  1553. (dnop Src32AnPrefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-src32-an-prefixed)
  1554. (dnop Src32AnPrefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-src32-an-prefixed)
  1555. ; Destination Registers
  1556. ;
  1557. (dnop Dst16RnQI "general register QI view" (MACH16 m16c-isa) h-gr-QI f-dst16-rn)
  1558. (dnop Dst16RnHI "general register HI view" (MACH16 m16c-isa) h-gr-HI f-dst16-rn)
  1559. (dnop Dst16RnSI "general register SI view" (MACH16 m16c-isa) h-gr-SI f-dst16-rn)
  1560. (dnop Dst16RnExtQI "general register QI/HI view for 'ext' insns" (MACH16 m16c-isa) h-gr-ext-QI f-dst16-rn-ext)
  1561. (dnop Dst32R0QI-S "general register QI view" (MACH32 m32c-isa) h-r0l f-nil)
  1562. (dnop Dst32R0HI-S "general register HI view" (MACH32 m32c-isa) h-r0 f-nil)
  1563. (dnop Dst32RnUnprefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-unprefixed-QI)
  1564. (dnop Dst32RnUnprefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-dst32-rn-unprefixed-HI)
  1565. (dnop Dst32RnUnprefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-dst32-rn-unprefixed-SI)
  1566. (dnop Dst32RnExtUnprefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-ext-QI f-dst32-rn-ext-unprefixed)
  1567. (dnop Dst32RnExtUnprefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-ext-HI f-dst32-rn-ext-unprefixed)
  1568. (dnop Dst32RnPrefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-prefixed-QI)
  1569. (dnop Dst32RnPrefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-dst32-rn-prefixed-HI)
  1570. (dnop Dst32RnPrefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-dst32-rn-prefixed-SI)
  1571. (dnop Dst16RnQI-S "general register QI view" (MACH16 m16c-isa) h-r0l-r0h f-dst16-rn-QI-s)
  1572. (dnop Dst16AnQI-S "address register QI view" (MACH16 m16c-isa) h-ar-QI f-dst16-rn-QI-s)
  1573. (dnop Bit16Rn "general register bit view" (MACH16 m16c-isa) h-gr-HI f-dst16-rn)
  1574. (dnop Bit32RnPrefixed "general register bit view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-prefixed-QI)
  1575. (dnop Bit32RnUnprefixed "general register bit view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-unprefixed-QI)
  1576. (dnop R0 "r0" (all-isas) h-r0 f-nil)
  1577. (dnop R1 "r1" (all-isas) h-r1 f-nil)
  1578. (dnop R2 "r2" (all-isas) h-r2 f-nil)
  1579. (dnop R3 "r3" (all-isas) h-r3 f-nil)
  1580. (dnop R0l "r0l" (all-isas) h-r0l f-nil)
  1581. (dnop R0h "r0h" (all-isas) h-r0h f-nil)
  1582. (dnop R2R0 "r2r0" (all-isas) h-r2r0 f-nil)
  1583. (dnop R3R1 "r3r1" (all-isas) h-r3r1 f-nil)
  1584. (dnop R1R2R0 "r1r2r0" (all-isas) h-r1r2r0 f-nil)
  1585. (dnop Dst16An "address register" (MACH16 m16c-isa) h-ar f-dst16-an)
  1586. (dnop Dst16AnQI "address register QI view" (MACH16 m16c-isa) h-ar-QI f-dst16-an)
  1587. (dnop Dst16AnHI "address register HI view" (MACH16 m16c-isa) h-ar-HI f-dst16-an)
  1588. (dnop Dst16AnSI "address register SI view" (MACH16 m16c-isa) h-ar-SI f-dst16-an)
  1589. (dnop Dst16An-S "address register HI view" (MACH16 m16c-isa) h-ar-HI f-dst16-an-s)
  1590. (dnop Dst32AnUnprefixed "address register" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed)
  1591. (dnop Dst32AnUnprefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-dst32-an-unprefixed)
  1592. (dnop Dst32AnUnprefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-dst32-an-unprefixed)
  1593. (dnop Dst32AnUnprefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed)
  1594. (dnop Dst32AnExtUnprefixed "address register" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed)
  1595. (dnop Dst32AnPrefixed "address register" (MACH32 m32c-isa) h-ar f-dst32-an-prefixed)
  1596. (dnop Dst32AnPrefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-dst32-an-prefixed)
  1597. (dnop Dst32AnPrefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-dst32-an-prefixed)
  1598. (dnop Dst32AnPrefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-dst32-an-prefixed)
  1599. (dnop Bit16An "address register bit view" (MACH16 m16c-isa) h-ar f-dst16-an)
  1600. (dnop Bit32AnPrefixed "address register bit" (MACH32 m32c-isa) h-ar f-dst32-an-prefixed)
  1601. (dnop Bit32AnUnprefixed "address register bit" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed)
  1602. (dnop A0 "a0" (all-isas) h-a0 f-nil)
  1603. (dnop A1 "a1" (all-isas) h-a1 f-nil)
  1604. (dnop sb "SB register" (all-isas SEM-ONLY) h-sb f-nil)
  1605. (dnop fb "FB register" (all-isas SEM-ONLY) h-fb f-nil)
  1606. (dnop sp "SP register" (all-isas SEM-ONLY) h-sp f-nil)
  1607. (define-full-operand SrcDst16-r0l-r0h-S-normal "r0l/r0h pair" (MACH16 m16c-isa)
  1608. h-sint DFLT f-5-1
  1609. ((parse "r0l_r0h") (print "r0l_r0h")) () ()
  1610. )
  1611. (define-full-operand Regsetpop "popm regset" (all-isas) h-uint
  1612. DFLT f-8-8 ((parse "pop_regset") (print "pop_regset")) () ())
  1613. (define-full-operand Regsetpush "pushm regset" (all-isas) h-uint
  1614. DFLT f-8-8 ((parse "push_regset") (print "push_regset")) () ())
  1615. (dnop Rn16-push-S "r0[lh]" (MACH16 m16c-isa) h-gr-QI f-4-1)
  1616. (dnop An16-push-S "a[01]" (MACH16 m16c-isa) h-ar-HI f-4-1)
  1617. ;-------------------------------------------------------------
  1618. ; Offsets and absolutes
  1619. ;-------------------------------------------------------------
  1620. (define-full-operand Dsp-8-u6 "unsigned 6 bit displacement at offset 8 bits" (all-isas)
  1621. h-uint DFLT f-dsp-8-u6
  1622. ((parse "unsigned6")) () ()
  1623. )
  1624. (define-full-operand Dsp-8-u8 "unsigned 8 bit displacement at offset 8 bits" (all-isas)
  1625. h-uint DFLT f-dsp-8-u8
  1626. ((parse "unsigned8")) () ()
  1627. )
  1628. (define-full-operand Dsp-8-u16 "unsigned 16 bit displacement at offset 8 bits" (all-isas)
  1629. h-uint DFLT f-dsp-8-u16
  1630. ((parse "unsigned16")) () ()
  1631. )
  1632. (define-full-operand Dsp-8-s8 "signed 8 bit displacement at offset 8 bits" (all-isas)
  1633. h-sint DFLT f-dsp-8-s8
  1634. ((parse "signed8")) () ()
  1635. )
  1636. (define-full-operand Dsp-8-s24 "signed 24 bit displacement at offset 8 bits" (all-isas)
  1637. h-sint DFLT f-dsp-8-s24
  1638. ((parse "signed24")) () ()
  1639. )
  1640. (define-full-operand Dsp-8-u24 "unsigned 24 bit displacement at offset 8 bits" (all-isas)
  1641. h-uint DFLT f-dsp-8-u24
  1642. ((parse "unsigned24")) () ()
  1643. )
  1644. (define-full-operand Dsp-10-u6 "unsigned 6 bit displacement at offset 10 bits" (all-isas)
  1645. h-uint DFLT f-dsp-10-u6
  1646. ((parse "unsigned6")) () ()
  1647. )
  1648. (define-full-operand Dsp-16-u8 "unsigned 8 bit displacement at offset 16 bits" (all-isas)
  1649. h-uint DFLT f-dsp-16-u8
  1650. ((parse "unsigned8")) () ()
  1651. )
  1652. (define-full-operand Dsp-16-u16 "unsigned 16 bit displacement at offset 16 bits" (all-isas)
  1653. h-uint DFLT f-dsp-16-u16
  1654. ((parse "unsigned16")) () ()
  1655. )
  1656. (define-full-operand Dsp-16-u20 "unsigned 20 bit displacement at offset 16 bits" (all-isas)
  1657. h-uint DFLT f-dsp-16-u24
  1658. ((parse "unsigned20")) () ()
  1659. )
  1660. (define-full-operand Dsp-16-u24 "unsigned 24 bit displacement at offset 16 bits" (all-isas)
  1661. h-uint DFLT f-dsp-16-u24
  1662. ((parse "unsigned24")) () ()
  1663. )
  1664. (define-full-operand Dsp-16-s8 "signed 8 bit displacement at offset 16 bits" (all-isas)
  1665. h-sint DFLT f-dsp-16-s8
  1666. ((parse "signed8")) () ()
  1667. )
  1668. (define-full-operand Dsp-16-s16 "signed 16 bit displacement at offset 16 bits" (all-isas)
  1669. h-sint DFLT f-dsp-16-s16
  1670. ((parse "signed16")) () ()
  1671. )
  1672. (define-full-operand Dsp-24-u8 "unsigned 8 bit displacement at offset 24 bits" (all-isas)
  1673. h-uint DFLT f-dsp-24-u8
  1674. ((parse "unsigned8")) () ()
  1675. )
  1676. (define-full-operand Dsp-24-u16 "unsigned 16 bit displacement at offset 24 bits" (all-isas)
  1677. h-uint DFLT f-dsp-24-u16
  1678. ((parse "unsigned16")) () ()
  1679. )
  1680. (define-full-operand Dsp-24-u20 "unsigned 20 bit displacement at offset 24 bits" (all-isas)
  1681. h-uint DFLT f-dsp-24-u24
  1682. ((parse "unsigned20")) () ()
  1683. )
  1684. (define-full-operand Dsp-24-u24 "unsigned 24 bit displacement at offset 24 bits" (all-isas)
  1685. h-uint DFLT f-dsp-24-u24
  1686. ((parse "unsigned24")) () ()
  1687. )
  1688. (define-full-operand Dsp-24-s8 "signed 8 bit displacement at offset 24 bits" (all-isas)
  1689. h-sint DFLT f-dsp-24-s8
  1690. ((parse "signed8")) () ()
  1691. )
  1692. (define-full-operand Dsp-24-s16 "signed 16 bit displacement at offset 24 bits" (all-isas)
  1693. h-sint DFLT f-dsp-24-s16
  1694. ((parse "signed16")) () ()
  1695. )
  1696. (define-full-operand Dsp-32-u8 "unsigned 8 bit displacement at offset 32 bits" (all-isas)
  1697. h-uint DFLT f-dsp-32-u8
  1698. ((parse "unsigned8")) () ()
  1699. )
  1700. (define-full-operand Dsp-32-u16 "unsigned 16 bit displacement at offset 32 bits" (all-isas)
  1701. h-uint DFLT f-dsp-32-u16
  1702. ((parse "unsigned16")) () ()
  1703. )
  1704. (define-full-operand Dsp-32-u24 "unsigned 24 bit displacement at offset 32 bits" (all-isas)
  1705. h-uint DFLT f-dsp-32-u24
  1706. ((parse "unsigned24")) () ()
  1707. )
  1708. (define-full-operand Dsp-32-u20 "unsigned 20 bit displacement at offset 32 bits" (all-isas)
  1709. h-uint DFLT f-dsp-32-u24
  1710. ((parse "unsigned20")) () ()
  1711. )
  1712. (define-full-operand Dsp-32-s8 "signed 8 bit displacement at offset 32 bits" (all-isas)
  1713. h-sint DFLT f-dsp-32-s8
  1714. ((parse "signed8")) () ()
  1715. )
  1716. (define-full-operand Dsp-32-s16 "signed 16 bit displacement at offset 32 bits" (all-isas)
  1717. h-sint DFLT f-dsp-32-s16
  1718. ((parse "signed16")) () ()
  1719. )
  1720. (define-full-operand Dsp-40-u8 "unsigned 8 bit displacement at offset 40 bits" (all-isas)
  1721. h-uint DFLT f-dsp-40-u8
  1722. ((parse "unsigned8")) () ()
  1723. )
  1724. (define-full-operand Dsp-40-s8 "signed 8 bit displacement at offset 40 bits" (all-isas)
  1725. h-sint DFLT f-dsp-40-s8
  1726. ((parse "signed8")) () ()
  1727. )
  1728. (define-full-operand Dsp-40-u16 "unsigned 16 bit displacement at offset 40 bits" (all-isas)
  1729. h-uint DFLT f-dsp-40-u16
  1730. ((parse "unsigned16")) () ()
  1731. )
  1732. (define-full-operand Dsp-40-s16 "signed 16 bit displacement at offset 40 bits" (all-isas)
  1733. h-sint DFLT f-dsp-40-s16
  1734. ((parse "signed16")) () ()
  1735. )
  1736. (define-full-operand Dsp-40-u20 "unsigned 20 bit displacement at offset 40 bits" (all-isas)
  1737. h-uint DFLT f-dsp-40-u20
  1738. ((parse "unsigned20")) () ()
  1739. )
  1740. (define-full-operand Dsp-40-u24 "unsigned 24 bit displacement at offset 40 bits" (all-isas)
  1741. h-uint DFLT f-dsp-40-u24
  1742. ((parse "unsigned24")) () ()
  1743. )
  1744. (define-full-operand Dsp-48-u8 "unsigned 8 bit displacement at offset 48 bits" (all-isas)
  1745. h-uint DFLT f-dsp-48-u8
  1746. ((parse "unsigned8")) () ()
  1747. )
  1748. (define-full-operand Dsp-48-s8 "signed 8 bit displacement at offset 48 bits" (all-isas)
  1749. h-sint DFLT f-dsp-48-s8
  1750. ((parse "signed8")) () ()
  1751. )
  1752. (define-full-operand Dsp-48-u16 "unsigned 16 bit displacement at offset 48 bits" (all-isas)
  1753. h-uint DFLT f-dsp-48-u16
  1754. ((parse "unsigned16")) () ()
  1755. )
  1756. (define-full-operand Dsp-48-s16 "signed 16 bit displacement at offset 48 bits" (all-isas)
  1757. h-sint DFLT f-dsp-48-s16
  1758. ((parse "signed16")) () ()
  1759. )
  1760. (define-full-operand Dsp-48-u20 "unsigned 24 bit displacement at offset 40 bits" (all-isas)
  1761. h-uint DFLT f-dsp-48-u20
  1762. ((parse "unsigned24")) () ()
  1763. )
  1764. (define-full-operand Dsp-48-u24 "unsigned 24 bit displacement at offset 48 bits" (all-isas)
  1765. h-uint DFLT f-dsp-48-u24
  1766. ((parse "unsigned24")) () ()
  1767. )
  1768. (define-full-operand Imm-8-s4 "signed 4 bit immediate at offset 8 bits" (all-isas)
  1769. h-sint DFLT f-imm-8-s4
  1770. ((parse "signed4")) () ()
  1771. )
  1772. (define-full-operand Imm-8-s4n "negated 4 bit immediate at offset 8 bits" (all-isas)
  1773. h-sint DFLT f-imm-8-s4
  1774. ((parse "signed4n") (print "signed4n")) () ()
  1775. )
  1776. (define-full-operand Imm-sh-8-s4 "signed 4 bit shift immediate at offset 8 bits" (all-isas)
  1777. h-shimm DFLT f-imm-8-s4
  1778. () () ()
  1779. )
  1780. (define-full-operand Imm-8-QI "signed 8 bit immediate at offset 8 bits" (all-isas)
  1781. h-sint DFLT f-dsp-8-s8
  1782. ((parse "signed8")) () ()
  1783. )
  1784. (define-full-operand Imm-8-HI "signed 16 bit immediate at offset 8 bits" (all-isas)
  1785. h-sint DFLT f-dsp-8-s16
  1786. ((parse "signed16")) () ()
  1787. )
  1788. (define-full-operand Imm-12-s4 "signed 4 bit immediate at offset 12 bits" (all-isas)
  1789. h-sint DFLT f-imm-12-s4
  1790. ((parse "signed4")) () ()
  1791. )
  1792. (define-full-operand Imm-12-s4n "negated 4 bit immediate at offset 12 bits" (all-isas)
  1793. h-sint DFLT f-imm-12-s4
  1794. ((parse "signed4n") (print "signed4n")) () ()
  1795. )
  1796. (define-full-operand Imm-sh-12-s4 "signed 4 bit shift immediate at offset 12 bits" (all-isas)
  1797. h-shimm DFLT f-imm-12-s4
  1798. () () ()
  1799. )
  1800. (define-full-operand Imm-13-u3 "signed 3 bit immediate at offset 13 bits" (all-isas)
  1801. h-sint DFLT f-imm-13-u3
  1802. ((parse "signed4")) () ()
  1803. )
  1804. (define-full-operand Imm-20-s4 "signed 4 bit immediate at offset 20 bits" (all-isas)
  1805. h-sint DFLT f-imm-20-s4
  1806. ((parse "signed4")) () ()
  1807. )
  1808. (define-full-operand Imm-sh-20-s4 "signed 4 bit shift immediate at offset 12 bits" (all-isas)
  1809. h-shimm DFLT f-imm-20-s4
  1810. () () ()
  1811. )
  1812. (define-full-operand Imm-16-QI "signed 8 bit immediate at offset 16 bits" (all-isas)
  1813. h-sint DFLT f-dsp-16-s8
  1814. ((parse "signed8")) () ()
  1815. )
  1816. (define-full-operand Imm-16-HI "signed 16 bit immediate at offset 16 bits" (all-isas)
  1817. h-sint DFLT f-dsp-16-s16
  1818. ((parse "signed16")) () ()
  1819. )
  1820. (define-full-operand Imm-16-SI "signed 32 bit immediate at offset 16 bits" (all-isas)
  1821. h-sint DFLT f-dsp-16-s32
  1822. ((parse "signed32")) () ()
  1823. )
  1824. (define-full-operand Imm-24-QI "signed 8 bit immediate at offset 24 bits" (all-isas)
  1825. h-sint DFLT f-dsp-24-s8
  1826. ((parse "signed8")) () ()
  1827. )
  1828. (define-full-operand Imm-24-HI "signed 16 bit immediate at offset 24 bits" (all-isas)
  1829. h-sint DFLT f-dsp-24-s16
  1830. ((parse "signed16")) () ()
  1831. )
  1832. (define-full-operand Imm-24-SI "signed 32 bit immediate at offset 24 bits" (all-isas)
  1833. h-sint DFLT f-dsp-24-s32
  1834. ((parse "signed32")) () ()
  1835. )
  1836. (define-full-operand Imm-32-QI "signed 8 bit immediate at offset 32 bits" (all-isas)
  1837. h-sint DFLT f-dsp-32-s8
  1838. ((parse "signed8")) () ()
  1839. )
  1840. (define-full-operand Imm-32-SI "signed 32 bit immediate at offset 32 bits" (all-isas)
  1841. h-sint DFLT f-dsp-32-s32
  1842. ((parse "signed32")) () ()
  1843. )
  1844. (define-full-operand Imm-32-HI "signed 16 bit immediate at offset 32 bits" (all-isas)
  1845. h-sint DFLT f-dsp-32-s16
  1846. ((parse "signed16")) () ()
  1847. )
  1848. (define-full-operand Imm-40-QI "signed 8 bit immediate at offset 40 bits" (all-isas)
  1849. h-sint DFLT f-dsp-40-s8
  1850. ((parse "signed8")) () ()
  1851. )
  1852. (define-full-operand Imm-40-HI "signed 16 bit immediate at offset 40 bits" (all-isas)
  1853. h-sint DFLT f-dsp-40-s16
  1854. ((parse "signed16")) () ()
  1855. )
  1856. (define-full-operand Imm-40-SI "signed 32 bit immediate at offset 40 bits" (all-isas)
  1857. h-sint DFLT f-dsp-40-s32
  1858. ((parse "signed32")) () ()
  1859. )
  1860. (define-full-operand Imm-48-QI "signed 8 bit immediate at offset 48 bits" (all-isas)
  1861. h-sint DFLT f-dsp-48-s8
  1862. ((parse "signed8")) () ()
  1863. )
  1864. (define-full-operand Imm-48-HI "signed 16 bit immediate at offset 48 bits" (all-isas)
  1865. h-sint DFLT f-dsp-48-s16
  1866. ((parse "signed16")) () ()
  1867. )
  1868. (define-full-operand Imm-48-SI "signed 32 bit immediate at offset 48 bits" (all-isas)
  1869. h-sint DFLT f-dsp-48-s32
  1870. ((parse "signed32")) () ()
  1871. )
  1872. (define-full-operand Imm-56-QI "signed 8 bit immediate at offset 56 bits" (all-isas)
  1873. h-sint DFLT f-dsp-56-s8
  1874. ((parse "signed8")) () ()
  1875. )
  1876. (define-full-operand Imm-56-HI "signed 16 bit immediate at offset 56 bits" (all-isas)
  1877. h-sint DFLT f-dsp-56-s16
  1878. ((parse "signed16")) () ()
  1879. )
  1880. (define-full-operand Imm-64-HI "signed 16 bit immediate at offset 64 bits" (all-isas)
  1881. h-sint DFLT f-dsp-64-s16
  1882. ((parse "signed16")) () ()
  1883. )
  1884. (define-full-operand Imm1-S "signed 1 bit immediate for short format binary insns" (m32c-isa)
  1885. h-sint DFLT f-imm1-S
  1886. ((parse "imm1_S")) () ()
  1887. )
  1888. (define-full-operand Imm3-S "signed 3 bit immediate for short format binary insns" (m32c-isa)
  1889. h-sint DFLT f-imm3-S
  1890. ((parse "imm3_S")) () ()
  1891. )
  1892. (define-full-operand Bit3-S "3 bit bit number" (m32c-isa)
  1893. h-sint DFLT f-imm3-S
  1894. ((parse "bit3_S")) () ()
  1895. )
  1896. ;-------------------------------------------------------------
  1897. ; Bit numbers
  1898. ;-------------------------------------------------------------
  1899. (define-full-operand Bitno16R "bit number for indexing registers" (m16c-isa)
  1900. h-uint DFLT f-dsp-16-u8
  1901. ((parse "Bitno16R")) () ()
  1902. )
  1903. (dnop Bitno32Prefixed "bit number for indexing objects" (m32c-isa) h-uint f-bitno32-prefixed)
  1904. (dnop Bitno32Unprefixed "bit number for indexing objects" (m32c-isa) h-uint f-bitno32-unprefixed)
  1905. (define-full-operand BitBase16-16-u8 "unsigned bit,base:8 at offset 16for m16c" (m16c-isa)
  1906. h-uint DFLT f-dsp-16-u8
  1907. ((parse "unsigned_bitbase8") (print "unsigned_bitbase")) () ()
  1908. )
  1909. (define-full-operand BitBase16-16-s8 "signed bit,base:8 at offset 16for m16c" (m16c-isa)
  1910. h-sint DFLT f-dsp-16-s8
  1911. ((parse "signed_bitbase8") (print "signed_bitbase")) () ()
  1912. )
  1913. (define-full-operand BitBase16-16-u16 "unsigned bit,base:16 at offset 16 for m16c" (m16c-isa)
  1914. h-uint DFLT f-dsp-16-u16
  1915. ((parse "unsigned_bitbase16") (print "unsigned_bitbase")) () ()
  1916. )
  1917. (define-full-operand BitBase16-8-u11-S "signed bit,base:11 at offset 16 for m16c" (m16c-isa)
  1918. h-uint DFLT f-bitbase16-u11-S
  1919. ((parse "unsigned_bitbase11") (print "unsigned_bitbase")) () ()
  1920. )
  1921. (define-full-operand BitBase32-16-u11-Unprefixed "unsigned bit,base:11 at offset 16 for m32c" (m32c-isa)
  1922. h-uint DFLT f-bitbase32-16-u11-unprefixed
  1923. ((parse "unsigned_bitbase11") (print "unsigned_bitbase")) () ()
  1924. )
  1925. (define-full-operand BitBase32-16-s11-Unprefixed "signed bit,base:11 at offset 16 for m32c" (m32c-isa)
  1926. h-sint DFLT f-bitbase32-16-s11-unprefixed
  1927. ((parse "signed_bitbase11") (print "signed_bitbase")) () ()
  1928. )
  1929. (define-full-operand BitBase32-16-u19-Unprefixed "unsigned bit,base:19 at offset 16 for m32c" (m32c-isa)
  1930. h-uint DFLT f-bitbase32-16-u19-unprefixed
  1931. ((parse "unsigned_bitbase19") (print "unsigned_bitbase")) () ()
  1932. )
  1933. (define-full-operand BitBase32-16-s19-Unprefixed "signed bit,base:19 at offset 16 for m32c" (m32c-isa)
  1934. h-sint DFLT f-bitbase32-16-s19-unprefixed
  1935. ((parse "signed_bitbase19") (print "signed_bitbase")) () ()
  1936. )
  1937. (define-full-operand BitBase32-16-u27-Unprefixed "unsigned bit,base:27 at offset 16 for m32c" (m32c-isa)
  1938. h-uint DFLT f-bitbase32-16-u27-unprefixed
  1939. ((parse "unsigned_bitbase27") (print "unsigned_bitbase")) () ()
  1940. )
  1941. (define-full-operand BitBase32-24-u11-Prefixed "unsigned bit,base:11 at offset 24 for m32c" (m32c-isa)
  1942. h-uint DFLT f-bitbase32-24-u11-prefixed
  1943. ((parse "unsigned_bitbase11") (print "unsigned_bitbase")) () ()
  1944. )
  1945. (define-full-operand BitBase32-24-s11-Prefixed "signed bit,base:11 at offset 24 for m32c" (m32c-isa)
  1946. h-sint DFLT f-bitbase32-24-s11-prefixed
  1947. ((parse "signed_bitbase11") (print "signed_bitbase")) () ()
  1948. )
  1949. (define-full-operand BitBase32-24-u19-Prefixed "unsigned bit,base:19 at offset 24 for m32c" (m32c-isa)
  1950. h-uint DFLT f-bitbase32-24-u19-prefixed
  1951. ((parse "unsigned_bitbase19") (print "unsigned_bitbase")) () ()
  1952. )
  1953. (define-full-operand BitBase32-24-s19-Prefixed "signed bit,base:19 at offset 24 for m32c" (m32c-isa)
  1954. h-sint DFLT f-bitbase32-24-s19-prefixed
  1955. ((parse "signed_bitbase19") (print "signed_bitbase")) () ()
  1956. )
  1957. (define-full-operand BitBase32-24-u27-Prefixed "unsigned bit,base:27 at offset 24 for m32c" (m32c-isa)
  1958. h-uint DFLT f-bitbase32-24-u27-prefixed
  1959. ((parse "unsigned_bitbase27") (print "unsigned_bitbase")) () ()
  1960. )
  1961. ;-------------------------------------------------------------
  1962. ; Labels
  1963. ;-------------------------------------------------------------
  1964. (define-full-operand Lab-5-3 "3 bit label" (all-isas RELAX)
  1965. h-iaddr DFLT f-lab-5-3
  1966. ((parse "lab_5_3")) () () )
  1967. (define-full-operand Lab32-jmp-s "3 bit label" (all-isas RELAX)
  1968. h-iaddr DFLT f-lab32-jmp-s
  1969. ((parse "lab_5_3")) () () )
  1970. (dnop Lab-8-8 "8 bit label" (all-isas RELAX) h-iaddr f-lab-8-8)
  1971. (dnop Lab-8-16 "16 bit label" (all-isas RELAX) h-iaddr f-lab-8-16)
  1972. (dnop Lab-8-24 "24 bit label" (all-isas RELAX) h-iaddr f-lab-8-24)
  1973. (dnop Lab-16-8 "8 bit label" (all-isas RELAX) h-iaddr f-lab-16-8)
  1974. (dnop Lab-24-8 "8 bit label" (all-isas RELAX) h-iaddr f-lab-24-8)
  1975. (dnop Lab-32-8 "8 bit label" (all-isas RELAX) h-iaddr f-lab-32-8)
  1976. (dnop Lab-40-8 "8 bit label" (all-isas RELAX) h-iaddr f-lab-40-8)
  1977. ;-------------------------------------------------------------
  1978. ; Condition code bits
  1979. ;-------------------------------------------------------------
  1980. (dnop sbit "negative bit" (SEM-ONLY all-isas) h-sbit f-nil)
  1981. (dnop obit "overflow bit" (SEM-ONLY all-isas) h-obit f-nil)
  1982. (dnop zbit "zero bit" (SEM-ONLY all-isas) h-zbit f-nil)
  1983. (dnop cbit "carry bit" (SEM-ONLY all-isas) h-cbit f-nil)
  1984. (dnop ubit "stack ptr select bit" (SEM-ONLY all-isas) h-ubit f-nil)
  1985. (dnop ibit "interrupt enable bit" (SEM-ONLY all-isas) h-ibit f-nil)
  1986. (dnop bbit "reg bank select bit" (SEM-ONLY all-isas) h-bbit f-nil)
  1987. (dnop dbit "debug bit" (SEM-ONLY all-isas) h-dbit f-nil)
  1988. ;-------------------------------------------------------------
  1989. ; Condition operands
  1990. ;-------------------------------------------------------------
  1991. (define-pmacro (cond-operand mach offset)
  1992. (dnop (.sym cond mach - offset) "condition" ((.sym m mach c-isa)) (.sym h-cond mach) (.sym f-dsp- offset -u8))
  1993. )
  1994. (cond-operand 16 16)
  1995. (cond-operand 16 24)
  1996. (cond-operand 16 32)
  1997. (cond-operand 32 16)
  1998. (cond-operand 32 24)
  1999. (cond-operand 32 32)
  2000. (cond-operand 32 40)
  2001. (dnop cond16c "condition" (m16c-isa) h-cond16c f-cond16)
  2002. (dnop cond16j "condition" (m16c-isa) h-cond16j f-cond16)
  2003. (dnop cond16j5 "condition" (m16c-isa) h-cond16j-5 f-cond16j-5)
  2004. (dnop cond32 "condition" (m32c-isa) h-cond32 f-cond32)
  2005. (dnop cond32j "condition" (m32c-isa) h-cond32 f-cond32j)
  2006. (dnop sccond32 "scCND condition" (m32c-isa) h-cond32 f-cond16)
  2007. (dnop flags16 "flags" (m16c-isa) h-flags f-9-3)
  2008. (dnop flags32 "flags" (m32c-isa) h-flags f-13-3)
  2009. (dnop cr16 "control" (m16c-isa) h-cr-16 f-9-3)
  2010. (dnop cr1-Unprefixed-32 "control" (m32c-isa) h-cr1-32 f-13-3)
  2011. (dnop cr1-Prefixed-32 "control" (m32c-isa) h-cr1-32 f-21-3)
  2012. (dnop cr2-32 "control" (m32c-isa) h-cr2-32 f-13-3)
  2013. (dnop cr3-Unprefixed-32 "control" (m32c-isa) h-cr3-32 f-13-3)
  2014. (dnop cr3-Prefixed-32 "control" (m32c-isa) h-cr3-32 f-21-3)
  2015. ;-------------------------------------------------------------
  2016. ; Suffixes
  2017. ;-------------------------------------------------------------
  2018. (define-full-operand Z "Suffix for zero format insns" (all-isas)
  2019. h-sint DFLT f-nil
  2020. ((parse "Z") (print "Z")) () ()
  2021. )
  2022. (define-full-operand S "Suffix for short format insns" (all-isas)
  2023. h-sint DFLT f-nil
  2024. ((parse "S") (print "S")) () ()
  2025. )
  2026. (define-full-operand Q "Suffix for quick format insns" (all-isas)
  2027. h-sint DFLT f-nil
  2028. ((parse "Q") (print "Q")) () ()
  2029. )
  2030. (define-full-operand G "Suffix for general format insns" (all-isas)
  2031. h-sint DFLT f-nil
  2032. ((parse "G") (print "G")) () ()
  2033. )
  2034. (define-full-operand X "Empty suffix" (all-isas)
  2035. h-sint DFLT f-nil
  2036. ((parse "X") (print "X")) () ()
  2037. )
  2038. (define-full-operand size "any size specifier" (all-isas)
  2039. h-sint DFLT f-nil
  2040. ((parse "size") (print "size")) () ()
  2041. )
  2042. ;-------------------------------------------------------------
  2043. ; Misc
  2044. ;-------------------------------------------------------------
  2045. (dnop BitIndex "Bit Index for the next insn" (SEM-ONLY MACH32 m32c-isa) h-bit-index f-nil)
  2046. (dnop SrcIndex "Source Index for the next insn" (SEM-ONLY MACH32 m32c-isa) h-src-index f-nil)
  2047. (dnop DstIndex "Destination Index for the next insn" (SEM-ONLY MACH32 m32c-isa) h-dst-index f-nil)
  2048. (dnop NoRemainder "Place holder for when the remainder is not kept" (SEM-ONLY MACH32 m32c-isa) h-none f-nil)
  2049. ;=============================================================
  2050. ; Derived Operands
  2051. ; Memory reference macros that clip addresses appropriately. Refer to
  2052. ; memory at ADDRESS in MODE, clipped appropriately for either the m16c
  2053. ; or m32c.
  2054. (define-pmacro (mem16 mode address)
  2055. (mem mode (and #xffff address)))
  2056. (define-pmacro (mem20 mode address)
  2057. (mem mode (and #xfffff address)))
  2058. (define-pmacro (mem32 mode address)
  2059. (mem mode (and #xffffff address)))
  2060. ; Like mem16 and mem32, but takes MACH as a parameter. MACH must be
  2061. ; either 16 or 32.
  2062. (define-pmacro (mem-mach mach mode address)
  2063. ((.sym mem mach) mode address))
  2064. ;-------------------------------------------------------------
  2065. ; Source
  2066. ;-------------------------------------------------------------
  2067. ; Rn direct
  2068. ;-------------------------------------------------------------
  2069. (define-pmacro (src16-Rn-direct-operand xmode)
  2070. (begin
  2071. (define-derived-operand
  2072. (name (.sym src16-Rn-direct- xmode))
  2073. (comment (.str "m16c Rn direct source " xmode))
  2074. (attrs (machine 16))
  2075. (mode xmode)
  2076. (args ((.sym Src16Rn xmode)))
  2077. (syntax (.str "$Src16Rn" xmode))
  2078. (base-ifield f-8-4)
  2079. (encoding (+ (f-8-2 0) (.sym Src16Rn xmode)))
  2080. (ifield-assertion (eq f-8-2 0))
  2081. (getter (trunc xmode (.sym Src16Rn xmode)))
  2082. (setter (set (.sym Src16Rn xmode) newval))
  2083. )
  2084. )
  2085. )
  2086. (src16-Rn-direct-operand QI)
  2087. (src16-Rn-direct-operand HI)
  2088. (define-pmacro (src32-Rn-direct-operand group base xmode)
  2089. (begin
  2090. (define-derived-operand
  2091. (name (.sym src32-Rn-direct- group - xmode))
  2092. (comment (.str "m32c Rn direct source " xmode))
  2093. (attrs (machine 32))
  2094. (mode xmode)
  2095. (args ((.sym Src32Rn group xmode)))
  2096. (syntax (.str "$Src32Rn" group xmode))
  2097. (base-ifield (.sym f- base -11))
  2098. (encoding (+ ((.sym f- base -3) 4) (.sym Src32Rn group xmode)))
  2099. (ifield-assertion (eq (.sym f- base -3) 4))
  2100. (getter (trunc xmode (.sym Src32Rn group xmode)))
  2101. (setter (set (.sym Src32Rn group xmode) newval))
  2102. )
  2103. )
  2104. )
  2105. (src32-Rn-direct-operand Unprefixed 1 QI)
  2106. (src32-Rn-direct-operand Prefixed 9 QI)
  2107. (src32-Rn-direct-operand Unprefixed 1 HI)
  2108. (src32-Rn-direct-operand Prefixed 9 HI)
  2109. (src32-Rn-direct-operand Unprefixed 1 SI)
  2110. (src32-Rn-direct-operand Prefixed 9 SI)
  2111. ;-------------------------------------------------------------
  2112. ; An direct
  2113. ;-------------------------------------------------------------
  2114. (define-pmacro (src16-An-direct-operand xmode)
  2115. (begin
  2116. (define-derived-operand
  2117. (name (.sym src16-An-direct- xmode))
  2118. (comment (.str "m16c An direct destination " xmode))
  2119. (attrs (machine 16))
  2120. (mode xmode)
  2121. (args ((.sym Src16An xmode)))
  2122. (syntax (.str "$Src16An" xmode))
  2123. (base-ifield f-8-4)
  2124. (encoding (+ (f-8-2 1) (f-10-1 0) (.sym Src16An xmode)))
  2125. (ifield-assertion (andif (eq f-8-2 1) (eq f-10-1 0)))
  2126. (getter (trunc xmode (.sym Src16An xmode)))
  2127. (setter (set (.sym Src16An xmode) newval))
  2128. )
  2129. )
  2130. )
  2131. (src16-An-direct-operand QI)
  2132. (src16-An-direct-operand HI)
  2133. (define-pmacro (src32-An-direct-operand group base1 base2 xmode)
  2134. (begin
  2135. (define-derived-operand
  2136. (name (.sym src32-An-direct- group - xmode))
  2137. (comment (.str "m32c An direct destination " xmode))
  2138. (attrs (machine 32))
  2139. (mode xmode)
  2140. (args ((.sym Src32An group xmode)))
  2141. (syntax (.str "$Src32An" group xmode))
  2142. (base-ifield (.sym f- base1 -11))
  2143. (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 1) (.sym Src32An group xmode)))
  2144. (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 1)))
  2145. (getter (trunc xmode (.sym Src32An group xmode)))
  2146. (setter (set (.sym Src32An group xmode) newval))
  2147. )
  2148. )
  2149. )
  2150. (src32-An-direct-operand Unprefixed 1 10 QI)
  2151. (src32-An-direct-operand Unprefixed 1 10 HI)
  2152. (src32-An-direct-operand Unprefixed 1 10 SI)
  2153. (src32-An-direct-operand Prefixed 9 18 QI)
  2154. (src32-An-direct-operand Prefixed 9 18 HI)
  2155. (src32-An-direct-operand Prefixed 9 18 SI)
  2156. ;-------------------------------------------------------------
  2157. ; An indirect
  2158. ;-------------------------------------------------------------
  2159. (define-pmacro (src16-An-indirect-operand xmode)
  2160. (begin
  2161. (define-derived-operand
  2162. (name (.sym src16-An-indirect- xmode))
  2163. (comment (.str "m16c An indirect destination " xmode))
  2164. (attrs (machine 16))
  2165. (mode xmode)
  2166. (args (Src16An))
  2167. (syntax "[$Src16An]")
  2168. (base-ifield f-8-4)
  2169. (encoding (+ (f-8-2 1) (f-10-1 1) Src16An))
  2170. (ifield-assertion (andif (eq f-8-2 1) (eq f-10-1 1)))
  2171. (getter (mem16 xmode Src16An))
  2172. (setter (set (mem16 xmode Src16An) newval))
  2173. )
  2174. )
  2175. )
  2176. (src16-An-indirect-operand QI)
  2177. (src16-An-indirect-operand HI)
  2178. (define-pmacro (src32-An-indirect-operand group base1 base2 xmode)
  2179. (begin
  2180. (define-derived-operand
  2181. (name (.sym src32-An-indirect- group - xmode))
  2182. (comment (.str "m32c An indirect destination " xmode))
  2183. (attrs (machine 32))
  2184. (mode xmode)
  2185. (args ((.sym Src32An group)))
  2186. (syntax (.str "[$Src32An" group "]"))
  2187. (base-ifield (.sym f- base1 -11))
  2188. (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 0) (.sym Src32An group)))
  2189. (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 0)))
  2190. (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group)
  2191. (const 0)))
  2192. (setter (c-call DFLT (.str "operand_setter_" xmode) newval
  2193. (.sym Src32An group) (const 0)))
  2194. ; (getter (mem32 xmode (.sym Src32An group)))
  2195. ; (setter (set (mem32 xmode (.sym Src32An group)) newval))
  2196. )
  2197. )
  2198. )
  2199. (src32-An-indirect-operand Unprefixed 1 10 QI)
  2200. (src32-An-indirect-operand Unprefixed 1 10 HI)
  2201. (src32-An-indirect-operand Unprefixed 1 10 SI)
  2202. (src32-An-indirect-operand Prefixed 9 18 QI)
  2203. (src32-An-indirect-operand Prefixed 9 18 HI)
  2204. (src32-An-indirect-operand Prefixed 9 18 SI)
  2205. ;-------------------------------------------------------------
  2206. ; dsp:d[r] relative
  2207. ;-------------------------------------------------------------
  2208. (define-pmacro (src16-relative-operand xmode)
  2209. (begin
  2210. (define-derived-operand
  2211. (name (.sym src16-16-8-SB-relative- xmode))
  2212. (comment (.str "m16c dsp:8[sb] relative destination " xmode))
  2213. (attrs (machine 16))
  2214. (mode xmode)
  2215. (args (Dsp-16-u8))
  2216. (syntax "${Dsp-16-u8}[sb]")
  2217. (base-ifield f-8-4)
  2218. (encoding (+ (f-8-4 #xA) Dsp-16-u8))
  2219. (ifield-assertion (eq f-8-4 #xA))
  2220. (getter (mem16 xmode (add Dsp-16-u8 (reg h-sb))))
  2221. (setter (set (mem16 xmode (add Dsp-16-u8 (reg h-sb))) newval))
  2222. )
  2223. (define-derived-operand
  2224. (name (.sym src16-16-16-SB-relative- xmode))
  2225. (comment (.str "m16c dsp:16[sb] relative destination " xmode))
  2226. (attrs (machine 16))
  2227. (mode xmode)
  2228. (args (Dsp-16-u16))
  2229. (syntax "${Dsp-16-u16}[sb]")
  2230. (base-ifield f-8-4)
  2231. (encoding (+ (f-8-4 #xE) Dsp-16-u16))
  2232. (ifield-assertion (eq f-8-4 #xE))
  2233. (getter (mem16 xmode (add Dsp-16-u16 (reg h-sb))))
  2234. (setter (set (mem16 xmode (add Dsp-16-u16 (reg h-sb))) newval))
  2235. )
  2236. (define-derived-operand
  2237. (name (.sym src16-16-8-FB-relative- xmode))
  2238. (comment (.str "m16c dsp:8[fb] relative destination " xmode))
  2239. (attrs (machine 16))
  2240. (mode xmode)
  2241. (args (Dsp-16-s8))
  2242. (syntax "${Dsp-16-s8}[fb]")
  2243. (base-ifield f-8-4)
  2244. (encoding (+ (f-8-4 #xB) Dsp-16-s8))
  2245. (ifield-assertion (eq f-8-4 #xB))
  2246. (getter (mem16 xmode (add Dsp-16-s8 (reg h-fb))))
  2247. (setter (set (mem16 xmode (add Dsp-16-s8 (reg h-fb))) newval))
  2248. )
  2249. (define-derived-operand
  2250. (name (.sym src16-16-8-An-relative- xmode))
  2251. (comment (.str "m16c dsp:8[An] relative destination " xmode))
  2252. (attrs (machine 16))
  2253. (mode xmode)
  2254. (args (Src16An Dsp-16-u8))
  2255. (syntax "${Dsp-16-u8}[$Src16An]")
  2256. (base-ifield f-8-4)
  2257. (encoding (+ (f-8-2 2) (f-10-1 0) Dsp-16-u8 Src16An))
  2258. (ifield-assertion (andif (eq f-8-2 2) (eq f-10-1 0)))
  2259. (getter (mem16 xmode (add Dsp-16-u8 Src16An)))
  2260. (setter (set (mem16 xmode (add Dsp-16-u8 Src16An)) newval))
  2261. )
  2262. (define-derived-operand
  2263. (name (.sym src16-16-16-An-relative- xmode))
  2264. (comment (.str "m16c dsp:16[An] relative destination " xmode))
  2265. (attrs (machine 16))
  2266. (mode xmode)
  2267. (args (Src16An Dsp-16-u16))
  2268. (syntax "${Dsp-16-u16}[$Src16An]")
  2269. (base-ifield f-8-4)
  2270. (encoding (+ (f-8-2 3) (f-10-1 0) Dsp-16-u16 Src16An))
  2271. (ifield-assertion (andif (eq f-8-2 3) (eq f-10-1 0)))
  2272. (getter (mem16 xmode (add Dsp-16-u16 Src16An)))
  2273. (setter (set (mem16 xmode (add Dsp-16-u16 Src16An)) newval))
  2274. )
  2275. (define-derived-operand
  2276. (name (.sym src16-16-20-An-relative- xmode))
  2277. (comment (.str "m16c dsp:20[An] relative destination " xmode))
  2278. (attrs (machine 16))
  2279. (mode xmode)
  2280. (args (Src16An Dsp-16-u20))
  2281. (syntax "${Dsp-16-u20}[$Src16An]")
  2282. (base-ifield f-8-4)
  2283. (encoding (+ (f-8-2 3) (f-10-1 0) Dsp-16-u20 Src16An))
  2284. (ifield-assertion (andif (eq f-8-2 3) (eq f-10-1 0)))
  2285. (getter (mem20 xmode (add Dsp-16-u20 Src16An)))
  2286. (setter (set (mem20 xmode (add Dsp-16-u20 Src16An)) newval))
  2287. )
  2288. )
  2289. )
  2290. (src16-relative-operand QI)
  2291. (src16-relative-operand HI)
  2292. (define-pmacro (src32-relative-operand offset group base1 base2 xmode)
  2293. (begin
  2294. (define-derived-operand
  2295. (name (.sym src32- offset -8-SB-relative- group - xmode))
  2296. (comment (.str "m32c dsp:8[sb] relative destination " xmode))
  2297. (attrs (machine 32))
  2298. (mode xmode)
  2299. (args ((.sym Dsp- offset -u8)))
  2300. (syntax (.str "${Dsp-" offset "-u8}[sb]"))
  2301. (base-ifield (.sym f- base1 -11))
  2302. (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u8)))
  2303. (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 2)))
  2304. (getter (c-call xmode (.str "operand_getter_" xmode) sb (.sym Dsp- offset -u8)))
  2305. (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb (.sym Dsp- offset -u8)))
  2306. ; (getter (mem32 xmode (add (.sym Dsp- offset -u8) (reg h-sb))))
  2307. ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval))
  2308. )
  2309. (define-derived-operand
  2310. (name (.sym src32- offset -16-SB-relative- group - xmode))
  2311. (comment (.str "m32c dsp:16[sb] relative destination " xmode))
  2312. (attrs (machine 32))
  2313. (mode xmode)
  2314. (args ((.sym Dsp- offset -u16)))
  2315. (syntax (.str "${Dsp-" offset "-u16}[sb]"))
  2316. (base-ifield (.sym f- base1 -11))
  2317. (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u16)))
  2318. (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 2)))
  2319. (getter (c-call xmode (.str "operand_getter_" xmode) sb (.sym Dsp- offset -u16)))
  2320. (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb (.sym Dsp- offset -u16)))
  2321. ; (getter (mem32 xmode (add (.sym Dsp- offset -u16) (reg h-sb))))
  2322. ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval))
  2323. )
  2324. (define-derived-operand
  2325. (name (.sym src32- offset -8-FB-relative- group - xmode))
  2326. (comment (.str "m32c dsp:8[fb] relative destination " xmode))
  2327. (attrs (machine 32))
  2328. (mode xmode)
  2329. (args ((.sym Dsp- offset -s8)))
  2330. (syntax (.str "${Dsp-" offset "-s8}[fb]"))
  2331. (base-ifield (.sym f- base1 -11))
  2332. (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s8)))
  2333. (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 3)))
  2334. (getter (c-call xmode (.str "operand_getter_" xmode) fb (.sym Dsp- offset -s8)))
  2335. (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb (.sym Dsp- offset -s8)))
  2336. ; (getter (mem32 xmode (add (.sym Dsp- offset -s8) (reg h-fb))))
  2337. ; (setter (set (mem32 xmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval))
  2338. )
  2339. (define-derived-operand
  2340. (name (.sym src32- offset -16-FB-relative- group - xmode))
  2341. (comment (.str "m32c dsp:16[fb] relative destination " xmode))
  2342. (attrs (machine 32))
  2343. (mode xmode)
  2344. (args ((.sym Dsp- offset -s16)))
  2345. (syntax (.str "${Dsp-" offset "-s16}[fb]"))
  2346. (base-ifield (.sym f- base1 -11))
  2347. (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s16)))
  2348. (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 3)))
  2349. (getter (c-call xmode (.str "operand_getter_" xmode) fb (.sym Dsp- offset -s16)))
  2350. (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb (.sym Dsp- offset -s16)))
  2351. ; (getter (mem32 xmode (add (.sym Dsp- offset -s16) (reg h-fb))))
  2352. ; (setter (set (mem32 xmode (add (.sym Dsp- offset -s16) (reg h-fb))) newval))
  2353. )
  2354. (define-derived-operand
  2355. (name (.sym src32- offset -8-An-relative- group - xmode))
  2356. (comment (.str "m32c dsp:8[An] relative destination " xmode))
  2357. (attrs (machine 32))
  2358. (mode xmode)
  2359. (args ((.sym Src32An group) (.sym Dsp- offset -u8)))
  2360. (syntax (.str "${Dsp-" offset "-u8}[$Src32An" group "]"))
  2361. (base-ifield (.sym f- base1 -11))
  2362. (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u8) (.sym Src32An group)))
  2363. (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -1) 0)))
  2364. (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group) (.sym Dsp- offset -u8)))
  2365. (setter (c-call DFLT (.str "operand_setter_" xmode) newval (.sym Src32An group) (.sym Dsp- offset -u8)))
  2366. ; (getter (mem32 xmode (add (.sym Dsp- offset -u8) (.sym Src32An group))))
  2367. ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u8) (.sym Src32An group))) newval))
  2368. )
  2369. (define-derived-operand
  2370. (name (.sym src32- offset -16-An-relative- group - xmode))
  2371. (comment (.str "m32c dsp:16[An] relative destination " xmode))
  2372. (attrs (machine 32))
  2373. (mode xmode)
  2374. (args ((.sym Src32An group) (.sym Dsp- offset -u16)))
  2375. (syntax (.str "${Dsp-" offset "-u16}[$Src32An" group "]"))
  2376. (base-ifield (.sym f- base1 -11))
  2377. (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u16) (.sym Src32An group)))
  2378. (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -1) 0)))
  2379. (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group) (.sym Dsp- offset -u16)))
  2380. (setter (c-call DFLT (.str "operand_setter_" xmode) newval (.sym Src32An group) (.sym Dsp- offset -u16)))
  2381. ; (getter (mem32 xmode (add (.sym Dsp- offset -u16) (.sym Src32An group))))
  2382. ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u16) (.sym Src32An group))) newval))
  2383. )
  2384. (define-derived-operand
  2385. (name (.sym src32- offset -24-An-relative- group - xmode))
  2386. (comment (.str "m32c dsp:16[An] relative destination " xmode))
  2387. (attrs (machine 32))
  2388. (mode xmode)
  2389. (args ((.sym Src32An group) (.sym Dsp- offset -u24)))
  2390. (syntax (.str "${Dsp-" offset "-u24}[$Src32An" group "]"))
  2391. (base-ifield (.sym f- base1 -11))
  2392. (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u24) (.sym Src32An group)))
  2393. (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -1) 0)))
  2394. (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group) (.sym Dsp- offset -u24) ))
  2395. (setter (c-call DFLT (.str "operand_setter_" xmode) newval (.sym Src32An group) (.sym Dsp- offset -u24)))
  2396. ; (getter (mem32 xmode (add (.sym Dsp- offset -u24) (.sym Src32An group))))
  2397. ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u24) (.sym Src32An group))) newval))
  2398. )
  2399. )
  2400. )
  2401. (src32-relative-operand 16 Unprefixed 1 10 QI)
  2402. (src32-relative-operand 16 Unprefixed 1 10 HI)
  2403. (src32-relative-operand 16 Unprefixed 1 10 SI)
  2404. (src32-relative-operand 24 Prefixed 9 18 QI)
  2405. (src32-relative-operand 24 Prefixed 9 18 HI)
  2406. (src32-relative-operand 24 Prefixed 9 18 SI)
  2407. ;-------------------------------------------------------------
  2408. ; Absolute address
  2409. ;-------------------------------------------------------------
  2410. (define-pmacro (src16-absolute xmode)
  2411. (begin
  2412. (define-derived-operand
  2413. (name (.sym src16-16-16-absolute- xmode))
  2414. (comment (.str "m16c absolute address " xmode))
  2415. (attrs (machine 16))
  2416. (mode xmode)
  2417. (args (Dsp-16-u16))
  2418. (syntax (.str "${Dsp-16-u16}"))
  2419. (base-ifield f-8-4)
  2420. (encoding (+ (f-8-4 #xF) Dsp-16-u16))
  2421. (ifield-assertion (eq f-8-4 #xF))
  2422. (getter (mem16 xmode Dsp-16-u16))
  2423. (setter (set (mem16 xmode Dsp-16-u16) newval))
  2424. )
  2425. )
  2426. )
  2427. (src16-absolute QI)
  2428. (src16-absolute HI)
  2429. (define-pmacro (src32-absolute offset group base1 base2 xmode)
  2430. (begin
  2431. (define-derived-operand
  2432. (name (.sym src32- offset -16-absolute- group - xmode))
  2433. (comment (.str "m32c absolute address " xmode))
  2434. (attrs (machine 32))
  2435. (mode xmode)
  2436. (args ((.sym Dsp- offset -u16)))
  2437. (syntax (.str "${Dsp-" offset "-u16}"))
  2438. (base-ifield (.sym f- base1 -11))
  2439. (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym Dsp- offset -u16)))
  2440. (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3)))
  2441. (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) (.sym Dsp- offset -u16)))
  2442. (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) (.sym Dsp- offset -u16)))
  2443. ; (getter (mem32 xmode (.sym Dsp- offset -u16)))
  2444. ; (setter (set (mem32 xmode (.sym Dsp- offset -u16)) newval))
  2445. )
  2446. (define-derived-operand
  2447. (name (.sym src32- offset -24-absolute- group - xmode))
  2448. (comment (.str "m32c absolute address " xmode))
  2449. (attrs (machine 32))
  2450. (mode xmode)
  2451. (args ((.sym Dsp- offset -u24)))
  2452. (syntax (.str "${Dsp-" offset "-u24}"))
  2453. (base-ifield (.sym f- base1 -11))
  2454. (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u24)))
  2455. (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2)))
  2456. (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) (.sym Dsp- offset -u24)))
  2457. (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) (.sym Dsp- offset -u24)))
  2458. ; (getter (mem32 xmode (.sym Dsp- offset -u24)))
  2459. ; (setter (set (mem32 xmode (.sym Dsp- offset -u24)) newval))
  2460. )
  2461. )
  2462. )
  2463. (src32-absolute 16 Unprefixed 1 10 QI)
  2464. (src32-absolute 16 Unprefixed 1 10 HI)
  2465. (src32-absolute 16 Unprefixed 1 10 SI)
  2466. (src32-absolute 24 Prefixed 9 18 QI)
  2467. (src32-absolute 24 Prefixed 9 18 HI)
  2468. (src32-absolute 24 Prefixed 9 18 SI)
  2469. ;-------------------------------------------------------------
  2470. ; An indirect indirect
  2471. ;
  2472. ; Double indirect addressing uses the lower 3 bytes of the value stored
  2473. ; at the address referenced by 'op' as the effective address.
  2474. ;-------------------------------------------------------------
  2475. (define-pmacro (indirect-addr op) (and USI (mem32 USI op) #x00ffffff))
  2476. ; (define-pmacro (src-An-indirect-indirect-operand xmode)
  2477. ; (define-derived-operand
  2478. ; (name (.sym src32-An-indirect-indirect- xmode))
  2479. ; (comment (.str "m32c An indirect indirect destination " xmode))
  2480. ; (attrs (machine 32))
  2481. ; (mode xmode)
  2482. ; (args (Src32AnPrefixed))
  2483. ; (syntax (.str "[[$Src32AnPrefixed]]"))
  2484. ; (base-ifield f-9-11)
  2485. ; (encoding (+ (f-9-3 0) (f-18-1 0) Src32AnPrefixed))
  2486. ; (ifield-assertion (andif (eq f-9-3 0) (eq f-18-1 0)))
  2487. ; (getter (mem32 xmode (indirect-addr Src32AnPrefixed)))
  2488. ; (setter (set (mem32 xmode (indirect-addr Src32AnPrefixed)) newval))
  2489. ; )
  2490. ; )
  2491. ; (src-An-indirect-indirect-operand QI)
  2492. ; (src-An-indirect-indirect-operand HI)
  2493. ; (src-An-indirect-indirect-operand SI)
  2494. ;-------------------------------------------------------------
  2495. ; Relative indirect
  2496. ;-------------------------------------------------------------
  2497. (define-pmacro (src-relative-indirect-operand xmode)
  2498. (begin
  2499. ; (define-derived-operand
  2500. ; (name (.sym src32-24-8-SB-relative-indirect- xmode))
  2501. ; (comment (.str "m32c dsp:8[sb] relative source " xmode))
  2502. ; (attrs (machine 32))
  2503. ; (mode xmode)
  2504. ; (args (Dsp-24-u8))
  2505. ; (syntax "[${Dsp-24-u8}[sb]]")
  2506. ; (base-ifield f-9-11)
  2507. ; (encoding (+ (f-9-3 1) (f-18-2 2) Dsp-24-u8))
  2508. ; (ifield-assertion (andif (eq f-9-3 1) (eq f-18-2 2)))
  2509. ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u8 (reg h-sb)))))
  2510. ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u8 (reg h-sb)))) newval))
  2511. ; )
  2512. ; (define-derived-operand
  2513. ; (name (.sym src32-24-16-SB-relative-indirect- xmode))
  2514. ; (comment (.str "m32c dsp:16[sb] relative source " xmode))
  2515. ; (attrs (machine 32))
  2516. ; (mode xmode)
  2517. ; (args (Dsp-24-u16))
  2518. ; (syntax "[${Dsp-24-u16}[sb]]")
  2519. ; (base-ifield f-9-11)
  2520. ; (encoding (+ (f-9-3 2) (f-18-2 2) Dsp-24-u16))
  2521. ; (ifield-assertion (andif (eq f-9-3 2) (eq f-18-2 2)))
  2522. ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u16 (reg h-sb)))))
  2523. ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u16 (reg h-sb)))) newval))
  2524. ; )
  2525. ; (define-derived-operand
  2526. ; (name (.sym src32-24-8-FB-relative-indirect- xmode))
  2527. ; (comment (.str "m32c dsp:8[fb] relative source " xmode))
  2528. ; (attrs (machine 32))
  2529. ; (mode xmode)
  2530. ; (args (Dsp-24-s8))
  2531. ; (syntax "[${Dsp-24-s8}[fb]]")
  2532. ; (base-ifield f-9-11)
  2533. ; (encoding (+ (f-9-3 1) (f-18-2 3) Dsp-24-s8))
  2534. ; (ifield-assertion (andif (eq f-9-3 1) (eq f-18-2 3)))
  2535. ; (getter (mem32 xmode (indirect-addr (add Dsp-24-s8 (reg h-fb)))))
  2536. ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-s8 (reg h-fb)))) newval))
  2537. ; )
  2538. ; (define-derived-operand
  2539. ; (name (.sym src32-24-16-FB-relative-indirect- xmode))
  2540. ; (comment (.str "m32c dsp:16[fb] relative source " xmode))
  2541. ; (attrs (machine 32))
  2542. ; (mode xmode)
  2543. ; (args (Dsp-24-s16))
  2544. ; (syntax "[${Dsp-24-s16}[fb]]")
  2545. ; (base-ifield f-9-11)
  2546. ; (encoding (+ (f-9-3 2) (f-18-2 3) Dsp-24-s16))
  2547. ; (ifield-assertion (andif (eq f-9-3 2) (eq f-18-2 3)))
  2548. ; (getter (mem32 xmode (indirect-addr (add Dsp-24-s16 (reg h-fb)))))
  2549. ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-s16 (reg h-fb)))) newval))
  2550. ; )
  2551. ; (define-derived-operand
  2552. ; (name (.sym src32-24-8-An-relative-indirect- xmode))
  2553. ; (comment (.str "m32c dsp:8[An] relative indirect source " xmode))
  2554. ; (attrs (machine 32))
  2555. ; (mode xmode)
  2556. ; (args (Src32AnPrefixed Dsp-24-u8))
  2557. ; (syntax "[${Dsp-24-u8}[$Src32AnPrefixed]]")
  2558. ; (base-ifield f-9-11)
  2559. ; (encoding (+ (f-9-3 1) (f-18-1 0) Dsp-24-u8 Src32AnPrefixed))
  2560. ; (ifield-assertion (andif (eq f-9-3 1) (eq f-18-1 0)))
  2561. ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u8 Src32AnPrefixed))))
  2562. ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u8 Src32AnPrefixed))) newval))
  2563. ; )
  2564. ; (define-derived-operand
  2565. ; (name (.sym src32-24-16-An-relative-indirect- xmode))
  2566. ; (comment (.str "m32c dsp:16[An] relative source " xmode))
  2567. ; (attrs (machine 32))
  2568. ; (mode xmode)
  2569. ; (args (Src32AnPrefixed Dsp-24-u16))
  2570. ; (syntax "[${Dsp-24-u16}[$Src32AnPrefixed]]")
  2571. ; (base-ifield f-9-11)
  2572. ; (encoding (+ (f-9-3 2) (f-18-1 0) Dsp-24-u16 Src32AnPrefixed))
  2573. ; (ifield-assertion (andif (eq f-9-3 2) (eq f-18-1 0)))
  2574. ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u16 Src32AnPrefixed))))
  2575. ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u16 Src32AnPrefixed))) newval))
  2576. ; )
  2577. ; (define-derived-operand
  2578. ; (name (.sym src32-24-24-An-relative-indirect- xmode))
  2579. ; (comment (.str "m32c dsp:24[An] relative source " xmode))
  2580. ; (attrs (machine 32))
  2581. ; (mode xmode)
  2582. ; (args (Src32AnPrefixed Dsp-24-u24))
  2583. ; (syntax "[${Dsp-24-u24}[$Src32AnPrefixed]]")
  2584. ; (base-ifield f-9-11)
  2585. ; (encoding (+ (f-9-3 3) (f-18-1 0) Dsp-24-u24 Src32AnPrefixed))
  2586. ; (ifield-assertion (andif (eq f-9-3 3) (eq f-18-1 0)))
  2587. ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u24 Src32AnPrefixed))))
  2588. ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u24 Src32AnPrefixed))) newval))
  2589. ; )
  2590. )
  2591. )
  2592. ; (src-relative-indirect-operand QI)
  2593. ; (src-relative-indirect-operand HI)
  2594. ; (src-relative-indirect-operand SI)
  2595. ;-------------------------------------------------------------
  2596. ; Absolute Indirect address
  2597. ;-------------------------------------------------------------
  2598. (define-pmacro (src32-absolute-indirect offset base1 base2 xmode)
  2599. (begin
  2600. ; (define-derived-operand
  2601. ; (name (.sym src32- offset -16-absolute-indirect-derived- xmode))
  2602. ; (comment (.str "m32c absolute indirect address " xmode))
  2603. ; (attrs (machine 32))
  2604. ; (mode xmode)
  2605. ; (args ((.sym Dsp- offset -u16)))
  2606. ; (syntax (.str "[${Dsp-" offset "-u16}]"))
  2607. ; (base-ifield (.sym f- base1 -11))
  2608. ; (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym Dsp- offset -u16)))
  2609. ; (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3)))
  2610. ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u16))))
  2611. ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u16))) newval))
  2612. ; )
  2613. ; (define-derived-operand
  2614. ; (name (.sym src32- offset -24-absolute-indirect-derived- xmode))
  2615. ; (comment (.str "m32c absolute indirect address " xmode))
  2616. ; (attrs (machine 32))
  2617. ; (mode xmode)
  2618. ; (args ((.sym Dsp- offset -u24)))
  2619. ; (syntax (.str "[${Dsp-" offset "-u24}]"))
  2620. ; (base-ifield (.sym f- base1 -11))
  2621. ; (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u24)))
  2622. ; (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2)))
  2623. ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u24))))
  2624. ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u24))) newval))
  2625. ; )
  2626. )
  2627. )
  2628. (src32-absolute-indirect 24 9 18 QI)
  2629. (src32-absolute-indirect 24 9 18 HI)
  2630. (src32-absolute-indirect 24 9 18 SI)
  2631. ;-------------------------------------------------------------
  2632. ; Register relative source operands for short format insns
  2633. ;-------------------------------------------------------------
  2634. (define-pmacro (src-2-S-operands mach xmode base opc1 opc2 opc3)
  2635. (begin
  2636. (define-derived-operand
  2637. (name (.sym src mach -2-S-8-SB-relative- xmode))
  2638. (comment (.str "m" mach "c SB relative address"))
  2639. (attrs (machine mach))
  2640. (mode xmode)
  2641. (args (Dsp-8-u8))
  2642. (syntax "${Dsp-8-u8}[sb]")
  2643. (base-ifield (.sym f- base -2))
  2644. (encoding (+ ((.sym f- base -2) opc1) Dsp-8-u8))
  2645. (ifield-assertion (eq (.sym f- base -2) opc1))
  2646. (getter (c-call xmode (.str "operand_getter_" xmode) sb Dsp-8-u8))
  2647. (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb Dsp-8-u8))
  2648. ; (getter (mem-mach mach xmode (indirect-addr (add (reg h-sb) Dsp-8-u8))))
  2649. ; (setter (set (mem-mach mach xmode (indirect-addr (add (reg h-sb) Dsp-8-u8))) newval))
  2650. )
  2651. (define-derived-operand
  2652. (name (.sym src mach -2-S-8-FB-relative- xmode))
  2653. (comment (.str "m" mach "c FB relative address"))
  2654. (attrs (machine mach))
  2655. (mode xmode)
  2656. (args (Dsp-8-s8))
  2657. (syntax "${Dsp-8-s8}[fb]")
  2658. (base-ifield (.sym f- base -2))
  2659. (encoding (+ ((.sym f- base -2) opc2) Dsp-8-s8))
  2660. (ifield-assertion (eq (.sym f- base -2) opc2))
  2661. (getter (c-call xmode (.str "operand_getter_" xmode) fb Dsp-8-s8))
  2662. (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb Dsp-8-s8))
  2663. ; (getter (mem-mach mach xmode (indirect-addr (add (reg h-fb) Dsp-8-s8))))
  2664. ; (setter (set (mem-mach mach xmode (indirect-addr (add (reg h-fb) Dsp-8-s8))) newval))
  2665. )
  2666. (define-derived-operand
  2667. (name (.sym src mach -2-S-16-absolute- xmode))
  2668. (comment (.str "m" mach "c absolute address"))
  2669. (attrs (machine mach))
  2670. (mode xmode)
  2671. (args (Dsp-8-u16))
  2672. (syntax "${Dsp-8-u16}")
  2673. (base-ifield (.sym f- base -2))
  2674. (encoding (+ ((.sym f- base -2) opc3) Dsp-8-u16))
  2675. (ifield-assertion (eq (.sym f- base -2) opc3))
  2676. (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) Dsp-8-u16))
  2677. (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) Dsp-8-u16))
  2678. ; (getter (mem-mach mach xmode Dsp-8-u16))
  2679. ; (setter (set (mem-mach mach xmode Dsp-8-u16) newval))
  2680. )
  2681. )
  2682. )
  2683. (src-2-S-operands 16 QI 6 1 2 3)
  2684. (src-2-S-operands 32 QI 2 2 3 1)
  2685. (src-2-S-operands 32 HI 2 2 3 1)
  2686. ;=============================================================
  2687. ; Derived Operands
  2688. ;-------------------------------------------------------------
  2689. ; Destination
  2690. ;-------------------------------------------------------------
  2691. ; Rn direct
  2692. ;-------------------------------------------------------------
  2693. (define-pmacro (dst16-Rn-direct-operand xmode)
  2694. (begin
  2695. (define-derived-operand
  2696. (name (.sym dst16-Rn-direct- xmode))
  2697. (comment (.str "m16c Rn direct destination " xmode))
  2698. (attrs (machine 16))
  2699. (mode xmode)
  2700. (args ((.sym Dst16Rn xmode)))
  2701. (syntax (.str "$Dst16Rn" xmode))
  2702. (base-ifield f-12-4)
  2703. (encoding (+ (f-12-2 0) (.sym Dst16Rn xmode)))
  2704. (ifield-assertion (eq f-12-2 0))
  2705. (getter (trunc xmode (.sym Dst16Rn xmode)))
  2706. (setter (set (.sym Dst16Rn xmode) newval))
  2707. )
  2708. )
  2709. )
  2710. (dst16-Rn-direct-operand QI)
  2711. (dst16-Rn-direct-operand HI)
  2712. (dst16-Rn-direct-operand SI)
  2713. (define-derived-operand
  2714. (name dst16-Rn-direct-Ext-QI)
  2715. (comment "m16c Rn direct destination QI")
  2716. (attrs (machine 16))
  2717. (mode HI)
  2718. (args (Dst16RnExtQI))
  2719. (syntax "$Dst16RnExtQI")
  2720. (base-ifield f-12-4)
  2721. (encoding (+ (f-12-2 0) Dst16RnExtQI (f-15-1 0)))
  2722. (ifield-assertion (andif (eq f-12-2 0) (eq f-15-1 0)))
  2723. (getter (trunc QI (.sym Dst16RnExtQI)))
  2724. (setter (set Dst16RnExtQI newval))
  2725. )
  2726. (define-pmacro (dst32-Rn-direct-operand group base xmode)
  2727. (begin
  2728. (define-derived-operand
  2729. (name (.sym dst32-Rn-direct- group - xmode))
  2730. (comment (.str "m32c Rn direct destination " xmode))
  2731. (attrs (machine 32))
  2732. (mode xmode)
  2733. (args ((.sym Dst32Rn group xmode)))
  2734. (syntax (.str "$Dst32Rn" group xmode))
  2735. (base-ifield (.sym f- base -6))
  2736. (encoding (+ ((.sym f- base -3) 4) (.sym Dst32Rn group xmode)))
  2737. (ifield-assertion (eq (.sym f- base -3) 4))
  2738. (getter (trunc xmode (.sym Dst32Rn group xmode)))
  2739. (setter (set (.sym Dst32Rn group xmode) newval))
  2740. )
  2741. )
  2742. )
  2743. (dst32-Rn-direct-operand Unprefixed 4 QI)
  2744. (dst32-Rn-direct-operand Prefixed 12 QI)
  2745. (dst32-Rn-direct-operand Unprefixed 4 HI)
  2746. (dst32-Rn-direct-operand Prefixed 12 HI)
  2747. (dst32-Rn-direct-operand Unprefixed 4 SI)
  2748. (dst32-Rn-direct-operand Prefixed 12 SI)
  2749. (define-pmacro (dst32-Rn-direct-Ext-operand group base1 base2 smode dmode)
  2750. (begin
  2751. (define-derived-operand
  2752. (name (.sym dst32-Rn-direct- group - smode))
  2753. (comment (.str "m32c Rn direct destination " smode))
  2754. (attrs (machine 32))
  2755. (mode dmode)
  2756. (args ((.sym Dst32Rn group smode)))
  2757. (syntax (.str "$Dst32Rn" group smode))
  2758. (base-ifield (.sym f- base1 -6))
  2759. (encoding (+ ((.sym f- base1 -3) 4) ((.sym f- base2 -1) 1) (.sym Dst32Rn group smode)))
  2760. (ifield-assertion (andif (eq (.sym f- base1 -3) 4) (eq (.sym f- base2 -1) 1)))
  2761. (getter (trunc smode (.sym Dst32Rn group smode)))
  2762. (setter (set (.sym Dst32Rn group smode) newval))
  2763. )
  2764. )
  2765. )
  2766. (dst32-Rn-direct-Ext-operand ExtUnprefixed 4 8 QI HI)
  2767. (dst32-Rn-direct-Ext-operand ExtUnprefixed 4 8 HI SI)
  2768. (define-derived-operand
  2769. (name dst32-R3-direct-Unprefixed-HI)
  2770. (comment "m32c R3 direct HI")
  2771. (attrs (machine 32))
  2772. (mode HI)
  2773. (args (R3))
  2774. (syntax "$R3")
  2775. (base-ifield f-4-6)
  2776. (encoding (+ (f-4-3 4) (f-8-2 #x1)))
  2777. (ifield-assertion (andif (eq f-4-3 4) (eq f-8-2 #x1)))
  2778. (getter (trunc HI R3))
  2779. (setter (set R3 newval))
  2780. )
  2781. ;-------------------------------------------------------------
  2782. ; An direct
  2783. ;-------------------------------------------------------------
  2784. (define-pmacro (dst16-An-direct-operand xmode)
  2785. (begin
  2786. (define-derived-operand
  2787. (name (.sym dst16-An-direct- xmode))
  2788. (comment (.str "m16c An direct destination " xmode))
  2789. (attrs (machine 16))
  2790. (mode xmode)
  2791. (args ((.sym Dst16An xmode)))
  2792. (syntax (.str "$Dst16An" xmode))
  2793. (base-ifield f-12-4)
  2794. (encoding (+ (f-12-2 1) (f-14-1 0) (.sym Dst16An xmode)))
  2795. (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 0)))
  2796. (getter (trunc xmode (.sym Dst16An xmode)))
  2797. (setter (set (.sym Dst16An xmode) newval))
  2798. )
  2799. )
  2800. )
  2801. (dst16-An-direct-operand QI)
  2802. (dst16-An-direct-operand HI)
  2803. (dst16-An-direct-operand SI)
  2804. (define-pmacro (dst32-An-direct-operand group base1 base2 xmode)
  2805. (begin
  2806. (define-derived-operand
  2807. (name (.sym dst32-An-direct- group - xmode))
  2808. (comment (.str "m32c An direct destination " xmode))
  2809. (attrs (machine 32))
  2810. (mode xmode)
  2811. (args ((.sym Dst32An group xmode)))
  2812. (syntax (.str "$Dst32An" group xmode))
  2813. (base-ifield (.sym f- base1 -6))
  2814. (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 1) (.sym Dst32An group xmode)))
  2815. (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 1)))
  2816. (getter (trunc xmode (.sym Dst32An group xmode)))
  2817. (setter (set (.sym Dst32An group xmode) newval))
  2818. )
  2819. )
  2820. )
  2821. (dst32-An-direct-operand Unprefixed 4 8 QI)
  2822. (dst32-An-direct-operand Prefixed 12 16 QI)
  2823. (dst32-An-direct-operand Unprefixed 4 8 HI)
  2824. (dst32-An-direct-operand Prefixed 12 16 HI)
  2825. (dst32-An-direct-operand Unprefixed 4 8 SI)
  2826. (dst32-An-direct-operand Prefixed 12 16 SI)
  2827. ;-------------------------------------------------------------
  2828. ; An indirect
  2829. ;-------------------------------------------------------------
  2830. (define-pmacro (dst16-An-indirect-operand xmode)
  2831. (begin
  2832. (define-derived-operand
  2833. (name (.sym dst16-An-indirect- xmode))
  2834. (comment (.str "m16c An indirect destination " xmode))
  2835. (attrs (machine 16))
  2836. (mode xmode)
  2837. (args (Dst16An))
  2838. (syntax "[$Dst16An]")
  2839. (base-ifield f-12-4)
  2840. (encoding (+ (f-12-2 1) (f-14-1 1) Dst16An))
  2841. (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 1)))
  2842. (getter (mem16 xmode Dst16An))
  2843. (setter (set (mem16 xmode Dst16An) newval))
  2844. )
  2845. )
  2846. )
  2847. (dst16-An-indirect-operand QI)
  2848. (dst16-An-indirect-operand HI)
  2849. (dst16-An-indirect-operand SI)
  2850. (define-derived-operand
  2851. (name dst16-An-indirect-Ext-QI)
  2852. (comment "m16c An indirect destination QI")
  2853. (attrs (machine 16))
  2854. (mode HI)
  2855. (args (Dst16An))
  2856. (syntax "[$Dst16An]")
  2857. (base-ifield f-12-4)
  2858. (encoding (+ (f-12-2 1) (f-14-1 1) Dst16An))
  2859. (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 1)))
  2860. (getter (mem16 QI Dst16An))
  2861. (setter (set (mem16 HI Dst16An) newval))
  2862. )
  2863. (define-pmacro (dst32-An-indirect-operand group base1 base2 smode dmode)
  2864. (begin
  2865. (define-derived-operand
  2866. (name (.sym dst32-An-indirect- group - smode))
  2867. (comment (.str "m32c An indirect destination " smode))
  2868. (attrs (machine 32))
  2869. (mode dmode)
  2870. (args ((.sym Dst32An group)))
  2871. (syntax (.str "[$Dst32An" group "]"))
  2872. (base-ifield (.sym f- base1 -6))
  2873. (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 0) (.sym Dst32An group)))
  2874. (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 0)))
  2875. (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group)
  2876. (const 0)))
  2877. (setter (c-call DFLT (.str "operand_setter_" dmode) newval
  2878. (.sym Dst32An group) (const 0)))
  2879. ; (getter (mem32 smode (.sym Dst32An group)))
  2880. ; (setter (set (mem32 dmode (.sym Dst32An group)) newval))
  2881. )
  2882. )
  2883. )
  2884. (dst32-An-indirect-operand Unprefixed 4 8 QI QI)
  2885. (dst32-An-indirect-operand Prefixed 12 16 QI QI)
  2886. (dst32-An-indirect-operand Unprefixed 4 8 HI HI)
  2887. (dst32-An-indirect-operand Prefixed 12 16 HI HI)
  2888. (dst32-An-indirect-operand Unprefixed 4 8 SI SI)
  2889. (dst32-An-indirect-operand Prefixed 12 16 SI SI)
  2890. (dst32-An-indirect-operand ExtUnprefixed 4 8 QI HI)
  2891. (dst32-An-indirect-operand ExtUnprefixed 4 8 HI SI)
  2892. ;-------------------------------------------------------------
  2893. ; dsp:d[r] relative
  2894. ;-------------------------------------------------------------
  2895. (define-pmacro (dst16-relative-operand offset xmode)
  2896. (begin
  2897. (define-derived-operand
  2898. (name (.sym dst16- offset -8-SB-relative- xmode))
  2899. (comment (.str "m16c dsp:8[sb] relative destination " xmode))
  2900. (attrs (machine 16))
  2901. (mode xmode)
  2902. (args ((.sym Dsp- offset -u8)))
  2903. (syntax (.str "${Dsp-" offset "-u8}[sb]"))
  2904. (base-ifield f-12-4)
  2905. (encoding (+ (f-12-4 #xA) (.sym Dsp- offset -u8)))
  2906. (ifield-assertion (eq f-12-4 #xA))
  2907. (getter (mem16 xmode (add (.sym Dsp- offset -u8) (reg h-sb))))
  2908. (setter (set (mem16 xmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval))
  2909. )
  2910. (define-derived-operand
  2911. (name (.sym dst16- offset -16-SB-relative- xmode))
  2912. (comment (.str "m16c dsp:16[sb] relative destination " xmode))
  2913. (attrs (machine 16))
  2914. (mode xmode)
  2915. (args ((.sym Dsp- offset -u16)))
  2916. (syntax (.str "${Dsp-" offset "-u16}[sb]"))
  2917. (base-ifield f-12-4)
  2918. (encoding (+ (f-12-4 #xE) (.sym Dsp- offset -u16)))
  2919. (ifield-assertion (eq f-12-4 #xE))
  2920. (getter (mem16 xmode (add (.sym Dsp- offset -u16) (reg h-sb))))
  2921. (setter (set (mem16 xmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval))
  2922. )
  2923. (define-derived-operand
  2924. (name (.sym dst16- offset -8-FB-relative- xmode))
  2925. (comment (.str "m16c dsp:8[fb] relative destination " xmode))
  2926. (attrs (machine 16))
  2927. (mode xmode)
  2928. (args ((.sym Dsp- offset -s8)))
  2929. (syntax (.str "${Dsp-" offset "-s8}[fb]"))
  2930. (base-ifield f-12-4)
  2931. (encoding (+ (f-12-4 #xB) (.sym Dsp- offset -s8)))
  2932. (ifield-assertion (eq f-12-4 #xB))
  2933. (getter (mem16 xmode (add (.sym Dsp- offset -s8) (reg h-fb))))
  2934. (setter (set (mem16 xmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval))
  2935. )
  2936. (define-derived-operand
  2937. (name (.sym dst16- offset -8-An-relative- xmode))
  2938. (comment (.str "m16c dsp:8[An] relative destination " xmode))
  2939. (attrs (machine 16))
  2940. (mode xmode)
  2941. (args (Dst16An (.sym Dsp- offset -u8)))
  2942. (syntax (.str "${Dsp-" offset "-u8}[$Dst16An]"))
  2943. (base-ifield f-12-4)
  2944. (encoding (+ (f-12-2 2) (f-14-1 0) (.sym Dsp- offset -u8) Dst16An))
  2945. (ifield-assertion (andif (eq f-12-2 2) (eq f-14-1 0)))
  2946. (getter (mem16 xmode (add (.sym Dsp- offset -u8) Dst16An)))
  2947. (setter (set (mem16 xmode (add (.sym Dsp- offset -u8) Dst16An)) newval))
  2948. )
  2949. (define-derived-operand
  2950. (name (.sym dst16- offset -16-An-relative- xmode))
  2951. (comment (.str "m16c dsp:16[An] relative destination " xmode))
  2952. (attrs (machine 16))
  2953. (mode xmode)
  2954. (args (Dst16An (.sym Dsp- offset -u16)))
  2955. (syntax (.str "${Dsp-" offset "-u16}[$Dst16An]"))
  2956. (base-ifield f-12-4)
  2957. (encoding (+ (f-12-2 3) (f-14-1 0) (.sym Dsp- offset -u16) Dst16An))
  2958. (ifield-assertion (andif (eq f-12-2 3) (eq f-14-1 0)))
  2959. (getter (mem16 xmode (add (.sym Dsp- offset -u16) Dst16An)))
  2960. (setter (set (mem16 xmode (add (.sym Dsp- offset -u16) Dst16An)) newval))
  2961. )
  2962. (define-derived-operand
  2963. (name (.sym dst16- offset -20-An-relative- xmode))
  2964. (comment (.str "m16c dsp:20[An] relative destination " xmode))
  2965. (attrs (machine 16))
  2966. (mode xmode)
  2967. (args (Dst16An (.sym Dsp- offset -u20)))
  2968. (syntax (.str "${Dsp-" offset "-u20}[$Dst16An]"))
  2969. (base-ifield f-12-4)
  2970. (encoding (+ (f-12-2 3) (f-14-1 0) (.sym Dsp- offset -u20) Dst16An))
  2971. (ifield-assertion (andif (eq f-12-2 3) (eq f-14-1 0)))
  2972. (getter (mem16 xmode (add (.sym Dsp- offset -u20) Dst16An)))
  2973. (setter (set (mem16 xmode (add (.sym Dsp- offset -u20) Dst16An)) newval))
  2974. )
  2975. )
  2976. )
  2977. (dst16-relative-operand 16 QI)
  2978. (dst16-relative-operand 24 QI)
  2979. (dst16-relative-operand 32 QI)
  2980. (dst16-relative-operand 40 QI)
  2981. (dst16-relative-operand 48 QI)
  2982. (dst16-relative-operand 16 HI)
  2983. (dst16-relative-operand 24 HI)
  2984. (dst16-relative-operand 32 HI)
  2985. (dst16-relative-operand 40 HI)
  2986. (dst16-relative-operand 48 HI)
  2987. (dst16-relative-operand 16 SI)
  2988. (dst16-relative-operand 24 SI)
  2989. (dst16-relative-operand 32 SI)
  2990. (dst16-relative-operand 40 SI)
  2991. (dst16-relative-operand 48 SI)
  2992. (define-pmacro (dst16-relative-Ext-operand offset smode dmode)
  2993. (begin
  2994. (define-derived-operand
  2995. (name (.sym dst16- offset -8-SB-relative-Ext- smode))
  2996. (comment (.str "m16c dsp:8[sb] relative destination " smode))
  2997. (attrs (machine 16))
  2998. (mode dmode)
  2999. (args ((.sym Dsp- offset -u8)))
  3000. (syntax (.str "${Dsp-" offset "-u8}[sb]"))
  3001. (base-ifield f-12-4)
  3002. (encoding (+ (f-12-4 #xA) (.sym Dsp- offset -u8)))
  3003. (ifield-assertion (eq f-12-4 #xA))
  3004. (getter (mem16 smode (add (.sym Dsp- offset -u8) (reg h-sb))))
  3005. (setter (set (mem16 dmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval))
  3006. )
  3007. (define-derived-operand
  3008. (name (.sym dst16- offset -16-SB-relative-Ext- smode))
  3009. (comment (.str "m16c dsp:16[sb] relative destination " smode))
  3010. (attrs (machine 16))
  3011. (mode dmode)
  3012. (args ((.sym Dsp- offset -u16)))
  3013. (syntax (.str "${Dsp-" offset "-u16}[sb]"))
  3014. (base-ifield f-12-4)
  3015. (encoding (+ (f-12-4 #xE) (.sym Dsp- offset -u16)))
  3016. (ifield-assertion (eq f-12-4 #xE))
  3017. (getter (mem16 smode (add (.sym Dsp- offset -u16) (reg h-sb))))
  3018. (setter (set (mem16 dmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval))
  3019. )
  3020. (define-derived-operand
  3021. (name (.sym dst16- offset -8-FB-relative-Ext- smode))
  3022. (comment (.str "m16c dsp:8[fb] relative destination " smode))
  3023. (attrs (machine 16))
  3024. (mode dmode)
  3025. (args ((.sym Dsp- offset -s8)))
  3026. (syntax (.str "${Dsp-" offset "-s8}[fb]"))
  3027. (base-ifield f-12-4)
  3028. (encoding (+ (f-12-4 #xB) (.sym Dsp- offset -s8)))
  3029. (ifield-assertion (eq f-12-4 #xB))
  3030. (getter (mem16 smode (add (.sym Dsp- offset -s8) (reg h-fb))))
  3031. (setter (set (mem16 dmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval))
  3032. )
  3033. (define-derived-operand
  3034. (name (.sym dst16- offset -8-An-relative-Ext- smode))
  3035. (comment (.str "m16c dsp:8[An] relative destination " smode))
  3036. (attrs (machine 16))
  3037. (mode dmode)
  3038. (args (Dst16An (.sym Dsp- offset -u8)))
  3039. (syntax (.str "${Dsp-" offset "-u8}[$Dst16An]"))
  3040. (base-ifield f-12-4)
  3041. (encoding (+ (f-12-2 2) (f-14-1 0) (.sym Dsp- offset -u8) Dst16An))
  3042. (ifield-assertion (andif (eq f-12-2 2) (eq f-14-1 0)))
  3043. (getter (mem16 smode (add (.sym Dsp- offset -u8) Dst16An)))
  3044. (setter (set (mem16 dmode (add (.sym Dsp- offset -u8) Dst16An)) newval))
  3045. )
  3046. (define-derived-operand
  3047. (name (.sym dst16- offset -16-An-relative-Ext- smode))
  3048. (comment (.str "m16c dsp:16[An] relative destination " smode))
  3049. (attrs (machine 16))
  3050. (mode dmode)
  3051. (args (Dst16An (.sym Dsp- offset -u16)))
  3052. (syntax (.str "${Dsp-" offset "-u16}[$Dst16An]"))
  3053. (base-ifield f-12-4)
  3054. (encoding (+ (f-12-2 3) (f-14-1 0) (.sym Dsp- offset -u16) Dst16An))
  3055. (ifield-assertion (andif (eq f-12-2 3) (eq f-14-1 0)))
  3056. (getter (mem16 smode (add (.sym Dsp- offset -u16) Dst16An)))
  3057. (setter (set (mem16 dmode (add (.sym Dsp- offset -u16) Dst16An)) newval))
  3058. )
  3059. )
  3060. )
  3061. (dst16-relative-Ext-operand 16 QI HI)
  3062. (define-pmacro (dst32-relative-operand offset group base1 base2 smode dmode)
  3063. (begin
  3064. (define-derived-operand
  3065. (name (.sym dst32- offset -8-SB-relative- group - smode))
  3066. (comment (.str "m32c dsp:8[sb] relative destination " smode))
  3067. (attrs (machine 32))
  3068. (mode dmode)
  3069. (args ((.sym Dsp- offset -u8)))
  3070. (syntax (.str "${Dsp-" offset "-u8}[sb]"))
  3071. (base-ifield (.sym f- base1 -6))
  3072. (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u8)))
  3073. (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 2)))
  3074. (getter (c-call dmode (.str "operand_getter_" dmode) sb (.sym Dsp- offset -u8)))
  3075. (setter (c-call DFLT (.str "operand_setter_" dmode) newval sb (.sym Dsp- offset -u8)))
  3076. ; (getter (mem32 smode (add (.sym Dsp- offset -u8) (reg h-sb))))
  3077. ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval))
  3078. )
  3079. (define-derived-operand
  3080. (name (.sym dst32- offset -16-SB-relative- group - smode))
  3081. (comment (.str "m32c dsp:16[sb] relative destination " smode))
  3082. (attrs (machine 32))
  3083. (mode dmode)
  3084. (args ((.sym Dsp- offset -u16)))
  3085. (syntax (.str "${Dsp-" offset "-u16}[sb]"))
  3086. (base-ifield (.sym f- base1 -6))
  3087. (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u16)))
  3088. (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 2)))
  3089. (getter (c-call dmode (.str "operand_getter_" dmode) sb (.sym Dsp- offset -u16)))
  3090. (setter (c-call DFLT (.str "operand_setter_" dmode) newval sb (.sym Dsp- offset -u16)))
  3091. ; (getter (mem32 smode (add (.sym Dsp- offset -u16) (reg h-sb))))
  3092. ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval))
  3093. )
  3094. (define-derived-operand
  3095. (name (.sym dst32- offset -8-FB-relative- group - smode))
  3096. (comment (.str "m32c dsp:8[fb] relative destination " smode))
  3097. (attrs (machine 32))
  3098. (mode dmode)
  3099. (args ((.sym Dsp- offset -s8)))
  3100. (syntax (.str "${Dsp-" offset "-s8}[fb]"))
  3101. (base-ifield (.sym f- base1 -6))
  3102. (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s8)))
  3103. (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 3)))
  3104. (getter (c-call dmode (.str "operand_getter_" dmode) fb (.sym Dsp- offset -s8)))
  3105. (setter (c-call DFLT (.str "operand_setter_" dmode) newval fb (.sym Dsp- offset -s8)))
  3106. ; (getter (mem32 smode (add (.sym Dsp- offset -s8) (reg h-fb))))
  3107. ; (setter (set (mem32 dmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval))
  3108. )
  3109. (define-derived-operand
  3110. (name (.sym dst32- offset -16-FB-relative- group - smode))
  3111. (comment (.str "m32c dsp:16[fb] relative destination " smode))
  3112. (attrs (machine 32))
  3113. (mode dmode)
  3114. (args ((.sym Dsp- offset -s16)))
  3115. (syntax (.str "${Dsp-" offset "-s16}[fb]"))
  3116. (base-ifield (.sym f- base1 -6))
  3117. (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s16)))
  3118. (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 3)))
  3119. (getter (c-call dmode (.str "operand_getter_" dmode) fb (.sym Dsp- offset -s16)))
  3120. (setter (c-call DFLT (.str "operand_setter_" dmode) newval fb (.sym Dsp- offset -s16)))
  3121. ; (getter (mem32 smode (add (.sym Dsp- offset -s16) (reg h-fb))))
  3122. ; (setter (set (mem32 dmode (add (.sym Dsp- offset -s16) (reg h-fb))) newval))
  3123. )
  3124. (define-derived-operand
  3125. (name (.sym dst32- offset -8-An-relative- group - smode))
  3126. (comment (.str "m32c dsp:8[An] relative destination " smode))
  3127. (attrs (machine 32))
  3128. (mode dmode)
  3129. (args ((.sym Dst32An group) (.sym Dsp- offset -u8)))
  3130. (syntax (.str "${Dsp-" offset "-u8}[$Dst32An" group "]"))
  3131. (base-ifield (.sym f- base1 -6))
  3132. (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u8) (.sym Dst32An group)))
  3133. (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -1) 0)))
  3134. (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group) (.sym Dsp- offset -u8)))
  3135. (setter (c-call DFLT (.str "operand_setter_" dmode) newval (.sym Dst32An group) (.sym Dsp- offset -u8)))
  3136. ; (getter (mem32 smode (add (.sym Dsp- offset -u8) (.sym Dst32An group))))
  3137. ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u8) (.sym Dst32An group))) newval))
  3138. )
  3139. (define-derived-operand
  3140. (name (.sym dst32- offset -16-An-relative- group - smode))
  3141. (comment (.str "m32c dsp:16[An] relative destination " smode))
  3142. (attrs (machine 32))
  3143. (mode dmode)
  3144. (args ((.sym Dst32An group) (.sym Dsp- offset -u16)))
  3145. (syntax (.str "${Dsp-" offset "-u16}[$Dst32An" group "]"))
  3146. (base-ifield (.sym f- base1 -6))
  3147. (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u16) (.sym Dst32An group)))
  3148. (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -1) 0)))
  3149. (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group) (.sym Dsp- offset -u16)))
  3150. (setter (c-call DFLT (.str "operand_setter_" dmode) newval (.sym Dst32An group) (.sym Dsp- offset -u16)))
  3151. ; (getter (mem32 smode (add (.sym Dsp- offset -u16) (.sym Dst32An group))))
  3152. ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u16) (.sym Dst32An group))) newval))
  3153. )
  3154. (define-derived-operand
  3155. (name (.sym dst32- offset -24-An-relative- group - smode))
  3156. (comment (.str "m32c dsp:16[An] relative destination " smode))
  3157. (attrs (machine 32))
  3158. (mode dmode)
  3159. (args ((.sym Dst32An group) (.sym Dsp- offset -u24)))
  3160. (syntax (.str "${Dsp-" offset "-u24}[$Dst32An" group "]"))
  3161. (base-ifield (.sym f- base1 -6))
  3162. (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u24) (.sym Dst32An group)))
  3163. (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -1) 0)))
  3164. (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group) (.sym Dsp- offset -u24)))
  3165. (setter (c-call DFLT (.str "operand_setter_" dmode) newval (.sym Dst32An group) (.sym Dsp- offset -u24)))
  3166. ; (getter (mem32 smode (add (.sym Dsp- offset -u24) (.sym Dst32An group))))
  3167. ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u24) (.sym Dst32An group))) newval))
  3168. )
  3169. )
  3170. )
  3171. (dst32-relative-operand 16 Unprefixed 4 8 QI QI)
  3172. (dst32-relative-operand 24 Unprefixed 4 8 QI QI)
  3173. (dst32-relative-operand 32 Unprefixed 4 8 QI QI)
  3174. (dst32-relative-operand 40 Unprefixed 4 8 QI QI)
  3175. (dst32-relative-operand 16 Unprefixed 4 8 HI HI)
  3176. (dst32-relative-operand 24 Unprefixed 4 8 HI HI)
  3177. (dst32-relative-operand 32 Unprefixed 4 8 HI HI)
  3178. (dst32-relative-operand 40 Unprefixed 4 8 HI HI)
  3179. (dst32-relative-operand 16 Unprefixed 4 8 SI SI)
  3180. (dst32-relative-operand 24 Unprefixed 4 8 SI SI)
  3181. (dst32-relative-operand 32 Unprefixed 4 8 SI SI)
  3182. (dst32-relative-operand 40 Unprefixed 4 8 SI SI)
  3183. (dst32-relative-operand 24 Prefixed 12 16 QI QI)
  3184. (dst32-relative-operand 32 Prefixed 12 16 QI QI)
  3185. (dst32-relative-operand 40 Prefixed 12 16 QI QI)
  3186. (dst32-relative-operand 48 Prefixed 12 16 QI QI)
  3187. (dst32-relative-operand 24 Prefixed 12 16 HI HI)
  3188. (dst32-relative-operand 32 Prefixed 12 16 HI HI)
  3189. (dst32-relative-operand 40 Prefixed 12 16 HI HI)
  3190. (dst32-relative-operand 48 Prefixed 12 16 HI HI)
  3191. (dst32-relative-operand 24 Prefixed 12 16 SI SI)
  3192. (dst32-relative-operand 32 Prefixed 12 16 SI SI)
  3193. (dst32-relative-operand 40 Prefixed 12 16 SI SI)
  3194. (dst32-relative-operand 48 Prefixed 12 16 SI SI)
  3195. (dst32-relative-operand 16 ExtUnprefixed 4 8 QI HI)
  3196. (dst32-relative-operand 16 ExtUnprefixed 4 8 HI SI)
  3197. ;-------------------------------------------------------------
  3198. ; Absolute address
  3199. ;-------------------------------------------------------------
  3200. (define-pmacro (dst16-absolute offset xmode)
  3201. (begin
  3202. (define-derived-operand
  3203. (name (.sym dst16- offset -16-absolute- xmode))
  3204. (comment (.str "m16c absolute address " xmode))
  3205. (attrs (machine 16))
  3206. (mode xmode)
  3207. (args ((.sym Dsp- offset -u16)))
  3208. (syntax (.str "${Dsp-" offset "-u16}"))
  3209. (base-ifield f-12-4)
  3210. (encoding (+ (f-12-4 #xF) (.sym Dsp- offset -u16)))
  3211. (ifield-assertion (eq f-12-4 #xF))
  3212. (getter (mem16 xmode (.sym Dsp- offset -u16)))
  3213. (setter (set (mem16 xmode (.sym Dsp- offset -u16)) newval))
  3214. )
  3215. )
  3216. )
  3217. (dst16-absolute 16 QI)
  3218. (dst16-absolute 24 QI)
  3219. (dst16-absolute 32 QI)
  3220. (dst16-absolute 40 QI)
  3221. (dst16-absolute 48 QI)
  3222. (dst16-absolute 16 HI)
  3223. (dst16-absolute 24 HI)
  3224. (dst16-absolute 32 HI)
  3225. (dst16-absolute 40 HI)
  3226. (dst16-absolute 48 HI)
  3227. (dst16-absolute 16 SI)
  3228. (dst16-absolute 24 SI)
  3229. (dst16-absolute 32 SI)
  3230. (dst16-absolute 40 SI)
  3231. (dst16-absolute 48 SI)
  3232. (define-derived-operand
  3233. (name dst16-16-16-absolute-Ext-QI)
  3234. (comment "m16c absolute address QI")
  3235. (attrs (machine 16))
  3236. (mode HI)
  3237. (args (Dsp-16-u16))
  3238. (syntax "${Dsp-16-u16}")
  3239. (base-ifield f-12-4)
  3240. (encoding (+ (f-12-4 #xF) Dsp-16-u16))
  3241. (ifield-assertion (eq f-12-4 #xF))
  3242. (getter (mem16 QI Dsp-16-u16))
  3243. (setter (set (mem16 HI Dsp-16-u16) newval))
  3244. )
  3245. (define-pmacro (dst32-absolute offset group base1 base2 smode dmode)
  3246. (begin
  3247. (define-derived-operand
  3248. (name (.sym dst32- offset -16-absolute- group - smode))
  3249. (comment (.str "m32c absolute address " smode))
  3250. (attrs (machine 32))
  3251. (mode dmode)
  3252. (args ((.sym Dsp- offset -u16)))
  3253. (syntax (.str "${Dsp-" offset "-u16}"))
  3254. (base-ifield (.sym f- base1 -6))
  3255. (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym Dsp- offset -u16)))
  3256. (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3)))
  3257. (getter (c-call smode (.str "operand_getter_" smode) (const 0) (.sym Dsp- offset -u16)))
  3258. (setter (c-call DFLT (.str "operand_setter_" dmode) newval (const 0) (.sym Dsp- offset -u16)))
  3259. ; (getter (mem32 smode (.sym Dsp- offset -u16)))
  3260. ; (setter (set (mem32 dmode (.sym Dsp- offset -u16)) newval))
  3261. )
  3262. (define-derived-operand
  3263. (name (.sym dst32- offset -24-absolute- group - smode))
  3264. (comment (.str "m32c absolute address " smode))
  3265. (attrs (machine 32))
  3266. (mode dmode)
  3267. (args ((.sym Dsp- offset -u24)))
  3268. (syntax (.str "${Dsp-" offset "-u24}"))
  3269. (base-ifield (.sym f- base1 -6))
  3270. (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u24)))
  3271. (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2)))
  3272. (getter (c-call smode (.str "operand_getter_" smode) (const 0) (.sym Dsp- offset -u24)))
  3273. (setter (c-call DFLT (.str "operand_setter_" dmode) newval (const 0) (.sym Dsp- offset -u24)))
  3274. ; (getter (mem32 smode (.sym Dsp- offset -u24)))
  3275. ; (setter (set (mem32 dmode (.sym Dsp- offset -u24)) newval))
  3276. )
  3277. )
  3278. )
  3279. (dst32-absolute 16 Unprefixed 4 8 QI QI)
  3280. (dst32-absolute 24 Unprefixed 4 8 QI QI)
  3281. (dst32-absolute 32 Unprefixed 4 8 QI QI)
  3282. (dst32-absolute 40 Unprefixed 4 8 QI QI)
  3283. (dst32-absolute 16 Unprefixed 4 8 HI HI)
  3284. (dst32-absolute 24 Unprefixed 4 8 HI HI)
  3285. (dst32-absolute 32 Unprefixed 4 8 HI HI)
  3286. (dst32-absolute 40 Unprefixed 4 8 HI HI)
  3287. (dst32-absolute 16 Unprefixed 4 8 SI SI)
  3288. (dst32-absolute 24 Unprefixed 4 8 SI SI)
  3289. (dst32-absolute 32 Unprefixed 4 8 SI SI)
  3290. (dst32-absolute 40 Unprefixed 4 8 SI SI)
  3291. (dst32-absolute 24 Prefixed 12 16 QI QI)
  3292. (dst32-absolute 32 Prefixed 12 16 QI QI)
  3293. (dst32-absolute 40 Prefixed 12 16 QI QI)
  3294. (dst32-absolute 48 Prefixed 12 16 QI QI)
  3295. (dst32-absolute 24 Prefixed 12 16 HI HI)
  3296. (dst32-absolute 32 Prefixed 12 16 HI HI)
  3297. (dst32-absolute 40 Prefixed 12 16 HI HI)
  3298. (dst32-absolute 48 Prefixed 12 16 HI HI)
  3299. (dst32-absolute 24 Prefixed 12 16 SI SI)
  3300. (dst32-absolute 32 Prefixed 12 16 SI SI)
  3301. (dst32-absolute 40 Prefixed 12 16 SI SI)
  3302. (dst32-absolute 48 Prefixed 12 16 SI SI)
  3303. (dst32-absolute 16 ExtUnprefixed 4 8 QI HI)
  3304. (dst32-absolute 16 ExtUnprefixed 4 8 HI SI)
  3305. ;-------------------------------------------------------------
  3306. ; An indirect indirect
  3307. ;-------------------------------------------------------------
  3308. ;(define-pmacro (dst-An-indirect-indirect-operand xmode)
  3309. ; (define-derived-operand
  3310. ; (name (.sym dst32-An-indirect-indirect- xmode))
  3311. ; (comment (.str "m32c An indirect indirect destination " xmode))
  3312. ; (attrs (machine 32))
  3313. ; (mode xmode)
  3314. ; (args (Dst32AnPrefixed))
  3315. ; (syntax (.str "[[$Dst32AnPrefixed]]"))
  3316. ; (base-ifield f-12-6)
  3317. ; (encoding (+ (f-12-3 0) (f-16-1 0) Dst32AnPrefixed))
  3318. ; (ifield-assertion (andif (eq f-12-3 0) (eq f-16-1 0)))
  3319. ; (getter (mem32 xmode (indirect-addr Dst32AnPrefixed)))
  3320. ; (setter (set (mem32 xmode (indirect-addr Dst32AnPrefixed)) newval))
  3321. ; )
  3322. ;)
  3323. ; (dst-An-indirect-indirect-operand QI)
  3324. ; (dst-An-indirect-indirect-operand HI)
  3325. ; (dst-An-indirect-indirect-operand SI)
  3326. ;-------------------------------------------------------------
  3327. ; Relative indirect
  3328. ;-------------------------------------------------------------
  3329. (define-pmacro (dst-relative-indirect-operand offset xmode)
  3330. (begin
  3331. ; (define-derived-operand
  3332. ; (name (.sym dst32- offset -8-SB-relative-indirect- xmode))
  3333. ; (comment (.str "m32c dsp:8[sb] relative destination " xmode))
  3334. ; (attrs (machine 32))
  3335. ; (mode xmode)
  3336. ; (args ((.sym Dsp- offset -u8)))
  3337. ; (syntax (.str "[${Dsp-" offset "-u8}[sb]]"))
  3338. ; (base-ifield f-12-6)
  3339. ; (encoding (+ (f-12-3 1) (f-16-2 2) (.sym Dsp- offset -u8)))
  3340. ; (ifield-assertion (andif (eq f-12-3 1) (eq f-16-2 2)))
  3341. ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) (reg h-sb)))))
  3342. ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) (reg h-sb)))) newval))
  3343. ; )
  3344. ; (define-derived-operand
  3345. ; (name (.sym dst32- offset -16-SB-relative-indirect- xmode))
  3346. ; (comment (.str "m32c dsp:16[sb] relative destination " xmode))
  3347. ; (attrs (machine 32))
  3348. ; (mode xmode)
  3349. ; (args ((.sym Dsp- offset -u16)))
  3350. ; (syntax (.str "[${Dsp-" offset "-u16}[sb]]"))
  3351. ; (base-ifield f-12-6)
  3352. ; (encoding (+ (f-12-3 2) (f-16-2 2) (.sym Dsp- offset -u16)))
  3353. ; (ifield-assertion (andif (eq f-12-3 2) (eq f-16-2 2)))
  3354. ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) (reg h-sb)))))
  3355. ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) (reg h-sb)))) newval))
  3356. ; )
  3357. ; (define-derived-operand
  3358. ; (name (.sym dst32- offset -8-FB-relative-indirect- xmode))
  3359. ; (comment (.str "m32c dsp:8[fb] relative destination " xmode))
  3360. ; (attrs (machine 32))
  3361. ; (mode xmode)
  3362. ; (args ((.sym Dsp- offset -s8)))
  3363. ; (syntax (.str "[${Dsp-" offset "-s8}[fb]]"))
  3364. ; (base-ifield f-12-6)
  3365. ; (encoding (+ (f-12-3 1) (f-16-2 3) (.sym Dsp- offset -s8)))
  3366. ; (ifield-assertion (andif (eq f-12-3 1) (eq f-16-2 3)))
  3367. ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s8) (reg h-fb)))))
  3368. ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s8) (reg h-fb)))) newval))
  3369. ; )
  3370. ; (define-derived-operand
  3371. ; (name (.sym dst32- offset -16-FB-relative-indirect- xmode))
  3372. ; (comment (.str "m32c dsp:16[fb] relative destination " xmode))
  3373. ; (attrs (machine 32))
  3374. ; (mode xmode)
  3375. ; (args ((.sym Dsp- offset -s16)))
  3376. ; (syntax (.str "[${Dsp-" offset "-s16}[fb]]"))
  3377. ; (base-ifield f-12-6)
  3378. ; (encoding (+ (f-12-3 2) (f-16-2 3) (.sym Dsp- offset -s16)))
  3379. ; (ifield-assertion (andif (eq f-12-3 2) (eq f-16-2 3)))
  3380. ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s16) (reg h-fb)))))
  3381. ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s16) (reg h-fb)))) newval))
  3382. ; )
  3383. ; (define-derived-operand
  3384. ; (name (.sym dst32- offset -8-An-relative-indirect- xmode))
  3385. ; (comment (.str "m32c dsp:8[An] relative indirect destination " xmode))
  3386. ; (attrs (machine 32))
  3387. ; (mode xmode)
  3388. ; (args (Dst32AnPrefixed (.sym Dsp- offset -u8)))
  3389. ; (syntax (.str "[${Dsp-" offset "-u8}[$Dst32AnPrefixed]]"))
  3390. ; (base-ifield f-12-6)
  3391. ; (encoding (+ (f-12-3 1) (f-16-1 0) (.sym Dsp- offset -u8) Dst32AnPrefixed))
  3392. ; (ifield-assertion (andif (eq f-12-3 1) (eq f-16-1 0)))
  3393. ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) Dst32AnPrefixed))))
  3394. ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) Dst32AnPrefixed))) newval))
  3395. ; )
  3396. ; (define-derived-operand
  3397. ; (name (.sym dst32- offset -16-An-relative-indirect- xmode))
  3398. ; (comment (.str "m32c dsp:16[An] relative destination " xmode))
  3399. ; (attrs (machine 32))
  3400. ; (mode xmode)
  3401. ; (args (Dst32AnPrefixed (.sym Dsp- offset -u16)))
  3402. ; (syntax (.str "[${Dsp-" offset "-u16}[$Dst32AnPrefixed]]"))
  3403. ; (base-ifield f-12-6)
  3404. ; (encoding (+ (f-12-3 2) (f-16-1 0) (.sym Dsp- offset -u16) Dst32AnPrefixed))
  3405. ; (ifield-assertion (andif (eq f-12-3 2) (eq f-16-1 0)))
  3406. ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) Dst32AnPrefixed))))
  3407. ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) Dst32AnPrefixed))) newval))
  3408. ; )
  3409. ; (define-derived-operand
  3410. ; (name (.sym dst32- offset -24-An-relative-indirect- xmode))
  3411. ; (comment (.str "m32c dsp:24[An] relative destination " xmode))
  3412. ; (attrs (machine 32))
  3413. ; (mode xmode)
  3414. ; (args (Dst32AnPrefixed (.sym Dsp- offset -u24)))
  3415. ; (syntax (.str "[${Dsp-" offset "-u24}[$Dst32AnPrefixed]]"))
  3416. ; (base-ifield f-12-6)
  3417. ; (encoding (+ (f-12-3 3) (f-16-1 0) (.sym Dsp- offset -u24) Dst32AnPrefixed))
  3418. ; (ifield-assertion (andif (eq f-12-3 3) (eq f-16-1 0)))
  3419. ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u24) Dst32AnPrefixed))))
  3420. ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u24) Dst32AnPrefixed))) newval))
  3421. ; )
  3422. )
  3423. )
  3424. ; (dst-relative-indirect-operand 24 QI)
  3425. ; (dst-relative-indirect-operand 32 QI)
  3426. ; (dst-relative-indirect-operand 40 QI)
  3427. ; (dst-relative-indirect-operand 48 QI)
  3428. ; (dst-relative-indirect-operand 24 HI)
  3429. ; (dst-relative-indirect-operand 32 HI)
  3430. ; (dst-relative-indirect-operand 40 HI)
  3431. ; (dst-relative-indirect-operand 48 HI)
  3432. ; (dst-relative-indirect-operand 24 SI)
  3433. ; (dst-relative-indirect-operand 32 SI)
  3434. ; (dst-relative-indirect-operand 40 SI)
  3435. ; (dst-relative-indirect-operand 48 SI)
  3436. ;-------------------------------------------------------------
  3437. ; Absolute indirect
  3438. ;-------------------------------------------------------------
  3439. (define-pmacro (dst-absolute-indirect offset xmode)
  3440. (begin
  3441. ; (define-derived-operand
  3442. ; (name (.sym dst32- offset -16-absolute-indirect-derived- xmode))
  3443. ; (comment (.str "m32c absolute indirect address " xmode))
  3444. ; (attrs (machine 32))
  3445. ; (mode xmode)
  3446. ; (args ((.sym Dsp- offset -u16)))
  3447. ; (syntax (.str "[${Dsp-" offset "-u16}]"))
  3448. ; (base-ifield f-12-6)
  3449. ; (encoding (+ (f-12-3 3) (f-16-2 3) (.sym Dsp- offset -u16)))
  3450. ; (ifield-assertion (andif (eq f-12-3 3) (eq f-16-2 3)))
  3451. ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u16))))
  3452. ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u16))) newval))
  3453. ; )
  3454. ; (define-derived-operand
  3455. ; (name (.sym dst32- offset -24-absolute-indirect-derived- xmode))
  3456. ; (comment (.str "m32c absolute indirect address " xmode))
  3457. ; (attrs (machine 32))
  3458. ; (mode xmode)
  3459. ; (args ((.sym Dsp- offset -u24)))
  3460. ; (syntax (.str "[${Dsp-" offset "-u24}]"))
  3461. ; (base-ifield f-12-6)
  3462. ; (encoding (+ (f-12-3 3) (f-16-2 2) (.sym Dsp- offset -u24)))
  3463. ; (ifield-assertion (andif (eq f-12-3 3) (eq f-16-2 2)))
  3464. ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u24))))
  3465. ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u24))) newval))
  3466. ; )
  3467. )
  3468. )
  3469. (dst-absolute-indirect 24 QI)
  3470. (dst-absolute-indirect 32 QI)
  3471. (dst-absolute-indirect 40 QI)
  3472. (dst-absolute-indirect 48 QI)
  3473. (dst-absolute-indirect 24 HI)
  3474. (dst-absolute-indirect 32 HI)
  3475. (dst-absolute-indirect 40 HI)
  3476. (dst-absolute-indirect 48 HI)
  3477. (dst-absolute-indirect 24 SI)
  3478. (dst-absolute-indirect 32 SI)
  3479. (dst-absolute-indirect 40 SI)
  3480. (dst-absolute-indirect 48 SI)
  3481. ;-------------------------------------------------------------
  3482. ; Bit operands
  3483. ;-------------------------------------------------------------
  3484. (define-pmacro (get-register-bit reg bitno)
  3485. (and (srl reg bitno) 1)
  3486. )
  3487. (define-pmacro (set-register-bit reg bitno value)
  3488. (set reg (or (and reg (inv (sll 1 bitno)))
  3489. (sll (and QI value 1) bitno)))
  3490. )
  3491. (define-pmacro (get-memory-bit mach base bitno)
  3492. (and (srl (mem-mach mach QI (add base (div bitno 8)))
  3493. (mod bitno 8))
  3494. 1)
  3495. )
  3496. (define-pmacro (set-memory-bit mach base bitno value)
  3497. (sequence ((USI addr))
  3498. (set addr (add base (div bitno 8)))
  3499. (set (mem-mach mach QI addr)
  3500. (or (and (mem-mach mach QI addr)
  3501. (inv (sll 1 (mod bitno 8))))
  3502. (sll (and QI value 1) (mod bitno 8)))))
  3503. )
  3504. ;-------------------------------------------------------------
  3505. ; Rn direct
  3506. ;-------------------------------------------------------------
  3507. (define-derived-operand
  3508. (name bit16-Rn-direct)
  3509. (comment "m16c Rn direct bit")
  3510. (attrs (machine 16))
  3511. (mode BI)
  3512. (args (Bitno16R Bit16Rn))
  3513. (syntax "$Bitno16R,$Bit16Rn")
  3514. (base-ifield f-12-4)
  3515. (encoding (+ (f-12-2 0) Bit16Rn Bitno16R))
  3516. (ifield-assertion (eq f-12-2 0))
  3517. (getter (get-register-bit Bit16Rn Bitno16R))
  3518. (setter (set-register-bit Bit16Rn Bitno16R newval))
  3519. )
  3520. (define-pmacro (bit32-Rn-direct-operand group base)
  3521. (begin
  3522. (define-derived-operand
  3523. (name (.sym bit32-Rn-direct- group))
  3524. (comment "m32c Rn direct bit")
  3525. (attrs (machine 32))
  3526. (mode BI)
  3527. (args ((.sym Bitno32 group) (.sym Bit32Rn group)))
  3528. (syntax (.str "$Bitno32" group ",$Bit32Rn" group))
  3529. (base-ifield (.sym f- base -6))
  3530. (encoding (+ ((.sym f- base -3) 4) (.sym Bit32Rn group) (.sym Bitno32 group)))
  3531. (ifield-assertion (eq (.sym f- base -3) 4))
  3532. (getter (get-register-bit (.sym Bit32Rn group) (.sym Bitno32 group)))
  3533. (setter (set-register-bit (.sym Bit32Rn group) (.sym Bitno32 group) newval))
  3534. )
  3535. )
  3536. )
  3537. (bit32-Rn-direct-operand Unprefixed 4)
  3538. (bit32-Rn-direct-operand Prefixed 12)
  3539. ;-------------------------------------------------------------
  3540. ; An direct
  3541. ;-------------------------------------------------------------
  3542. (define-derived-operand
  3543. (name bit16-An-direct)
  3544. (comment "m16c An direct bit")
  3545. (attrs (machine 16))
  3546. (mode BI)
  3547. (args (Bitno16R Bit16An))
  3548. (syntax "$Bitno16R,$Bit16An")
  3549. (base-ifield f-12-4)
  3550. (encoding (+ (f-12-2 1) (f-14-1 0) Bit16An Bitno16R))
  3551. (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 0)))
  3552. (getter (get-register-bit Bit16An Bitno16R))
  3553. (setter (set-register-bit Bit16An Bitno16R newval))
  3554. )
  3555. (define-pmacro (bit32-An-direct-operand group base1 base2)
  3556. (begin
  3557. (define-derived-operand
  3558. (name (.sym bit32-An-direct- group))
  3559. (comment "m32c An direct bit")
  3560. (attrs (machine 32))
  3561. (mode BI)
  3562. (args ((.sym Bitno32 group) (.sym Bit32An group)))
  3563. (syntax (.str "$Bitno32" group ",$Bit32An" group))
  3564. (base-ifield (.sym f- base1 -6))
  3565. (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 1) (.sym Bit32An group) (.sym Bitno32 group)))
  3566. (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 1)))
  3567. (getter (get-register-bit (.sym Bit32An group) (.sym Bitno32 group)))
  3568. (setter (set-register-bit (.sym Bit32An group) (.sym Bitno32 group) newval))
  3569. )
  3570. )
  3571. )
  3572. (bit32-An-direct-operand Unprefixed 4 8)
  3573. (bit32-An-direct-operand Prefixed 12 16)
  3574. ;-------------------------------------------------------------
  3575. ; An indirect
  3576. ;-------------------------------------------------------------
  3577. (define-derived-operand
  3578. (name bit16-An-indirect)
  3579. (comment "m16c An indirect bit")
  3580. (attrs (machine 16))
  3581. (mode BI)
  3582. (args (Bit16An))
  3583. (syntax "[$Bit16An]")
  3584. (base-ifield f-12-4)
  3585. (encoding (+ (f-12-2 1) (f-14-1 1) Bit16An))
  3586. (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 1)))
  3587. (getter (get-memory-bit 16 0 Bit16An))
  3588. (setter (set-memory-bit 16 0 Bit16An newval))
  3589. )
  3590. (define-pmacro (bit32-An-indirect-operand group base1 base2)
  3591. (begin
  3592. (define-derived-operand
  3593. (name (.sym bit32-An-indirect- group))
  3594. (comment "m32c An indirect destination ")
  3595. (attrs (machine 32))
  3596. (mode BI)
  3597. (args ((.sym Bitno32 group) (.sym Bit32An group)))
  3598. (syntax (.str "$Bitno32" group ",[$Bit32An" group "]"))
  3599. (base-ifield (.sym f- base1 -6))
  3600. (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 0) (.sym Bit32An group) (.sym Bitno32 group)))
  3601. (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 0)))
  3602. (getter (get-memory-bit 32 (.sym Bit32An group) (.sym Bitno32 group)))
  3603. (setter (set-memory-bit 32 (.sym Bit32An group) (.sym Bitno32 group) newval))
  3604. )
  3605. )
  3606. )
  3607. (bit32-An-indirect-operand Unprefixed 4 8)
  3608. (bit32-An-indirect-operand Prefixed 12 16)
  3609. ;-------------------------------------------------------------
  3610. ; dsp:d[r] relative
  3611. ;-------------------------------------------------------------
  3612. (define-pmacro (bit16-relative-operand offset)
  3613. (begin
  3614. (define-derived-operand
  3615. (name (.sym bit16- offset -8-SB-relative))
  3616. (comment (.str "m16c dsp:8[sb] relative bit " xmode))
  3617. (attrs (machine 16))
  3618. (mode BI)
  3619. (args ((.sym BitBase16- offset -u8)))
  3620. (syntax (.str "${BitBase16-" offset "-u8}[sb]"))
  3621. (base-ifield f-12-4)
  3622. (encoding (+ (f-12-4 #xA) (.sym BitBase16- offset -u8)))
  3623. (ifield-assertion (eq f-12-4 #xA))
  3624. (getter (get-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u8)))
  3625. (setter (set-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u8) newval))
  3626. )
  3627. (define-derived-operand
  3628. (name (.sym bit16- offset -16-SB-relative))
  3629. (comment (.str "m16c dsp:16[sb] relative bit " xmode))
  3630. (attrs (machine 16))
  3631. (mode BI)
  3632. (args ((.sym BitBase16- offset -u16)))
  3633. (syntax (.str "${BitBase16-" offset "-u16}[sb]"))
  3634. (base-ifield f-12-4)
  3635. (encoding (+ (f-12-4 #xE) (.sym BitBase16- offset -u16)))
  3636. (ifield-assertion (eq f-12-4 #xE))
  3637. (getter (get-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u16)))
  3638. (setter (set-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u16) newval))
  3639. )
  3640. (define-derived-operand
  3641. (name (.sym bit16- offset -8-FB-relative))
  3642. (comment (.str "m16c dsp:8[fb] relative bit " xmode))
  3643. (attrs (machine 16))
  3644. (mode BI)
  3645. (args ((.sym BitBase16- offset -s8)))
  3646. (syntax (.str "${BitBase16-" offset "-s8}[fb]"))
  3647. (base-ifield f-12-4)
  3648. (encoding (+ (f-12-4 #xB) (.sym BitBase16- offset -s8)))
  3649. (ifield-assertion (eq f-12-4 #xB))
  3650. (getter (get-memory-bit 16 (reg h-fb) (.sym BitBase16- offset -s8)))
  3651. (setter (set-memory-bit 16 (reg h-fb) (.sym BitBase16- offset -s8) newval))
  3652. )
  3653. (define-derived-operand
  3654. (name (.sym bit16- offset -8-An-relative))
  3655. (comment (.str "m16c dsp:8[An] relative bit " xmode))
  3656. (attrs (machine 16))
  3657. (mode BI)
  3658. (args (Bit16An (.sym Dsp- offset -u8)))
  3659. (syntax (.str "${Dsp-" offset "-u8}[$Bit16An]"))
  3660. (base-ifield f-12-4)
  3661. (encoding (+ (f-12-2 2) (f-14-1 0) (.sym Dsp- offset -u8) Bit16An))
  3662. (ifield-assertion (andif (eq f-12-2 2) (eq f-14-1 0)))
  3663. (getter (get-memory-bit 16 (.sym Dsp- offset -u8) Bit16An))
  3664. (setter (set-memory-bit 16 (.sym Dsp- offset -u8) Bit16An newval))
  3665. )
  3666. (define-derived-operand
  3667. (name (.sym bit16- offset -16-An-relative))
  3668. (comment (.str "m16c dsp:16[An] relative bit " xmode))
  3669. (attrs (machine 16))
  3670. (mode BI)
  3671. (args (Bit16An (.sym Dsp- offset -u16)))
  3672. (syntax (.str "${Dsp-" offset "-u16}[$Bit16An]"))
  3673. (base-ifield f-12-4)
  3674. (encoding (+ (f-12-2 3) (f-14-1 0) (.sym Dsp- offset -u16) Bit16An))
  3675. (ifield-assertion (andif (eq f-12-2 3) (eq f-14-1 0)))
  3676. (getter (get-memory-bit 16 (.sym Dsp- offset -u16) Bit16An))
  3677. (setter (set-memory-bit 16 (.sym Dsp- offset -u16) Bit16An newval))
  3678. )
  3679. )
  3680. )
  3681. (bit16-relative-operand 16)
  3682. (define-pmacro (bit32-relative-operand offset group base1 base2)
  3683. (begin
  3684. (define-derived-operand
  3685. (name (.sym bit32- offset -11-SB-relative- group))
  3686. (comment "m32c bit,base:11[sb] relative bit")
  3687. (attrs (machine 32))
  3688. (mode BI)
  3689. (args ((.sym BitBase32- offset -u11- group)))
  3690. (syntax (.str "${BitBase32-" offset "-u11-" group "}[sb]"))
  3691. (base-ifield (.sym f- base1 -12))
  3692. (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 2) (.sym BitBase32- offset -u11- group)))
  3693. (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 2)))
  3694. (getter (get-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u11- group)))
  3695. (setter (set-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u11- group) newval))
  3696. )
  3697. (define-derived-operand
  3698. (name (.sym bit32- offset -19-SB-relative- group))
  3699. (comment "m32c bit,base:19[sb] relative bit")
  3700. (attrs (machine 32))
  3701. (mode BI)
  3702. (args ((.sym BitBase32- offset -u19- group)))
  3703. (syntax (.str "${BitBase32-" offset "-u19-" group "}[sb]"))
  3704. (base-ifield (.sym f- base1 -12))
  3705. (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 2) (.sym BitBase32- offset -u19- group)))
  3706. (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 2)))
  3707. (getter (get-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u19- group)))
  3708. (setter (set-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u19- group) newval))
  3709. )
  3710. (define-derived-operand
  3711. (name (.sym bit32- offset -11-FB-relative- group))
  3712. (comment "m32c bit,base:11[fb] relative bit")
  3713. (attrs (machine 32))
  3714. (mode BI)
  3715. (args ((.sym BitBase32- offset -s11- group)))
  3716. (syntax (.str "${BitBase32-" offset "-s11-" group "}[fb]"))
  3717. (base-ifield (.sym f- base1 -12))
  3718. (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 3) (.sym BitBase32- offset -s11- group)))
  3719. (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 3)))
  3720. (getter (get-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s11- group)))
  3721. (setter (set-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s11- group) newval))
  3722. )
  3723. (define-derived-operand
  3724. (name (.sym bit32- offset -19-FB-relative- group))
  3725. (comment "m32c bit,base:19[fb] relative bit")
  3726. (attrs (machine 32))
  3727. (mode BI)
  3728. (args ((.sym BitBase32- offset -s19- group)))
  3729. (syntax (.str "${BitBase32-" offset "-s19-" group "}[fb]"))
  3730. (base-ifield (.sym f- base1 -12))
  3731. (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 3) (.sym BitBase32- offset -s19- group)))
  3732. (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 3)))
  3733. (getter (get-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s19- group)))
  3734. (setter (set-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s19- group) newval))
  3735. )
  3736. (define-derived-operand
  3737. (name (.sym bit32- offset -11-An-relative- group))
  3738. (comment "m32c bit,base:11[An] relative bit")
  3739. (attrs (machine 32))
  3740. (mode BI)
  3741. (args ((.sym BitBase32- offset -u11- group) (.sym Bit32An group)))
  3742. (syntax (.str "${BitBase32-" offset "-u11-" group "}[$Bit32An" group "]"))
  3743. (base-ifield (.sym f- base1 -12))
  3744. (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -1) 0) (.sym BitBase32- offset -u11- group) (.sym Bit32An group)))
  3745. (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -1) 0)))
  3746. (getter (get-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u11- group)))
  3747. (setter (set-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u11- group) newval))
  3748. )
  3749. (define-derived-operand
  3750. (name (.sym bit32- offset -19-An-relative- group))
  3751. (comment "m32c bit,base:19[An] relative bit")
  3752. (attrs (machine 32))
  3753. (mode BI)
  3754. (args ((.sym BitBase32- offset -u19- group) (.sym Bit32An group)))
  3755. (syntax (.str "${BitBase32-" offset "-u19-" group "}[$Bit32An" group "]"))
  3756. (base-ifield (.sym f- base1 -12))
  3757. (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -1) 0) (.sym BitBase32- offset -u19- group) (.sym Bit32An group)))
  3758. (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -1) 0)))
  3759. (getter (get-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u19- group)))
  3760. (setter (set-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u19- group) newval))
  3761. )
  3762. (define-derived-operand
  3763. (name (.sym bit32- offset -27-An-relative- group))
  3764. (comment "m32c bit,base:27[An] relative bit")
  3765. (attrs (machine 32))
  3766. (mode BI)
  3767. (args ((.sym BitBase32- offset -u27- group) (.sym Bit32An group)))
  3768. (syntax (.str "${BitBase32-" offset "-u27-" group "}[$Bit32An" group "]"))
  3769. (base-ifield (.sym f- base1 -12))
  3770. (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -1) 0) (.sym BitBase32- offset -u27- group) (.sym Bit32An group)))
  3771. (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -1) 0)))
  3772. (getter (get-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u27- group)))
  3773. (setter (set-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u27- group) newval))
  3774. )
  3775. )
  3776. )
  3777. (bit32-relative-operand 16 Unprefixed 4 8)
  3778. (bit32-relative-operand 24 Prefixed 12 16)
  3779. (define-derived-operand
  3780. (name bit16-11-SB-relative-S)
  3781. (comment "m16c bit,base:11[sb] relative bit")
  3782. (attrs (machine 16))
  3783. (mode BI)
  3784. (args (BitBase16-8-u11-S))
  3785. (syntax "${BitBase16-8-u11-S}[sb]")
  3786. (base-ifield (.sym f-5-3))
  3787. (encoding (+ BitBase16-8-u11-S))
  3788. ; (ifield-assertion (#t))
  3789. (getter (get-memory-bit 16 (reg h-sb) BitBase16-8-u11-S))
  3790. (setter (set-memory-bit 16 (reg h-sb) BitBase16-8-u11-S newval))
  3791. )
  3792. (define-derived-operand
  3793. (name Rn16-push-S-derived)
  3794. (comment "m16c r0[lh] for push,pop short version")
  3795. (attrs (machine 16))
  3796. (mode QI)
  3797. (args (Rn16-push-S))
  3798. (syntax "${Rn16-push-S}")
  3799. (base-ifield (.sym f-4-1))
  3800. (encoding (+ Rn16-push-S))
  3801. ; (ifield-assertion (#t))
  3802. (getter (trunc QI Rn16-push-S))
  3803. (setter (set Rn16-push-S newval))
  3804. )
  3805. (define-derived-operand
  3806. (name An16-push-S-derived)
  3807. (comment "m16c r0[lh] for push,pop short version")
  3808. (attrs (machine 16))
  3809. (mode HI)
  3810. (args (An16-push-S))
  3811. (syntax "${An16-push-S}")
  3812. (base-ifield (.sym f-4-1))
  3813. (encoding (+ An16-push-S))
  3814. ; (ifield-assertion (#t))
  3815. (getter (trunc QI An16-push-S))
  3816. (setter (set An16-push-S newval))
  3817. )
  3818. ;-------------------------------------------------------------
  3819. ; Absolute address
  3820. ;-------------------------------------------------------------
  3821. (define-pmacro (bit16-absolute offset)
  3822. (begin
  3823. (define-derived-operand
  3824. (name (.sym bit16- offset -16-absolute))
  3825. (comment "m16c absolute address")
  3826. (attrs (machine 16))
  3827. (mode BI)
  3828. (args ((.sym BitBase16- offset -u16)))
  3829. (syntax (.str "${BitBase16-" offset "-u16}"))
  3830. (base-ifield f-12-4)
  3831. (encoding (+ (f-12-4 #xF) (.sym BitBase16- offset -u16)))
  3832. (ifield-assertion (eq f-12-4 #xF))
  3833. (getter (get-memory-bit 16 0 (.sym BitBase16- offset -u16)))
  3834. (setter (set-memory-bit 16 0 (.sym BitBase16- offset -u16) newval))
  3835. )
  3836. )
  3837. )
  3838. (bit16-absolute 16)
  3839. (define-pmacro (bit32-absolute offset group base1 base2)
  3840. (begin
  3841. (define-derived-operand
  3842. (name (.sym bit32- offset -19-absolute- group))
  3843. (comment "m32c absolute address bit")
  3844. (attrs (machine 32))
  3845. (mode BI)
  3846. (args ((.sym BitBase32- offset -u19- group)))
  3847. (syntax (.str "${BitBase32-" offset "-u19-" group "}"))
  3848. (base-ifield (.sym f- base1 -12))
  3849. (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym BitBase32- offset -u19- group)))
  3850. (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3)))
  3851. (getter (get-memory-bit 32 0 (.sym BitBase32- offset -u19- group)))
  3852. (setter (set-memory-bit 32 0 (.sym BitBase32- offset -u19- group) newval))
  3853. )
  3854. (define-derived-operand
  3855. (name (.sym bit32- offset -27-absolute- group))
  3856. (comment "m32c absolute address bit")
  3857. (attrs (machine 32))
  3858. (mode BI)
  3859. (args ((.sym BitBase32- offset -u27- group)))
  3860. (syntax (.str "${BitBase32-" offset "-u27-" group "}"))
  3861. (base-ifield (.sym f- base1 -12))
  3862. (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym BitBase32- offset -u27- group)))
  3863. (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2)))
  3864. (getter (get-memory-bit 32 0 (.sym BitBase32- offset -u27- group)))
  3865. (setter (set-memory-bit 32 0 (.sym BitBase32- offset -u27- group) newval))
  3866. )
  3867. )
  3868. )
  3869. (bit32-absolute 16 Unprefixed 4 8)
  3870. (bit32-absolute 24 Prefixed 12 16)
  3871. ;-------------------------------------------------------------
  3872. ; Destination operands for short fomat insns
  3873. ;-------------------------------------------------------------
  3874. (define-derived-operand
  3875. (name dst16-3-S-R0l-direct-QI)
  3876. (comment "m16c R0l direct QI")
  3877. (attrs (machine 16))
  3878. (mode QI)
  3879. (args (R0l))
  3880. (syntax "r0l")
  3881. (base-ifield f-5-3)
  3882. (encoding (+ (f-5-3 4)))
  3883. (ifield-assertion (eq f-5-3 4))
  3884. (getter (trunc QI R0l))
  3885. (setter (set R0l newval))
  3886. )
  3887. (define-derived-operand
  3888. (name dst16-3-S-R0h-direct-QI)
  3889. (comment "m16c R0h direct QI")
  3890. (attrs (machine 16))
  3891. (mode QI)
  3892. (args (R0h))
  3893. (syntax "r0h")
  3894. (base-ifield f-5-3)
  3895. (encoding (+ (f-5-3 3)))
  3896. (ifield-assertion (eq f-5-3 3))
  3897. (getter (trunc QI R0h))
  3898. (setter (set R0h newval))
  3899. )
  3900. (define-derived-operand
  3901. (name dst16-3-S-8-8-SB-relative-QI)
  3902. (comment "m16c SB relative QI")
  3903. (attrs (machine 16))
  3904. (mode QI)
  3905. (args (Dsp-8-u8))
  3906. (syntax "${Dsp-8-u8}[sb]")
  3907. (base-ifield f-5-3)
  3908. (encoding (+ (f-5-3 5) Dsp-8-u8))
  3909. (ifield-assertion (eq f-5-3 5))
  3910. (getter (mem16 QI (add Dsp-8-u8 (reg h-sb))))
  3911. (setter (set (mem16 QI (add Dsp-8-u8 (reg h-sb))) newval))
  3912. )
  3913. (define-derived-operand
  3914. (name dst16-3-S-8-8-FB-relative-QI)
  3915. (comment "m16c FB relative QI")
  3916. (attrs (machine 16))
  3917. (mode QI)
  3918. (args (Dsp-8-s8))
  3919. (syntax "${Dsp-8-s8}[fb]")
  3920. (base-ifield f-5-3)
  3921. (encoding (+ (f-5-3 6) Dsp-8-s8))
  3922. (ifield-assertion (eq f-5-3 6))
  3923. (getter (mem16 QI (add Dsp-8-s8 (reg h-fb))))
  3924. (setter (set (mem16 QI (add Dsp-8-s8 (reg h-fb))) newval))
  3925. )
  3926. (define-derived-operand
  3927. (name dst16-3-S-8-16-absolute-QI)
  3928. (comment "m16c absolute address QI")
  3929. (attrs (machine 16))
  3930. (mode QI)
  3931. (args (Dsp-8-u16))
  3932. (syntax "${Dsp-8-u16}")
  3933. (base-ifield f-5-3)
  3934. (encoding (+ (f-5-3 7) Dsp-8-u16))
  3935. (ifield-assertion (eq f-5-3 7))
  3936. (getter (mem16 QI Dsp-8-u16))
  3937. (setter (set (mem16 QI Dsp-8-u16) newval))
  3938. )
  3939. (define-derived-operand
  3940. (name dst16-3-S-16-8-SB-relative-QI)
  3941. (comment "m16c SB relative QI")
  3942. (attrs (machine 16))
  3943. (mode QI)
  3944. (args (Dsp-16-u8))
  3945. (syntax "${Dsp-16-u8}[sb]")
  3946. (base-ifield f-5-3)
  3947. (encoding (+ (f-5-3 5) Dsp-16-u8))
  3948. (ifield-assertion (eq f-5-3 5))
  3949. (getter (mem16 QI (add Dsp-16-u8 (reg h-sb))))
  3950. (setter (set (mem16 QI (add Dsp-16-u8 (reg h-sb))) newval))
  3951. )
  3952. (define-derived-operand
  3953. (name dst16-3-S-16-8-FB-relative-QI)
  3954. (comment "m16c FB relative QI")
  3955. (attrs (machine 16))
  3956. (mode QI)
  3957. (args (Dsp-16-s8))
  3958. (syntax "${Dsp-16-s8}[fb]")
  3959. (base-ifield f-5-3)
  3960. (encoding (+ (f-5-3 6) Dsp-16-s8))
  3961. (ifield-assertion (eq f-5-3 6))
  3962. (getter (mem16 QI (add Dsp-16-s8 (reg h-fb))))
  3963. (setter (set (mem16 QI (add Dsp-16-s8 (reg h-fb))) newval))
  3964. )
  3965. (define-derived-operand
  3966. (name dst16-3-S-16-16-absolute-QI)
  3967. (comment "m16c absolute address QI")
  3968. (attrs (machine 16))
  3969. (mode QI)
  3970. (args (Dsp-16-u16))
  3971. (syntax "${Dsp-16-u16}")
  3972. (base-ifield f-5-3)
  3973. (encoding (+ (f-5-3 7) Dsp-16-u16))
  3974. (ifield-assertion (eq f-5-3 7))
  3975. (getter (mem16 QI Dsp-16-u16))
  3976. (setter (set (mem16 QI Dsp-16-u16) newval))
  3977. )
  3978. (define-derived-operand
  3979. (name srcdst16-r0l-r0h-S-derived)
  3980. (comment "m16c r0l/r0h operand for short format insns")
  3981. (attrs (machine 16))
  3982. (mode SI)
  3983. (args (SrcDst16-r0l-r0h-S-normal))
  3984. (syntax "${SrcDst16-r0l-r0h-S-normal}")
  3985. (base-ifield f-6-3)
  3986. (encoding (+ (f-6-2 0) SrcDst16-r0l-r0h-S-normal))
  3987. (ifield-assertion (eq f-6-2 0))
  3988. (getter (trunc SI SrcDst16-r0l-r0h-S-normal))
  3989. (setter ()) ; no setter
  3990. )
  3991. (define-derived-operand
  3992. (name dst32-2-S-R0l-direct-QI)
  3993. (comment "m32c R0l direct QI")
  3994. (attrs (machine 32))
  3995. (mode QI)
  3996. (args (R0l))
  3997. (syntax "r0l")
  3998. (base-ifield f-2-2)
  3999. (encoding (+ (f-2-2 0)))
  4000. (ifield-assertion (eq f-2-2 0))
  4001. (getter (trunc QI R0l))
  4002. (setter (set R0l newval))
  4003. )
  4004. (define-derived-operand
  4005. (name dst32-2-S-R0-direct-HI)
  4006. (comment "m32c R0 direct HI")
  4007. (attrs (machine 32))
  4008. (mode HI)
  4009. (args (R0))
  4010. (syntax "r0")
  4011. (base-ifield f-2-2)
  4012. (encoding (+ (f-2-2 0)))
  4013. (ifield-assertion (eq f-2-2 0))
  4014. (getter (trunc HI R0))
  4015. (setter (set R0 newval))
  4016. )
  4017. (define-derived-operand
  4018. (name dst32-1-S-A0-direct-HI)
  4019. (comment "m32c A0 direct HI")
  4020. (attrs (machine 32))
  4021. (mode HI)
  4022. (args (A0))
  4023. (syntax "a0")
  4024. (base-ifield f-7-1)
  4025. (encoding (+ (f-7-1 0)))
  4026. (ifield-assertion (eq f-7-1 0))
  4027. (getter (trunc HI A0))
  4028. (setter (set A0 newval))
  4029. )
  4030. (define-derived-operand
  4031. (name dst32-1-S-A1-direct-HI)
  4032. (comment "m32c A1 direct HI")
  4033. (attrs (machine 32))
  4034. (mode HI)
  4035. (args (A1))
  4036. (syntax "a1")
  4037. (base-ifield f-7-1)
  4038. (encoding (+ (f-7-1 1)))
  4039. (ifield-assertion (eq f-7-1 1))
  4040. (getter (trunc HI A1))
  4041. (setter (set A1 newval))
  4042. )
  4043. (define-pmacro (dst32-2-S-operands xmode)
  4044. (begin
  4045. (define-derived-operand
  4046. (name (.sym dst32-2-S-8-SB-relative- xmode))
  4047. (comment "m32c SB relative for short binary insns")
  4048. (attrs (machine 32))
  4049. (mode xmode)
  4050. (args (Dsp-8-u8))
  4051. (syntax "${Dsp-8-u8}[sb]")
  4052. (base-ifield f-2-2)
  4053. (encoding (+ (f-2-2 2) Dsp-8-u8))
  4054. (ifield-assertion (eq f-2-2 2))
  4055. (getter (c-call xmode (.str "operand_getter_" xmode) sb Dsp-8-u8))
  4056. (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb Dsp-8-u8))
  4057. ; (getter (mem32 xmode (add Dsp-8-u8 (reg h-sb))))
  4058. ; (setter (set (mem32 xmode (add Dsp-8-u8 (reg h-sb))) newval))
  4059. )
  4060. (define-derived-operand
  4061. (name (.sym dst32-2-S-8-FB-relative- xmode))
  4062. (comment "m32c FB relative for short binary insns")
  4063. (attrs (machine 32))
  4064. (mode xmode)
  4065. (args (Dsp-8-s8))
  4066. (syntax "${Dsp-8-s8}[fb]")
  4067. (base-ifield f-2-2)
  4068. (encoding (+ (f-2-2 3) Dsp-8-s8))
  4069. (ifield-assertion (eq f-2-2 3))
  4070. (getter (c-call xmode (.str "operand_getter_" xmode) fb Dsp-8-s8))
  4071. (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb Dsp-8-s8))
  4072. ; (getter (mem32 xmode (add Dsp-8-s8 (reg h-fb))))
  4073. ; (setter (set (mem32 xmode (add Dsp-8-s8 (reg h-fb))) newval))
  4074. )
  4075. (define-derived-operand
  4076. (name (.sym dst32-2-S-16-absolute- xmode))
  4077. (comment "m32c absolute address for short binary insns")
  4078. (attrs (machine 32))
  4079. (mode xmode)
  4080. (args (Dsp-8-u16))
  4081. (syntax "${Dsp-8-u16}")
  4082. (base-ifield f-2-2)
  4083. (encoding (+ (f-2-2 1) Dsp-8-u16))
  4084. (ifield-assertion (eq f-2-2 1))
  4085. (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) Dsp-8-u16))
  4086. (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) Dsp-8-u16))
  4087. ; (getter (mem32 xmode Dsp-8-u16))
  4088. ; (setter (set (mem32 xmode Dsp-8-u16) newval))
  4089. )
  4090. ; (define-derived-operand
  4091. ; (name (.sym dst32-2-S-8-SB-relative-indirect- xmode))
  4092. ; (comment "m32c SB relative for short binary insns")
  4093. ; (attrs (machine 32))
  4094. ; (mode xmode)
  4095. ; (args (Dsp-16-u8))
  4096. ; (syntax "[${Dsp-16-u8}[sb]]")
  4097. ; (base-ifield f-10-2)
  4098. ; (encoding (+ (f-10-2 2) Dsp-16-u8))
  4099. ; (ifield-assertion (eq f-10-2 2))
  4100. ; (getter (mem32 xmode (indirect-addr (add Dsp-16-u8 (reg h-sb)))))
  4101. ; (setter (set (mem32 xmode (indirect-addr (add Dsp-16-u8 (reg h-sb)))) newval))
  4102. ; )
  4103. ; (define-derived-operand
  4104. ; (name (.sym dst32-2-S-8-FB-relative-indirect- xmode))
  4105. ; (comment "m32c FB relative for short binary insns")
  4106. ; (attrs (machine 32))
  4107. ; (mode xmode)
  4108. ; (args (Dsp-16-s8))
  4109. ; (syntax "[${Dsp-16-s8}[fb]]")
  4110. ; (base-ifield f-10-2)
  4111. ; (encoding (+ (f-10-2 3) Dsp-16-s8))
  4112. ; (ifield-assertion (eq f-10-2 3))
  4113. ; (getter (mem32 xmode (indirect-addr (add Dsp-16-s8 (reg h-fb)))))
  4114. ; (setter (set (mem32 xmode (indirect-addr (add Dsp-16-s8 (reg h-fb)))) newval))
  4115. ; )
  4116. ; (define-derived-operand
  4117. ; (name (.sym dst32-2-S-16-absolute-indirect- xmode))
  4118. ; (comment "m32c absolute address for short binary insns")
  4119. ; (attrs (machine 32))
  4120. ; (mode xmode)
  4121. ; (args (Dsp-16-u16))
  4122. ; (syntax "[${Dsp-16-u16}]")
  4123. ; (base-ifield f-10-2)
  4124. ; (encoding (+ (f-10-2 1) Dsp-16-u16))
  4125. ; (ifield-assertion (eq f-10-2 1))
  4126. ; (getter (mem32 xmode (indirect-addr Dsp-16-u16)))
  4127. ; (setter (set (mem32 xmode (indirect-addr Dsp-16-u16)) newval))
  4128. ; )
  4129. )
  4130. )
  4131. (dst32-2-S-operands QI)
  4132. (dst32-2-S-operands HI)
  4133. (dst32-2-S-operands SI)
  4134. ;=============================================================
  4135. ; Anyof operands
  4136. ;-------------------------------------------------------------
  4137. ; Source operands with no additional fields
  4138. ;-------------------------------------------------------------
  4139. (define-pmacro (src16-basic-operand xmode)
  4140. (begin
  4141. (define-anyof-operand
  4142. (name (.sym src16-basic- xmode))
  4143. (comment (.str "m16c source operand of size " xmode " with no additional fields"))
  4144. (attrs (machine 16))
  4145. (mode xmode)
  4146. (choices
  4147. (.sym src16-Rn-direct- xmode)
  4148. (.sym src16-An-direct- xmode)
  4149. (.sym src16-An-indirect- xmode)
  4150. )
  4151. )
  4152. )
  4153. )
  4154. (src16-basic-operand QI)
  4155. (src16-basic-operand HI)
  4156. (define-pmacro (src32-basic-operand xmode)
  4157. (begin
  4158. (define-anyof-operand
  4159. (name (.sym src32-basic-Unprefixed- xmode))
  4160. (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
  4161. (attrs (machine 32))
  4162. (mode xmode)
  4163. (choices
  4164. (.sym src32-Rn-direct-Unprefixed- xmode)
  4165. (.sym src32-An-direct-Unprefixed- xmode)
  4166. (.sym src32-An-indirect-Unprefixed- xmode)
  4167. )
  4168. )
  4169. (define-anyof-operand
  4170. (name (.sym src32-basic-Prefixed- xmode))
  4171. (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
  4172. (attrs (machine 32))
  4173. (mode xmode)
  4174. (choices
  4175. (.sym src32-Rn-direct-Prefixed- xmode)
  4176. (.sym src32-An-direct-Prefixed- xmode)
  4177. (.sym src32-An-indirect-Prefixed- xmode)
  4178. )
  4179. )
  4180. ; (define-anyof-operand
  4181. ; (name (.sym src32-basic-indirect- xmode))
  4182. ; (comment (.str "m32c destination operand of size " xmode " indirect with no additional fields"))
  4183. ; (attrs (machine 32))
  4184. ; (mode xmode)
  4185. ; (choices
  4186. ; (.sym src32-An-indirect-indirect- xmode)
  4187. ; )
  4188. ; )
  4189. )
  4190. )
  4191. (src32-basic-operand QI)
  4192. (src32-basic-operand HI)
  4193. (src32-basic-operand SI)
  4194. (define-anyof-operand
  4195. (name src32-basic-ExtPrefixed-QI)
  4196. (comment "m32c source operand of size QI with no additional fields")
  4197. (attrs (machine 32))
  4198. (mode QI)
  4199. (choices
  4200. src32-Rn-direct-Prefixed-QI
  4201. src32-An-indirect-Prefixed-QI
  4202. )
  4203. )
  4204. ;-------------------------------------------------------------
  4205. ; Source operands with additional fields at offset 16 bits
  4206. ;-------------------------------------------------------------
  4207. (define-pmacro (src16-16-operand xmode)
  4208. (begin
  4209. (define-anyof-operand
  4210. (name (.sym src16-16-8- xmode))
  4211. (comment (.str "m16c source operand of size " xmode " with additional 8 bit fields at offset 16"))
  4212. (attrs (machine 16))
  4213. (mode xmode)
  4214. (choices
  4215. (.sym src16-16-8-An-relative- xmode)
  4216. (.sym src16-16-8-SB-relative- xmode)
  4217. (.sym src16-16-8-FB-relative- xmode)
  4218. )
  4219. )
  4220. (define-anyof-operand
  4221. (name (.sym src16-16-16- xmode))
  4222. (comment (.str "m16c source operand of size " xmode " with additional 16 bit fields at offset 16"))
  4223. (attrs (machine 16))
  4224. (mode xmode)
  4225. (choices
  4226. (.sym src16-16-16-An-relative- xmode)
  4227. (.sym src16-16-16-SB-relative- xmode)
  4228. (.sym src16-16-16-absolute- xmode)
  4229. )
  4230. )
  4231. )
  4232. )
  4233. (src16-16-operand QI)
  4234. (src16-16-operand HI)
  4235. (define-pmacro (src32-16-operand xmode)
  4236. (begin
  4237. (define-anyof-operand
  4238. (name (.sym src32-16-8-Unprefixed- xmode))
  4239. (comment (.str "m32c source operand of size " xmode " with additional 8 bit fields at offset 16"))
  4240. (attrs (machine 32))
  4241. (mode xmode)
  4242. (choices
  4243. (.sym src32-16-8-An-relative-Unprefixed- xmode)
  4244. (.sym src32-16-8-SB-relative-Unprefixed- xmode)
  4245. (.sym src32-16-8-FB-relative-Unprefixed- xmode)
  4246. )
  4247. )
  4248. (define-anyof-operand
  4249. (name (.sym src32-16-16-Unprefixed- xmode))
  4250. (comment (.str "m32c source operand of size " xmode " with additional 16 bit fields at offset 16"))
  4251. (attrs (machine 32))
  4252. (mode xmode)
  4253. (choices
  4254. (.sym src32-16-16-An-relative-Unprefixed- xmode)
  4255. (.sym src32-16-16-SB-relative-Unprefixed- xmode)
  4256. (.sym src32-16-16-FB-relative-Unprefixed- xmode)
  4257. (.sym src32-16-16-absolute-Unprefixed- xmode)
  4258. )
  4259. )
  4260. (define-anyof-operand
  4261. (name (.sym src32-16-24-Unprefixed- xmode))
  4262. (comment (.str "m32c source operand of size " xmode " with additional 24 bit fields at offset 16"))
  4263. (attrs (machine 32))
  4264. (mode xmode)
  4265. (choices
  4266. (.sym src32-16-24-An-relative-Unprefixed- xmode)
  4267. (.sym src32-16-24-absolute-Unprefixed- xmode)
  4268. )
  4269. )
  4270. )
  4271. )
  4272. (src32-16-operand QI)
  4273. (src32-16-operand HI)
  4274. (src32-16-operand SI)
  4275. ;-------------------------------------------------------------
  4276. ; Source operands with additional fields at offset 24 bits
  4277. ;-------------------------------------------------------------
  4278. (define-pmacro (src-24-operand group xmode)
  4279. (begin
  4280. (define-anyof-operand
  4281. (name (.sym src32-24-8- group - xmode))
  4282. (comment (.str "m32c source operand of size " xmode " with additional 8 bit fields at offset 24"))
  4283. (attrs (machine 32))
  4284. (mode xmode)
  4285. (choices
  4286. (.sym src32-24-8-An-relative- group - xmode)
  4287. (.sym src32-24-8-SB-relative- group - xmode)
  4288. (.sym src32-24-8-FB-relative- group - xmode)
  4289. )
  4290. )
  4291. (define-anyof-operand
  4292. (name (.sym src32-24-16- group - xmode))
  4293. (comment (.str "m32c source operand of size " xmode " with additional 16 bit fields at offset 16"))
  4294. (attrs (machine 32))
  4295. (mode xmode)
  4296. (choices
  4297. (.sym src32-24-16-An-relative- group - xmode)
  4298. (.sym src32-24-16-SB-relative- group - xmode)
  4299. (.sym src32-24-16-FB-relative- group - xmode)
  4300. (.sym src32-24-16-absolute- group - xmode)
  4301. )
  4302. )
  4303. (define-anyof-operand
  4304. (name (.sym src32-24-24- group - xmode))
  4305. (comment (.str "m32c source operand of size " xmode " with additional 24 bit fields at offset 16"))
  4306. (attrs (machine 32))
  4307. (mode xmode)
  4308. (choices
  4309. (.sym src32-24-24-An-relative- group - xmode)
  4310. (.sym src32-24-24-absolute- group - xmode)
  4311. )
  4312. )
  4313. )
  4314. )
  4315. (src-24-operand Prefixed QI)
  4316. (src-24-operand Prefixed HI)
  4317. (src-24-operand Prefixed SI)
  4318. (define-pmacro (src-24-indirect-operand xmode)
  4319. (begin
  4320. ; (define-anyof-operand
  4321. ; (name (.sym src32-24-8-indirect- xmode))
  4322. ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
  4323. ; (attrs (machine 32))
  4324. ; (mode xmode)
  4325. ; (choices
  4326. ; (.sym src32-24-8-An-relative-indirect- xmode)
  4327. ; (.sym src32-24-8-SB-relative-indirect- xmode)
  4328. ; (.sym src32-24-8-FB-relative-indirect- xmode)
  4329. ; )
  4330. ; )
  4331. ; (define-anyof-operand
  4332. ; (name (.sym src32-24-16-indirect- xmode))
  4333. ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
  4334. ; (attrs (machine 32))
  4335. ; (mode xmode)
  4336. ; (choices
  4337. ; (.sym src32-24-16-An-relative-indirect- xmode)
  4338. ; (.sym src32-24-16-SB-relative-indirect- xmode)
  4339. ; (.sym src32-24-16-FB-relative-indirect- xmode)
  4340. ; )
  4341. ; )
  4342. ; (define-anyof-operand
  4343. ; (name (.sym src32-24-24-indirect- xmode))
  4344. ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
  4345. ; (attrs (machine 32))
  4346. ; (mode xmode)
  4347. ; (choices
  4348. ; (.sym src32-24-24-An-relative-indirect- xmode)
  4349. ; )
  4350. ; )
  4351. ; (define-anyof-operand
  4352. ; (name (.sym src32-24-16-absolute-indirect- xmode))
  4353. ; (comment (.str "m32c source operand of size " xmode " 16 bit absolute indirect"))
  4354. ; (attrs (machine 32))
  4355. ; (mode xmode)
  4356. ; (choices
  4357. ; (.sym src32-24-16-absolute-indirect-derived- xmode)
  4358. ; )
  4359. ; )
  4360. ; (define-anyof-operand
  4361. ; (name (.sym src32-24-24-absolute-indirect- xmode))
  4362. ; (comment (.str "m32c source operand of size " xmode " 24 bit absolute indirect"))
  4363. ; (attrs (machine 32))
  4364. ; (mode xmode)
  4365. ; (choices
  4366. ; (.sym src32-24-24-absolute-indirect-derived- xmode)
  4367. ; )
  4368. ; )
  4369. )
  4370. )
  4371. ; (src-24-indirect-operand QI)
  4372. ; (src-24-indirect-operand HI)
  4373. ; (src-24-indirect-operand SI)
  4374. ;-------------------------------------------------------------
  4375. ; Destination operands with no additional fields
  4376. ;-------------------------------------------------------------
  4377. (define-pmacro (dst16-basic-operand xmode)
  4378. (begin
  4379. (define-anyof-operand
  4380. (name (.sym dst16-basic- xmode))
  4381. (comment (.str "m16c destination operand of size " xmode " with no additional fields"))
  4382. (attrs (machine 16))
  4383. (mode xmode)
  4384. (choices
  4385. (.sym dst16-Rn-direct- xmode)
  4386. (.sym dst16-An-direct- xmode)
  4387. (.sym dst16-An-indirect- xmode)
  4388. )
  4389. )
  4390. )
  4391. )
  4392. (dst16-basic-operand QI)
  4393. (dst16-basic-operand HI)
  4394. (dst16-basic-operand SI)
  4395. (define-pmacro (dst32-basic-operand xmode)
  4396. (begin
  4397. (define-anyof-operand
  4398. (name (.sym dst32-basic-Unprefixed- xmode))
  4399. (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
  4400. (attrs (machine 32))
  4401. (mode xmode)
  4402. (choices
  4403. (.sym dst32-Rn-direct-Unprefixed- xmode)
  4404. (.sym dst32-An-direct-Unprefixed- xmode)
  4405. (.sym dst32-An-indirect-Unprefixed- xmode)
  4406. )
  4407. )
  4408. (define-anyof-operand
  4409. (name (.sym dst32-basic-Prefixed- xmode))
  4410. (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
  4411. (attrs (machine 32))
  4412. (mode xmode)
  4413. (choices
  4414. (.sym dst32-Rn-direct-Prefixed- xmode)
  4415. (.sym dst32-An-direct-Prefixed- xmode)
  4416. (.sym dst32-An-indirect-Prefixed- xmode)
  4417. )
  4418. )
  4419. )
  4420. )
  4421. (dst32-basic-operand QI)
  4422. (dst32-basic-operand HI)
  4423. (dst32-basic-operand SI)
  4424. ;-------------------------------------------------------------
  4425. ; Destination operands with possible additional fields at offset 16 bits
  4426. ;-------------------------------------------------------------
  4427. (define-pmacro (dst16-16-operand xmode)
  4428. (begin
  4429. (define-anyof-operand
  4430. (name (.sym dst16-16- xmode))
  4431. (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16"))
  4432. (attrs (machine 16))
  4433. (mode xmode)
  4434. (choices
  4435. (.sym dst16-Rn-direct- xmode)
  4436. (.sym dst16-An-direct- xmode)
  4437. (.sym dst16-An-indirect- xmode)
  4438. (.sym dst16-16-8-An-relative- xmode)
  4439. (.sym dst16-16-16-An-relative- xmode)
  4440. (.sym dst16-16-8-SB-relative- xmode)
  4441. (.sym dst16-16-16-SB-relative- xmode)
  4442. (.sym dst16-16-8-FB-relative- xmode)
  4443. (.sym dst16-16-16-absolute- xmode)
  4444. )
  4445. )
  4446. (define-anyof-operand
  4447. (name (.sym dst16-16-8- xmode))
  4448. (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16"))
  4449. (attrs (machine 16))
  4450. (mode xmode)
  4451. (choices
  4452. (.sym dst16-16-8-An-relative- xmode)
  4453. (.sym dst16-16-8-SB-relative- xmode)
  4454. (.sym dst16-16-8-FB-relative- xmode)
  4455. )
  4456. )
  4457. (define-anyof-operand
  4458. (name (.sym dst16-16-16- xmode))
  4459. (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16"))
  4460. (attrs (machine 16))
  4461. (mode xmode)
  4462. (choices
  4463. (.sym dst16-16-16-An-relative- xmode)
  4464. (.sym dst16-16-16-SB-relative- xmode)
  4465. (.sym dst16-16-16-absolute- xmode)
  4466. )
  4467. )
  4468. (define-anyof-operand
  4469. (name (.sym dst16-16-16sa- xmode))
  4470. (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16"))
  4471. (attrs (machine 16))
  4472. (mode xmode)
  4473. (choices
  4474. (.sym dst16-16-16-SB-relative- xmode)
  4475. (.sym dst16-16-16-absolute- xmode)
  4476. )
  4477. )
  4478. (define-anyof-operand
  4479. (name (.sym dst16-16-20ar- xmode))
  4480. (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16"))
  4481. (attrs (machine 16))
  4482. (mode xmode)
  4483. (choices
  4484. (.sym dst16-16-20-An-relative- xmode)
  4485. )
  4486. )
  4487. )
  4488. )
  4489. (dst16-16-operand QI)
  4490. (dst16-16-operand HI)
  4491. (dst16-16-operand SI)
  4492. (define-anyof-operand
  4493. (name dst16-16-Ext-QI)
  4494. (comment "m16c destination operand of size QI for 'ext' insns with additional fields at offset 16")
  4495. (attrs (machine 16))
  4496. (mode QI)
  4497. (choices
  4498. dst16-Rn-direct-Ext-QI
  4499. dst16-An-indirect-Ext-QI
  4500. dst16-16-8-An-relative-Ext-QI
  4501. dst16-16-16-An-relative-Ext-QI
  4502. dst16-16-8-SB-relative-Ext-QI
  4503. dst16-16-16-SB-relative-Ext-QI
  4504. dst16-16-8-FB-relative-Ext-QI
  4505. dst16-16-16-absolute-Ext-QI
  4506. )
  4507. )
  4508. (define-derived-operand
  4509. (name dst16-An-indirect-Mova-HI)
  4510. (comment "m16c addressof An indirect destination HI")
  4511. (attrs (ISA m16c))
  4512. (mode HI)
  4513. (args (Dst16An))
  4514. (syntax "[$Dst16An]")
  4515. (base-ifield f-12-4)
  4516. (encoding (+ (f-12-2 1) (f-14-1 1) Dst16An))
  4517. (ifield-assertion
  4518. (andif (eq f-12-2 1) (eq f-14-1 1)))
  4519. (getter Dst16An)
  4520. (setter (nop))
  4521. )
  4522. (define-derived-operand
  4523. (name dst16-16-8-An-relative-Mova-HI)
  4524. (comment
  4525. "m16c addressof dsp:8[An] relative destination HI")
  4526. (attrs (ISA m16c))
  4527. (mode HI)
  4528. (args (Dst16An Dsp-16-u8))
  4529. (syntax "${Dsp-16-u8}[$Dst16An]")
  4530. (base-ifield f-12-4)
  4531. (encoding
  4532. (+ (f-12-2 2) (f-14-1 0) Dsp-16-u8 Dst16An))
  4533. (ifield-assertion
  4534. (andif (eq f-12-2 2) (eq f-14-1 0)))
  4535. (getter (add Dsp-16-u8 Dst16An))
  4536. (setter (nop))
  4537. )
  4538. (define-derived-operand
  4539. (name dst16-16-16-An-relative-Mova-HI)
  4540. (comment
  4541. "m16c addressof dsp:16[An] relative destination HI")
  4542. (attrs (ISA m16c))
  4543. (mode HI)
  4544. (args (Dst16An Dsp-16-u16))
  4545. (syntax "${Dsp-16-u16}[$Dst16An]")
  4546. (base-ifield f-12-4)
  4547. (encoding
  4548. (+ (f-12-2 3) (f-14-1 0) Dsp-16-u16 Dst16An))
  4549. (ifield-assertion
  4550. (andif (eq f-12-2 3) (eq f-14-1 0)))
  4551. (getter (add Dsp-16-u16 Dst16An))
  4552. (setter (nop))
  4553. )
  4554. (define-derived-operand
  4555. (name dst16-16-8-SB-relative-Mova-HI)
  4556. (comment
  4557. "m16c addressof dsp:8[sb] relative destination HI")
  4558. (attrs (ISA m16c))
  4559. (mode HI)
  4560. (args (Dsp-16-u8))
  4561. (syntax "${Dsp-16-u8}[sb]")
  4562. (base-ifield f-12-4)
  4563. (encoding (+ (f-12-4 10) Dsp-16-u8))
  4564. (ifield-assertion (eq f-12-4 10))
  4565. (getter (add Dsp-16-u8 (reg h-sb)))
  4566. (setter (nop))
  4567. )
  4568. (define-derived-operand
  4569. (name dst16-16-16-SB-relative-Mova-HI)
  4570. (comment
  4571. "m16c addressof dsp:16[sb] relative destination HI")
  4572. (attrs (ISA m16c))
  4573. (mode HI)
  4574. (args (Dsp-16-u16))
  4575. (syntax "${Dsp-16-u16}[sb]")
  4576. (base-ifield f-12-4)
  4577. (encoding (+ (f-12-4 14) Dsp-16-u16))
  4578. (ifield-assertion (eq f-12-4 14))
  4579. (getter (add Dsp-16-u16 (reg h-sb)))
  4580. (setter (nop))
  4581. )
  4582. (define-derived-operand
  4583. (name dst16-16-8-FB-relative-Mova-HI)
  4584. (comment
  4585. "m16c addressof dsp:8[fb] relative destination HI")
  4586. (attrs (ISA m16c))
  4587. (mode HI)
  4588. (args (Dsp-16-s8))
  4589. (syntax "${Dsp-16-s8}[fb]")
  4590. (base-ifield f-12-4)
  4591. (encoding (+ (f-12-4 11) Dsp-16-s8))
  4592. (ifield-assertion (eq f-12-4 11))
  4593. (getter (add Dsp-16-s8 (reg h-fb)))
  4594. (setter (nop))
  4595. )
  4596. (define-derived-operand
  4597. (name dst16-16-16-absolute-Mova-HI)
  4598. (comment "m16c addressof absolute address HI")
  4599. (attrs (ISA m16c))
  4600. (mode HI)
  4601. (args (Dsp-16-u16))
  4602. (syntax "${Dsp-16-u16}")
  4603. (base-ifield f-12-4)
  4604. (encoding (+ (f-12-4 15) Dsp-16-u16))
  4605. (ifield-assertion (eq f-12-4 15))
  4606. (getter Dsp-16-u16)
  4607. (setter (nop))
  4608. )
  4609. (define-anyof-operand
  4610. (name dst16-16-Mova-HI)
  4611. (comment "m16c addressof destination operand of size HI with additional fields at offset 16")
  4612. (attrs (machine 16))
  4613. (mode HI)
  4614. (choices
  4615. dst16-An-indirect-Mova-HI
  4616. dst16-16-8-An-relative-Mova-HI
  4617. dst16-16-16-An-relative-Mova-HI
  4618. dst16-16-8-SB-relative-Mova-HI
  4619. dst16-16-16-SB-relative-Mova-HI
  4620. dst16-16-8-FB-relative-Mova-HI
  4621. dst16-16-16-absolute-Mova-HI
  4622. )
  4623. )
  4624. (define-derived-operand
  4625. (name dst32-An-indirect-Unprefixed-Mova-SI)
  4626. (comment "m32c addressof An indirect destination SI")
  4627. (attrs (ISA m32c))
  4628. (mode SI)
  4629. (args (Dst32AnUnprefixed))
  4630. (syntax "[$Dst32AnUnprefixed]")
  4631. (base-ifield f-4-6)
  4632. (encoding
  4633. (+ (f-4-3 0) (f-8-1 0) Dst32AnUnprefixed))
  4634. (ifield-assertion
  4635. (andif (eq f-4-3 0) (eq f-8-1 0)))
  4636. (getter Dst32AnUnprefixed)
  4637. (setter (nop))
  4638. )
  4639. (define-derived-operand
  4640. (name dst32-16-8-An-relative-Unprefixed-Mova-SI)
  4641. (comment "m32c addressof dsp:8[An] relative destination SI")
  4642. (attrs (ISA m32c))
  4643. (mode SI)
  4644. (args (Dst32AnUnprefixed Dsp-16-u8))
  4645. (syntax "${Dsp-16-u8}[$Dst32AnUnprefixed]")
  4646. (base-ifield f-4-6)
  4647. (encoding
  4648. (+ (f-4-3 1)
  4649. (f-8-1 0)
  4650. Dsp-16-u8
  4651. Dst32AnUnprefixed))
  4652. (ifield-assertion
  4653. (andif (eq f-4-3 1) (eq f-8-1 0)))
  4654. (getter (add Dsp-16-u8 Dst32AnUnprefixed))
  4655. (setter (nop))
  4656. )
  4657. (define-derived-operand
  4658. (name dst32-16-16-An-relative-Unprefixed-Mova-SI)
  4659. (comment
  4660. "m32c addressof dsp:16[An] relative destination SI")
  4661. (attrs (ISA m32c))
  4662. (mode SI)
  4663. (args (Dst32AnUnprefixed Dsp-16-u16))
  4664. (syntax "${Dsp-16-u16}[$Dst32AnUnprefixed]")
  4665. (base-ifield f-4-6)
  4666. (encoding
  4667. (+ (f-4-3 2)
  4668. (f-8-1 0)
  4669. Dsp-16-u16
  4670. Dst32AnUnprefixed))
  4671. (ifield-assertion
  4672. (andif (eq f-4-3 2) (eq f-8-1 0)))
  4673. (getter (add Dsp-16-u16 Dst32AnUnprefixed))
  4674. (setter (nop))
  4675. )
  4676. (define-derived-operand
  4677. (name dst32-16-24-An-relative-Unprefixed-Mova-SI)
  4678. (comment "addressof m32c dsp:16[An] relative destination SI")
  4679. (attrs (ISA m32c))
  4680. (mode SI)
  4681. (args (Dst32AnUnprefixed Dsp-16-u24))
  4682. (syntax "${Dsp-16-u24}[$Dst32AnUnprefixed]")
  4683. (base-ifield f-4-6)
  4684. (encoding
  4685. (+ (f-4-3 3)
  4686. (f-8-1 0)
  4687. Dsp-16-u24
  4688. Dst32AnUnprefixed))
  4689. (ifield-assertion
  4690. (andif (eq f-4-3 3) (eq f-8-1 0)))
  4691. (getter (add Dsp-16-u24 Dst32AnUnprefixed))
  4692. (setter (nop))
  4693. )
  4694. (define-derived-operand
  4695. (name dst32-16-8-SB-relative-Unprefixed-Mova-SI)
  4696. (comment "m32c addressof dsp:8[sb] relative destination SI")
  4697. (attrs (ISA m32c))
  4698. (mode SI)
  4699. (args (Dsp-16-u8))
  4700. (syntax "${Dsp-16-u8}[sb]")
  4701. (base-ifield f-4-6)
  4702. (encoding (+ (f-4-3 1) (f-8-2 2) Dsp-16-u8))
  4703. (ifield-assertion
  4704. (andif (eq f-4-3 1) (eq f-8-2 2)))
  4705. (getter (add Dsp-16-u8 (reg h-sb)))
  4706. (setter (nop))
  4707. )
  4708. (define-derived-operand
  4709. (name dst32-16-16-SB-relative-Unprefixed-Mova-SI)
  4710. (comment "m32c addressof dsp:16[sb] relative destination SI")
  4711. (attrs (ISA m32c))
  4712. (mode SI)
  4713. (args (Dsp-16-u16))
  4714. (syntax "${Dsp-16-u16}[sb]")
  4715. (base-ifield f-4-6)
  4716. (encoding (+ (f-4-3 2) (f-8-2 2) Dsp-16-u16))
  4717. (ifield-assertion
  4718. (andif (eq f-4-3 2) (eq f-8-2 2)))
  4719. (getter (add Dsp-16-u16 (reg h-sb)))
  4720. (setter (nop))
  4721. )
  4722. (define-derived-operand
  4723. (name dst32-16-8-FB-relative-Unprefixed-Mova-SI)
  4724. (comment "m32c addressof dsp:8[fb] relative destination SI")
  4725. (attrs (ISA m32c))
  4726. (mode SI)
  4727. (args (Dsp-16-s8))
  4728. (syntax "${Dsp-16-s8}[fb]")
  4729. (base-ifield f-4-6)
  4730. (encoding (+ (f-4-3 1) (f-8-2 3) Dsp-16-s8))
  4731. (ifield-assertion
  4732. (andif (eq f-4-3 1) (eq f-8-2 3)))
  4733. (getter (add Dsp-16-s8 (reg h-fb)))
  4734. (setter (nop))
  4735. )
  4736. (define-derived-operand
  4737. (name dst32-16-16-FB-relative-Unprefixed-Mova-SI)
  4738. (comment "m32c addressof dsp:16[fb] relative destination SI")
  4739. (attrs (ISA m32c))
  4740. (mode SI)
  4741. (args (Dsp-16-s16))
  4742. (syntax "${Dsp-16-s16}[fb]")
  4743. (base-ifield f-4-6)
  4744. (encoding (+ (f-4-3 2) (f-8-2 3) Dsp-16-s16))
  4745. (ifield-assertion
  4746. (andif (eq f-4-3 2) (eq f-8-2 3)))
  4747. (getter (add Dsp-16-s16 (reg h-fb)))
  4748. (setter (nop))
  4749. )
  4750. (define-derived-operand
  4751. (name dst32-16-16-absolute-Unprefixed-Mova-SI)
  4752. (comment "m32c addressof absolute address SI") (attrs (ISA m32c))
  4753. (mode SI)
  4754. (args (Dsp-16-u16))
  4755. (syntax "${Dsp-16-u16}")
  4756. (base-ifield f-4-6)
  4757. (encoding (+ (f-4-3 3) (f-8-2 3) Dsp-16-u16))
  4758. (ifield-assertion
  4759. (andif (eq f-4-3 3) (eq f-8-2 3)))
  4760. (getter Dsp-16-u16)
  4761. (setter (nop))
  4762. )
  4763. (define-derived-operand
  4764. (name dst32-16-24-absolute-Unprefixed-Mova-SI)
  4765. (comment "m32c addressof absolute address SI") (attrs (ISA m32c))
  4766. (mode SI)
  4767. (args (Dsp-16-u24))
  4768. (syntax "${Dsp-16-u24}")
  4769. (base-ifield f-4-6)
  4770. (encoding (+ (f-4-3 3) (f-8-2 2) Dsp-16-u24))
  4771. (ifield-assertion
  4772. (andif (eq f-4-3 3) (eq f-8-2 2)))
  4773. (getter Dsp-16-u24)
  4774. (setter (nop))
  4775. )
  4776. (define-anyof-operand
  4777. (name dst32-16-Unprefixed-Mova-SI)
  4778. (comment
  4779. "m32c addressof destination operand of size SI with additional fields at offset 16")
  4780. (attrs (ISA m32c))
  4781. (mode SI)
  4782. (choices
  4783. dst32-An-indirect-Unprefixed-Mova-SI
  4784. dst32-16-8-An-relative-Unprefixed-Mova-SI
  4785. dst32-16-16-An-relative-Unprefixed-Mova-SI
  4786. dst32-16-24-An-relative-Unprefixed-Mova-SI
  4787. dst32-16-8-SB-relative-Unprefixed-Mova-SI
  4788. dst32-16-16-SB-relative-Unprefixed-Mova-SI
  4789. dst32-16-8-FB-relative-Unprefixed-Mova-SI
  4790. dst32-16-16-FB-relative-Unprefixed-Mova-SI
  4791. dst32-16-16-absolute-Unprefixed-Mova-SI
  4792. dst32-16-24-absolute-Unprefixed-Mova-SI))
  4793. (define-pmacro (dst32-16-operand xmode)
  4794. (begin
  4795. (define-anyof-operand
  4796. (name (.sym dst32-16-Unprefixed- xmode))
  4797. (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
  4798. (attrs (machine 32))
  4799. (mode xmode)
  4800. (choices
  4801. (.sym dst32-Rn-direct-Unprefixed- xmode)
  4802. (.sym dst32-An-direct-Unprefixed- xmode)
  4803. (.sym dst32-An-indirect-Unprefixed- xmode)
  4804. (.sym dst32-16-8-An-relative-Unprefixed- xmode)
  4805. (.sym dst32-16-16-An-relative-Unprefixed- xmode)
  4806. (.sym dst32-16-24-An-relative-Unprefixed- xmode)
  4807. (.sym dst32-16-8-SB-relative-Unprefixed- xmode)
  4808. (.sym dst32-16-16-SB-relative-Unprefixed- xmode)
  4809. (.sym dst32-16-8-FB-relative-Unprefixed- xmode)
  4810. (.sym dst32-16-16-FB-relative-Unprefixed- xmode)
  4811. (.sym dst32-16-16-absolute-Unprefixed- xmode)
  4812. (.sym dst32-16-24-absolute-Unprefixed- xmode)
  4813. )
  4814. )
  4815. (define-anyof-operand
  4816. (name (.sym dst32-16-8-Unprefixed- xmode))
  4817. (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
  4818. (attrs (machine 32))
  4819. (mode xmode)
  4820. (choices
  4821. (.sym dst32-16-8-An-relative-Unprefixed- xmode)
  4822. (.sym dst32-16-8-SB-relative-Unprefixed- xmode)
  4823. (.sym dst32-16-8-FB-relative-Unprefixed- xmode)
  4824. )
  4825. )
  4826. (define-anyof-operand
  4827. (name (.sym dst32-16-16-Unprefixed- xmode))
  4828. (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
  4829. (attrs (machine 32))
  4830. (mode xmode)
  4831. (choices
  4832. (.sym dst32-16-16-An-relative-Unprefixed- xmode)
  4833. (.sym dst32-16-16-SB-relative-Unprefixed- xmode)
  4834. (.sym dst32-16-16-FB-relative-Unprefixed- xmode)
  4835. (.sym dst32-16-16-absolute-Unprefixed- xmode)
  4836. )
  4837. )
  4838. (define-anyof-operand
  4839. (name (.sym dst32-16-16sa-Unprefixed- xmode))
  4840. (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
  4841. (attrs (machine 32))
  4842. (mode xmode)
  4843. (choices
  4844. (.sym dst32-16-16-SB-relative-Unprefixed- xmode)
  4845. (.sym dst32-16-16-FB-relative-Unprefixed- xmode)
  4846. (.sym dst32-16-16-absolute-Unprefixed- xmode)
  4847. )
  4848. )
  4849. (define-anyof-operand
  4850. (name (.sym dst32-16-24-Unprefixed- xmode))
  4851. (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
  4852. (attrs (machine 32))
  4853. (mode xmode)
  4854. (choices
  4855. (.sym dst32-16-24-An-relative-Unprefixed- xmode)
  4856. (.sym dst32-16-24-absolute-Unprefixed- xmode)
  4857. )
  4858. )
  4859. )
  4860. )
  4861. (dst32-16-operand QI)
  4862. (dst32-16-operand HI)
  4863. (dst32-16-operand SI)
  4864. (define-pmacro (dst32-16-Ext-operand smode dmode)
  4865. (begin
  4866. (define-anyof-operand
  4867. (name (.sym dst32-16-ExtUnprefixed- smode))
  4868. (comment (.str "m32c destination operand of size " smode " with additional fields at offset 16"))
  4869. (attrs (machine 32))
  4870. (mode dmode)
  4871. (choices
  4872. (.sym dst32-Rn-direct-ExtUnprefixed- smode)
  4873. (.sym dst32-An-direct-Unprefixed- dmode) ; ExtUnprefixed mode not required for this operand -- use the normal dmode version
  4874. (.sym dst32-An-indirect-ExtUnprefixed- smode)
  4875. (.sym dst32-16-8-An-relative-ExtUnprefixed- smode)
  4876. (.sym dst32-16-16-An-relative-ExtUnprefixed- smode)
  4877. (.sym dst32-16-24-An-relative-ExtUnprefixed- smode)
  4878. (.sym dst32-16-8-SB-relative-ExtUnprefixed- smode)
  4879. (.sym dst32-16-16-SB-relative-ExtUnprefixed- smode)
  4880. (.sym dst32-16-8-FB-relative-ExtUnprefixed- smode)
  4881. (.sym dst32-16-16-FB-relative-ExtUnprefixed- smode)
  4882. (.sym dst32-16-16-absolute-ExtUnprefixed- smode)
  4883. (.sym dst32-16-24-absolute-ExtUnprefixed- smode)
  4884. )
  4885. )
  4886. )
  4887. )
  4888. (dst32-16-Ext-operand QI HI)
  4889. (dst32-16-Ext-operand HI SI)
  4890. (define-anyof-operand
  4891. (name dst32-16-Unprefixed-Mulex-HI)
  4892. (comment "m32c destination operand of size HI with additional fields at offset 16")
  4893. (attrs (machine 32))
  4894. (mode HI)
  4895. (choices
  4896. dst32-R3-direct-Unprefixed-HI
  4897. dst32-An-direct-Unprefixed-HI
  4898. dst32-An-indirect-Unprefixed-HI
  4899. dst32-16-8-An-relative-Unprefixed-HI
  4900. dst32-16-16-An-relative-Unprefixed-HI
  4901. dst32-16-24-An-relative-Unprefixed-HI
  4902. dst32-16-8-SB-relative-Unprefixed-HI
  4903. dst32-16-16-SB-relative-Unprefixed-HI
  4904. dst32-16-8-FB-relative-Unprefixed-HI
  4905. dst32-16-16-FB-relative-Unprefixed-HI
  4906. dst32-16-16-absolute-Unprefixed-HI
  4907. dst32-16-24-absolute-Unprefixed-HI
  4908. )
  4909. )
  4910. ;-------------------------------------------------------------
  4911. ; Destination operands with possible additional fields at offset 24 bits
  4912. ;-------------------------------------------------------------
  4913. (define-pmacro (dst16-24-operand xmode)
  4914. (begin
  4915. (define-anyof-operand
  4916. (name (.sym dst16-24- xmode))
  4917. (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 24"))
  4918. (attrs (machine 16))
  4919. (mode xmode)
  4920. (choices
  4921. (.sym dst16-Rn-direct- xmode)
  4922. (.sym dst16-An-direct- xmode)
  4923. (.sym dst16-An-indirect- xmode)
  4924. (.sym dst16-24-8-An-relative- xmode)
  4925. (.sym dst16-24-16-An-relative- xmode)
  4926. (.sym dst16-24-8-SB-relative- xmode)
  4927. (.sym dst16-24-16-SB-relative- xmode)
  4928. (.sym dst16-24-8-FB-relative- xmode)
  4929. (.sym dst16-24-16-absolute- xmode)
  4930. )
  4931. )
  4932. )
  4933. )
  4934. (dst16-24-operand QI)
  4935. (dst16-24-operand HI)
  4936. (define-pmacro (dst32-24-operand xmode)
  4937. (begin
  4938. (define-anyof-operand
  4939. (name (.sym dst32-24-Unprefixed- xmode))
  4940. (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
  4941. (attrs (machine 32))
  4942. (mode xmode)
  4943. (choices
  4944. (.sym dst32-Rn-direct-Unprefixed- xmode)
  4945. (.sym dst32-An-direct-Unprefixed- xmode)
  4946. (.sym dst32-An-indirect-Unprefixed- xmode)
  4947. (.sym dst32-24-8-An-relative-Unprefixed- xmode)
  4948. (.sym dst32-24-16-An-relative-Unprefixed- xmode)
  4949. (.sym dst32-24-24-An-relative-Unprefixed- xmode)
  4950. (.sym dst32-24-8-SB-relative-Unprefixed- xmode)
  4951. (.sym dst32-24-16-SB-relative-Unprefixed- xmode)
  4952. (.sym dst32-24-8-FB-relative-Unprefixed- xmode)
  4953. (.sym dst32-24-16-FB-relative-Unprefixed- xmode)
  4954. (.sym dst32-24-16-absolute-Unprefixed- xmode)
  4955. (.sym dst32-24-24-absolute-Unprefixed- xmode)
  4956. )
  4957. )
  4958. (define-anyof-operand
  4959. (name (.sym dst32-24-Prefixed- xmode))
  4960. (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
  4961. (attrs (machine 32))
  4962. (mode xmode)
  4963. (choices
  4964. (.sym dst32-Rn-direct-Prefixed- xmode)
  4965. (.sym dst32-An-direct-Prefixed- xmode)
  4966. (.sym dst32-An-indirect-Prefixed- xmode)
  4967. (.sym dst32-24-8-An-relative-Prefixed- xmode)
  4968. (.sym dst32-24-16-An-relative-Prefixed- xmode)
  4969. (.sym dst32-24-24-An-relative-Prefixed- xmode)
  4970. (.sym dst32-24-8-SB-relative-Prefixed- xmode)
  4971. (.sym dst32-24-16-SB-relative-Prefixed- xmode)
  4972. (.sym dst32-24-8-FB-relative-Prefixed- xmode)
  4973. (.sym dst32-24-16-FB-relative-Prefixed- xmode)
  4974. (.sym dst32-24-16-absolute-Prefixed- xmode)
  4975. (.sym dst32-24-24-absolute-Prefixed- xmode)
  4976. )
  4977. )
  4978. (define-anyof-operand
  4979. (name (.sym dst32-24-8-Prefixed- xmode))
  4980. (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
  4981. (attrs (machine 32))
  4982. (mode xmode)
  4983. (choices
  4984. (.sym dst32-24-8-An-relative-Prefixed- xmode)
  4985. (.sym dst32-24-8-SB-relative-Prefixed- xmode)
  4986. (.sym dst32-24-8-FB-relative-Prefixed- xmode)
  4987. )
  4988. )
  4989. (define-anyof-operand
  4990. (name (.sym dst32-24-16-Prefixed- xmode))
  4991. (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
  4992. (attrs (machine 32))
  4993. (mode xmode)
  4994. (choices
  4995. (.sym dst32-24-16-An-relative-Prefixed- xmode)
  4996. (.sym dst32-24-16-SB-relative-Prefixed- xmode)
  4997. (.sym dst32-24-16-FB-relative-Prefixed- xmode)
  4998. (.sym dst32-24-16-absolute-Prefixed- xmode)
  4999. )
  5000. )
  5001. (define-anyof-operand
  5002. (name (.sym dst32-24-24-Prefixed- xmode))
  5003. (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
  5004. (attrs (machine 32))
  5005. (mode xmode)
  5006. (choices
  5007. (.sym dst32-24-24-An-relative-Prefixed- xmode)
  5008. (.sym dst32-24-24-absolute-Prefixed- xmode)
  5009. )
  5010. )
  5011. ; (define-anyof-operand
  5012. ; (name (.sym dst32-24-indirect- xmode))
  5013. ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
  5014. ; (attrs (machine 32))
  5015. ; (mode xmode)
  5016. ; (choices
  5017. ; (.sym dst32-An-indirect-indirect- xmode)
  5018. ; (.sym dst32-24-8-An-relative-indirect- xmode)
  5019. ; (.sym dst32-24-16-An-relative-indirect- xmode)
  5020. ; (.sym dst32-24-24-An-relative-indirect- xmode)
  5021. ; (.sym dst32-24-8-SB-relative-indirect- xmode)
  5022. ; (.sym dst32-24-16-SB-relative-indirect- xmode)
  5023. ; (.sym dst32-24-8-FB-relative-indirect- xmode)
  5024. ; (.sym dst32-24-16-FB-relative-indirect- xmode)
  5025. ; )
  5026. ; )
  5027. ; (define-anyof-operand
  5028. ; (name (.sym dst32-basic-indirect- xmode))
  5029. ; (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
  5030. ; (attrs (machine 32))
  5031. ; (mode xmode)
  5032. ; (choices
  5033. ; (.sym dst32-An-indirect-indirect- xmode)
  5034. ; )
  5035. ; )
  5036. ; (define-anyof-operand
  5037. ; (name (.sym dst32-24-8-indirect- xmode))
  5038. ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
  5039. ; (attrs (machine 32))
  5040. ; (mode xmode)
  5041. ; (choices
  5042. ; (.sym dst32-24-8-An-relative-indirect- xmode)
  5043. ; (.sym dst32-24-8-SB-relative-indirect- xmode)
  5044. ; (.sym dst32-24-8-FB-relative-indirect- xmode)
  5045. ; )
  5046. ; )
  5047. ; (define-anyof-operand
  5048. ; (name (.sym dst32-24-16-indirect- xmode))
  5049. ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
  5050. ; (attrs (machine 32))
  5051. ; (mode xmode)
  5052. ; (choices
  5053. ; (.sym dst32-24-16-An-relative-indirect- xmode)
  5054. ; (.sym dst32-24-16-SB-relative-indirect- xmode)
  5055. ; (.sym dst32-24-16-FB-relative-indirect- xmode)
  5056. ; )
  5057. ; )
  5058. ; (define-anyof-operand
  5059. ; (name (.sym dst32-24-24-indirect- xmode))
  5060. ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
  5061. ; (attrs (machine 32))
  5062. ; (mode xmode)
  5063. ; (choices
  5064. ; (.sym dst32-24-24-An-relative-indirect- xmode)
  5065. ; )
  5066. ; )
  5067. ; (define-anyof-operand
  5068. ; (name (.sym dst32-24-absolute-indirect- xmode))
  5069. ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
  5070. ; (attrs (machine 32))
  5071. ; (mode xmode)
  5072. ; (choices
  5073. ; (.sym dst32-24-16-absolute-indirect-derived- xmode)
  5074. ; (.sym dst32-24-24-absolute-indirect-derived- xmode)
  5075. ; )
  5076. ; )
  5077. ; (define-anyof-operand
  5078. ; (name (.sym dst32-24-16-absolute-indirect- xmode))
  5079. ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
  5080. ; (attrs (machine 32))
  5081. ; (mode xmode)
  5082. ; (choices
  5083. ; (.sym dst32-24-16-absolute-indirect-derived- xmode)
  5084. ; )
  5085. ; )
  5086. ; (define-anyof-operand
  5087. ; (name (.sym dst32-24-24-absolute-indirect- xmode))
  5088. ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
  5089. ; (attrs (machine 32))
  5090. ; (mode xmode)
  5091. ; (choices
  5092. ; (.sym dst32-24-24-absolute-indirect-derived- xmode)
  5093. ; )
  5094. ; )
  5095. )
  5096. )
  5097. (dst32-24-operand QI)
  5098. (dst32-24-operand HI)
  5099. (dst32-24-operand SI)
  5100. ;-------------------------------------------------------------
  5101. ; Destination operands with possible additional fields at offset 32 bits
  5102. ;-------------------------------------------------------------
  5103. (define-pmacro (dst16-32-operand xmode)
  5104. (begin
  5105. (define-anyof-operand
  5106. (name (.sym dst16-32- xmode))
  5107. (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 32"))
  5108. (attrs (machine 16))
  5109. (mode xmode)
  5110. (choices
  5111. (.sym dst16-Rn-direct- xmode)
  5112. (.sym dst16-An-direct- xmode)
  5113. (.sym dst16-An-indirect- xmode)
  5114. (.sym dst16-32-8-An-relative- xmode)
  5115. (.sym dst16-32-16-An-relative- xmode)
  5116. (.sym dst16-32-8-SB-relative- xmode)
  5117. (.sym dst16-32-16-SB-relative- xmode)
  5118. (.sym dst16-32-8-FB-relative- xmode)
  5119. (.sym dst16-32-16-absolute- xmode)
  5120. )
  5121. )
  5122. )
  5123. )
  5124. (dst16-32-operand QI)
  5125. (dst16-32-operand HI)
  5126. ; This macro actually handles operands at offset 32, 40 and 48 bits
  5127. (define-pmacro (dst32-32plus-operand offset xmode)
  5128. (begin
  5129. (define-anyof-operand
  5130. (name (.sym dst32- offset -Unprefixed- xmode))
  5131. (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
  5132. (attrs (machine 32))
  5133. (mode xmode)
  5134. (choices
  5135. (.sym dst32-Rn-direct-Unprefixed- xmode)
  5136. (.sym dst32-An-direct-Unprefixed- xmode)
  5137. (.sym dst32-An-indirect-Unprefixed- xmode)
  5138. (.sym dst32- offset -8-An-relative-Unprefixed- xmode)
  5139. (.sym dst32- offset -16-An-relative-Unprefixed- xmode)
  5140. (.sym dst32- offset -24-An-relative-Unprefixed- xmode)
  5141. (.sym dst32- offset -8-SB-relative-Unprefixed- xmode)
  5142. (.sym dst32- offset -16-SB-relative-Unprefixed- xmode)
  5143. (.sym dst32- offset -8-FB-relative-Unprefixed- xmode)
  5144. (.sym dst32- offset -16-FB-relative-Unprefixed- xmode)
  5145. (.sym dst32- offset -16-absolute-Unprefixed- xmode)
  5146. (.sym dst32- offset -24-absolute-Unprefixed- xmode)
  5147. )
  5148. )
  5149. (define-anyof-operand
  5150. (name (.sym dst32- offset -Prefixed- xmode))
  5151. (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
  5152. (attrs (machine 32))
  5153. (mode xmode)
  5154. (choices
  5155. (.sym dst32-Rn-direct-Prefixed- xmode)
  5156. (.sym dst32-An-direct-Prefixed- xmode)
  5157. (.sym dst32-An-indirect-Prefixed- xmode)
  5158. (.sym dst32- offset -8-An-relative-Prefixed- xmode)
  5159. (.sym dst32- offset -16-An-relative-Prefixed- xmode)
  5160. (.sym dst32- offset -24-An-relative-Prefixed- xmode)
  5161. (.sym dst32- offset -8-SB-relative-Prefixed- xmode)
  5162. (.sym dst32- offset -16-SB-relative-Prefixed- xmode)
  5163. (.sym dst32- offset -8-FB-relative-Prefixed- xmode)
  5164. (.sym dst32- offset -16-FB-relative-Prefixed- xmode)
  5165. (.sym dst32- offset -16-absolute-Prefixed- xmode)
  5166. (.sym dst32- offset -24-absolute-Prefixed- xmode)
  5167. )
  5168. )
  5169. ; (define-anyof-operand
  5170. ; (name (.sym dst32- offset -indirect- xmode))
  5171. ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
  5172. ; (attrs (machine 32))
  5173. ; (mode xmode)
  5174. ; (choices
  5175. ; (.sym dst32-An-indirect-indirect- xmode)
  5176. ; (.sym dst32- offset -8-An-relative-indirect- xmode)
  5177. ; (.sym dst32- offset -16-An-relative-indirect- xmode)
  5178. ; (.sym dst32- offset -24-An-relative-indirect- xmode)
  5179. ; (.sym dst32- offset -8-SB-relative-indirect- xmode)
  5180. ; (.sym dst32- offset -16-SB-relative-indirect- xmode)
  5181. ; (.sym dst32- offset -8-FB-relative-indirect- xmode)
  5182. ; (.sym dst32- offset -16-FB-relative-indirect- xmode)
  5183. ; )
  5184. ; )
  5185. ; (define-anyof-operand
  5186. ; (name (.sym dst32- offset -absolute-indirect- xmode))
  5187. ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
  5188. ; (attrs (machine 32))
  5189. ; (mode xmode)
  5190. ; (choices
  5191. ; (.sym dst32- offset -16-absolute-indirect-derived- xmode)
  5192. ; (.sym dst32- offset -24-absolute-indirect-derived- xmode)
  5193. ; )
  5194. ; )
  5195. )
  5196. )
  5197. (dst32-32plus-operand 32 QI)
  5198. (dst32-32plus-operand 32 HI)
  5199. (dst32-32plus-operand 32 SI)
  5200. (dst32-32plus-operand 40 QI)
  5201. (dst32-32plus-operand 40 HI)
  5202. (dst32-32plus-operand 40 SI)
  5203. ;-------------------------------------------------------------
  5204. ; Destination operands with possible additional fields at offset 48 bits
  5205. ;-------------------------------------------------------------
  5206. (define-pmacro (dst32-48-operand offset xmode)
  5207. (begin
  5208. (define-anyof-operand
  5209. (name (.sym dst32- offset -Prefixed- xmode))
  5210. (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
  5211. (attrs (machine 32))
  5212. (mode xmode)
  5213. (choices
  5214. (.sym dst32-Rn-direct-Prefixed- xmode)
  5215. (.sym dst32-An-direct-Prefixed- xmode)
  5216. (.sym dst32-An-indirect-Prefixed- xmode)
  5217. (.sym dst32- offset -8-An-relative-Prefixed- xmode)
  5218. (.sym dst32- offset -16-An-relative-Prefixed- xmode)
  5219. (.sym dst32- offset -24-An-relative-Prefixed- xmode)
  5220. (.sym dst32- offset -8-SB-relative-Prefixed- xmode)
  5221. (.sym dst32- offset -16-SB-relative-Prefixed- xmode)
  5222. (.sym dst32- offset -8-FB-relative-Prefixed- xmode)
  5223. (.sym dst32- offset -16-FB-relative-Prefixed- xmode)
  5224. (.sym dst32- offset -16-absolute-Prefixed- xmode)
  5225. (.sym dst32- offset -24-absolute-Prefixed- xmode)
  5226. )
  5227. )
  5228. ; (define-anyof-operand
  5229. ; (name (.sym dst32- offset -indirect- xmode))
  5230. ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
  5231. ; (attrs (machine 32))
  5232. ; (mode xmode)
  5233. ; (choices
  5234. ; (.sym dst32-An-indirect-indirect- xmode)
  5235. ; (.sym dst32- offset -8-An-relative-indirect- xmode)
  5236. ; (.sym dst32- offset -16-An-relative-indirect- xmode)
  5237. ; (.sym dst32- offset -24-An-relative-indirect- xmode)
  5238. ; (.sym dst32- offset -8-SB-relative-indirect- xmode)
  5239. ; (.sym dst32- offset -16-SB-relative-indirect- xmode)
  5240. ; (.sym dst32- offset -8-FB-relative-indirect- xmode)
  5241. ; (.sym dst32- offset -16-FB-relative-indirect- xmode)
  5242. ; )
  5243. ; )
  5244. ; (define-anyof-operand
  5245. ; (name (.sym dst32- offset -absolute-indirect- xmode))
  5246. ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
  5247. ; (attrs (machine 32))
  5248. ; (mode xmode)
  5249. ; (choices
  5250. ; (.sym dst32- offset -16-absolute-indirect-derived- xmode)
  5251. ; (.sym dst32- offset -24-absolute-indirect-derived- xmode)
  5252. ; )
  5253. ; )
  5254. )
  5255. )
  5256. (dst32-48-operand 48 QI)
  5257. (dst32-48-operand 48 HI)
  5258. (dst32-48-operand 48 SI)
  5259. ;-------------------------------------------------------------
  5260. ; Bit operands for m16c
  5261. ;-------------------------------------------------------------
  5262. (define-pmacro (bit16-operand offset)
  5263. (begin
  5264. (define-anyof-operand
  5265. (name (.sym bit16- offset))
  5266. (comment (.str "m16c bit operand with possible additional fields at offset 24"))
  5267. (attrs (machine 16))
  5268. (mode BI)
  5269. (choices
  5270. bit16-Rn-direct
  5271. bit16-An-direct
  5272. bit16-An-indirect
  5273. (.sym bit16- offset -8-An-relative)
  5274. (.sym bit16- offset -16-An-relative)
  5275. (.sym bit16- offset -8-SB-relative)
  5276. (.sym bit16- offset -16-SB-relative)
  5277. (.sym bit16- offset -8-FB-relative)
  5278. (.sym bit16- offset -16-absolute)
  5279. )
  5280. )
  5281. (define-anyof-operand
  5282. (name (.sym bit16- offset -basic))
  5283. (comment (.str "m16c bit operand with no additional fields"))
  5284. (attrs (machine 16))
  5285. (mode BI)
  5286. (choices
  5287. bit16-An-indirect
  5288. )
  5289. )
  5290. (define-anyof-operand
  5291. (name (.sym bit16- offset -8))
  5292. (comment (.str "m16c bit operand with possible additional fields at offset 24"))
  5293. (attrs (machine 16))
  5294. (mode BI)
  5295. (choices
  5296. bit16-Rn-direct
  5297. bit16-An-direct
  5298. (.sym bit16- offset -8-An-relative)
  5299. (.sym bit16- offset -8-SB-relative)
  5300. (.sym bit16- offset -8-FB-relative)
  5301. )
  5302. )
  5303. (define-anyof-operand
  5304. (name (.sym bit16- offset -16))
  5305. (comment (.str "m16c bit operand with possible additional fields at offset 24"))
  5306. (attrs (machine 16))
  5307. (mode BI)
  5308. (choices
  5309. (.sym bit16- offset -16-An-relative)
  5310. (.sym bit16- offset -16-SB-relative)
  5311. (.sym bit16- offset -16-absolute)
  5312. )
  5313. )
  5314. )
  5315. )
  5316. (bit16-operand 16)
  5317. ;-------------------------------------------------------------
  5318. ; Bit operands for m32c
  5319. ;-------------------------------------------------------------
  5320. (define-pmacro (bit32-operand offset group)
  5321. (begin
  5322. (define-anyof-operand
  5323. (name (.sym bit32- offset - group))
  5324. (comment (.str "m32c bit operand with possible additional fields at offset 24"))
  5325. (attrs (machine 32))
  5326. (mode BI)
  5327. (choices
  5328. (.sym bit32-Rn-direct- group)
  5329. (.sym bit32-An-direct- group)
  5330. (.sym bit32-An-indirect- group)
  5331. (.sym bit32- offset -11-An-relative- group)
  5332. (.sym bit32- offset -19-An-relative- group)
  5333. (.sym bit32- offset -27-An-relative- group)
  5334. (.sym bit32- offset -11-SB-relative- group)
  5335. (.sym bit32- offset -19-SB-relative- group)
  5336. (.sym bit32- offset -11-FB-relative- group)
  5337. (.sym bit32- offset -19-FB-relative- group)
  5338. (.sym bit32- offset -19-absolute- group)
  5339. (.sym bit32- offset -27-absolute- group)
  5340. )
  5341. )
  5342. )
  5343. )
  5344. (bit32-operand 16 Unprefixed)
  5345. (bit32-operand 24 Prefixed)
  5346. (define-anyof-operand
  5347. (name bit32-basic-Unprefixed)
  5348. (comment "m32c bit operand with no additional fields")
  5349. (attrs (machine 32))
  5350. (mode BI)
  5351. (choices
  5352. bit32-Rn-direct-Unprefixed
  5353. bit32-An-direct-Unprefixed
  5354. bit32-An-indirect-Unprefixed
  5355. )
  5356. )
  5357. (define-anyof-operand
  5358. (name bit32-16-8-Unprefixed)
  5359. (comment "m32c bit operand with 8 bit additional fields")
  5360. (attrs (machine 32))
  5361. (mode BI)
  5362. (choices
  5363. bit32-16-11-An-relative-Unprefixed
  5364. bit32-16-11-SB-relative-Unprefixed
  5365. bit32-16-11-FB-relative-Unprefixed
  5366. )
  5367. )
  5368. (define-anyof-operand
  5369. (name bit32-16-16-Unprefixed)
  5370. (comment "m32c bit operand with 16 bit additional fields")
  5371. (attrs (machine 32))
  5372. (mode BI)
  5373. (choices
  5374. bit32-16-19-An-relative-Unprefixed
  5375. bit32-16-19-SB-relative-Unprefixed
  5376. bit32-16-19-FB-relative-Unprefixed
  5377. bit32-16-19-absolute-Unprefixed
  5378. )
  5379. )
  5380. (define-anyof-operand
  5381. (name bit32-16-24-Unprefixed)
  5382. (comment "m32c bit operand with 24 bit additional fields")
  5383. (attrs (machine 32))
  5384. (mode BI)
  5385. (choices
  5386. bit32-16-27-An-relative-Unprefixed
  5387. bit32-16-27-absolute-Unprefixed
  5388. )
  5389. )
  5390. ;-------------------------------------------------------------
  5391. ; Operands for short format binary insns
  5392. ;-------------------------------------------------------------
  5393. (define-anyof-operand
  5394. (name src16-2-S)
  5395. (comment "m16c source operand of size QI for short format insns")
  5396. (attrs (machine 16))
  5397. (mode QI)
  5398. (choices
  5399. src16-2-S-8-SB-relative-QI
  5400. src16-2-S-8-FB-relative-QI
  5401. src16-2-S-16-absolute-QI
  5402. )
  5403. )
  5404. (define-anyof-operand
  5405. (name src32-2-S-QI)
  5406. (comment "m32c source operand of size QI for short format insns")
  5407. (attrs (machine 32))
  5408. (mode QI)
  5409. (choices
  5410. src32-2-S-8-SB-relative-QI
  5411. src32-2-S-8-FB-relative-QI
  5412. src32-2-S-16-absolute-QI
  5413. )
  5414. )
  5415. (define-anyof-operand
  5416. (name src32-2-S-HI)
  5417. (comment "m32c source operand of size QI for short format insns")
  5418. (attrs (machine 32))
  5419. (mode HI)
  5420. (choices
  5421. src32-2-S-8-SB-relative-HI
  5422. src32-2-S-8-FB-relative-HI
  5423. src32-2-S-16-absolute-HI
  5424. )
  5425. )
  5426. (define-anyof-operand
  5427. (name Dst16-3-S-8)
  5428. (comment "m16c destination operand of size QI for short format insns")
  5429. (attrs (machine 16))
  5430. (mode QI)
  5431. (choices
  5432. dst16-3-S-R0l-direct-QI
  5433. dst16-3-S-R0h-direct-QI
  5434. dst16-3-S-8-8-SB-relative-QI
  5435. dst16-3-S-8-8-FB-relative-QI
  5436. dst16-3-S-8-16-absolute-QI
  5437. )
  5438. )
  5439. (define-anyof-operand
  5440. (name Dst16-3-S-16)
  5441. (comment "m16c destination operand of size QI for short format insns")
  5442. (attrs (machine 16))
  5443. (mode QI)
  5444. (choices
  5445. dst16-3-S-R0l-direct-QI
  5446. dst16-3-S-R0h-direct-QI
  5447. dst16-3-S-16-8-SB-relative-QI
  5448. dst16-3-S-16-8-FB-relative-QI
  5449. dst16-3-S-16-16-absolute-QI
  5450. )
  5451. )
  5452. (define-anyof-operand
  5453. (name srcdst16-r0l-r0h-S)
  5454. (comment "m16c r0l/r0h operand of size QI for short format insns")
  5455. (attrs (machine 16))
  5456. (mode SI)
  5457. (choices
  5458. srcdst16-r0l-r0h-S-derived
  5459. )
  5460. )
  5461. (define-anyof-operand
  5462. (name dst32-2-S-basic-QI)
  5463. (comment "m32c r0l operand of size QI for short format binary insns")
  5464. (attrs (machine 32))
  5465. (mode QI)
  5466. (choices
  5467. dst32-2-S-R0l-direct-QI
  5468. )
  5469. )
  5470. (define-anyof-operand
  5471. (name dst32-2-S-basic-HI)
  5472. (comment "m32c r0 operand of size HI for short format binary insns")
  5473. (attrs (machine 32))
  5474. (mode HI)
  5475. (choices
  5476. dst32-2-S-R0-direct-HI
  5477. )
  5478. )
  5479. (define-pmacro (dst32-2-S-operands xmode)
  5480. (begin
  5481. (define-anyof-operand
  5482. (name (.sym dst32-2-S-8- xmode))
  5483. (comment "m32c operand of size " xmode " for short format binary insns")
  5484. (attrs (machine 32))
  5485. (mode xmode)
  5486. (choices
  5487. (.sym dst32-2-S-8-SB-relative- xmode)
  5488. (.sym dst32-2-S-8-FB-relative- xmode)
  5489. )
  5490. )
  5491. (define-anyof-operand
  5492. (name (.sym dst32-2-S-16- xmode))
  5493. (comment "m32c operand of size " xmode " for short format binary insns")
  5494. (attrs (machine 32))
  5495. (mode xmode)
  5496. (choices
  5497. (.sym dst32-2-S-16-absolute- xmode)
  5498. )
  5499. )
  5500. ; (define-anyof-operand
  5501. ; (name (.sym dst32-2-S-8-indirect- xmode))
  5502. ; (comment "m32c operand of size " xmode " for short format binary insns")
  5503. ; (attrs (machine 32))
  5504. ; (mode xmode)
  5505. ; (choices
  5506. ; (.sym dst32-2-S-8-SB-relative-indirect- xmode)
  5507. ; (.sym dst32-2-S-8-FB-relative-indirect- xmode)
  5508. ; )
  5509. ; )
  5510. ; (define-anyof-operand
  5511. ; (name (.sym dst32-2-S-absolute-indirect- xmode))
  5512. ; (comment "m32c operand of size " xmode " for short format binary insns")
  5513. ; (attrs (machine 32))
  5514. ; (mode xmode)
  5515. ; (choices
  5516. ; (.sym dst32-2-S-16-absolute-indirect- xmode)
  5517. ; )
  5518. ; )
  5519. )
  5520. )
  5521. (dst32-2-S-operands QI)
  5522. (dst32-2-S-operands HI)
  5523. (dst32-2-S-operands SI)
  5524. (define-anyof-operand
  5525. (name dst32-an-S)
  5526. (comment "m32c An operand for short format binary insns")
  5527. (attrs (machine 32))
  5528. (mode HI)
  5529. (choices
  5530. dst32-1-S-A0-direct-HI
  5531. dst32-1-S-A1-direct-HI
  5532. )
  5533. )
  5534. (define-anyof-operand
  5535. (name bit16-11-S)
  5536. (comment "m16c bit operand for short format insns")
  5537. (attrs (machine 16))
  5538. (mode BI)
  5539. (choices
  5540. bit16-11-SB-relative-S
  5541. )
  5542. )
  5543. (define-anyof-operand
  5544. (name Rn16-push-S-anyof)
  5545. (comment "m16c bit operand for short format insns")
  5546. (attrs (machine 16))
  5547. (mode QI)
  5548. (choices
  5549. Rn16-push-S-derived
  5550. )
  5551. )
  5552. (define-anyof-operand
  5553. (name An16-push-S-anyof)
  5554. (comment "m16c bit operand for short format insns")
  5555. (attrs (machine 16))
  5556. (mode HI)
  5557. (choices
  5558. An16-push-S-derived
  5559. )
  5560. )
  5561. ;=============================================================
  5562. ; Common macros for instruction definitions
  5563. ;
  5564. (define-pmacro (set-z x)
  5565. (sequence ()
  5566. (set zbit (zflag x)))
  5567. )
  5568. (define-pmacro (set-s x)
  5569. (sequence ()
  5570. (set sbit (nflag x)))
  5571. )
  5572. (define-pmacro (set-z-and-s x)
  5573. (sequence ()
  5574. (set-z x)
  5575. (set-s x))
  5576. )
  5577. ;=============================================================
  5578. ; Unary insn macros
  5579. ;-------------------------------------------------------------
  5580. (define-pmacro (unary-insn-defn-g mach group mode wstr op encoding sem opg)
  5581. (dni (.sym op mach wstr - group)
  5582. (.str op wstr opg " dst" mach "-" group "-" mode)
  5583. ((machine mach) RL_1ADDR)
  5584. (.str op wstr opg " ${dst" mach "-" group "-" mode "}")
  5585. encoding
  5586. (sem mode (.sym dst mach - group - mode))
  5587. ())
  5588. )
  5589. (define-pmacro (unary-insn-defn mach group mode wstr op encoding sem)
  5590. (unary-insn-defn-g mach group mode wstr op encoding sem "")
  5591. )
  5592. (define-pmacro (unary16-defn-g mode wstr wbit op opc1 opc2 opc3 sem opg)
  5593. (unary-insn-defn-g 16 16 mode wstr op
  5594. (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16- mode))
  5595. sem opg)
  5596. )
  5597. (define-pmacro (unary16-defn mode wstr wbit op opc1 opc2 opc3 sem)
  5598. (unary-16-defn-g mode wstr wbit op opc1 opc2 opc3 sem "")
  5599. )
  5600. (define-pmacro (unary32-defn-g mode wstr wbit op opc1 opc2 opc3 sem opg)
  5601. (begin
  5602. ; Multi insns are tried for assembly in the reverse order in which they appear here, so
  5603. ; define the absolute-indirect insns first in order to prevent them from being selected
  5604. ; when the mode is register-indirect
  5605. ; (unary-insn-defn 32 24-absolute-indirect mode wstr op
  5606. ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-15-1 wbit) (.sym dst32-24-absolute-indirect- mode) (f-18-2 opc2) (f-20-4 opc3))
  5607. ; sem)
  5608. (unary-insn-defn-g 32 16-Unprefixed mode wstr op
  5609. (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3))
  5610. sem opg)
  5611. ; (unary-insn-defn 32 24-indirect mode wstr op
  5612. ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-15-1 wbit) (.sym dst32-24-indirect- mode) (f-18-2 opc2) (f-20-4 opc3))
  5613. ; sem)
  5614. )
  5615. )
  5616. (define-pmacro (unary32-defn mode wstr wbit op opc1 opc2 opc3 sem)
  5617. (unary32-defn-g mode wstr wbit op opc1 opc2 opc3 sem "")
  5618. )
  5619. (define-pmacro (unary-insn-mach-g mach op opc1 opc2 opc3 sem opg)
  5620. (begin
  5621. (.apply (.sym unary mach -defn-g) (QI .b 0 op opc1 opc2 opc3 sem opg))
  5622. (.apply (.sym unary mach -defn-g) (HI .w 1 op opc1 opc2 opc3 sem opg))
  5623. )
  5624. )
  5625. (define-pmacro (unary-insn-mach mach op opc1 opc2 opc3 sem)
  5626. (unary-insn-mach-g mach op opc1 opc2 opc3 sem "")
  5627. )
  5628. (define-pmacro (unary-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
  5629. (begin
  5630. (unary-insn-mach-g 16 op opc16-1 opc16-2 opc16-3 sem "")
  5631. (unary-insn-mach-g 32 op opc32-1 opc32-2 opc32-3 sem "")
  5632. )
  5633. )
  5634. (define-pmacro (unary-insn-g op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
  5635. (begin
  5636. (unary-insn-mach-g 16 op opc16-1 opc16-2 opc16-3 sem "$G")
  5637. (unary-insn-mach-g 32 op opc32-1 opc32-2 opc32-3 sem "$G")
  5638. )
  5639. )
  5640. ;-------------------------------------------------------------
  5641. ; Sign/zero extension macros
  5642. ;-------------------------------------------------------------
  5643. (define-pmacro (ext-insn-defn mach group smode dmode wstr op encoding sem)
  5644. (dni (.sym op mach wstr - group)
  5645. (.str op wstr " dst" mach "-" group "-" smode)
  5646. ((machine mach))
  5647. (.str op wstr " ${dst" mach "-" group "-" smode "}")
  5648. encoding
  5649. (sem smode dmode (.sym dst mach - group - smode) (.sym dst mach - group - smode))
  5650. ())
  5651. )
  5652. (define-pmacro (ext16-defn smode dmode wstr wbit op opc1 opc2 opc3 sem)
  5653. (ext-insn-defn 16 16-Ext smode dmode wstr op
  5654. (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-Ext- smode))
  5655. sem)
  5656. )
  5657. (define-pmacro (ext32-defn smode dmode wstr wbit op opc1 opc2 opc3 sem)
  5658. (ext-insn-defn 32 16-ExtUnprefixed smode dmode wstr op
  5659. (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst32-16-ExtUnprefixed- smode))
  5660. sem)
  5661. )
  5662. (define-pmacro (ext32-binary-insn src-group dst-group op wstr encoding sem)
  5663. (dni (.sym op 32 wstr - src-group - dst-group)
  5664. (.str op 32 wstr " src32-" src-group "-QI,dst32-" dst-group "-HI")
  5665. ((machine 32))
  5666. (.str op wstr " ${src32-" src-group "-QI},${dst32-" dst-group "-HI}")
  5667. encoding
  5668. (sem QI HI (.sym src32- src-group -QI) (.sym dst32 - dst-group -HI))
  5669. ())
  5670. )
  5671. (define-pmacro (ext32-binary-defn op wstr opc1 opc2 sem)
  5672. (begin
  5673. (ext32-binary-insn basic-ExtPrefixed 24-Prefixed op wstr
  5674. (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 0) src32-basic-ExtPrefixed-QI dst32-24-Prefixed-HI (f-20-4 opc2))
  5675. sem)
  5676. (ext32-binary-insn 24-24-Prefixed 48-Prefixed op wstr
  5677. (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 0) src32-24-24-Prefixed-QI dst32-48-Prefixed-HI (f-20-4 opc2))
  5678. sem)
  5679. (ext32-binary-insn 24-16-Prefixed 40-Prefixed op wstr
  5680. (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 0) src32-24-16-Prefixed-QI dst32-40-Prefixed-HI (f-20-4 opc2))
  5681. sem)
  5682. (ext32-binary-insn 24-8-Prefixed 32-Prefixed op wstr
  5683. (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 0) src32-24-8-Prefixed-QI dst32-32-Prefixed-HI (f-20-4 opc2))
  5684. sem)
  5685. )
  5686. )
  5687. ;=============================================================
  5688. ; Binary Arithmetic macros
  5689. ;
  5690. ;-------------------------------------------------------------
  5691. ;<arith>.size:S src2,r0[l] -- for m32c
  5692. ;-------------------------------------------------------------
  5693. (define-pmacro (binary-arith32-S-src2 op xmode wstr wbit opc1 opc2 sem)
  5694. (dni (.sym op 32 wstr .S-src2-r0- xmode)
  5695. (.str op 32 wstr ":S src2,r0[l]")
  5696. ((machine 32))
  5697. (.str op wstr"$S ${src32-2-S-" xmode "},${Dst32R0" xmode "-S}")
  5698. (+ opc1 opc2 (.sym src32-2-S- xmode) (f-7-1 wbit))
  5699. (sem xmode (.sym src32-2-S- xmode) (.sym Dst32R0 xmode -S))
  5700. ())
  5701. )
  5702. ;-------------------------------------------------------------
  5703. ;<arith>.b:S src2,r0l/r0h -- for m16c
  5704. ;-------------------------------------------------------------
  5705. (define-pmacro (binary-arith16-b-S-src2 op opc1 opc2 sem)
  5706. (begin
  5707. (dni (.sym op 16 .b.S-src2)
  5708. (.str op ".b:S src2,r0[lh]")
  5709. ((machine 16))
  5710. (.str op ".b$S ${src16-2-S},${Dst16RnQI-S}")
  5711. (+ opc1 opc2 Dst16RnQI-S src16-2-S)
  5712. (sem QI src16-2-S Dst16RnQI-S)
  5713. ())
  5714. (dni (.sym op 16 .b.S-r0l-r0h)
  5715. (.str op ".b:S r0l/r0h")
  5716. ((machine 16))
  5717. (.str op ".b$S ${srcdst16-r0l-r0h-S}")
  5718. (+ opc1 opc2 srcdst16-r0l-r0h-S)
  5719. (if (eq srcdst16-r0l-r0h-S 0)
  5720. (sem QI R0h R0l)
  5721. (sem QI R0l R0h))
  5722. ())
  5723. )
  5724. )
  5725. ;-------------------------------------------------------------
  5726. ;<arith>.b:S #imm8,dst3 -- for m16c
  5727. ;-------------------------------------------------------------
  5728. (define-pmacro (binary-arith16-b-S-imm8-dst3 op sz opc1 opc2 sem)
  5729. (dni (.sym op 16 .b.S-imm8-dst3)
  5730. (.str op sz ":S imm8,dst3")
  5731. ((machine 16))
  5732. (.str op sz "$S #${Imm-8-QI},${Dst16-3-S-16}")
  5733. (+ opc1 opc2 Dst16-3-S-16 Imm-8-QI)
  5734. (sem QI Imm-8-QI Dst16-3-S-16)
  5735. ())
  5736. )
  5737. ;-------------------------------------------------------------
  5738. ;<arith>.size:Q #imm4,sp -- for m16c
  5739. ;-------------------------------------------------------------
  5740. (define-pmacro (binary-arith16-Q-sp op opc1 opc2 opc3 sem)
  5741. (dni (.sym op 16 -wQ-sp)
  5742. (.str op ".w:q #imm4,sp")
  5743. ((machine 16))
  5744. (.str op ".w$Q #${Imm-12-s4},sp")
  5745. (+ opc1 opc2 opc3 Imm-12-s4)
  5746. (sem QI Imm-12-s4 sp)
  5747. ())
  5748. )
  5749. ;-------------------------------------------------------------
  5750. ;<arith>.size:G #imm,sp -- for m16c
  5751. ;-------------------------------------------------------------
  5752. (define-pmacro (binary-arith16-G-sp-defn mode wstr wbit op opc1 opc2 opc3 opc4 sem)
  5753. (dni (.sym op 16 wstr - G-sp)
  5754. (.str op wstr " imm-sp " mode)
  5755. ((machine 16))
  5756. (.str op wstr "$G #${Imm-16-" mode "},sp")
  5757. (+ opc1 opc2 (f-7-1 wbit) opc3 opc4 (.sym Imm-16- mode))
  5758. (sem mode (.sym Imm-16- mode) sp)
  5759. ())
  5760. )
  5761. (define-pmacro (binary-arith16-G-sp op opc1 opc2 opc3 opc4 sem)
  5762. (begin
  5763. (binary-arith16-G-sp-defn QI .b 0 op opc1 opc2 opc3 opc4 sem)
  5764. (binary-arith16-G-sp-defn HI .w 1 op opc1 opc2 opc3 opc4 sem)
  5765. )
  5766. )
  5767. ;-------------------------------------------------------------
  5768. ;<arith>.size:G #imm,dst -- for m16c and m32c
  5769. ;-------------------------------------------------------------
  5770. (define-pmacro (binary-arith-imm-dst-defn mach src dstgroup dmode wstr op suffix encoding sem)
  5771. (dni (.sym op mach wstr - imm-G - dstgroup)
  5772. (.str op wstr " " mach "-imm-G-" dstgroup "-" dmode)
  5773. ((machine mach) RL_1ADDR)
  5774. (.str op wstr "$"suffix " #${" src "},${dst" mach "-" dstgroup "-" dmode "}")
  5775. encoding
  5776. (sem dmode src (.sym dst mach - dstgroup - dmode))
  5777. ())
  5778. )
  5779. ; m16c variants
  5780. (define-pmacro (binary-arith16-imm-dst-defn smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
  5781. (begin
  5782. (binary-arith-imm-dst-defn 16 (.sym Imm-32- smode) 16-16 dmode wstr op suffix
  5783. (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-16- dmode) (.sym Imm-32- smode))
  5784. sem)
  5785. (binary-arith-imm-dst-defn 16 (.sym Imm-24- smode) 16-8 dmode wstr op suffix
  5786. (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-8- dmode) (.sym Imm-24- smode))
  5787. sem)
  5788. (binary-arith-imm-dst-defn 16 (.sym Imm-16- smode) basic dmode wstr op suffix
  5789. (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-basic- dmode) (.sym Imm-16- smode))
  5790. sem)
  5791. )
  5792. )
  5793. ; m32c Unprefixed variants
  5794. (define-pmacro (binary-arith32-imm-dst-Unprefixed smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
  5795. (begin
  5796. (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 16-24-Unprefixed dmode wstr op suffix
  5797. (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3) (.sym dst32-16-24-Unprefixed- dmode) (.sym Imm-40- smode))
  5798. sem)
  5799. (binary-arith-imm-dst-defn 32 (.sym Imm-32- smode) 16-16-Unprefixed dmode wstr op suffix
  5800. (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3) (.sym dst32-16-16-Unprefixed- dmode) (.sym Imm-32- smode))
  5801. sem)
  5802. (binary-arith-imm-dst-defn 32 (.sym Imm-24- smode) 16-8-Unprefixed dmode wstr op suffix
  5803. (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3) (.sym dst32-16-8-Unprefixed- dmode) (.sym Imm-24- smode))
  5804. sem)
  5805. (binary-arith-imm-dst-defn 32 (.sym Imm-16- smode) basic-Unprefixed dmode wstr op suffix
  5806. (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3) (.sym dst32-basic-Unprefixed- dmode) (.sym Imm-16- smode))
  5807. sem)
  5808. )
  5809. )
  5810. ; m32c Prefixed variants
  5811. (define-pmacro (binary-arith32-imm-dst-Prefixed smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
  5812. (begin
  5813. (binary-arith-imm-dst-defn 32 (.sym Imm-48- smode) 24-24-Prefixed dmode wstr op suffix
  5814. (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-24-Prefixed- dmode) (.sym Imm-48- smode))
  5815. sem)
  5816. (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 24-16-Prefixed dmode wstr op suffix
  5817. (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-16-Prefixed- dmode) (.sym Imm-40- smode))
  5818. sem)
  5819. (binary-arith-imm-dst-defn 32 (.sym Imm-32- smode) 24-8-Prefixed dmode wstr op suffix
  5820. (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-8-Prefixed- dmode) (.sym Imm-32- smode))
  5821. sem)
  5822. (binary-arith-imm-dst-defn 32 (.sym Imm-24- smode) basic-Prefixed dmode wstr op suffix
  5823. (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-basic-Prefixed- dmode) (.sym Imm-24- smode))
  5824. sem)
  5825. )
  5826. )
  5827. ; All m32c variants
  5828. (define-pmacro (binary-arith32-imm-dst-defn smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
  5829. (begin
  5830. ; Multi insns are tried for assembly in the reverse order in which they appear here, so
  5831. ; define the absolute-indirect insns first in order to prevent them from being selected
  5832. ; when the mode is register-indirect
  5833. ; (binary-arith-imm-dst-defn 32 (.sym Imm-48- smode) 24-24-absolute-indirect dmode wstr op suffix
  5834. ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-24-absolute-indirect- dmode) (.sym Imm-48- smode))
  5835. ; sem)
  5836. ; (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 24-16-absolute-indirect dmode wstr op suffix
  5837. ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-16-absolute-indirect- dmode) (.sym Imm-40- smode))
  5838. ; sem)
  5839. ; Unprefixed modes next
  5840. (binary-arith32-imm-dst-Unprefixed smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
  5841. ; Remaining indirect modes
  5842. ; (binary-arith-imm-dst-defn 32 (.sym Imm-24- smode) basic-indirect dmode wstr op suffix
  5843. ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-basic-indirect- dmode) (.sym Imm-24- smode))
  5844. ; sem)
  5845. ; (binary-arith-imm-dst-defn 32 (.sym Imm-48- smode) 24-24-indirect dmode wstr op suffix
  5846. ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-24-indirect- dmode) (.sym Imm-48- smode))
  5847. ; sem)
  5848. ; (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 24-16-indirect dmode wstr op suffix
  5849. ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-16-indirect- dmode) (.sym Imm-40- smode))
  5850. ; sem)
  5851. ; (binary-arith-imm-dst-defn 32 (.sym Imm-32- smode) 24-8-indirect dmode wstr op suffix
  5852. ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-8-indirect- dmode) (.sym Imm-32- smode))
  5853. ; sem)
  5854. )
  5855. )
  5856. (define-pmacro (binary-arith-imm-dst-mach mach op suffix opc1 opc2 opc3 sem)
  5857. (begin
  5858. (.apply (.sym binary-arith mach -imm-dst-defn) (QI QI .b 0 op suffix opc1 opc2 opc3 sem))
  5859. (.apply (.sym binary-arith mach -imm-dst-defn) (HI HI .w 1 op suffix opc1 opc2 opc3 sem))
  5860. )
  5861. )
  5862. (define-pmacro (binary-arith-imm-dst op suffix opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
  5863. (begin
  5864. (binary-arith-imm-dst-mach 16 op suffix opc16-1 opc16-2 opc16-3 sem)
  5865. (binary-arith-imm-dst-mach 32 op suffix opc32-1 opc32-2 opc32-3 sem)
  5866. )
  5867. )
  5868. ;-------------------------------------------------------------
  5869. ;<arith>.size:Q #imm4,dst -- for m16c and m32c
  5870. ;-------------------------------------------------------------
  5871. (define-pmacro (binary-arith-imm4-dst-defn mach src dstgroup mode wstr op encoding sem)
  5872. (dni (.sym op mach wstr - imm4-Q - dstgroup)
  5873. (.str op wstr " " mach "-imm4-Q-" dstgroup "-" mode)
  5874. ((machine mach) RL_1ADDR)
  5875. (.str op wstr "$Q #${" src "},${dst" mach "-" dstgroup "-" mode "}")
  5876. encoding
  5877. (sem mode src (.sym dst mach - dstgroup - mode))
  5878. ())
  5879. )
  5880. ; m16c variants
  5881. (define-pmacro (binary-arith16-imm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem)
  5882. (binary-arith-imm4-dst-defn 16 Imm-8-s4 16 mode wstr op
  5883. (+ opc1 opc2 (f-7-1 wbit2) Imm-8-s4 (.sym dst16-16- mode))
  5884. sem)
  5885. )
  5886. (define-pmacro (binary-arith16-shimm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem)
  5887. (binary-arith-imm4-dst-defn 16 Imm-sh-8-s4 16 mode wstr op
  5888. (+ opc1 opc2 (f-7-1 wbit2) Imm-sh-8-s4 (.sym dst16-16- mode))
  5889. sem)
  5890. )
  5891. ; m32c variants
  5892. (define-pmacro (binary-arith32-imm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem)
  5893. (begin
  5894. ; Multi insns are tried for assembly in the reverse order in which they appear here, so
  5895. ; define the absolute-indirect insns first in order to prevent them from being selected
  5896. ; when the mode is register-indirect
  5897. ; (binary-arith-imm4-dst-defn 32 Imm-20-s4 24-absolute-indirect mode wstr op
  5898. ; (+ (f-0-4 0) (f-4-4 9) (f-8-3 opc1) (f-11-1 wbit1) (f-15-1 wbit2) (.sym dst32-24-absolute-indirect- mode) (f-18-2 opc2) Imm-20-s4)
  5899. ; sem)
  5900. (binary-arith-imm4-dst-defn 32 Imm-12-s4 16-Unprefixed mode wstr op
  5901. (+ (f-0-3 opc1) (f-3-1 wbit1) (f-7-1 wbit2) (.sym dst32-16-Unprefixed- mode) (f-10-2 opc2) Imm-12-s4)
  5902. sem)
  5903. ; (binary-arith-imm4-dst-defn 32 Imm-20-s4 24-indirect mode wstr op
  5904. ; (+ (f-0-4 0) (f-4-4 9) (f-8-3 opc1) (f-11-1 wbit1) (f-15-1 wbit2) (.sym dst32-24-indirect- mode) (f-18-2 opc2) Imm-20-s4)
  5905. ; sem)
  5906. )
  5907. )
  5908. (define-pmacro (binary-arith32-shimm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem)
  5909. (begin
  5910. ; Multi insns are tried for assembly in the reverse order in which they appear here, so
  5911. ; define the absolute-indirect insns first in order to prevent them from being selected
  5912. ; when the mode is register-indirect
  5913. ; (binary-arith-imm4-dst-defn 32 Imm-sh-20-s4 24-absolute-indirect mode wstr op
  5914. ; (+ (f-0-4 0) (f-4-4 9) (f-8-3 opc1) (f-11-1 wbit1) (f-15-1 wbit2) (.sym dst32-24-absolute-indirect- mode) (f-18-2 opc2) Imm-sh-20-s4)
  5915. ; sem)
  5916. (binary-arith-imm4-dst-defn 32 Imm-sh-12-s4 16-Unprefixed mode wstr op
  5917. (+ (f-0-3 opc1) (f-3-1 wbit1) (f-7-1 wbit2) (.sym dst32-16-Unprefixed- mode) (f-10-2 opc2) Imm-sh-12-s4)
  5918. sem)
  5919. ; (binary-arith-imm4-dst-defn 32 Imm-sh-20-s4 24-indirect mode wstr op
  5920. ; (+ (f-0-4 0) (f-4-4 9) (f-8-3 opc1) (f-11-1 wbit1) (f-15-1 wbit2) (.sym dst32-24-indirect- mode) (f-18-2 opc2) Imm-sh-20-s4)
  5921. ; sem)
  5922. )
  5923. )
  5924. (define-pmacro (binary-arith-imm4-dst-mach mach op opc1 opc2 sem)
  5925. (begin
  5926. (.apply (.sym binary-arith mach -imm4-dst-defn) (QI .b 0 0 op opc1 opc2 sem))
  5927. (.apply (.sym binary-arith mach -imm4-dst-defn) (HI .w 0 1 op opc1 opc2 sem))
  5928. )
  5929. )
  5930. (define-pmacro (binary-arith-imm4-dst op opc16-1 opc16-2 opc32-1 opc32-2 sem)
  5931. (begin
  5932. (binary-arith-imm4-dst-mach 16 op opc16-1 opc16-2 sem)
  5933. (binary-arith-imm4-dst-mach 32 op opc32-1 opc32-2 sem)
  5934. )
  5935. )
  5936. ;-------------------------------------------------------------
  5937. ;<arith>.size:G src,dst -- for m16c and m32c
  5938. ;-------------------------------------------------------------
  5939. (define-pmacro (binary-arith-src-dst-defn mach srcgroup dstgroup smode dmode wstr op suffix encoding sem)
  5940. (dni (.sym op mach wstr - srcgroup - dstgroup)
  5941. (.str op wstr " dst" mach "-" srcgroup "-" dstgroup "-" dmode)
  5942. ((machine mach) RL_2ADDR)
  5943. (.str op wstr "$" suffix " ${src" mach "-" srcgroup "-" smode "},${dst" mach "-" dstgroup "-" dmode "}")
  5944. encoding
  5945. (sem dmode (.sym src mach - srcgroup - smode) (.sym dst mach - dstgroup - dmode))
  5946. ())
  5947. )
  5948. ; m16c variants
  5949. (define-pmacro (binary-arith16-src-dst-defn smode dmode wstr wbit op suffix opc1 opc2 sem)
  5950. (begin
  5951. (binary-arith-src-dst-defn 16 basic 16 smode dmode wstr op suffix
  5952. (+ opc1 opc2 (f-7-1 wbit) (.sym src16-basic- smode) (.sym dst16-16- dmode))
  5953. sem)
  5954. (binary-arith-src-dst-defn 16 16-16 32 smode dmode wstr op suffix
  5955. (+ opc1 opc2 (f-7-1 wbit) (.sym src16-16-16- smode) (.sym dst16-32- dmode))
  5956. sem)
  5957. (binary-arith-src-dst-defn 16 16-8 24 smode dmode wstr op suffix
  5958. (+ opc1 opc2 (f-7-1 wbit) (.sym src16-16-8- smode) (.sym dst16-24- dmode))
  5959. sem)
  5960. )
  5961. )
  5962. ; m32c Prefixed variants
  5963. (define-pmacro (binary-arith32-src-dst-Prefixed smode dmode wstr wbit op suffix opc1 opc2 sem)
  5964. (begin
  5965. (binary-arith-src-dst-defn 32 basic-Prefixed 24-Prefixed smode dmode wstr op suffix
  5966. (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit) (.sym src32-basic-Prefixed- smode) (.sym dst32-24-Prefixed- dmode) (f-20-4 opc2))
  5967. sem)
  5968. (binary-arith-src-dst-defn 32 24-24-Prefixed 48-Prefixed smode dmode wstr op suffix
  5969. (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit) (.sym src32-24-24-Prefixed- smode) (.sym dst32-48-Prefixed- dmode) (f-20-4 opc2))
  5970. sem)
  5971. (binary-arith-src-dst-defn 32 24-16-Prefixed 40-Prefixed smode dmode wstr op suffix
  5972. (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit) (.sym src32-24-16-Prefixed- smode) (.sym dst32-40-Prefixed- dmode) (f-20-4 opc2))
  5973. sem)
  5974. (binary-arith-src-dst-defn 32 24-8-Prefixed 32-Prefixed smode dmode wstr op suffix
  5975. (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit) (.sym src32-24-8-Prefixed- smode) (.sym dst32-32-Prefixed- dmode) (f-20-4 opc2))
  5976. sem)
  5977. )
  5978. )
  5979. ; all m32c variants
  5980. (define-pmacro (binary-arith32-src-dst-defn smode dmode wstr wbit op suffix opc1 opc2 sem)
  5981. (begin
  5982. ; Multi insns are tried for assembly in the reverse order in which they appear here, so
  5983. ; define the absolute-indirect insns first in order to prevent them from being selected
  5984. ; when the mode is register-indirect
  5985. ; (binary-arith-src-dst-defn 32 24-24-absolute-indirect 48-absolute-indirect smode dmode wstr op suffix
  5986. ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
  5987. ; (.sym src32-24-24-absolute-indirect- smode) (.sym dst32-48-absolute-indirect- dmode) (f-20-4 opc2))
  5988. ; sem)
  5989. ; (binary-arith-src-dst-defn 32 24-16-absolute-indirect 40-absolute-indirect smode dmode wstr op suffix
  5990. ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
  5991. ; (.sym src32-24-16-absolute-indirect- smode) (.sym dst32-40-absolute-indirect- dmode) (f-20-4 opc2))
  5992. ; sem)
  5993. ; (binary-arith-src-dst-defn 32 24-24-absolute-indirect 48-Prefixed smode dmode wstr op suffix
  5994. ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
  5995. ; (.sym src32-24-24-absolute-indirect- smode) (.sym dst32-48-Prefixed- dmode) (f-20-4 opc2))
  5996. ; sem)
  5997. ; (binary-arith-src-dst-defn 32 24-16-absolute-indirect 40-Prefixed smode dmode wstr op suffix
  5998. ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
  5999. ; (.sym src32-24-16-absolute-indirect- smode) (.sym dst32-40-Prefixed- dmode) (f-20-4 opc2))
  6000. ; sem)
  6001. ; (binary-arith-src-dst-defn 32 24-24-absolute-indirect 48-indirect smode dmode wstr op suffix
  6002. ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
  6003. ; (.sym src32-24-24-absolute-indirect- smode) (.sym dst32-48-indirect- dmode) (f-20-4 opc2))
  6004. ; sem)
  6005. ; (binary-arith-src-dst-defn 32 24-16-absolute-indirect 40-indirect smode dmode wstr op suffix
  6006. ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
  6007. ; (.sym src32-24-16-absolute-indirect- smode) (.sym dst32-40-indirect- dmode) (f-20-4 opc2))
  6008. ; sem)
  6009. ; (binary-arith-src-dst-defn 32 basic-Prefixed 24-absolute-indirect smode dmode wstr op suffix
  6010. ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
  6011. ; (.sym src32-basic-Prefixed- smode) (.sym dst32-24-absolute-indirect- dmode) (f-20-4 opc2))
  6012. ; sem)
  6013. ; (binary-arith-src-dst-defn 32 24-24-Prefixed 48-absolute-indirect smode dmode wstr op suffix
  6014. ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
  6015. ; (.sym src32-24-24-Prefixed- smode) (.sym dst32-48-absolute-indirect- dmode) (f-20-4 opc2))
  6016. ; sem)
  6017. ; (binary-arith-src-dst-defn 32 24-16-Prefixed 40-absolute-indirect smode dmode wstr op suffix
  6018. ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
  6019. ; (.sym src32-24-16-Prefixed- smode) (.sym dst32-40-absolute-indirect- dmode) (f-20-4 opc2))
  6020. ; sem)
  6021. ; (binary-arith-src-dst-defn 32 24-8-Prefixed 32-absolute-indirect smode dmode wstr op suffix
  6022. ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
  6023. ; (.sym src32-24-8-Prefixed- smode) (.sym dst32-32-absolute-indirect- dmode) (f-20-4 opc2))
  6024. ; sem)
  6025. ; (binary-arith-src-dst-defn 32 basic-indirect 24-absolute-indirect smode dmode wstr op suffix
  6026. ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
  6027. ; (.sym src32-basic-indirect- smode) (.sym dst32-24-absolute-indirect- dmode) (f-20-4 opc2))
  6028. ; sem)
  6029. ; (binary-arith-src-dst-defn 32 24-24-indirect 48-absolute-indirect smode dmode wstr op suffix
  6030. ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
  6031. ; (.sym src32-24-24-indirect- smode) (.sym dst32-48-absolute-indirect- dmode) (f-20-4 opc2))
  6032. ; sem)
  6033. ; (binary-arith-src-dst-defn 32 24-16-indirect 40-absolute-indirect smode dmode wstr op suffix
  6034. ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
  6035. ; (.sym src32-24-16-indirect- smode) (.sym dst32-40-absolute-indirect- dmode) (f-20-4 opc2))
  6036. ; sem)
  6037. ; (binary-arith-src-dst-defn 32 24-8-indirect 32-absolute-indirect smode dmode wstr op suffix
  6038. ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
  6039. ; (.sym src32-24-8-indirect- smode) (.sym dst32-32-absolute-indirect- dmode) (f-20-4 opc2))
  6040. ; sem)
  6041. (binary-arith-src-dst-defn 32 basic-Unprefixed 16-Unprefixed smode dmode wstr op suffix
  6042. (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-basic-Unprefixed- smode) (.sym dst32-16-Unprefixed- dmode) (f-12-4 opc2))
  6043. sem)
  6044. (binary-arith-src-dst-defn 32 16-24-Unprefixed 40-Unprefixed smode dmode wstr op suffix
  6045. (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-16-24-Unprefixed- smode) (.sym dst32-40-Unprefixed- dmode) (f-12-4 opc2))
  6046. sem)
  6047. (binary-arith-src-dst-defn 32 16-16-Unprefixed 32-Unprefixed smode dmode wstr op suffix
  6048. (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-16-16-Unprefixed- smode) (.sym dst32-32-Unprefixed- dmode) (f-12-4 opc2))
  6049. sem)
  6050. (binary-arith-src-dst-defn 32 16-8-Unprefixed 24-Unprefixed smode dmode wstr op suffix
  6051. (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-16-8-Unprefixed- smode) (.sym dst32-24-Unprefixed- dmode) (f-12-4 opc2))
  6052. sem)
  6053. ; (binary-arith-src-dst-defn 32 basic-indirect 24-Prefixed smode dmode wstr op suffix
  6054. ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
  6055. ; (.sym src32-basic-indirect- smode) (.sym dst32-24-Prefixed- dmode) (f-20-4 opc2))
  6056. ; sem)
  6057. ; (binary-arith-src-dst-defn 32 24-24-indirect 48-Prefixed smode dmode wstr op suffix
  6058. ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
  6059. ; (.sym src32-24-24-indirect- smode) (.sym dst32-48-Prefixed- dmode) (f-20-4 opc2))
  6060. ; sem)
  6061. ; (binary-arith-src-dst-defn 32 24-16-indirect 40-Prefixed smode dmode wstr op suffix
  6062. ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
  6063. ; (.sym src32-24-16-indirect- smode) (.sym dst32-40-Prefixed- dmode) (f-20-4 opc2))
  6064. ; sem)
  6065. ; (binary-arith-src-dst-defn 32 24-8-indirect 32-Prefixed smode dmode wstr op suffix
  6066. ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
  6067. ; (.sym src32-24-8-indirect- smode) (.sym dst32-32-Prefixed- dmode) (f-20-4 opc2))
  6068. ; sem)
  6069. ; (binary-arith-src-dst-defn 32 basic-Prefixed 24-indirect smode dmode wstr op suffix
  6070. ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
  6071. ; (.sym src32-basic-Prefixed- smode) (.sym dst32-24-indirect- dmode) (f-20-4 opc2))
  6072. ; sem)
  6073. ; (binary-arith-src-dst-defn 32 24-24-Prefixed 48-indirect smode dmode wstr op suffix
  6074. ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
  6075. ; (.sym src32-24-24-Prefixed- smode) (.sym dst32-48-indirect- dmode) (f-20-4 opc2))
  6076. ; sem)
  6077. ; (binary-arith-src-dst-defn 32 24-16-Prefixed 40-indirect smode dmode wstr op suffix
  6078. ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
  6079. ; (.sym src32-24-16-Prefixed- smode) (.sym dst32-40-indirect- dmode) (f-20-4 opc2))
  6080. ; sem)
  6081. ; (binary-arith-src-dst-defn 32 24-8-Prefixed 32-indirect smode dmode wstr op suffix
  6082. ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
  6083. ; (.sym src32-24-8-Prefixed- smode) (.sym dst32-32-indirect- dmode) (f-20-4 opc2))
  6084. ; sem)
  6085. ; (binary-arith-src-dst-defn 32 basic-indirect 24-indirect smode dmode wstr op suffix
  6086. ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
  6087. ; (.sym src32-basic-indirect- smode) (.sym dst32-24-indirect- dmode) (f-20-4 opc2))
  6088. ; sem)
  6089. ; (binary-arith-src-dst-defn 32 24-24-indirect 48-indirect smode dmode wstr op suffix
  6090. ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
  6091. ; (.sym src32-24-24-indirect- smode) (.sym dst32-48-indirect- dmode) (f-20-4 opc2))
  6092. ; sem)
  6093. ; (binary-arith-src-dst-defn 32 24-16-indirect 40-indirect smode dmode wstr op suffix
  6094. ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
  6095. ; (.sym src32-24-16-indirect- smode) (.sym dst32-40-indirect- dmode) (f-20-4 opc2))
  6096. ; sem)
  6097. ; (binary-arith-src-dst-defn 32 24-8-indirect 32-indirect smode dmode wstr op suffix
  6098. ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
  6099. ; (.sym src32-24-8-indirect- smode) (.sym dst32-32-indirect- dmode) (f-20-4 opc2))
  6100. ; sem)
  6101. )
  6102. )
  6103. (define-pmacro (binary-arith-src-dst-mach mach op suffix opc1 opc2 sem)
  6104. (begin
  6105. (.apply (.sym binary-arith mach -src-dst-defn) (QI QI .b 0 op suffix opc1 opc2 sem))
  6106. (.apply (.sym binary-arith mach -src-dst-defn) (HI HI .w 1 op suffix opc1 opc2 sem))
  6107. )
  6108. )
  6109. (define-pmacro (binary-arith-src-dst op suffix opc16-1 opc16-2 opc32-1 opc32-2 sem)
  6110. (begin
  6111. (binary-arith-src-dst-mach 16 op suffix opc16-1 opc16-2 sem)
  6112. (binary-arith-src-dst-mach 32 op suffix opc32-1 opc32-2 sem)
  6113. )
  6114. )
  6115. ;-------------------------------------------------------------
  6116. ;<arith>.size:S #imm,dst -- for m32c
  6117. ;-------------------------------------------------------------
  6118. (define-pmacro (binary-arith32-s-imm-dst-defn src dstgroup mode wstr op encoding sem)
  6119. (dni (.sym op 32 wstr - imm-S - dstgroup)
  6120. (.str op wstr " 32-imm-S-" dstgroup "-" mode)
  6121. ((machine 32))
  6122. (.str op wstr "$S #${" src "},${dst32-" dstgroup "-" mode "}")
  6123. encoding
  6124. (sem mode src (.sym dst32- dstgroup - mode))
  6125. ())
  6126. )
  6127. (define-pmacro (binary-arith32-z-imm-dst-defn src dstgroup mode wstr op encoding sem)
  6128. (dni (.sym op 32 wstr - imm-Z - dstgroup)
  6129. (.str op wstr " 32-imm-Z-" dstgroup "-" mode)
  6130. ((machine 32))
  6131. (.str op wstr "$Z #0,${dst32-" dstgroup "-" mode "}")
  6132. encoding
  6133. (sem mode (const 0) (.sym dst32- dstgroup - mode))
  6134. ())
  6135. )
  6136. (define-pmacro (binary-arith32-s-imm-dst mode wstr wbit op opc1 opc2 sem)
  6137. (begin
  6138. ; (binary-arith32-s-imm-dst-defn (.sym Imm-32- mode) 2-S-absolute-indirect mode wstr op
  6139. ; (+ (f-0-4 0) (f-4-4 9) (f-8-2 opc1) (.sym dst32-2-S-absolute-indirect- mode) (f-12-3 opc2) (f-15-1 wbit) (.sym Imm-32- mode))
  6140. ; sem)
  6141. (binary-arith32-s-imm-dst-defn (.sym Imm-8- mode) 2-S-basic mode wstr op
  6142. (+ (f-0-2 opc1) (.sym dst32-2-S-basic- mode) (f-4-3 opc2) (f-7-1 wbit) (.sym Imm-8- mode))
  6143. sem)
  6144. (binary-arith32-s-imm-dst-defn (.sym Imm-24- mode) 2-S-16 mode wstr op
  6145. (+ (f-0-2 opc1) (.sym dst32-2-S-16- mode) (f-4-3 opc2) (f-7-1 wbit) (.sym Imm-24- mode))
  6146. sem)
  6147. (binary-arith32-s-imm-dst-defn (.sym Imm-16- mode) 2-S-8 mode wstr op
  6148. (+ (f-0-2 opc1) (.sym dst32-2-S-8- mode) (f-4-3 opc2) (f-7-1 wbit) (.sym Imm-16- mode))
  6149. sem)
  6150. ; (binary-arith32-s-imm-dst-defn (.sym Imm-24- mode) 2-S-8-indirect mode wstr op
  6151. ; (+ (f-0-4 0) (f-4-4 9) (f-8-2 opc1) (.sym dst32-2-S-8-indirect- mode) (f-12-3 opc2) (f-15-1 wbit) (.sym Imm-24- mode))
  6152. ; sem)
  6153. )
  6154. )
  6155. (define-pmacro (binary-arith32-z-imm-dst mode wstr wbit op opc1 opc2 sem)
  6156. (begin
  6157. ; (binary-arith32-z-imm-dst-defn (.sym Imm-32- mode) 2-S-absolute-indirect mode wstr op
  6158. ; (+ (f-0-4 0) (f-4-4 9) (f-8-2 opc1) (.sym dst32-2-S-absolute-indirect- mode) (f-12-3 opc2) (f-15-1 wbit) (.sym Imm-32- mode))
  6159. ; sem)
  6160. (binary-arith32-z-imm-dst-defn (.sym Imm-8- mode) 2-S-basic mode wstr op
  6161. (+ (f-0-2 opc1) (.sym dst32-2-S-basic- mode) (f-4-3 opc2) (f-7-1 wbit))
  6162. sem)
  6163. (binary-arith32-z-imm-dst-defn (.sym Imm-24- mode) 2-S-16 mode wstr op
  6164. (+ (f-0-2 opc1) (.sym dst32-2-S-16- mode) (f-4-3 opc2) (f-7-1 wbit))
  6165. sem)
  6166. (binary-arith32-z-imm-dst-defn (.sym Imm-16- mode) 2-S-8 mode wstr op
  6167. (+ (f-0-2 opc1) (.sym dst32-2-S-8- mode) (f-4-3 opc2) (f-7-1 wbit))
  6168. sem)
  6169. ; (binary-arith32-z-imm-dst-defn (.sym Imm-24- mode) 2-S-8-indirect mode wstr op
  6170. ; (+ (f-0-4 0) (f-4-4 9) (f-8-2 opc1) (.sym dst32-2-S-8-indirect- mode) (f-12-3 opc2) (f-15-1 wbit) (.sym Imm-24- mode))
  6171. ; sem)
  6172. )
  6173. )
  6174. ;-------------------------------------------------------------
  6175. ;<arith>.L:S #imm1,An -- for m32c
  6176. ;-------------------------------------------------------------
  6177. (define-pmacro (binary-arith32-l-s-imm1-an op opc1 opc2 sem)
  6178. (begin
  6179. (dni (.sym op 32.l-s-imm1-S-an)
  6180. (.str op ".l 32-imm1-S-an")
  6181. ((machine 32))
  6182. (.str op ".l$S #${Imm1-S},${dst32-an-S}")
  6183. (+ opc1 Imm1-S opc2 dst32-an-S)
  6184. (sem SI Imm1-S dst32-an-S)
  6185. ())
  6186. )
  6187. )
  6188. ;-------------------------------------------------------------
  6189. ;<arith>.L:Q #imm3,sp -- for m32c
  6190. ;-------------------------------------------------------------
  6191. (define-pmacro (binary-arith32-l-q-imm3-sp op opc1 opc2 sem)
  6192. (begin
  6193. (dni (.sym op 32.l-imm3-Q)
  6194. (.str op ".l 32-imm3-Q")
  6195. ((machine 32))
  6196. (.str op ".l$Q #${Imm3-S},sp")
  6197. (+ opc1 Imm3-S opc2)
  6198. (sem SI Imm3-S sp)
  6199. ())
  6200. )
  6201. )
  6202. ;-------------------------------------------------------------
  6203. ;<arith>.L:S #imm8,sp -- for m32c
  6204. ;-------------------------------------------------------------
  6205. (define-pmacro (binary-arith32-l-s-imm8-sp op opc1 opc2 opc3 opc4 sem)
  6206. (begin
  6207. (dni (.sym op 32.l-imm8-S)
  6208. (.str op ".l 32-imm8-S")
  6209. ((machine 32))
  6210. (.str op ".l$S #${Imm-16-QI},sp")
  6211. (+ opc1 opc2 opc3 opc4 Imm-16-QI)
  6212. (sem SI Imm-16-QI sp)
  6213. ())
  6214. )
  6215. )
  6216. ;-------------------------------------------------------------
  6217. ;<arith>.L:G #imm16,sp -- for m32c
  6218. ;-------------------------------------------------------------
  6219. (define-pmacro (binary-arith32-l-g-imm16-sp op opc1 opc2 opc3 opc4 sem)
  6220. (begin
  6221. (dni (.sym op 32.l-imm16-G)
  6222. (.str op ".l 32-imm16-G")
  6223. ((machine 32))
  6224. (.str op ".l$G #${Imm-16-HI},sp")
  6225. (+ opc1 opc2 opc3 opc4 Imm-16-HI)
  6226. (sem SI Imm-16-HI sp)
  6227. ())
  6228. )
  6229. )
  6230. ;-------------------------------------------------------------
  6231. ;<arith>jnz.size #imm4,dst,label -- for m16c and m32c
  6232. ;-------------------------------------------------------------
  6233. (define-pmacro (arith-jnz-imm4-dst-defn mach src dstgroup label mode wstr op encoding sem)
  6234. (dni (.sym op mach wstr - imm4 - dstgroup)
  6235. (.str op wstr " " mach "-imm4-" dstgroup "-" label "-" mode)
  6236. (RL_JUMP RELAXABLE (machine mach))
  6237. (.str op wstr " #${" src "},${dst" mach "-" dstgroup "-" mode "},${" label "}")
  6238. encoding
  6239. (sem mode src (.sym dst mach - dstgroup - mode) label)
  6240. ())
  6241. )
  6242. ; m16c variants
  6243. (define-pmacro (arith-jnz16-imm4-dst-defn mode wstr wbit op i4n opc1 opc2 sem)
  6244. (begin
  6245. (arith-jnz-imm4-dst-defn 16 (.sym Imm-8- i4n) basic Lab-16-8 mode wstr op
  6246. (+ opc1 opc2 (f-7-1 wbit) (.sym Imm-8- i4n) (.sym dst16-basic- mode) Lab-16-8)
  6247. sem)
  6248. (arith-jnz-imm4-dst-defn 16 (.sym Imm-8- i4n) 16-16 Lab-32-8 mode wstr op
  6249. (+ opc1 opc2 (f-7-1 wbit) (.sym Imm-8- i4n) (.sym dst16-16-16- mode) Lab-32-8)
  6250. sem)
  6251. (arith-jnz-imm4-dst-defn 16 (.sym Imm-8- i4n) 16-8 Lab-24-8 mode wstr op
  6252. (+ opc1 opc2 (f-7-1 wbit) (.sym Imm-8- i4n) (.sym dst16-16-8- mode) Lab-24-8)
  6253. sem)
  6254. )
  6255. )
  6256. ; m32c variants
  6257. (define-pmacro (arith-jnz32-imm4-dst-defn mode wstr wbit op i4n opc1 opc2 sem)
  6258. (begin
  6259. (arith-jnz-imm4-dst-defn 32 (.sym Imm-12- i4n) basic-Unprefixed Lab-16-8 mode wstr op
  6260. (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-basic-Unprefixed- mode) (f-10-2 opc2) (.sym Imm-12- i4n) Lab-16-8)
  6261. sem)
  6262. (arith-jnz-imm4-dst-defn 32 (.sym Imm-12- i4n) 16-24-Unprefixed Lab-40-8 mode wstr op
  6263. (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-24-Unprefixed- mode) (f-10-2 opc2) (.sym Imm-12- i4n) Lab-40-8)
  6264. sem)
  6265. (arith-jnz-imm4-dst-defn 32 (.sym Imm-12- i4n) 16-16-Unprefixed Lab-32-8 mode wstr op
  6266. (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-16-Unprefixed- mode) (f-10-2 opc2) (.sym Imm-12- i4n) Lab-32-8)
  6267. sem)
  6268. (arith-jnz-imm4-dst-defn 32 (.sym Imm-12- i4n) 16-8-Unprefixed Lab-24-8 mode wstr op
  6269. (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-8-Unprefixed- mode) (f-10-2 opc2) (.sym Imm-12- i4n) Lab-24-8)
  6270. sem)
  6271. )
  6272. )
  6273. (define-pmacro (arith-jnz-imm4-dst-mach mach op i4n opc1 opc2 sem)
  6274. (begin
  6275. (.apply (.sym arith-jnz mach -imm4-dst-defn) (QI .b 0 op i4n opc1 opc2 sem))
  6276. (.apply (.sym arith-jnz mach -imm4-dst-defn) (HI .w 1 op i4n opc1 opc2 sem))
  6277. )
  6278. )
  6279. (define-pmacro (arith-jnz-imm4-dst op i4n opc16-1 opc16-2 opc32-1 opc32-2 sem)
  6280. (begin
  6281. (arith-jnz-imm4-dst-mach 16 op i4n opc16-1 opc16-2 sem)
  6282. (arith-jnz-imm4-dst-mach 32 op i4n opc32-1 opc32-2 sem)
  6283. )
  6284. )
  6285. ;-------------------------------------------------------------
  6286. ;mov.size dsp8[sp],dst -- for m16c and m32c
  6287. ;-------------------------------------------------------------
  6288. (define-pmacro (mov-dspsp-dst-defn mach dstgroup dsp mode wstr op encoding sem)
  6289. (dni (.sym op mach wstr -dspsp-dst- dstgroup)
  6290. (.str op wstr " " mach "-dsp[sp]-" dstgroup "-" dsp "-" mode)
  6291. ((machine mach))
  6292. (.str op wstr "$G ${" dsp "}[sp],${dst" mach "-" dstgroup "-" mode "}")
  6293. encoding
  6294. (sem mach mode dsp (.sym dst mach - dstgroup - mode))
  6295. ())
  6296. )
  6297. (define-pmacro (mov-src-dspsp-defn mach dstgroup dsp mode wstr op encoding sem)
  6298. (dni (.sym op mach wstr -dst-dspsp- dstgroup)
  6299. (.str op wstr " " mach "-dsp[sp]-" dstgroup "-" dsp "-" mode)
  6300. ((machine mach))
  6301. (.str op wstr "$G ${dst" mach "-" dstgroup "-" mode "},${" dsp "}[sp]")
  6302. encoding
  6303. (sem mach mode (.sym dst mach - dstgroup - mode) dsp)
  6304. ())
  6305. )
  6306. ; m16c variants
  6307. (define-pmacro (mov16-dspsp-dst-defn mode wstr wbit op opc1 opc2 opc3 sem)
  6308. (begin
  6309. (mov-dspsp-dst-defn 16 basic Dsp-16-s8 mode wstr op
  6310. (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-basic- mode) Dsp-16-s8)
  6311. sem)
  6312. (mov-dspsp-dst-defn 16 16-16 Dsp-32-s8 mode wstr op
  6313. (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-16- mode) Dsp-32-s8)
  6314. sem)
  6315. (mov-dspsp-dst-defn 16 16-8 Dsp-24-s8 mode wstr op
  6316. (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-8- mode) Dsp-24-s8)
  6317. sem)
  6318. )
  6319. )
  6320. (define-pmacro (mov16-src-dspsp-defn mode wstr wbit op opc1 opc2 opc3 sem)
  6321. (begin
  6322. (mov-src-dspsp-defn 16 basic Dsp-16-s8 mode wstr op
  6323. (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-basic- mode) Dsp-16-s8)
  6324. sem)
  6325. (mov-src-dspsp-defn 16 16-16 Dsp-32-s8 mode wstr op
  6326. (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-16- mode) Dsp-32-s8)
  6327. sem)
  6328. (mov-src-dspsp-defn 16 16-8 Dsp-24-s8 mode wstr op
  6329. (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-8- mode) Dsp-24-s8)
  6330. sem)
  6331. )
  6332. )
  6333. ; m32c variants
  6334. (define-pmacro (mov32-dspsp-dst-defn mode wstr wbit op opc1 opc2 opc3 sem)
  6335. (begin
  6336. (mov-dspsp-dst-defn 32 basic-Unprefixed Dsp-16-s8 mode wstr op
  6337. (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-basic-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-16-s8)
  6338. sem)
  6339. (mov-dspsp-dst-defn 32 16-24-Unprefixed Dsp-40-s8 mode wstr op
  6340. (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-24-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-40-s8)
  6341. sem)
  6342. (mov-dspsp-dst-defn 32 16-16-Unprefixed Dsp-32-s8 mode wstr op
  6343. (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-16-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-32-s8)
  6344. sem)
  6345. (mov-dspsp-dst-defn 32 16-8-Unprefixed Dsp-24-s8 mode wstr op
  6346. (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-8-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-24-s8)
  6347. sem)
  6348. )
  6349. )
  6350. (define-pmacro (mov32-src-dspsp-defn mode wstr wbit op opc1 opc2 opc3 sem)
  6351. (begin
  6352. (mov-src-dspsp-defn 32 basic-Unprefixed Dsp-16-s8 mode wstr op
  6353. (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-basic-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-16-s8)
  6354. sem)
  6355. (mov-src-dspsp-defn 32 16-24-Unprefixed Dsp-40-s8 mode wstr op
  6356. (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-24-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-40-s8)
  6357. sem)
  6358. (mov-src-dspsp-defn 32 16-16-Unprefixed Dsp-32-s8 mode wstr op
  6359. (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-16-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-32-s8)
  6360. sem)
  6361. (mov-src-dspsp-defn 32 16-8-Unprefixed Dsp-24-s8 mode wstr op
  6362. (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-8-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-24-s8)
  6363. sem)
  6364. )
  6365. )
  6366. (define-pmacro (mov-src-dspsp-mach mach op opc1 opc2 opc3 sem)
  6367. (begin
  6368. (.apply (.sym mov mach -src-dspsp-defn) (QI .b 0 op opc1 opc2 opc3 sem))
  6369. (.apply (.sym mov mach -src-dspsp-defn) (HI .w 1 op opc1 opc2 opc3 sem))
  6370. )
  6371. )
  6372. (define-pmacro (mov-dspsp-dst-mach mach op opc1 opc2 opc3 sem)
  6373. (begin
  6374. (.apply (.sym mov mach -dspsp-dst-defn) (QI .b 0 op opc1 opc2 opc3 sem))
  6375. (.apply (.sym mov mach -dspsp-dst-defn) (HI .w 1 op opc1 opc2 opc3 sem))
  6376. )
  6377. )
  6378. (define-pmacro (mov-dspsp-dst op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
  6379. (begin
  6380. (mov-dspsp-dst-mach 16 op opc16-1 opc16-2 opc16-3 sem)
  6381. (mov-dspsp-dst-mach 32 op opc32-1 opc32-2 opc32-3 sem)
  6382. )
  6383. )
  6384. (define-pmacro (mov-src-dspsp op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
  6385. (begin
  6386. (mov-src-dspsp-mach 16 op opc16-1 opc16-2 opc16-3 sem)
  6387. (mov-src-dspsp-mach 32 op opc32-1 opc32-2 opc32-3 sem)
  6388. )
  6389. )
  6390. ;-------------------------------------------------------------
  6391. ; lde dsp24,dst -- for m16c
  6392. ;-------------------------------------------------------------
  6393. (define-pmacro (lde-dst-dsp mode wstr wbit dstgroup srcdisp)
  6394. (begin
  6395. (dni (.sym lde wstr - dstgroup -u20)
  6396. (.str "lde" wstr "-" dstgroup "-u20")
  6397. ((machine 16))
  6398. (.str "lde" wstr " ${" srcdisp "},${dst16-" dstgroup "-" mode "}")
  6399. (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x8)
  6400. (.sym dst16- dstgroup - mode) srcdisp)
  6401. (nop)
  6402. ())
  6403. (dni (.sym lde wstr - dstgroup -u20a0)
  6404. (.str "lde" wstr "-" dstgroup "-u20a0")
  6405. ((machine 16))
  6406. (.str "lde" wstr " ${" srcdisp "}[a0],${dst16-" dstgroup "-" mode "}")
  6407. (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x9)
  6408. (.sym dst16- dstgroup - mode) srcdisp)
  6409. (nop)
  6410. ())
  6411. (dni (.sym lde wstr - dstgroup -a1a0)
  6412. (.str "lde" wstr "-" dstgroup "-a1a0")
  6413. ((machine 16))
  6414. (.str "lde" wstr " [a1a0],${dst16-" dstgroup "-" mode "}")
  6415. (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #xa)
  6416. (.sym dst16- dstgroup - mode))
  6417. (nop)
  6418. ())
  6419. )
  6420. )
  6421. (define-pmacro (lde-dst mode wstr wbit)
  6422. (begin
  6423. ; like: QI .b 0
  6424. (lde-dst-dsp mode wstr wbit basic Dsp-16-u20)
  6425. (lde-dst-dsp mode wstr wbit 16-8 Dsp-24-u20)
  6426. (lde-dst-dsp mode wstr wbit 16-16 Dsp-32-u20)
  6427. )
  6428. )
  6429. ;-------------------------------------------------------------
  6430. ; ste dst,dsp24 -- for m16c
  6431. ;-------------------------------------------------------------
  6432. (define-pmacro (ste-dst-dsp mode wstr wbit dstgroup srcdisp)
  6433. (begin
  6434. (dni (.sym ste wstr - dstgroup -u20)
  6435. (.str "ste" wstr "-" dstgroup "-u20")
  6436. ((machine 16))
  6437. (.str "ste" wstr " ${dst16-" dstgroup "-" mode "},${" srcdisp "}")
  6438. (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x0)
  6439. (.sym dst16- dstgroup - mode) srcdisp)
  6440. (nop)
  6441. ())
  6442. (dni (.sym ste wstr - dstgroup -u20a0)
  6443. (.str "ste" wstr "-" dstgroup "-u20a0")
  6444. ((machine 16))
  6445. (.str "ste" wstr " ${dst16-" dstgroup "-" mode "},${" srcdisp "}[a0]")
  6446. (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x1)
  6447. (.sym dst16- dstgroup - mode) srcdisp)
  6448. (nop)
  6449. ())
  6450. (dni (.sym ste wstr - dstgroup -a1a0)
  6451. (.str "ste" wstr "-" dstgroup "-a1a0")
  6452. ((machine 16))
  6453. (.str "ste" wstr " ${dst16-" dstgroup "-" mode "},[a1a0]")
  6454. (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x2)
  6455. (.sym dst16- dstgroup - mode))
  6456. (nop)
  6457. ())
  6458. )
  6459. )
  6460. (define-pmacro (ste-dst mode wstr wbit)
  6461. (begin
  6462. ; like: QI .b 0
  6463. (ste-dst-dsp mode wstr wbit basic Dsp-16-u20)
  6464. (ste-dst-dsp mode wstr wbit 16-8 Dsp-24-u20)
  6465. (ste-dst-dsp mode wstr wbit 16-16 Dsp-32-u20)
  6466. )
  6467. )
  6468. ;=============================================================
  6469. ; Division
  6470. ;-------------------------------------------------------------
  6471. (define-pmacro (div-sem divop modop opmode reg src quot rem max min)
  6472. (sequence ()
  6473. (if (eq src 0)
  6474. (set obit (const BI 1))
  6475. (sequence ((opmode quot-result) (opmode rem-result))
  6476. (set quot-result (divop opmode (ext opmode reg) src))
  6477. (set rem-result (modop opmode (ext opmode reg) src))
  6478. (set obit (orif (gt opmode quot-result max)
  6479. (lt opmode quot-result min)))
  6480. (set quot quot-result)
  6481. (set rem rem-result))))
  6482. )
  6483. ;<divop>.size #imm -- for m16c and m32c
  6484. (define-pmacro (div-imm-defn mach wstr op src encoding divop modop opmode reg quot rem max min sem)
  6485. (dni (.sym op mach wstr - src)
  6486. (.str op mach wstr "-" src)
  6487. ((machine mach))
  6488. (.str op wstr " #${" src "}")
  6489. encoding
  6490. (sem divop modop opmode reg src quot rem max min)
  6491. ())
  6492. )
  6493. (define-pmacro (div16-imm-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 opc4 sem)
  6494. (div-imm-defn 16 wstr op (.sym Imm-16 - smode)
  6495. (+ opc1 opc2 (f-7-1 wbit) opc3 opc4 (.sym Imm-16 - smode))
  6496. divop modop opmode reg quot rem max min
  6497. sem)
  6498. )
  6499. (define-pmacro (div32-imm-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 opc4 sem)
  6500. (div-imm-defn 32 wstr op (.sym Imm-16 - smode)
  6501. (+ (f-0-4 opc1) (f-4-4 opc2) (f-8-3 opc3) (f-11-1 wbit) (f-12-4 opc4) (.sym Imm-16 - smode))
  6502. divop modop opmode reg quot rem max min
  6503. sem)
  6504. )
  6505. (define-pmacro (div-imm-mach mach op divop modop opmode max-QI min-QI max-HI min-HI opc1 opc2 opc3 opc4 sem)
  6506. (begin
  6507. (.apply (.sym div mach -imm-defn) (QI .b 0 op divop modop opmode R0 R0l R0h max-QI min-QI opc1 opc2 opc3 opc4 sem))
  6508. (.apply (.sym div mach -imm-defn) (HI .w 1 op divop modop opmode R2R0 R0 R2 max-HI min-HI opc1 opc2 opc3 opc4 sem))
  6509. )
  6510. )
  6511. (define-pmacro (div-imm op divop modop opmode max-QI min-QI max-HI min-HI opc16-1 opc16-2 opc16-3 opc16-4 opc32-1 opc32-2 opc32-3 opc32-4 sem)
  6512. (begin
  6513. (div-imm-mach 16 op divop modop opmode max-QI min-QI max-HI min-HI opc16-1 opc16-2 opc16-3 opc16-4 sem)
  6514. (div-imm-mach 32 op divop modop opmode max-QI min-QI max-HI min-HI opc32-1 opc32-2 opc32-3 opc32-4 sem)
  6515. )
  6516. )
  6517. ;<divop>.size src -- for m16c and m32c
  6518. (define-pmacro (div-src-defn mach wstr op src encoding divop modop opmode reg quot rem max min sem)
  6519. (dni (.sym op mach wstr - src)
  6520. (.str op mach wstr "-" src)
  6521. ((machine mach))
  6522. (.str op wstr " ${" src "}")
  6523. encoding
  6524. (sem divop modop opmode reg src quot rem max min)
  6525. ())
  6526. )
  6527. (define-pmacro (div16-src-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 sem)
  6528. (div-src-defn 16 wstr op (.sym dst16-16 - smode)
  6529. (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16 - smode))
  6530. divop modop opmode reg quot rem max min
  6531. sem)
  6532. )
  6533. (define-pmacro (div32-src-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 sem)
  6534. (begin
  6535. ; Multi insns are tried for assembly in the reverse order in which they appear here, so
  6536. ; define the absolute-indirect insns first in order to prevent them from being selected
  6537. ; when the mode is register-indirect
  6538. ; (div-src-defn 32 wstr op (.sym dst32-24-absolute-indirect- smode)
  6539. ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-15-1 wbit) (f-18-2 opc2) (f-20-4 opc3) (.sym dst32-24-absolute-indirect - smode))
  6540. ; divop modop opmode reg quot rem max min
  6541. ; sem)
  6542. (div-src-defn 32 wstr op (.sym dst32-16-Unprefixed- smode)
  6543. (+ (f-0-4 opc1) (f-7-1 wbit) (f-10-2 opc2) (f-12-4 opc3) (.sym dst32-16-Unprefixed- smode))
  6544. divop modop opmode reg quot rem max min
  6545. sem)
  6546. ; (div-src-defn 32 wstr op (.sym dst32-24-indirect- smode)
  6547. ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-15-1 wbit) (f-18-2 opc2) (f-20-4 opc3) (.sym dst32-24-indirect - smode))
  6548. ; divop modop opmode reg quot rem max min
  6549. ; sem)
  6550. )
  6551. )
  6552. (define-pmacro (div-src-mach mach op divop modop opmode max-QI min-QI max-HI min-HI opc1 opc2 opc3 sem)
  6553. (begin
  6554. (.apply (.sym div mach -src-defn) (QI .b 0 op divop modop opmode R0 R0l R0h max-QI min-QI opc1 opc2 opc3 sem))
  6555. (.apply (.sym div mach -src-defn) (HI .w 1 op divop modop opmode R2R0 R0 R2 max-HI min-HI opc1 opc2 opc3 sem))
  6556. )
  6557. )
  6558. (define-pmacro (div-src op divop modop opmode max-QI min-QI max-HI min-HI opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
  6559. (begin
  6560. (div-src-mach 16 op divop modop opmode max-QI min-QI max-HI min-HI opc16-1 opc16-2 opc16-3 sem)
  6561. (div-src-mach 32 op divop modop opmode max-QI min-QI max-HI min-HI opc32-1 opc32-2 opc32-3 sem)
  6562. )
  6563. )
  6564. ;=============================================================
  6565. ; Bit manipulation
  6566. ;
  6567. (define-pmacro (bit-insn-defn mach op suffix opnd encoding sem)
  6568. (dni (.sym op mach - suffix - opnd)
  6569. (.str op mach ":" suffix " " opnd)
  6570. ((machine mach))
  6571. (.str op "$" suffix " ${" opnd "}")
  6572. encoding
  6573. (sem opnd)
  6574. ())
  6575. )
  6576. (define-pmacro (bitsrc16-defn op opc1 opc2 opc3 sem)
  6577. (bit-insn-defn 16 op X bit16-16
  6578. (+ opc1 opc2 opc3 bit16-16)
  6579. sem)
  6580. )
  6581. (define-pmacro (bitsrc32-defn op opc1 opc2 opc3 sem)
  6582. (begin
  6583. (bit-insn-defn 32 op X bit32-24-Prefixed
  6584. (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) bit32-24-Prefixed (f-15-1 opc2) (f-18-3 opc3))
  6585. sem)
  6586. )
  6587. )
  6588. (define-pmacro (bitsrc-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
  6589. (begin
  6590. (bitsrc16-defn op opc16-1 opc16-2 opc16-3 sem)
  6591. (bitsrc32-defn op opc32-1 opc32-2 opc32-3 sem)
  6592. )
  6593. )
  6594. (define-pmacro (bitdst16-defn op opc1 opc2 opc3 opc4 opc5 opc6 sem)
  6595. (begin
  6596. (bit-insn-defn 16 op G bit16-16-basic (+ opc1 opc2 opc3 bit16-16-basic) sem)
  6597. (bit-insn-defn 16 op G bit16-16-16 (+ opc1 opc2 opc3 bit16-16-16) sem)
  6598. (bit-insn-defn 16 op S bit16-11-S (+ opc4 opc5 opc6 bit16-11-S) sem)
  6599. (bit-insn-defn 16 op G bit16-16-8 (+ opc1 opc2 opc3 bit16-16-8) sem)
  6600. )
  6601. )
  6602. (define-pmacro (bitdst32-defn op opc1 opc2 opc3 sem)
  6603. (begin
  6604. (bit-insn-defn 32 op X bit32-16-Unprefixed
  6605. (+ (f-0-4 opc1) bit32-16-Unprefixed (f-7-1 opc2) (f-10-3 opc3))
  6606. sem)
  6607. )
  6608. )
  6609. (define-pmacro (bitdstnos-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
  6610. (begin
  6611. (bitsrc16-defn op opc16-1 opc16-2 opc16-3 sem)
  6612. (bitdst32-defn op opc32-1 opc32-2 opc32-3 sem)
  6613. )
  6614. )
  6615. (define-pmacro (bitdst-insn op opc16-1 opc16-2 opc16-3 opc16-4 opc16-5 opc16-6 opc32-1 opc32-2 opc32-3 sem)
  6616. (begin
  6617. (bitdst16-defn op opc16-1 opc16-2 opc16-3 opc16-4 opc16-5 opc16-6 sem)
  6618. (bitdst32-defn op opc32-1 opc32-2 opc32-3 sem)
  6619. )
  6620. )
  6621. ;=============================================================
  6622. ; Bit condition
  6623. ;
  6624. (define-pmacro (bitcond-insn-defn mach op bit-opnd cond-opnd encoding sem)
  6625. (dni (.sym op mach - bit-opnd - cond-opnd)
  6626. (.str op mach " " bit-opnd " " cond-opnd)
  6627. ((machine mach))
  6628. (.str op "${" cond-opnd "} ${" bit-opnd "}")
  6629. encoding
  6630. (sem mach bit-opnd cond-opnd)
  6631. ())
  6632. )
  6633. (define-pmacro (bitcond16-defn op opc1 opc2 opc3 sem)
  6634. (begin
  6635. (bitcond-insn-defn 16 op bit16-16-basic cond16-16 (+ opc1 opc2 opc3 bit16-16-basic cond16-16) sem)
  6636. (bitcond-insn-defn 16 op bit16-16-16 cond16-32 (+ opc1 opc2 opc3 bit16-16-16 cond16-32) sem)
  6637. (bitcond-insn-defn 16 op bit16-16-8 cond16-24 (+ opc1 opc2 opc3 bit16-16-8 cond16-24) sem)
  6638. )
  6639. )
  6640. (define-pmacro (bitcond32-defn op opc1 opc2 opc3 sem)
  6641. (begin
  6642. (bitcond-insn-defn 32 op bit32-16-24-Unprefixed cond32-40
  6643. (+ (f-0-4 opc1) bit32-16-24-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-40)
  6644. sem)
  6645. (bitcond-insn-defn 32 op bit32-16-16-Unprefixed cond32-32
  6646. (+ (f-0-4 opc1) bit32-16-16-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-32)
  6647. sem)
  6648. (bitcond-insn-defn 32 op bit32-16-8-Unprefixed cond32-24
  6649. (+ (f-0-4 opc1) bit32-16-8-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-24)
  6650. sem)
  6651. (bitcond-insn-defn 32 op bit32-basic-Unprefixed cond32-16
  6652. (+ (f-0-4 opc1) bit32-basic-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-16)
  6653. sem)
  6654. )
  6655. )
  6656. (define-pmacro (bitcond-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
  6657. (begin
  6658. (bitcond16-defn op opc16-1 opc16-2 opc16-3 sem)
  6659. (bitcond32-defn op opc32-1 opc32-2 opc32-3 sem)
  6660. )
  6661. )
  6662. ;=============================================================
  6663. ;<insn>.size #imm1,#imm2,dst -- for m32c
  6664. ;
  6665. (define-pmacro (insn-imm1-imm2-dst-defn src1 src2 dstgroup xmode wstr op encoding sem)
  6666. (dni (.sym op 32 wstr - src1 - src2 - dstgroup)
  6667. (.str op 32 wstr "-" src1 "-" src2 "-" dstgroup "-" xmode)
  6668. ((machine 32))
  6669. (.str op wstr " #${" src1 "},#${" src2 "},${dst32-" dstgroup "-" xmode "}")
  6670. encoding
  6671. (sem xmode src1 src2 (.sym dst32- dstgroup - xmode))
  6672. ())
  6673. )
  6674. ; m32c Prefixed variants
  6675. (define-pmacro (insn32-imm1-imm2-dst-Prefixed-defn xmode wstr wbit base1 base2 base3 base4 op opc1 opc2 opc3 sem)
  6676. (begin
  6677. (insn-imm1-imm2-dst-defn (.sym Imm-48- xmode) (.sym Imm- base4 - xmode) 24-24-Prefixed xmode wstr op
  6678. (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3)
  6679. (.sym dst32-24-24-Prefixed- xmode) (.sym Imm-48- xmode) (.sym Imm- base4 - xmode))
  6680. sem)
  6681. (insn-imm1-imm2-dst-defn (.sym Imm-40- xmode) (.sym Imm- base3 - xmode) 24-16-Prefixed xmode wstr op
  6682. (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3)
  6683. (.sym dst32-24-16-Prefixed- xmode) (.sym Imm-40- xmode) (.sym Imm- base3 - xmode))
  6684. sem)
  6685. (insn-imm1-imm2-dst-defn (.sym Imm-32- xmode) (.sym Imm- base2 - xmode) 24-8-Prefixed xmode wstr op
  6686. (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3)
  6687. (.sym dst32-24-8-Prefixed- xmode) (.sym Imm-32- xmode) (.sym Imm- base2 - xmode))
  6688. sem)
  6689. (insn-imm1-imm2-dst-defn (.sym Imm-24- xmode) (.sym Imm- base1 - xmode) basic-Prefixed xmode wstr op
  6690. (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3)
  6691. (.sym dst32-basic-Prefixed- xmode) (.sym Imm-24- xmode) (.sym Imm- base1 - xmode))
  6692. sem)
  6693. )
  6694. )
  6695. ; m32c Unprefixed variants
  6696. (define-pmacro (insn32-imm1-imm2-dst-Unprefixed-defn xmode wstr wbit base1 base2 base3 base4 op opc1 opc2 opc3 sem)
  6697. (begin
  6698. (insn-imm1-imm2-dst-defn (.sym Imm-40- xmode) (.sym Imm- base4 - xmode) 16-24-Unprefixed xmode wstr op
  6699. (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3)
  6700. (.sym dst32-16-24-Unprefixed- xmode) (.sym Imm-40- xmode) (.sym Imm- base4 - xmode))
  6701. sem)
  6702. (insn-imm1-imm2-dst-defn (.sym Imm-32- xmode) (.sym Imm- base3 - xmode) 16-16-Unprefixed xmode wstr op
  6703. (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3)
  6704. (.sym dst32-16-16-Unprefixed- xmode) (.sym Imm-32- xmode) (.sym Imm- base3 - xmode))
  6705. sem)
  6706. (insn-imm1-imm2-dst-defn (.sym Imm-24- xmode) (.sym Imm- base2 - xmode) 16-8-Unprefixed xmode wstr op
  6707. (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3)
  6708. (.sym dst32-16-8-Unprefixed- xmode) (.sym Imm-24- xmode) (.sym Imm- base2 - xmode))
  6709. sem)
  6710. (insn-imm1-imm2-dst-defn (.sym Imm-16- xmode) (.sym Imm- base1 - xmode) basic-Unprefixed xmode wstr op
  6711. (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3)
  6712. (.sym dst32-basic-Unprefixed- xmode) (.sym Imm-16- xmode) (.sym Imm- base1 - xmode))
  6713. sem)
  6714. )
  6715. )
  6716. (define-pmacro (insn-imm1-imm2-dst-Prefixed op opc32-1 opc32-2 opc32-3 sem)
  6717. (begin
  6718. (insn32-imm1-imm2-dst-Prefixed-defn QI .b 0 32 40 48 56 op opc32-1 opc32-2 opc32-3 sem)
  6719. (insn32-imm1-imm2-dst-Prefixed-defn HI .w 1 40 48 56 64 op opc32-1 opc32-2 opc32-3 sem)
  6720. )
  6721. )
  6722. (define-pmacro (insn-imm1-imm2-dst-Unprefixed op opc32-1 opc32-2 opc32-3 sem)
  6723. (begin
  6724. (insn32-imm1-imm2-dst-Unprefixed-defn QI .b 0 24 32 40 48 op opc32-1 opc32-2 opc32-3 sem)
  6725. (insn32-imm1-imm2-dst-Unprefixed-defn HI .w 1 32 40 48 56 op opc32-1 opc32-2 opc32-3 sem)
  6726. )
  6727. )
  6728. ;=============================================================
  6729. ; Insn definitions
  6730. ;-------------------------------------------------------------
  6731. ; abs - absolute
  6732. ;-------------------------------------------------------------
  6733. (define-pmacro (abs-sem mode dst)
  6734. (sequence ((mode result))
  6735. (set result (abs mode dst))
  6736. (set obit (eq result dst))
  6737. (set-z-and-s result)
  6738. (set dst result))
  6739. )
  6740. (unary-insn abs (f-0-4 7) (f-4-3 3) (f-8-4 #xF) #xA #x1 #xF abs-sem)
  6741. ;-------------------------------------------------------------
  6742. ; adcf - addition carry flag
  6743. ;-------------------------------------------------------------
  6744. (define-pmacro (adcf-sem mode dst)
  6745. (sequence ((mode result))
  6746. (set result (addc mode dst 0 cbit))
  6747. (set obit (add-oflag mode dst 0 cbit))
  6748. (set cbit (add-cflag mode dst 0 cbit))
  6749. (set-z-and-s result)
  6750. (set dst result))
  6751. )
  6752. (unary-insn adcf (f-0-4 7) (f-4-3 3) (f-8-4 #xE) #xB #x1 #xE adcf-sem)
  6753. ;-------------------------------------------------------------
  6754. ; add - binary addition
  6755. ;-------------------------------------------------------------
  6756. (define-pmacro (add-sem mode src1 dst)
  6757. (sequence ((mode result))
  6758. (set result (add mode src1 dst))
  6759. (set obit (add-oflag mode src1 dst 0))
  6760. (set cbit (add-cflag mode src1 dst 0))
  6761. (set-z-and-s result)
  6762. (set dst result))
  6763. )
  6764. ; add.L:G #imm32,dst (m32 #2)
  6765. (binary-arith32-imm-dst-defn SI SI .l 0 add G #x8 #x3 #x1 add-sem)
  6766. ; add.size:G #imm,dst (m16 #1 m32 #1)
  6767. (binary-arith-imm-dst add G (f-0-4 7) (f-4-3 3) (f-8-4 4) #x8 #x2 #xE add-sem)
  6768. ; add.size:Q #imm4,dst (m16 #2 m32 #3)
  6769. (binary-arith-imm4-dst add (f-0-4 #xC) (f-4-3 4) #x7 #x3 add-sem)
  6770. (binary-arith32-imm4-dst-defn SI .l 1 0 add #x7 #x3 add-sem)
  6771. ; add.b:S #imm8,dst3 (m16 #3)
  6772. (binary-arith16-b-S-imm8-dst3 add ".b" (f-0-4 8) (f-4-1 0) add-sem)
  6773. ; add.BW:Q #imm4,sp (m16 #7)
  6774. (binary-arith16-Q-sp add (f-0-4 7) (f-4-4 #xD) (f-8-4 #xB) add-sem)
  6775. (dnmi add16-bQ-sp "add16-bQ-sp" ()
  6776. "add.b:q #${Imm-12-s4},sp"
  6777. (emit add16-wQ-sp Imm-12-s4))
  6778. ; add.BW:G #imm,sp (m16 #6)
  6779. (binary-arith16-G-sp add (f-0-4 7) (f-4-3 6) (f-8-4 #xE) (f-12-4 #xB) add-sem)
  6780. ; add.BW:G src,dst (m16 #4 m32 #6)
  6781. (binary-arith-src-dst add G (f-0-4 #xA) (f-4-3 0) #x1 #x8 add-sem)
  6782. ; add.B.S src2,r0l/r0h (m16 #5)
  6783. (binary-arith16-b-S-src2 add (f-0-4 2) (f-4-1 0) add-sem)
  6784. ; add.L:G src,dst (m32 #7)
  6785. (binary-arith32-src-dst-defn SI SI .l 1 add G #x1 #x2 add-sem)
  6786. ; add.L:S #imm{1,2},A0/A1 (m32 #5)
  6787. (binary-arith32-l-s-imm1-an add (f-0-2 2) (f-3-4 6) add-sem)
  6788. ; add.L:Q #imm3,sp (m32 #9)
  6789. (binary-arith32-l-q-imm3-sp add (f-0-2 1) (f-4-3 1) add-sem)
  6790. ; add.L:S #imm8,sp (m32 #10)
  6791. (binary-arith32-l-s-imm8-sp add (f-0-4 #xb) (f-4-4 6) (f-8-4 0) (f-12-4 3) add-sem)
  6792. ; add.L:G #imm16,sp (m32 #8)
  6793. (binary-arith32-l-g-imm16-sp add (f-0-4 #xb) (f-4-4 6) (f-8-4 1) (f-12-4 3) add-sem)
  6794. ; add.BW:S #imm,dst2 (m32 #4)
  6795. (binary-arith32-s-imm-dst QI .b 0 add #x0 #x3 add-sem)
  6796. (binary-arith32-s-imm-dst HI .w 1 add #x0 #x3 add-sem)
  6797. ;-------------------------------------------------------------
  6798. ; adc - binary add with carry
  6799. ;-------------------------------------------------------------
  6800. (define-pmacro (addc-sem mode src dst)
  6801. (sequence ((mode result))
  6802. (set result (addc mode src dst cbit))
  6803. (set obit (add-oflag mode src dst cbit))
  6804. (set cbit (add-cflag mode src dst cbit))
  6805. (set-z-and-s result)
  6806. (set dst result))
  6807. )
  6808. ; adc.size:G #imm,dst
  6809. (binary-arith16-imm-dst-defn QI QI .b 0 adc X (f-0-4 7) (f-4-3 3) (f-8-4 6) addc-sem)
  6810. (binary-arith16-imm-dst-defn HI HI .w 1 adc X (f-0-4 7) (f-4-3 3) (f-8-4 6) addc-sem)
  6811. (binary-arith32-imm-dst-Prefixed QI QI .b 0 adc X #x8 #x2 #xE addc-sem)
  6812. (binary-arith32-imm-dst-Prefixed HI HI .w 1 adc X #x8 #x2 #xE addc-sem)
  6813. ; adc.BW:G src,dst
  6814. (binary-arith16-src-dst-defn QI QI .b 0 adc X (f-0-4 #xB) (f-4-3 0) addc-sem)
  6815. (binary-arith16-src-dst-defn HI HI .w 1 adc X (f-0-4 #xB) (f-4-3 0) addc-sem)
  6816. (binary-arith32-src-dst-Prefixed QI QI .b 0 adc X #x1 #x4 addc-sem)
  6817. (binary-arith32-src-dst-Prefixed HI HI .w 1 adc X #x1 #x4 addc-sem)
  6818. ;-------------------------------------------------------------
  6819. ; dadc - decimal add with carry
  6820. ; dadd - decimal addition
  6821. ;-------------------------------------------------------------
  6822. (define-pmacro (dadc-sem mode src dst)
  6823. (sequence ((mode result))
  6824. (set result (subc mode dst src (not cbit)))
  6825. (set cbit (sub-cflag mode dst src (not cbit)))
  6826. (set-z-and-s result)
  6827. (set dst result))
  6828. )
  6829. (define-pmacro (decimal-subtraction16-insn op opc1 opc2)
  6830. (begin
  6831. ; op.b #imm8,r0l
  6832. (dni (.sym op 16.b-imm8)
  6833. (.str op ".b #imm8")
  6834. ((machine 16))
  6835. (.str op ".b #${Imm-16-QI},r0l")
  6836. (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 opc1) Imm-16-QI)
  6837. ((.sym op -sem) QI Imm-16-QI R0l)
  6838. ())
  6839. ; op.w #imm16,r0
  6840. (dni (.sym op 16.w-imm16)
  6841. (.str op ".b #imm16")
  6842. ((machine 16))
  6843. (.str op ".w #${Imm-16-HI},r0")
  6844. (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 opc1) Imm-16-HI)
  6845. ((.sym op -sem) HI Imm-16-HI R0)
  6846. ())
  6847. ; op.b #r0h,r0l
  6848. (dni (.sym op 16.b-r0h-r0l)
  6849. (.str op ".b r0h,r0l")
  6850. ((machine 16))
  6851. (.str op ".b r0h,r0l")
  6852. (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 opc2))
  6853. ((.sym op -sem) QI R0h R0l)
  6854. ())
  6855. ; op.w #r1,r0
  6856. (dni (.sym op 16.w-r1-r0)
  6857. (.str op ".b r1,r0")
  6858. ((machine 16))
  6859. (.str op ".w r1,r0")
  6860. (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 opc2))
  6861. ((.sym op -sem) HI R1 R0)
  6862. ())
  6863. )
  6864. )
  6865. ; dadc for m16c
  6866. (decimal-subtraction16-insn dadc #xE #x6 )
  6867. ; dadc.size #imm,dst
  6868. (binary-arith32-imm-dst-Prefixed QI QI .b 0 dadc X #x8 #x0 #xE dadc-sem)
  6869. (binary-arith32-imm-dst-Prefixed HI HI .w 1 dadc X #x8 #x0 #xE dadc-sem)
  6870. ; dadc.BW src,dst
  6871. (binary-arith32-src-dst-Prefixed QI QI .b 0 dadc X #x1 #x8 dadc-sem)
  6872. (binary-arith32-src-dst-Prefixed HI HI .w 1 dadc X #x1 #x8 dadc-sem)
  6873. (define-pmacro (dadd-sem mode src dst)
  6874. (sequence ((mode result))
  6875. (set result (subc mode dst src 0))
  6876. (set cbit (sub-cflag mode dst src 0))
  6877. (set-z-and-s result)
  6878. (set dst result))
  6879. )
  6880. ; dadd for m16c
  6881. (decimal-subtraction16-insn dadd #xC #x4)
  6882. ; dadd.size #imm,dst
  6883. (binary-arith32-imm-dst-Prefixed QI QI .b 0 dadd X #x8 #x1 #xE dadd-sem)
  6884. (binary-arith32-imm-dst-Prefixed HI HI .w 1 dadd X #x8 #x1 #xE dadd-sem)
  6885. ; dadd.BW src,dst
  6886. (binary-arith32-src-dst-Prefixed QI QI .b 0 dadd X #x1 #x0 dadd-sem)
  6887. (binary-arith32-src-dst-Prefixed HI HI .w 1 dadd X #x1 #x0 dadd-sem)
  6888. ;-------------------------------------------------------------;
  6889. ; addx - Add extend sign with no carry
  6890. ;-------------------------------------------------------------;
  6891. (define-pmacro (addx-sem mode src dst)
  6892. (sequence ((SI source) (SI result))
  6893. (set source (zext SI (trunc QI src)))
  6894. (set result (add SI source dst))
  6895. (set obit (add-oflag SI source dst 0))
  6896. (set cbit (add-cflag SI source dst 0))
  6897. (set-z-and-s result)
  6898. (set dst result))
  6899. )
  6900. ; addx #imm,dst
  6901. (binary-arith32-imm-dst-defn QI SI "" 0 addx X #x8 #x1 #x1 addx-sem)
  6902. ; addx src,dst
  6903. (binary-arith32-src-dst-defn QI SI "" 0 addx X #x1 #x2 addx-sem)
  6904. ;-------------------------------------------------------------
  6905. ; adjnz - Add/Sub and branch if not zero
  6906. ;-------------------------------------------------------------
  6907. (define-pmacro (arith-jnz-sem mode src dst label)
  6908. (sequence ((mode result))
  6909. (set result (add mode src dst))
  6910. (set dst result)
  6911. (if (ne result 0)
  6912. (set pc label)))
  6913. )
  6914. ; adjnz.size #imm4,dst,label
  6915. (arith-jnz-imm4-dst adjnz s4 (f-0-4 #xF) (f-4-3 4) #xf #x1 arith-jnz-sem)
  6916. ;-------------------------------------------------------------
  6917. ; and - binary and
  6918. ;-------------------------------------------------------------
  6919. (define-pmacro (and-sem mode src1 dst)
  6920. (sequence ((mode result))
  6921. (set result (and mode src1 dst))
  6922. (set-z-and-s result)
  6923. (set dst result))
  6924. )
  6925. ; and.size:G #imm,dst (m16 #1 m32 #1)
  6926. (binary-arith-imm-dst and G (f-0-4 7) (f-4-3 3) (f-8-4 2) #x8 #x3 #xF and-sem)
  6927. ; and.b:S #imm8,dst3 (m16 #2)
  6928. (binary-arith16-b-S-imm8-dst3 and ".b" (f-0-4 9) (f-4-1 0) and-sem)
  6929. ; and.BW:G src,dst (m16 #3 m32 #3)
  6930. (binary-arith-src-dst and G (f-0-4 #x9) (f-4-3 0) #x1 #xD and-sem)
  6931. ; and.B.S src2,r0l/r0h (m16 #4)
  6932. (binary-arith16-b-S-src2 and (f-0-4 1) (f-4-1 0) and-sem)
  6933. ; and.BW:S #imm,dst2 (m32 #2)
  6934. (binary-arith32-s-imm-dst QI .b 0 and #x1 #x6 and-sem)
  6935. (binary-arith32-s-imm-dst HI .w 1 and #x1 #x6 and-sem)
  6936. ;-------------------------------------------------------------
  6937. ; band - bit and
  6938. ;-------------------------------------------------------------
  6939. (define-pmacro (band-sem src)
  6940. (set cbit (and src cbit))
  6941. )
  6942. (bitsrc-insn band (f-0-4 7) (f-4-4 #xE) (f-8-4 4) #xD #x0 #x1 band-sem)
  6943. ;-------------------------------------------------------------
  6944. ; bclr - bit clear
  6945. ;-------------------------------------------------------------
  6946. (define-pmacro (bclr-sem dst)
  6947. (set dst 0)
  6948. )
  6949. (bitdst-insn bclr (f-0-4 7) (f-4-4 #xE) (f-8-4 8) (f-0-2 1) (f-2-2 0) (f-4-1 0) #xD #x0 #x6 bclr-sem)
  6950. ;-------------------------------------------------------------
  6951. ; bitindex - bit index
  6952. ;-------------------------------------------------------------
  6953. (define-pmacro (bitindex-sem mode dst)
  6954. (set BitIndex dst)
  6955. )
  6956. (unary-insn-defn 32 16-Unprefixed QI .b bitindex
  6957. (+ (f-0-4 #xC) (f-7-1 0) dst32-16-Unprefixed-QI (f-10-2 #x2) (f-12-4 #xE))
  6958. bitindex-sem)
  6959. (unary-insn-defn 32 16-Unprefixed HI .w bitindex
  6960. (+ (f-0-4 #xC) (f-7-1 1) dst32-16-Unprefixed-HI (f-10-2 #x2) (f-12-4 #xE))
  6961. bitindex-sem)
  6962. ;-------------------------------------------------------------
  6963. ; bmCnd - bit move condition
  6964. ;-------------------------------------------------------------
  6965. (define-pmacro (test-condition16 cond)
  6966. (case UQI cond
  6967. ((#x00) (trunc BI cbit))
  6968. ((#x01) (not (or cbit zbit)))
  6969. ((#x02) (trunc BI zbit))
  6970. ((#x03) (trunc BI sbit))
  6971. ((#x04) (or zbit (xor sbit obit)))
  6972. ((#x05) (trunc BI obit))
  6973. ((#x06) (xor sbit obit))
  6974. ((#xf8) (not cbit))
  6975. ((#xf9) (or cbit zbit))
  6976. ((#xfa) (not zbit))
  6977. ((#xfb) (not sbit))
  6978. ((#xfc) (not (or zbit (xor sbit obit))))
  6979. ((#xfd) (not obit))
  6980. ((#xfe) (not (xor sbit obit)))
  6981. (else (const BI 0))
  6982. )
  6983. )
  6984. (define-pmacro (test-condition32 cond)
  6985. (case UQI cond
  6986. ((#x00) (not cbit))
  6987. ((#x01) (or cbit zbit))
  6988. ((#x02) (not zbit))
  6989. ((#x03) (not sbit))
  6990. ((#x04) (not obit))
  6991. ((#x05) (not (or zbit (xor sbit obit))))
  6992. ((#x06) (not (xor sbit obit)))
  6993. ((#x08) (trunc BI cbit))
  6994. ((#x09) (not (or cbit zbit)))
  6995. ((#x0a) (trunc BI zbit))
  6996. ((#x0b) (trunc BI sbit))
  6997. ((#x0c) (trunc BI obit))
  6998. ((#x0d) (or zbit (xor sbit obit)))
  6999. ((#x0e) (xor sbit obit))
  7000. (else (const BI 0))
  7001. )
  7002. )
  7003. (define-pmacro (bitcond-sem mach op cond)
  7004. (if ((.sym test-condition mach) cond)
  7005. (set op 1)
  7006. (set op 0))
  7007. )
  7008. (bitcond-insn bm (f-0-4 7) (f-4-4 #xE) (f-8-4 2) #xD #x0 #x2 bitcond-sem)
  7009. (dni bm16-c
  7010. "bm16 C"
  7011. ((machine 16))
  7012. "bm$cond16c c"
  7013. (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xD) cond16c)
  7014. (bitcond-sem 16 cbit cond16c)
  7015. ())
  7016. (dni bm32-c
  7017. "bm32 C"
  7018. ((machine 32))
  7019. "bm$cond32 c"
  7020. (+ (f-0-4 #xD) (f-4-4 #x9) (f-8-1 0) (f-10-3 5) cond32)
  7021. (bitcond-sem 32 cbit cond32)
  7022. ())
  7023. ;-------------------------------------------------------------
  7024. ; bnand
  7025. ;-------------------------------------------------------------
  7026. (define-pmacro (bnand-sem src)
  7027. (set cbit (and (inv src) cbit))
  7028. )
  7029. (bitsrc-insn bnand (f-0-4 7) (f-4-4 #xE) (f-8-4 5) #xD #x0 #x3 bnand-sem)
  7030. ;-------------------------------------------------------------
  7031. ; bnor
  7032. ;-------------------------------------------------------------
  7033. (define-pmacro (bnor-sem src)
  7034. (set cbit (or (inv src) cbit))
  7035. )
  7036. (bitsrc-insn bnor (f-0-4 7) (f-4-4 #xE) (f-8-4 7) #xD #x0 #x6 bnor-sem)
  7037. ;-------------------------------------------------------------
  7038. ; bnot
  7039. ;-------------------------------------------------------------
  7040. (define-pmacro (bnot-sem dst)
  7041. (set dst (inv dst))
  7042. )
  7043. (bitdst-insn bnot (f-0-4 7) (f-4-4 #xE) (f-8-4 #xA) (f-0-2 1) (f-2-2 1) (f-4-1 0) #xD #x0 #x3 bnot-sem)
  7044. ;-------------------------------------------------------------
  7045. ; bntst
  7046. ;-------------------------------------------------------------
  7047. (define-pmacro (bntst-sem src)
  7048. (set cbit (inv src))
  7049. (set zbit (inv src))
  7050. )
  7051. (bitsrc-insn bntst (f-0-4 7) (f-4-4 #xE) (f-8-4 3) #xD #x0 #x0 bntst-sem)
  7052. ;-------------------------------------------------------------
  7053. ; bnxor
  7054. ;-------------------------------------------------------------
  7055. (define-pmacro (bnxor-sem src)
  7056. (set cbit (xor (inv src) cbit))
  7057. )
  7058. (bitsrc-insn bnxor (f-0-4 7) (f-4-4 #xE) (f-8-4 #xD) #xD #x0 #x7 bnxor-sem)
  7059. ;-------------------------------------------------------------
  7060. ; bor
  7061. ;-------------------------------------------------------------
  7062. (define-pmacro (bor-sem src)
  7063. (set cbit (or src cbit))
  7064. )
  7065. (bitsrc-insn bor (f-0-4 7) (f-4-4 #xE) (f-8-4 #x6) #xD #x0 #x4 bor-sem)
  7066. ;-------------------------------------------------------------
  7067. ; brk
  7068. ;-------------------------------------------------------------
  7069. (dni brk16
  7070. "brk"
  7071. ((machine 16))
  7072. "brk"
  7073. (+ (f-0-4 #x0) (f-4-4 #x0))
  7074. (nop)
  7075. ())
  7076. (dni brk32
  7077. "brk"
  7078. ((machine 32))
  7079. "brk"
  7080. (+ (f-0-4 #x0) (f-4-4 #x0))
  7081. (nop)
  7082. ())
  7083. ;-------------------------------------------------------------
  7084. ; brk2
  7085. ;-------------------------------------------------------------
  7086. (dni brk232
  7087. "brk2"
  7088. ((machine 32))
  7089. "brk2"
  7090. (+ (f-0-4 #x0) (f-4-4 #x8))
  7091. (nop)
  7092. ())
  7093. ;-------------------------------------------------------------
  7094. ; bset
  7095. ;-------------------------------------------------------------
  7096. (define-pmacro (bset-sem dst)
  7097. (set dst 1)
  7098. )
  7099. (bitdst-insn bset (f-0-4 7) (f-4-4 #xE) (f-8-4 9) (f-0-2 1) (f-2-2 0) (f-4-1 1) #xD #x0 #x7 bset-sem)
  7100. ;-------------------------------------------------------------
  7101. ; btst
  7102. ;-------------------------------------------------------------
  7103. (define-pmacro (btst-sem dst)
  7104. (set zbit (inv dst))
  7105. (set cbit dst)
  7106. )
  7107. (bitdst16-defn btst (f-0-4 7) (f-4-4 #xE) (f-8-4 #xB) (f-0-2 1) (f-2-2 1) (f-4-1 1) btst-sem)
  7108. (bit-insn-defn 32 btst G bit32-16-Unprefixed
  7109. (+ (f-0-4 #xD) bit32-16-Unprefixed (f-7-1 #x0) (f-10-3 #x0))
  7110. btst-sem)
  7111. (dni btst.s "btst:s" ((machine 32))
  7112. "btst:s ${Bit3-S},${Dsp-8-u16}"
  7113. (+ (f-0-2 #x0) (f-4-3 #x5) Bit3-S Dsp-8-u16)
  7114. () ())
  7115. ;-------------------------------------------------------------
  7116. ; btstc
  7117. ;-------------------------------------------------------------
  7118. (define-pmacro (btstc-sem dst)
  7119. (set zbit (inv dst))
  7120. (set cbit dst)
  7121. (set dst (const 0))
  7122. )
  7123. (bitdstnos-insn btstc (f-0-4 7) (f-4-4 #xE) (f-8-4 #x0) #xD #x0 #x4 btstc-sem)
  7124. ;-------------------------------------------------------------
  7125. ; btsts
  7126. ;-------------------------------------------------------------
  7127. (define-pmacro (btsts-sem dst)
  7128. (set zbit (inv dst))
  7129. (set cbit dst)
  7130. (set dst (const 0))
  7131. )
  7132. (bitdstnos-insn btsts (f-0-4 7) (f-4-4 #xE) (f-8-4 #x1) #xD #x0 #x5 btsts-sem)
  7133. ;-------------------------------------------------------------
  7134. ; bxor
  7135. ;-------------------------------------------------------------
  7136. (define-pmacro (bxor-sem src)
  7137. (set cbit (xor src cbit))
  7138. )
  7139. (bitsrc-insn bxor (f-0-4 7) (f-4-4 #xE) (f-8-4 #xC) #xD #x0 #x5 bxor-sem)
  7140. ;-------------------------------------------------------------
  7141. ; clip
  7142. ;-------------------------------------------------------------
  7143. (define-pmacro (clip-sem mode imm1 imm2 dest)
  7144. (sequence ()
  7145. (if (gt mode imm1 dest)
  7146. (set dest imm1))
  7147. (if (lt mode imm2 dest)
  7148. (set dest imm2)))
  7149. )
  7150. (insn-imm1-imm2-dst-Prefixed clip #x8 #x3 #xE clip-sem)
  7151. ;-------------------------------------------------------------
  7152. ; cmp - binary compare
  7153. ;-------------------------------------------------------------
  7154. (define-pmacro (cmp-sem mode src1 dst)
  7155. (sequence ((mode result))
  7156. (set result (sub mode dst src1))
  7157. (set obit (sub-oflag mode dst src1 0))
  7158. (set cbit (not (sub-cflag mode dst src1 0)))
  7159. (set-z-and-s result))
  7160. )
  7161. ; cmp.L:G #imm32,dst (m32 #2)
  7162. (binary-arith32-imm-dst-defn SI SI .l 0 cmp G #xA #x3 #x1 cmp-sem)
  7163. ; cmp.size:G #imm,dst (m16 #1 m32 #1)
  7164. (binary-arith-imm-dst cmp G (f-0-4 7) (f-4-3 3) (f-8-4 8) #x9 #x2 #xE cmp-sem)
  7165. ; cmp.size:Q #imm4,dst (m16 #2 m32 #3)
  7166. (binary-arith-imm4-dst cmp (f-0-4 #xD) (f-4-3 0) #x7 #x1 cmp-sem)
  7167. ; cmp.b:S #imm8,dst3 (m16 #3)
  7168. (binary-arith16-b-S-imm8-dst3 cmp ".b" (f-0-4 #xE) (f-4-1 0) cmp-sem)
  7169. ; cmp.BW:G src,dst (m16 #4 m32 #5)
  7170. (binary-arith-src-dst cmp G (f-0-4 #xC) (f-4-3 0) #x1 #x6 cmp-sem)
  7171. ; cmp.B.S src2,r0l/r0h (m16 #5)
  7172. (binary-arith16-b-S-src2 cmp (f-0-4 3) (f-4-1 1) cmp-sem)
  7173. ; cmp.L:G src,dst (m32 #6)
  7174. (binary-arith32-src-dst-defn SI SI .l 1 cmp G #x1 #x1 cmp-sem)
  7175. ; cmp.BW:S #imm,dst2 (m32 #4)
  7176. (binary-arith32-s-imm-dst QI .b 0 cmp #x1 #x3 cmp-sem)
  7177. (binary-arith32-s-imm-dst HI .w 1 cmp #x1 #x3 cmp-sem)
  7178. ; cmp.BW:s src2,r0[l] (m32 #7)
  7179. (binary-arith32-S-src2 cmp QI .b 0 (f-0-2 1) (f-4-3 0) cmp-sem)
  7180. (binary-arith32-S-src2 cmp HI .w 1 (f-0-2 1) (f-4-3 0) cmp-sem)
  7181. ;-------------------------------------------------------------
  7182. ; cmpx - binary compare extend sign
  7183. ;-------------------------------------------------------------
  7184. (define-pmacro (cmpx-sem mode src1 dst)
  7185. (sequence ((mode result))
  7186. (set result (sub mode dst (ext mode src1)))
  7187. (set obit (sub-oflag mode dst (ext mode src1) 0))
  7188. (set cbit (sub-cflag mode dst (ext mode src1) 0))
  7189. (set-z-and-s result))
  7190. )
  7191. (binary-arith32-imm-dst-defn QI SI "" 0 cmpx X #xA #x1 #x1 cmpx-sem)
  7192. ;-------------------------------------------------------------
  7193. ; dec - decrement
  7194. ;-------------------------------------------------------------
  7195. (define-pmacro (dec-sem mode dest)
  7196. (sequence ((mode result))
  7197. (set result (sub mode dest 1))
  7198. (set-z-and-s result)
  7199. (set dest result))
  7200. )
  7201. (dni dec16.b
  7202. "dec.b Dst16-3-S-8"
  7203. ((machine 16))
  7204. "dec.b ${Dst16-3-S-8}"
  7205. (+ (f-0-4 #xA) (f-4-1 #x1) Dst16-3-S-8)
  7206. (dec-sem QI Dst16-3-S-8)
  7207. ())
  7208. (dni dec16.w
  7209. "dec.w Dst16An-S"
  7210. ((machine 16))
  7211. "dec.w ${Dst16An-S}"
  7212. (+ (f-0-4 #xF) (f-5-3 #x2) Dst16An-S)
  7213. (dec-sem HI Dst16An-S)
  7214. ())
  7215. (unary32-defn QI .b 0 dec #xB #x0 #xE dec-sem)
  7216. (unary32-defn HI .w 1 dec #xB #x0 #xE dec-sem)
  7217. ;-------------------------------------------------------------
  7218. ; div - divide
  7219. ; divu - divide unsigned
  7220. ; divx - divide extension
  7221. ;-------------------------------------------------------------
  7222. ; div.BW #imm
  7223. (div-imm div div mod SI 127 -128 32767 -32768 (f-0-4 #x7) (f-4-3 6) (f-8-4 #xE) (f-12-4 #x1) #xB #x0 #x2 #x3 div-sem)
  7224. (div-imm divu udiv umod USI 255 0 65535 0 (f-0-4 #x7) (f-4-3 6) (f-8-4 #xE) (f-12-4 #x0) #xB #x0 #x0 #x3 div-sem)
  7225. (div-imm divx div mod SI 127 -128 32767 -32768 (f-0-4 #x7) (f-4-3 6) (f-8-4 #xE) (f-12-4 #x3) #xB #x2 #x2 #x3 div-sem)
  7226. ; div.BW src
  7227. (div-src div div mod SI 127 -128 32767 -32768 (f-0-4 #x7) (f-4-3 3) (f-8-4 #xD) #x8 #x1 #xE div-sem)
  7228. (div-src divu udiv umod USI 255 0 65535 0 (f-0-4 #x7) (f-4-3 3) (f-8-4 #xC) #x8 #x0 #xE div-sem)
  7229. (div-src divx div mod SI 127 -128 32767 -32768 (f-0-4 #x7) (f-4-3 3) (f-8-4 #x9) #x9 #x1 #xE div-sem)
  7230. (div-src-defn 32 .l div dst32-24-Prefixed-SI
  7231. (+ (f-0-4 0) (f-4-4 1) (f-8-4 #xA) (f-15-1 1) (f-18-2 #x1) (f-20-4 #xf) dst32-24-Prefixed-SI)
  7232. div mod SI R2R0 R2R0 NoRemainder #x7fffffff (neg SI #x80000000)
  7233. div-sem)
  7234. (div-src-defn 32 .l divu dst32-24-Prefixed-SI
  7235. (+ (f-0-4 0) (f-4-4 1) (f-8-4 #xA) (f-15-1 1) (f-18-2 #x0) (f-20-4 #xf) dst32-24-Prefixed-SI)
  7236. udiv umod USI R2R0 R2R0 NoRemainder #x80000000 0
  7237. div-sem)
  7238. (div-src-defn 32 .l divx dst32-24-Prefixed-SI
  7239. (+ (f-0-4 0) (f-4-4 1) (f-8-4 #xA) (f-15-1 1) (f-18-2 #x2) (f-20-4 #xf) dst32-24-Prefixed-SI)
  7240. div mod SI R2R0 R2R0 NoRemainder #x7fffffff (neg SI #x80000000)
  7241. div-sem)
  7242. ;-------------------------------------------------------------
  7243. ; dsbb - decimal subtraction with borrow
  7244. ; dsub - decimal subtraction
  7245. ;-------------------------------------------------------------
  7246. (define-pmacro (dsbb-sem mode src dst)
  7247. (sequence ((mode result))
  7248. (set result (subc mode dst src (not cbit)))
  7249. (set cbit (sub-cflag mode dst src (not cbit)))
  7250. (set-z-and-s result)
  7251. (set dst result))
  7252. )
  7253. ; dsbb for m16c
  7254. (decimal-subtraction16-insn dsbb #xF #x7)
  7255. ; dsbb.size #imm,dst
  7256. (binary-arith32-imm-dst-Prefixed QI QI .b 0 dsbb X #x9 #x0 #xE dsbb-sem)
  7257. (binary-arith32-imm-dst-Prefixed HI HI .w 1 dsbb X #x9 #x0 #xE dsbb-sem)
  7258. ; dsbb.BW src,dst
  7259. (binary-arith32-src-dst-Prefixed QI QI .b 0 dsbb X #x1 #xA dsbb-sem)
  7260. (binary-arith32-src-dst-Prefixed HI HI .w 1 dsbb X #x1 #xA dsbb-sem)
  7261. (define-pmacro (dsub-sem mode src dst)
  7262. (sequence ((mode result))
  7263. (set result (subc mode dst src 0))
  7264. (set cbit (sub-cflag mode dst src 0))
  7265. (set-z-and-s result)
  7266. (set dst result))
  7267. )
  7268. ; dsub for m16c
  7269. (decimal-subtraction16-insn dsub #xD #x5)
  7270. ; dsub.size #imm,dst
  7271. (binary-arith32-imm-dst-Prefixed QI QI .b 0 dsub X #x9 #x1 #xE dsub-sem)
  7272. (binary-arith32-imm-dst-Prefixed HI HI .w 1 dsub X #x9 #x1 #xE dsub-sem)
  7273. ; dsub.BW src,dst
  7274. (binary-arith32-src-dst-Prefixed QI QI .b 0 dsub X #x1 #x2 dsub-sem)
  7275. (binary-arith32-src-dst-Prefixed HI HI .w 1 dsub X #x1 #x2 dsub-sem)
  7276. ;-------------------------------------------------------------
  7277. ; sub - binary subtraction
  7278. ;-------------------------------------------------------------
  7279. (define-pmacro (sub-sem mode src1 dst)
  7280. (sequence ((mode result))
  7281. (set result (sub mode dst src1))
  7282. (set obit (sub-oflag mode dst src1 0))
  7283. (set cbit (sub-cflag mode dst src1 0))
  7284. (set dst result)
  7285. (set-z-and-s result)))
  7286. ; sub.size:G #imm,dst (m16 #1 m32 #1)
  7287. (binary-arith-imm-dst sub G (f-0-4 7) (f-4-3 3) (f-8-4 5) #x8 #x3 #xE sub-sem)
  7288. ; sub.b:S #imm8,dst3 (m16 #2)
  7289. (binary-arith16-b-S-imm8-dst3 sub ".b" (f-0-4 8) (f-4-1 1) sub-sem)
  7290. ; sub.BW:G src,dst (m16 #3 m32 #4)
  7291. (binary-arith-src-dst sub G (f-0-4 #xA) (f-4-3 4) #x1 #xA sub-sem)
  7292. ; sub.B.S src2,r0l/r0h (m16 #4)
  7293. (binary-arith16-b-S-src2 sub (f-0-4 2) (f-4-1 1) sub-sem)
  7294. ; sub.L:G #imm32,dst (m32 #2)
  7295. (binary-arith32-imm-dst-defn SI SI .l 0 sub G #x9 #x3 #x1 sub-sem)
  7296. ; sub.BW:S #imm,dst2 (m32 #3)
  7297. (binary-arith32-s-imm-dst QI .b 0 sub #x0 #x7 sub-sem)
  7298. (binary-arith32-s-imm-dst HI .w 1 sub #x0 #x7 sub-sem)
  7299. ; sub.L:G src,dst (m32 #5)
  7300. (binary-arith32-src-dst-defn SI SI .l 1 sub G #x1 #x0 sub-sem)
  7301. ;-------------------------------------------------------------
  7302. ; enter - enter function
  7303. ; exitd - exit and deallocate stack frame
  7304. ;-------------------------------------------------------------
  7305. (define-pmacro (enter16-sem mach amt)
  7306. (sequence ()
  7307. (set (reg h-sp) (sub (reg h-sp) 2))
  7308. (set (mem16 HI (reg h-sp)) (reg h-fb))
  7309. (set (reg h-fb) (reg h-sp))
  7310. (set (reg h-sp) (sub (reg h-sp) amt))))
  7311. (define-pmacro (exit16-sem mach)
  7312. (sequence ((SI newpc))
  7313. (set (reg h-sp) (reg h-fb))
  7314. (set (reg h-fb) (mem16 HI (reg h-sp)))
  7315. (set (reg h-sp) (add (reg h-sp) 2))
  7316. (set newpc (mem16 HI (reg h-sp)))
  7317. (set (reg h-sp) (add (reg h-sp) 2))
  7318. (set newpc (or newpc (sll (mem16 QI (reg h-sp)) (const 16))))
  7319. (set (reg h-sp) (add (reg h-sp) 1))
  7320. (set pc newpc)))
  7321. (define-pmacro (enter32-sem mach amt)
  7322. (sequence ()
  7323. (set (reg h-sp) (sub (reg h-sp) 4))
  7324. (set (mem32 SI (reg h-sp)) (reg h-fb))
  7325. (set (reg h-fb) (reg h-sp))
  7326. (set (reg h-sp) (sub (reg h-sp) amt))))
  7327. (define-pmacro (exit32-sem mach)
  7328. (sequence ((SI newpc))
  7329. (set (reg h-sp) (reg h-fb))
  7330. (set (reg h-fb) (mem32 SI (reg h-sp)))
  7331. (set (reg h-sp) (add (reg h-sp) 4))
  7332. (set newpc (mem32 SI (reg h-sp)))
  7333. (set (reg h-sp) (add (reg h-sp) 4))
  7334. (set pc newpc)))
  7335. (dni enter16 "enter #Imm-16-QI" ((machine 16))
  7336. ("enter #${Dsp-16-u8}")
  7337. (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 2) Dsp-16-u8)
  7338. (enter16-sem 16 Dsp-16-u8)
  7339. ())
  7340. (dni exitd16 "exitd" ((machine 16))
  7341. ("exitd")
  7342. (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 2))
  7343. (exit16-sem 16)
  7344. ())
  7345. (dni enter32 "enter #Imm-8-QI" ((machine 32))
  7346. ("enter #${Dsp-8-u8}")
  7347. (+ (f-0-4 #xE) (f-4-4 #xC) Dsp-8-u8)
  7348. (enter32-sem 32 Dsp-8-u8)
  7349. ())
  7350. (dni exitd32 "exitd" ((machine 32))
  7351. ("exitd")
  7352. (+ (f-0-4 #xF) (f-4-4 #xC))
  7353. (exit32-sem 32)
  7354. ())
  7355. ;-------------------------------------------------------------
  7356. ; fclr - flag register clear
  7357. ; fset - flag register set
  7358. ;-------------------------------------------------------------
  7359. (define-pmacro (set-flags-sem flag)
  7360. (sequence ((SI tmp))
  7361. (case DFLT flag
  7362. ((#x0) (set cbit 1))
  7363. ((#x1) (set dbit 1))
  7364. ((#x2) (set zbit 1))
  7365. ((#x3) (set sbit 1))
  7366. ((#x4) (set bbit 1))
  7367. ((#x5) (set obit 1))
  7368. ((#x6) (set ibit 1))
  7369. ((#x7) (set ubit 1)))
  7370. )
  7371. )
  7372. (define-pmacro (clear-flags-sem flag)
  7373. (sequence ((SI tmp))
  7374. (case DFLT flag
  7375. ((#x0) (set cbit 0))
  7376. ((#x1) (set dbit 0))
  7377. ((#x2) (set zbit 0))
  7378. ((#x3) (set sbit 0))
  7379. ((#x4) (set bbit 0))
  7380. ((#x5) (set obit 0))
  7381. ((#x6) (set ibit 0))
  7382. ((#x7) (set ubit 0)))
  7383. )
  7384. )
  7385. (dni fclr16 "fclr flag" ((machine 16))
  7386. ("fclr ${flags16}")
  7387. (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) flags16 (f-12-4 5))
  7388. (clear-flags-sem flags16)
  7389. ())
  7390. (dni fset16 "fset flag" ((machine 16))
  7391. ("fset ${flags16}")
  7392. (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) flags16 (f-12-4 4))
  7393. (set-flags-sem flags16)
  7394. ())
  7395. (dni fclr "fclr" ((machine 32))
  7396. ("fclr ${flags32}")
  7397. (+ (f-0-4 #xD) (f-4-4 3) (f-8-4 #xE) (f-12-1 1) flags32)
  7398. (clear-flags-sem flags32)
  7399. ())
  7400. (dni fset "fset" ((machine 32))
  7401. ("fset ${flags32}")
  7402. (+ (f-0-4 #xD) (f-4-4 1) (f-8-4 #xE) (f-12-1 1) flags32)
  7403. (set-flags-sem flags32)
  7404. ())
  7405. ;-------------------------------------------------------------
  7406. ; inc - increment
  7407. ;-------------------------------------------------------------
  7408. (define-pmacro (inc-sem mode dest)
  7409. (sequence ((mode result))
  7410. (set result (add mode dest 1))
  7411. (set-z-and-s result)
  7412. (set dest result))
  7413. )
  7414. (dni inc16.b
  7415. "inc.b Dst16-3-S-8"
  7416. ((machine 16))
  7417. "inc.b ${Dst16-3-S-8}"
  7418. (+ (f-0-4 #xA) (f-4-1 #x0) Dst16-3-S-8)
  7419. (inc-sem QI Dst16-3-S-8)
  7420. ())
  7421. (dni inc16.w
  7422. "inc.w Dst16An-S"
  7423. ((machine 16))
  7424. "inc.w ${Dst16An-S}"
  7425. (+ (f-0-4 #xB) (f-5-3 #x2) Dst16An-S)
  7426. (inc-sem HI Dst16An-S)
  7427. ())
  7428. (unary32-defn QI .b 0 inc #xA #x0 #xE inc-sem)
  7429. (unary32-defn HI .w 1 inc #xA #x0 #xE inc-sem)
  7430. ;-------------------------------------------------------------
  7431. ; freit - fast return from interrupt (m32)
  7432. ; int - interrupt
  7433. ; into - interrupt on overflow
  7434. ;-------------------------------------------------------------
  7435. ; ??? semantics
  7436. (dni freit32 "FREIT" ((machine 32))
  7437. ("freit")
  7438. (+ (f-0-4 9) (f-4-4 #xF))
  7439. (nop)
  7440. ())
  7441. (dni int16 "int Dsp-10-u6" ((machine 16))
  7442. ("int #${Dsp-10-u6}")
  7443. (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-2 3) Dsp-10-u6)
  7444. (c-call VOID "do_int" pc Dsp-10-u6)
  7445. ())
  7446. (dni into16 "into" ((machine 16))
  7447. ("into")
  7448. (+ (f-0-4 #xF) (f-4-4 6))
  7449. (nop)
  7450. ())
  7451. (dni int32 "int Dsp-8-u6" ((machine 32))
  7452. ("int #${Dsp-8-u6}")
  7453. (+ (f-0-4 #xB) (f-4-4 #xE) Dsp-8-u6 (f-14-2 0))
  7454. (c-call VOID "do_int" pc Dsp-8-u6)
  7455. ())
  7456. (dni into32 "into" ((machine 32))
  7457. ("into")
  7458. (+ (f-0-4 #xB) (f-4-4 #xF))
  7459. (nop)
  7460. ())
  7461. ;-------------------------------------------------------------
  7462. ; index (m32c)
  7463. ;-------------------------------------------------------------
  7464. ; TODO add support to insns allowing index
  7465. (define-pmacro (indexb-sem mode d) (set SrcIndex d) (set DstIndex d))
  7466. (define-pmacro (indexbd-sem mode d) (set SrcIndex (const 0)) (set DstIndex d))
  7467. (define-pmacro (indexbs-sem mode d) (set SrcIndex d) (set DstIndex (const 0)))
  7468. (define-pmacro (indexw-sem mode d)
  7469. (set SrcIndex (sll d (const 2))) (set DstIndex (sll d (const 2))))
  7470. (define-pmacro (indexwd-sem mode d)
  7471. (set SrcIndex (const 0)) (set DstIndex (sll d (const 2))))
  7472. (define-pmacro (indexws-sem mode d)
  7473. (set SrcIndex (sll d (const 2))) (set DstIndex (const 0)))
  7474. (define-pmacro (indexl-sem mode d)
  7475. (set SrcIndex d) (set DstIndex (sll d (const 2))))
  7476. (define-pmacro (indexld-sem mode d)
  7477. (set SrcIndex (const 0)) (set DstIndex (sll d (const 2))))
  7478. (define-pmacro (indexls-sem mode d)
  7479. (set SrcIndex (sll d (const 2))) (set DstIndex (const 0)))
  7480. ; Note that "wbit" not where the size bit goes here, hence, it's
  7481. ; always 0 in these calls but op2 differs instead.
  7482. ; indexb src (index byte)
  7483. (unary32-defn QI .b 0 indexb #x8 0 #x3 indexb-sem)
  7484. (unary32-defn HI .w 0 indexb #x8 1 #x3 indexb-sem)
  7485. ; indexbd src (index byte dest)
  7486. (unary32-defn QI .b 0 indexbd #xA 0 3 indexbd-sem)
  7487. (unary32-defn HI .w 0 indexbd #xA 1 3 indexbd-sem)
  7488. ; indexbs src (index byte src)
  7489. (unary32-defn QI .b 0 indexbs #xC 0 3 indexbs-sem)
  7490. (unary32-defn HI .w 0 indexbs #xC 1 3 indexbs-sem)
  7491. ; indexl src (index long)
  7492. (unary32-defn QI .b 0 indexl 9 2 3 indexl-sem)
  7493. (unary32-defn HI .w 0 indexl 9 3 3 indexl-sem)
  7494. ; indexld src (index long dest)
  7495. (unary32-defn QI .b 0 indexld #xB 2 3 indexld-sem)
  7496. (unary32-defn HI .w 0 indexld #xB 3 3 indexld-sem)
  7497. ; indexls src (index long src)
  7498. (unary32-defn QI .b 0 indexls 9 0 3 indexls-sem)
  7499. (unary32-defn HI .w 0 indexls 9 1 3 indexls-sem)
  7500. ; indexw src (index word)
  7501. (unary32-defn QI .b 0 indexw 8 2 3 indexw-sem)
  7502. (unary32-defn HI .w 0 indexw 8 3 3 indexw-sem)
  7503. ; indexwd src (index word dest)
  7504. (unary32-defn QI .b 0 indexwd #xA 2 3 indexwd-sem)
  7505. (unary32-defn HI .w 0 indexwd #xA 3 3 indexwd-sem)
  7506. ; indexws (index word src)
  7507. (unary32-defn QI .b 0 indexws #xC 2 3 indexws-sem)
  7508. (unary32-defn HI .w 0 indexws #xC 3 3 indexws-sem)
  7509. ;-------------------------------------------------------------
  7510. ; jcc - jump on condition
  7511. ;-------------------------------------------------------------
  7512. (define-pmacro (jcnd32-sem cnd label)
  7513. (sequence ()
  7514. (case DFLT cnd
  7515. ((#x00) (if (not cbit) (set pc label))) ;ltu nc
  7516. ((#x01) (if (not (and cbit (not zbit))) (set pc label))) ;leu
  7517. ((#x02) (if (not zbit) (set pc label))) ;ne nz
  7518. ((#x03) (if (not sbit) (set pc label))) ;pz
  7519. ((#x04) (if (not obit) (set pc label))) ;no
  7520. ((#x05) (if (not (or zbit (xor sbit obit))) (set pc label))) ;gt
  7521. ((#x06) (if (not (xor sbit obit)) (set pc label))) ;ge
  7522. ((#x08) (if (trunc BI cbit) (set pc label))) ;geu c
  7523. ((#x09) (if (and cbit (not zbit)) (set pc label))) ;gtu
  7524. ((#x0a) (if (trunc BI zbit) (set pc label))) ;eq z
  7525. ((#x0b) (if (trunc BI sbit) (set pc label))) ;n
  7526. ((#x0c) (if (trunc BI obit) (set pc label))) ;o
  7527. ((#x0d) (if (or zbit (xor sbit obit)) (set pc label))) ;le
  7528. ((#x0e) (if (xor sbit obit) (set pc label))) ;lt
  7529. )
  7530. )
  7531. )
  7532. (define-pmacro (jcnd16-sem cnd label)
  7533. (sequence ()
  7534. (case DFLT cnd
  7535. ((#x00) (if (trunc BI cbit) (set pc label))) ;geu c
  7536. ((#x01) (if (and cbit (not zbit)) (set pc label))) ;gtu
  7537. ((#x02) (if (trunc BI zbit) (set pc label))) ;eq z
  7538. ((#x03) (if (trunc BI sbit) (set pc label))) ;n
  7539. ((#x04) (if (not cbit) (set pc label))) ;ltu nc
  7540. ((#x05) (if (not (and cbit (not zbit))) (set pc label))) ;leu
  7541. ((#x06) (if (not zbit) (set pc label))) ;ne nz
  7542. ((#x07) (if (not sbit) (set pc label))) ;pz
  7543. ((#x08) (if (or zbit (xor sbit obit)) (set pc label))) ;le
  7544. ((#x09) (if (trunc BI obit) (set pc label))) ;o
  7545. ((#x0a) (if (not (xor sbit obit)) (set pc label))) ;ge
  7546. ((#x0c) (if (not (or zbit (xor sbit obit))) (set pc label))) ;gt
  7547. ((#x0d) (if (not obit) (set pc label))) ;no
  7548. ((#x0e) (if (xor sbit obit) (set pc label))) ;lt
  7549. )
  7550. )
  7551. )
  7552. (dni jcnd16-5
  7553. "jCnd label"
  7554. (RL_JUMP RELAXABLE (machine 16))
  7555. "j$cond16j5 ${Lab-8-8}"
  7556. (+ (f-0-4 #x6) (f-4-1 1) cond16j5 Lab-8-8)
  7557. (jcnd16-sem cond16j5 Lab-8-8)
  7558. ()
  7559. )
  7560. (dni jcnd16
  7561. "jCnd label"
  7562. (RL_JUMP RELAXABLE (machine 16))
  7563. "j$cond16j ${Lab-16-8}"
  7564. (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xC) cond16j Lab-16-8)
  7565. (jcnd16-sem cond16j Lab-16-8)
  7566. ()
  7567. )
  7568. (dni jcnd32
  7569. "jCnd label"
  7570. (RL_JUMP RELAXABLE (machine 32))
  7571. "j$cond32j ${Lab-8-8}"
  7572. (+ (f-0-1 1) (f-4-3 5) cond32j Lab-8-8)
  7573. (jcnd32-sem cond32j Lab-8-8)
  7574. ()
  7575. )
  7576. ;-------------------------------------------------------------
  7577. ; jmp - jump
  7578. ;-------------------------------------------------------------
  7579. ; jmp.s label3 (m16 #1)
  7580. (dni jmp16.s "jmp.s Lab-5-3" (RL_JUMP RELAXABLE (machine 16))
  7581. ("jmp.s ${Lab-5-3}")
  7582. (+ (f-0-4 6) (f-4-1 0) Lab-5-3)
  7583. (sequence () (set pc Lab-5-3))
  7584. ())
  7585. ; jmp.b label8 (m16 #2)
  7586. (dni jmp16.b "jmp.b Lab-8-8" (RL_JUMP RELAXABLE (machine 16))
  7587. ("jmp.b ${Lab-8-8}")
  7588. (+ (f-0-4 #xF) (f-4-4 #xE) Lab-8-8)
  7589. (sequence () (set pc Lab-8-8))
  7590. ())
  7591. ; jmp.w label16 (m16 #3)
  7592. (dni jmp16.w "jmp.w Lab-8-16" (RL_JUMP RELAXABLE (machine 16))
  7593. ("jmp.w ${Lab-8-16}")
  7594. (+ (f-0-4 #xF) (f-4-4 4) Lab-8-16)
  7595. (sequence () (set pc Lab-8-16))
  7596. ())
  7597. ; jmp.a label24 (m16 #4)
  7598. (dni jmp16.a "jmp.a Lab-8-24" (RL_JUMP RELAXABLE (machine 16))
  7599. ("jmp.a ${Lab-8-24}")
  7600. (+ (f-0-4 #xF) (f-4-4 #xC) Lab-8-24)
  7601. (sequence () (set pc Lab-8-24))
  7602. ())
  7603. (define-pmacro (jmp16-sem mode dst)
  7604. (set pc (and dst #xfffff))
  7605. )
  7606. (define-pmacro (jmp32-sem mode dst)
  7607. (set pc dst)
  7608. )
  7609. ; jmpi.w dst (m16 #1 m32 #2)
  7610. (unary-insn-defn 16 16 HI .w jmpi (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 2) dst16-16-HI) jmp16-sem)
  7611. (unary-insn-defn 32 16-Unprefixed HI .w jmpi (+ (f-0-4 #xC) (f-7-1 1) dst32-16-Unprefixed-HI (f-10-2 #x0) (f-12-4 #xF)) jmp32-sem)
  7612. ; jmpi.a dst (m16 #2 m32 #2)
  7613. (unary-insn-defn 16 16 SI .a jmpi (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 0) dst16-16-SI) jmp16-sem)
  7614. (unary-insn-defn 32 16-Unprefixed SI .a jmpi (+ (f-0-4 #x8) (f-7-1 0) dst32-16-Unprefixed-SI (f-10-2 #x0) (f-12-4 1)) jmp32-sem)
  7615. ; jmps imm8 (m16 #1)
  7616. (dni jmps16 "jmps Imm-8-QI" ((machine 16))
  7617. ("jmps #${Imm-8-QI}")
  7618. (+ (f-0-4 #xE) (f-4-4 #xE) Imm-8-QI)
  7619. (sequence () (set pc Imm-8-QI))
  7620. ())
  7621. ; jmp.s label3 (m32 #1)
  7622. (dni jmp32.s
  7623. "jmp.s label"
  7624. (RL_JUMP RELAXABLE (machine 32))
  7625. "jmp.s ${Lab32-jmp-s}"
  7626. (+ (f-0-2 1) (f-4-3 5) Lab32-jmp-s)
  7627. (set pc Lab32-jmp-s)
  7628. ()
  7629. )
  7630. ; jmp.b label8 (m32 #2)
  7631. (dni jmp32.b "jmp.b Lab-8-8" (RL_JUMP RELAXABLE (machine 32))
  7632. ("jmp.b ${Lab-8-8}")
  7633. (+ (f-0-4 #xB) (f-4-4 #xB) Lab-8-8)
  7634. (set pc Lab-8-8)
  7635. ())
  7636. ; jmp.w label16 (m32 #3)
  7637. (dni jmp32.w "jmp.w Lab-8-16" (RL_JUMP RELAXABLE (machine 32))
  7638. ("jmp.w ${Lab-8-16}")
  7639. (+ (f-0-4 #xC) (f-4-4 #xE) Lab-8-16)
  7640. (set pc Lab-8-16)
  7641. ())
  7642. ; jmp.a label24 (m32 #4)
  7643. (dni jmp32.a "jmp.a Lab-8-24" (RL_JUMP RELAXABLE (machine 32))
  7644. ("jmp.a ${Lab-8-24}")
  7645. (+ (f-0-4 #xC) (f-4-4 #xC) Lab-8-24)
  7646. (set pc Lab-8-24)
  7647. ())
  7648. ; jmp.s imm8 (m32 #1)
  7649. (dni jmps32 "jmps Imm-8-QI" (RL_JUMP (machine 32))
  7650. ("jmps #${Imm-8-QI}")
  7651. (+ (f-0-4 #xD) (f-4-4 #xC) Imm-8-QI)
  7652. (set pc Imm-8-QI)
  7653. ())
  7654. ;-------------------------------------------------------------
  7655. ; jsr jump subroutine
  7656. ;-------------------------------------------------------------
  7657. (define-pmacro (jsr16-sem length dst)
  7658. (sequence ((SI tpc))
  7659. (set tpc (add pc length))
  7660. (set (reg h-sp) (sub (reg h-sp) 2))
  7661. (set (mem16 HI (reg h-sp)) (srl (and tpc #xffff00) 8))
  7662. (set (reg h-sp) (sub (reg h-sp) 1))
  7663. (set (mem16 QI (reg h-sp)) (and tpc #xff))
  7664. (set pc dst)
  7665. )
  7666. )
  7667. (define-pmacro (jsr32-sem length dst)
  7668. (sequence ((SI tpc))
  7669. (set tpc (add pc length))
  7670. (set (reg h-sp) (sub (reg h-sp) 2))
  7671. (set (mem32 HI (reg h-sp)) (srl (and tpc #xffff0000) 16))
  7672. (set (reg h-sp) (sub (reg h-sp) 2))
  7673. (set (mem32 HI (reg h-sp)) (and tpc #xffff))
  7674. (set pc dst)
  7675. )
  7676. )
  7677. ; jsr.w label16 (m16 #1)
  7678. (dni jsr16.w "jsr.w Lab-8-16" (RL_JUMP RELAXABLE (machine 16))
  7679. ("jsr.w ${Lab-8-16}")
  7680. (+ (f-0-4 #xF) (f-4-4 5) Lab-8-16)
  7681. (jsr16-sem 3 Lab-8-16)
  7682. ())
  7683. ; jsr.a label24 (m16 #2)
  7684. (dni jsr16.a "jsr.a Lab-8-24" (RL_JUMP RELAXABLE (machine 16))
  7685. ("jsr.a ${Lab-8-24}")
  7686. (+ (f-0-4 #xF) (f-4-4 #xD) Lab-8-24)
  7687. (jsr16-sem 4 Lab-8-24)
  7688. ())
  7689. (define-pmacro (jsri-defn mode op16 op16-1 op16-2 op16-3 op16-sem
  7690. op32 op32-1 op32-2 op32-3 op32-4 op32-sem len)
  7691. (begin
  7692. (dni (.sym jsri16 mode - op16)
  7693. (.str "jsri." mode " " op16)
  7694. (RL_1ADDR (machine 16))
  7695. (.str "jsri." mode " ${" op16 "}")
  7696. (+ op16-1 op16-2 op16-3 op16)
  7697. (op16-sem len op16)
  7698. ())
  7699. (dni (.sym jsri32 mode - op32)
  7700. (.str "jsri." mode " " op32)
  7701. (RL_1ADDR (machine 32))
  7702. (.str "jsri." mode " ${" op32 "}")
  7703. (+ op32-1 op32-2 op32-3 op32-4 op32)
  7704. (op32-sem len op32)
  7705. ())
  7706. )
  7707. )
  7708. ; jsri.w dst (m16 #1 m32 #1))
  7709. (jsri-defn w dst16-16-20ar-HI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x3) jsr16-sem
  7710. dst32-16-24-Unprefixed-HI (f-0-4 #xC) (f-7-1 1) (f-10-2 #x1) (f-12-4 #xF) jsr32-sem 4)
  7711. (jsri-defn w dst16-16-16sa-HI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x3) jsr16-sem
  7712. dst32-16-16sa-Unprefixed-HI (f-0-4 #xC) (f-7-1 1) (f-10-2 #x1) (f-12-4 #xF) jsr32-sem 4)
  7713. (jsri-defn w dst16-16-8-HI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x3) jsr16-sem
  7714. dst32-16-8-Unprefixed-HI (f-0-4 #xC) (f-7-1 1) (f-10-2 #x1) (f-12-4 #xF) jsr32-sem 3)
  7715. (jsri-defn w dst16-basic-HI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x3) jsr16-sem
  7716. dst32-basic-Unprefixed-HI (f-0-4 #xC) (f-7-1 1) (f-10-2 #x1) (f-12-4 #xF) jsr32-sem 2)
  7717. ; jsri.a (m16 #2 m32 #2)
  7718. (jsri-defn a dst16-16-20ar-SI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x1) jsr16-sem
  7719. dst32-16-24-Unprefixed-SI (f-0-4 #x9) (f-7-1 0) (f-10-2 #x0) (f-12-4 #x1) jsr32-sem 4)
  7720. (jsri-defn a dst16-16-8-SI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x1) jsr16-sem
  7721. dst32-16-8-Unprefixed-SI (f-0-4 #x9) (f-7-1 0) (f-10-2 #x0) (f-12-4 #x1) jsr32-sem 3)
  7722. (jsri-defn a dst16-16-16sa-SI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x1) jsr16-sem
  7723. dst32-16-16sa-Unprefixed-SI (f-0-4 #x9) (f-7-1 0) (f-10-2 #x0) (f-12-4 #x1) jsr32-sem 4)
  7724. (jsri-defn a dst16-basic-SI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x1) jsr16-sem
  7725. dst32-basic-Unprefixed-SI (f-0-4 #x9) (f-7-1 0) (f-10-2 #x0) (f-12-4 #x1) jsr32-sem 2)
  7726. (dni jsri32.a "jsr.w dst32-16-24-Unprefixed-HI" (RL_1ADDR (machine 32))
  7727. ("jsri.a ${dst32-16-24-Unprefixed-SI}")
  7728. (+ (f-0-4 #x9) (f-7-1 0) dst32-16-24-Unprefixed-SI (f-10-2 #x0) (f-12-4 #x1))
  7729. (jsr32-sem 6 dst32-16-24-Unprefixed-SI)
  7730. ())
  7731. ; jsr.w label16 (m32 #1)
  7732. (dni jsr32.w "jsr.w label" (RL_JUMP RELAXABLE (machine 32))
  7733. ("jsr.w ${Lab-8-16}")
  7734. (+ (f-0-4 #xC) (f-4-4 #xF) Lab-8-16)
  7735. (jsr32-sem 3 Lab-8-16)
  7736. ())
  7737. ; jsr.a label16 (m32 #2)
  7738. (dni jsr32.a "jsr.a label" (RL_JUMP (machine 32))
  7739. ("jsr.a ${Lab-8-24}")
  7740. (+ (f-0-4 #xC) (f-4-4 #xD) Lab-8-24)
  7741. (jsr32-sem 4 Lab-8-24)
  7742. ())
  7743. ; jsrs imm8 (m16 #1)
  7744. (dni jsrs16 "jsrs Imm-8-QI" ((machine 16))
  7745. ("jsrs #${Imm-8-QI}")
  7746. (+ (f-0-4 #xE) (f-4-4 #xF) Imm-8-QI)
  7747. (jsr16-sem 2 Imm-8-QI)
  7748. ())
  7749. ; jsrs imm8 (m32 #1)
  7750. (dni jsrs "jsrs #Imm-8-QI" ((machine 32))
  7751. ("jsrs #${Imm-8-QI}")
  7752. (+ (f-0-4 #xD) (f-4-4 #xD) Imm-8-QI)
  7753. (jsr32-sem 2 Imm-8-QI)
  7754. ())
  7755. ;-------------------------------------------------------------
  7756. ; ldc - load control register
  7757. ; stc - store control register
  7758. ;-------------------------------------------------------------
  7759. (define-pmacro (ldc32-cr1-sem src dst)
  7760. (sequence ()
  7761. (case DFLT dst
  7762. ((#x0) (set (reg h-dct0) src))
  7763. ((#x1) (set (reg h-dct1) src))
  7764. ((#x2) (sequence ((HI tflag))
  7765. (set tflag src)
  7766. (if (and tflag #x1) (set cbit 1))
  7767. (if (and tflag #x2) (set dbit 1))
  7768. (if (and tflag #x4) (set zbit 1))
  7769. (if (and tflag #x8) (set sbit 1))
  7770. (if (and tflag #x10) (set bbit 1))
  7771. (if (and tflag #x20) (set obit 1))
  7772. (if (and tflag #x40) (set ibit 1))
  7773. (if (and tflag #x80) (set ubit 1))))
  7774. ((#x3) (set (reg h-svf) src))
  7775. ((#x4) (set (reg h-drc0) src))
  7776. ((#x5) (set (reg h-drc1) src))
  7777. ((#x6) (set (reg h-dmd0) src))
  7778. ((#x7) (set (reg h-dmd1) src))
  7779. )
  7780. )
  7781. )
  7782. (define-pmacro (ldc32-cr2-sem src dst)
  7783. (sequence ()
  7784. (case DFLT dst
  7785. ((#x0) (set (reg h-intb) src))
  7786. ((#x1) (set (reg h-sp) src))
  7787. ((#x2) (set (reg h-sb) src))
  7788. ((#x3) (set (reg h-fb) src))
  7789. ((#x4) (set (reg h-svp) src))
  7790. ((#x5) (set (reg h-vct) src))
  7791. ((#x7) (set (reg h-isp) src))
  7792. )
  7793. )
  7794. )
  7795. (define-pmacro (ldc32-cr3-sem src dst)
  7796. (sequence ()
  7797. (case DFLT dst
  7798. ((#x2) (set (reg h-dma0) src))
  7799. ((#x3) (set (reg h-dma1) src))
  7800. ((#x4) (set (reg h-dra0) src))
  7801. ((#x5) (set (reg h-dra1) src))
  7802. ((#x6) (set (reg h-dsa0) src))
  7803. ((#x7) (set (reg h-dsa1) src))
  7804. )
  7805. )
  7806. )
  7807. (define-pmacro (ldc16-sem src dst)
  7808. (sequence ()
  7809. (case DFLT dst
  7810. ((#x1) (set (reg h-intb) src))
  7811. ((#x2) (set (reg h-intb) (or (reg h-intb) (sll src (const 16)))))
  7812. ((#x3) (sequence ((HI tflag))
  7813. (set tflag src)
  7814. (if (and tflag #x1) (set cbit 1))
  7815. (if (and tflag #x2) (set dbit 1))
  7816. (if (and tflag #x4) (set zbit 1))
  7817. (if (and tflag #x8) (set sbit 1))
  7818. (if (and tflag #x10) (set bbit 1))
  7819. (if (and tflag #x20) (set obit 1))
  7820. (if (and tflag #x40) (set ibit 1))
  7821. (if (and tflag #x80) (set ubit 1))))
  7822. ((#x4) (set (reg h-isp) src))
  7823. ((#x5) (set (reg h-sp) src))
  7824. ((#x6) (set (reg h-sb) src))
  7825. ((#x7) (set (reg h-fb) src))
  7826. )
  7827. )
  7828. )
  7829. (define-pmacro (stc32-cr1-sem src dst)
  7830. (sequence ()
  7831. (case DFLT src
  7832. ((#x0) (set dst (reg h-dct0)))
  7833. ((#x1) (set dst (reg h-dct1)))
  7834. ((#x2) (sequence ((HI tflag))
  7835. (set tflag 0)
  7836. (if (eq cbit 1) (set tflag (or tflag #x1)))
  7837. (if (eq dbit 1) (set tflag (or tflag #x2)))
  7838. (if (eq zbit 1) (set tflag (or tflag #x4)))
  7839. (if (eq sbit 1) (set tflag (or tflag #x8)))
  7840. (if (eq bbit 1) (set tflag (or tflag #x10)))
  7841. (if (eq obit 1) (set tflag (or tflag #x20)))
  7842. (if (eq ibit 1) (set tflag (or tflag #x40)))
  7843. (if (eq ubit 1) (set tflag (or tflag #x80)))
  7844. (set dst tflag)))
  7845. ((#x3) (set dst (reg h-svf)))
  7846. ((#x4) (set dst (reg h-drc0)))
  7847. ((#x5) (set dst (reg h-drc1)))
  7848. ((#x6) (set dst (reg h-dmd0)))
  7849. ((#x7) (set dst (reg h-dmd1)))
  7850. )
  7851. )
  7852. )
  7853. (define-pmacro (stc32-cr2-sem src dst)
  7854. (sequence ()
  7855. (case DFLT src
  7856. ((#x0) (set dst (reg h-intb)))
  7857. ((#x1) (set dst (reg h-sp)))
  7858. ((#x2) (set dst (reg h-sb)))
  7859. ((#x3) (set dst (reg h-fb)))
  7860. ((#x4) (set dst (reg h-svp)))
  7861. ((#x5) (set dst (reg h-vct)))
  7862. ((#x7) (set dst (reg h-isp)))
  7863. )
  7864. )
  7865. )
  7866. (define-pmacro (stc32-cr3-sem src dst)
  7867. (sequence ()
  7868. (case DFLT src
  7869. ((#x2) (set dst (reg h-dma0)))
  7870. ((#x3) (set dst (reg h-dma1)))
  7871. ((#x4) (set dst (reg h-dra0)))
  7872. ((#x5) (set dst (reg h-dra1)))
  7873. ((#x6) (set dst (reg h-dsa0)))
  7874. ((#x7) (set dst (reg h-dsa1)))
  7875. )
  7876. )
  7877. )
  7878. (define-pmacro (stc16-sem src dst)
  7879. (sequence ()
  7880. (case DFLT src
  7881. ((#x1) (set dst (and (reg h-intb) (const #xffff))))
  7882. ((#x2) (set dst (srl (reg h-intb) (const 16))))
  7883. ((#x3) (sequence ((HI tflag))
  7884. (set tflag 0)
  7885. (if (eq cbit 1) (set tflag (or tflag #x1)))
  7886. (if (eq dbit 1) (set tflag (or tflag #x2)))
  7887. (if (eq zbit 1) (set tflag (or tflag #x4)))
  7888. (if (eq sbit 1) (set tflag (or tflag #x8)))
  7889. (if (eq bbit 1) (set tflag (or tflag #x10)))
  7890. (if (eq obit 1) (set tflag (or tflag #x20)))
  7891. (if (eq ibit 1) (set tflag (or tflag #x40)))
  7892. (if (eq ubit 1) (set tflag (or tflag #x80)))
  7893. (set dst tflag)))
  7894. ((#x4) (set dst (reg h-isp)))
  7895. ((#x5) (set dst (reg h-sp)))
  7896. ((#x6) (set dst (reg h-sb)))
  7897. ((#x7) (set dst (reg h-fb)))
  7898. )
  7899. )
  7900. )
  7901. (dni ldc16.imm16 "ldc #imm,dst" ((machine 16))
  7902. ("ldc #${Imm-16-HI},${cr16}")
  7903. (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) (f-12-4 0) cr16 Imm-16-HI)
  7904. (ldc16-sem Imm-16-HI cr16)
  7905. ())
  7906. (dni ldc16.dst "ldc src,dest" ((machine 16))
  7907. ("ldc ${dst16-16-HI},${cr16}")
  7908. (+ (f-0-4 7) (f-4-4 #xA) (f-8-1 1) cr16 dst16-16-HI)
  7909. (ldc16-sem dst16-16-HI cr16)
  7910. ())
  7911. ; ldc src,dest (m32c #4)
  7912. (dni ldc32.src-cr1 "ldc src,dst" ((machine 32))
  7913. ("ldc ${dst32-24-Prefixed-HI},${cr1-Prefixed-32}")
  7914. (+ (f-0-4 0) (f-4-4 1) (f-8-4 #xD) dst32-24-Prefixed-HI (f-15-1 1) (f-18-2 0) (f-20-1 1) cr1-Prefixed-32)
  7915. (ldc32-cr1-sem dst32-24-Prefixed-HI cr1-Prefixed-32)
  7916. ())
  7917. ; ldc src,dest (m32c #5)
  7918. (dni ldc32.src-cr2 "ldc src,dest" ((machine 32))
  7919. ("ldc ${dst32-16-Unprefixed-SI},${cr2-32}")
  7920. (+ (f-0-4 #xD) dst32-16-Unprefixed-SI (f-7-1 1) (f-10-2 0) (f-12-1 0) cr2-32)
  7921. (ldc32-cr2-sem dst32-16-Unprefixed-SI cr2-32)
  7922. ())
  7923. ; ldc src,dest (m32c #6)
  7924. (dni ldc32.src-cr3 "ldc src,dst" ((machine 32))
  7925. ("ldc ${dst32-24-Prefixed-SI},${cr3-Prefixed-32}")
  7926. (+ (f-0-4 0) (f-4-4 1) (f-8-4 #xD) dst32-24-Prefixed-SI (f-15-1 1) (f-18-2 0) (f-20-1 0) cr3-Prefixed-32)
  7927. (ldc32-cr3-sem dst32-24-Prefixed-SI cr3-Prefixed-32)
  7928. ())
  7929. ; ldc src,dest (m32c #1)
  7930. (dni ldc32.imm16-cr1 "ldc #imm,dst" ((machine 32))
  7931. ("ldc #${Imm-16-HI},${cr1-Unprefixed-32}")
  7932. (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 #xA) (f-12-1 1) cr1-Unprefixed-32 Imm-16-HI)
  7933. (ldc32-cr1-sem Imm-16-HI cr1-Unprefixed-32)
  7934. ())
  7935. ; ldc src,dest (m32c #2)
  7936. (dni ldc32.imm16-cr2 "ldc #imm,dst" ((machine 32))
  7937. ("ldc #${Dsp-16-u24},${cr2-32}")
  7938. (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 2) (f-12-1 1) cr2-32 Dsp-16-u24)
  7939. (ldc32-cr2-sem Dsp-16-u24 cr2-32)
  7940. ())
  7941. ; ldc src,dest (m32c #3)
  7942. (dni ldc32.imm16-cr3 "ldc #imm,dst" ((machine 32))
  7943. ("ldc #${Dsp-16-u24},${cr3-Unprefixed-32}")
  7944. (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 6) (f-12-1 1) cr3-Unprefixed-32 Dsp-16-u24)
  7945. (ldc32-cr3-sem Dsp-16-u24 cr3-Unprefixed-32)
  7946. ())
  7947. (dni stc16.src "stc src,dest" ((machine 16))
  7948. ("stc ${cr16},${dst16-16-HI}")
  7949. (+ (f-0-4 7) (f-4-4 #xB) (f-8-1 1) cr16 dst16-16-HI)
  7950. (stc16-sem cr16 dst16-16-HI )
  7951. ())
  7952. (dni stc16.pc "stc pc,dest" ((machine 16))
  7953. ("stc pc,${dst16-16-HI}")
  7954. (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xC) dst16-16-HI)
  7955. (sequence () (set dst16-16-HI (reg h-pc)))
  7956. ())
  7957. (dni stc32.src-cr1 "stc src,dst" ((machine 32))
  7958. ("stc ${cr1-Prefixed-32},${dst32-24-Prefixed-HI}")
  7959. (+ (f-0-4 0) (f-4-4 1) (f-8-4 #xD) dst32-24-Prefixed-HI (f-15-1 1) (f-18-2 1) (f-20-1 1) cr1-Prefixed-32)
  7960. (stc32-cr1-sem cr1-Prefixed-32 dst32-24-Prefixed-HI )
  7961. ())
  7962. (dni stc32.src-cr2 "stc src,dest" ((machine 32))
  7963. ("stc ${cr2-32},${dst32-16-Unprefixed-SI}")
  7964. (+ (f-0-4 #xD) dst32-16-Unprefixed-SI (f-7-1 1) (f-10-2 0) (f-12-1 2) cr2-32)
  7965. (stc32-cr2-sem cr2-32 dst32-16-Unprefixed-SI )
  7966. ())
  7967. (dni stc32.src-cr3 "stc src,dst" ((machine 32))
  7968. ("stc ${cr3-Prefixed-32},${dst32-24-Prefixed-SI}")
  7969. (+ (f-0-4 0) (f-4-4 1) (f-8-4 #xD) dst32-24-Prefixed-SI (f-15-1 1) (f-18-2 1) (f-20-1 0) cr3-Prefixed-32)
  7970. (stc32-cr3-sem cr3-Prefixed-32 dst32-24-Prefixed-SI )
  7971. ())
  7972. ;-------------------------------------------------------------
  7973. ; ldctx - load context
  7974. ; stctx - store context
  7975. ;-------------------------------------------------------------
  7976. ; ??? semantics
  7977. (dni ldctx16 "ldctx abs16,abs24" ((machine 16))
  7978. ("ldctx ${Dsp-16-u16},${Dsp-32-u24}")
  7979. (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 #x0) Dsp-16-u16 Dsp-32-u24)
  7980. (nop)
  7981. ())
  7982. (dni ldctx32 "ldctx abs16,abs24" ((machine 32))
  7983. ("ldctx ${Dsp-16-u16},${Dsp-32-u24}")
  7984. (+ (f-0-4 #xB) (f-4-4 #x6) (f-8-4 #xC) (f-12-4 #x3) Dsp-16-u16 Dsp-32-u24)
  7985. (nop)
  7986. ())
  7987. (dni stctx16 "stctx abs16,abs24" ((machine 16))
  7988. ("stctx ${Dsp-16-u16},${Dsp-32-u24}")
  7989. (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 #x0) Dsp-16-u16 Dsp-32-u24)
  7990. (nop)
  7991. ())
  7992. (dni stctx32 "stctx abs16,abs24" ((machine 32))
  7993. ("stctx ${Dsp-16-u16},${Dsp-32-u24}")
  7994. (+ (f-0-4 #xB) (f-4-4 #x6) (f-8-4 #xD) (f-12-4 #x3) Dsp-16-u16 Dsp-32-u24)
  7995. (nop)
  7996. ())
  7997. ;-------------------------------------------------------------
  7998. ; lde - load from extra far data area (m16)
  7999. ; ste - store to extra far data area (m16)
  8000. ;-------------------------------------------------------------
  8001. (lde-dst QI .b 0)
  8002. (lde-dst HI .w 1)
  8003. (ste-dst QI .b 0)
  8004. (ste-dst HI .w 1)
  8005. ;-------------------------------------------------------------
  8006. ; ldipl - load interrupt permission level
  8007. ;-------------------------------------------------------------
  8008. ; ??? semantics
  8009. ; ldintb <==> ldc #imm,intbh ; ldc #imm,intbl
  8010. (dni ldipl16.imm "ldipl #imm" ((machine 16))
  8011. ("ldipl #${Imm-13-u3}")
  8012. (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xA) (f-12-1 0) Imm-13-u3)
  8013. (nop)
  8014. ())
  8015. (dni ldipl32.imm "ldipl #imm" ((machine 32))
  8016. ("ldipl #${Imm-13-u3}")
  8017. (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 #xE) (f-12-1 1) Imm-13-u3)
  8018. (nop)
  8019. ())
  8020. ;-------------------------------------------------------------
  8021. ; max - maximum value
  8022. ;-------------------------------------------------------------
  8023. ; TODO check semantics for min -1,0
  8024. (define-pmacro (max-sem mode src dst)
  8025. (sequence ()
  8026. (if (gt mode src dst)
  8027. (set mode dst src)))
  8028. )
  8029. ; max.size:G #imm,dst
  8030. (binary-arith32-imm-dst-Prefixed QI QI .b 0 max X #x8 #x3 #xF max-sem)
  8031. (binary-arith32-imm-dst-Prefixed HI HI .w 1 max X #x8 #x3 #xF max-sem)
  8032. ; max.BW:G src,dst
  8033. (binary-arith32-src-dst-Prefixed QI QI .b 0 max X #x1 #xD max-sem)
  8034. (binary-arith32-src-dst-Prefixed HI HI .w 1 max X #x1 #xD max-sem)
  8035. ;-------------------------------------------------------------
  8036. ; min - minimum value
  8037. ;-------------------------------------------------------------
  8038. (define-pmacro (min-sem mode src dst)
  8039. (sequence ()
  8040. (if (lt mode src dst)
  8041. (set mode dst src)))
  8042. )
  8043. ; min.size:G #imm,dst
  8044. (binary-arith32-imm-dst-Prefixed QI QI .b 0 min X #x8 #x2 #xF min-sem)
  8045. (binary-arith32-imm-dst-Prefixed HI HI .w 1 min X #x8 #x2 #xF min-sem)
  8046. ; min.BW:G src,dst
  8047. (binary-arith32-src-dst-Prefixed QI QI .b 0 min X #x1 #xC min-sem)
  8048. (binary-arith32-src-dst-Prefixed HI HI .w 1 min X #x1 #xC min-sem)
  8049. ;-------------------------------------------------------------
  8050. ; mov - move
  8051. ;-------------------------------------------------------------
  8052. (define-pmacro (mov-sem mode src1 dst)
  8053. (sequence ((mode result))
  8054. (set result src1)
  8055. (set-z-and-s result)
  8056. (set mode dst src1))
  8057. )
  8058. (define-pmacro (mov-dspsp-dst-sem mach mode src1 dst)
  8059. (set dst (mem-mach mach mode (add sp src1)))
  8060. )
  8061. (define-pmacro (mov-src-dspsp-sem mach mode src dst1)
  8062. (set (mem-mach mach mode (add sp dst1)) src)
  8063. )
  8064. (define-pmacro (mov16-imm-an-defn size mode imm regn op1 op2)
  8065. (dni (.sym mov16. size .S-imm- regn)
  8066. (.str "mov." size ":S " imm "," regn)
  8067. ((machine 16))
  8068. (.str "mov." size "$S #${" imm "}," regn)
  8069. (+ op1 op2 imm)
  8070. (mov-sem mode imm (reg (.sym h- regn)))
  8071. ())
  8072. )
  8073. ; mov.size:G #imm,dst (m16 #1 m32 #1)
  8074. (binary-arith-imm-dst mov G (f-0-4 7) (f-4-3 2) (f-8-4 #xC) #x9 #x2 #xF mov-sem)
  8075. ; mov.L:G #imm32,dst (m32 #2)
  8076. (binary-arith32-imm-dst-defn SI SI .l 0 mov G #xB #x3 #x1 mov-sem)
  8077. ; mov.BW:S #imm,dst2 (m32 #4)
  8078. (binary-arith32-s-imm-dst QI .b 0 mov #x0 #x2 mov-sem)
  8079. (binary-arith32-s-imm-dst HI .w 1 mov #x0 #x2 mov-sem)
  8080. ; mov.b:S #imm8,dst3 (m16 #3)
  8081. (binary-arith16-b-S-imm8-dst3 mov ".b" (f-0-4 #xC) (f-4-1 0) mov-sem)
  8082. ; mov.b:S #imm8,aN (m16 #4)
  8083. (mov16-imm-an-defn b QI Imm-8-QI a0 (f-0-4 #xE) (f-4-4 2))
  8084. (mov16-imm-an-defn b QI Imm-8-QI a1 (f-0-4 #xE) (f-4-4 #xA))
  8085. (mov16-imm-an-defn w HI Imm-8-HI a0 (f-0-4 #xA) (f-4-4 2))
  8086. (mov16-imm-an-defn w HI Imm-8-HI a1 (f-0-4 #xA) (f-4-4 #xA))
  8087. ; mov.WL:S #imm,A0/A1 (m32 #5)
  8088. (define-pmacro (mov32-wl-s-defn mode sz op1 imm regn op2)
  8089. (dni (.sym mov32- sz - regn)
  8090. (.str "mov." sz ":s" imm "," regn)
  8091. ((machine 32))
  8092. (.str "mov." sz "$S #${" imm "}," regn)
  8093. (+ (f-0-4 op1) (f-4-4 op2) imm)
  8094. (mov-sem mode imm (reg (.sym h- regn)))
  8095. ())
  8096. )
  8097. (mov32-wl-s-defn HI w #x9 Imm-8-HI a0 #xC)
  8098. (mov32-wl-s-defn HI w #x9 Imm-8-HI a1 #xD)
  8099. (mov32-wl-s-defn SI l #xB Dsp-8-s24 a0 #xC)
  8100. (mov32-wl-s-defn SI l #xB Dsp-8-s24 a1 #xD)
  8101. ; mov.size:Q #imm4,dst (m16 #2 m32 #3)
  8102. (binary-arith16-imm4-dst-defn QI .b 0 0 mov (f-0-4 #xD) (f-4-3 4) mov-sem)
  8103. (binary-arith16-imm4-dst-defn HI .w 0 1 mov (f-0-4 #xD) (f-4-3 4) mov-sem)
  8104. (binary-arith32-imm4-dst-defn QI .b 1 0 mov #x7 #x2 mov-sem)
  8105. (binary-arith32-imm4-dst-defn HI .w 1 1 mov #x7 #x2 mov-sem)
  8106. ; mov.BW:Z #0,dst (m16 #5 m32 #6)
  8107. (dni mov16.b-Z-imm8-dst3
  8108. "mov.b:Z #0,Dst16-3-S-8"
  8109. ((machine 16))
  8110. "mov.b$Z #0,${Dst16-3-S-8}"
  8111. (+ (f-0-4 #xB) (f-4-1 #x0) Dst16-3-S-8)
  8112. (mov-sem QI (const 0) Dst16-3-S-8)
  8113. ())
  8114. ; (binary-arith16-b-Z-imm8-dst3 mov ".b" (f-0-4 #xB) (f-4-1 0) mov-sem)
  8115. (binary-arith32-z-imm-dst QI .b 0 mov #x0 #x1 mov-sem)
  8116. (binary-arith32-z-imm-dst HI .w 1 mov #x0 #x1 mov-sem)
  8117. ; mov.BW:G src,dst (m16 #6 m32 #7)
  8118. (binary-arith-src-dst mov G (f-0-4 #x7) (f-4-3 1) #x1 #xB mov-sem)
  8119. ; mov.B:S src2,a0/a1 (m16 #7)
  8120. (dni (.sym mov 16 .b.S-An)
  8121. (.str mov ".b:S src2,a[01]")
  8122. ((machine 16))
  8123. (.str mov ".b$S ${src16-2-S},${Dst16AnQI-S}")
  8124. (+ (f-0-4 #x3) (f-4-1 0) Dst16AnQI-S src16-2-S)
  8125. (mov-sem QI src16-2-S Dst16AnQI-S)
  8126. ())
  8127. (define-pmacro (mov16-b-s-an-defn op1 op2 op2c)
  8128. (dni (.sym mov16.b.S- op1 - op2)
  8129. (.str mov ".b:S " op1 "," op2)
  8130. ((machine 16))
  8131. (.str mov ".b$S " op1 "," op2)
  8132. (+ (f-0-4 #x3) op2c)
  8133. (mov-sem QI (reg (.sym h- op1)) (reg (.sym h- op2)))
  8134. ())
  8135. )
  8136. (mov16-b-s-an-defn r0l a1 (f-4-4 #x4))
  8137. (mov16-b-s-an-defn r0h a0 (f-4-4 #x0))
  8138. ; mov.L:G src,dst (m32 #8)
  8139. (binary-arith32-src-dst-defn SI SI .l 1 mov G #x1 #x3 mov-sem)
  8140. ; mov.B:S r0l/r0h,dst2 (m16 #8)
  8141. (dni (.sym mov 16 .b.S-Rn-An)
  8142. (.str mov ".b:S r0[lh],src2")
  8143. ((machine 16))
  8144. (.str mov ".b$S ${Dst16RnQI-S},${src16-2-S}")
  8145. (+ (f-0-4 #x0) (f-4-1 0) Dst16RnQI-S src16-2-S)
  8146. (mov-sem QI src16-2-S Dst16RnQI-S)
  8147. ())
  8148. ; mov.B.S src2,r0l/r0h (m16 #9)
  8149. (binary-arith16-b-S-src2 mov (f-0-4 0) (f-4-1 1) mov-sem)
  8150. ; mov.BW:S src2,r0l/r0 (m32 #9)
  8151. ; mov.BW:S src2,r1l/r1 (m32 #10)
  8152. (define-pmacro (mov32-src-r sz szcode mode src dst opc1 opc2)
  8153. (begin
  8154. (dni (.sym mov32. sz - src - dst)
  8155. (.str "mov." sz "src," dst)
  8156. ((machine 32))
  8157. (.str "mov." sz "$S ${" (.sym src - mode) "}," dst)
  8158. (+ (f-0-2 opc1) (.sym src - mode) (f-4-3 opc2) (f-7-1 szcode))
  8159. (mov-sem mode (.sym src - mode) (reg (.sym h- dst)))
  8160. ())
  8161. )
  8162. )
  8163. (mov32-src-r b 0 QI dst32-2-S-16 r0l 0 4)
  8164. (mov32-src-r w 1 HI dst32-2-S-16 r0 0 4)
  8165. (mov32-src-r b 0 QI dst32-2-S-8 r0l 0 4)
  8166. (mov32-src-r w 1 HI dst32-2-S-8 r0 0 4)
  8167. (mov32-src-r b 0 QI dst32-2-S-basic r1l 1 7)
  8168. (mov32-src-r w 1 HI dst32-2-S-basic r1 1 7)
  8169. (mov32-src-r b 0 QI dst32-2-S-16 r1l 1 7)
  8170. (mov32-src-r w 1 HI dst32-2-S-16 r1 1 7)
  8171. (mov32-src-r b 0 QI dst32-2-S-8 r1l 1 7)
  8172. (mov32-src-r w 1 HI dst32-2-S-8 r1 1 7)
  8173. ; mov.BW:S r0l/r0,dst2 (m32 #11)
  8174. (define-pmacro (mov32-r-dest sz szcode mode src dst opc1 opc2)
  8175. (begin
  8176. (dni (.sym mov32. sz - src - dst)
  8177. (.str "mov." sz "src," dst)
  8178. ((machine 32))
  8179. (.str "mov." sz "$S " src ",${" (.sym dst - mode) "}")
  8180. (+ (f-0-2 opc1) (.sym dst - mode) (f-4-3 opc2) (f-7-1 szcode))
  8181. (mov-sem mode (reg (.sym h- src)) (.sym dst - mode))
  8182. ())
  8183. )
  8184. )
  8185. (mov32-r-dest b 0 QI r0l dst32-2-S-16 0 0)
  8186. (mov32-r-dest w 1 HI r0 dst32-2-S-16 0 0)
  8187. (mov32-r-dest b 0 QI r0l dst32-2-S-8 0 0)
  8188. (mov32-r-dest w 1 HI r0 dst32-2-S-8 0 0)
  8189. ; mov.L:S src,A0/A1 (m32 #12)
  8190. (define-pmacro (mov32-src-a src dst dstcode opc1 opc2)
  8191. (begin
  8192. (dni (.sym mov32. sz - src - dst)
  8193. (.str "mov." sz "src," dst)
  8194. ((machine 32))
  8195. (.str "mov.l" "$S ${" (.sym src - SI) "}," dst)
  8196. (+ (f-0-2 opc1) (.sym src - SI) (f-4-3 opc2) (f-7-1 dstcode))
  8197. (mov-sem SI (.sym src - SI) (reg (.sym h- dst)))
  8198. ())
  8199. )
  8200. )
  8201. (mov32-src-a dst32-2-S-16 a0 0 1 4)
  8202. (mov32-src-a dst32-2-S-16 a1 1 1 4)
  8203. (mov32-src-a dst32-2-S-8 a0 0 1 4)
  8204. (mov32-src-a dst32-2-S-8 a1 1 1 4)
  8205. ; mov.BW:G dsp8[sp],dst (m16 #10 m32 #13)
  8206. ; mov.BW:G src,dsp8[sp] (m16 #11 m32 #14)
  8207. (mov-dspsp-dst mov (f-0-4 #x7) (f-4-3 2) (f-8-4 #xB) #xB #x0 #xF mov-dspsp-dst-sem)
  8208. (mov-src-dspsp mov (f-0-4 #x7) (f-4-3 2) (f-8-4 #x3) #xA #x0 #xF mov-src-dspsp-sem)
  8209. ;-------------------------------------------------------------
  8210. ; mova - move effective address
  8211. ;-------------------------------------------------------------
  8212. (define-pmacro (mov16a-defn dst dstop dstcode)
  8213. (dni (.sym mova16. src - dst)
  8214. (.str "mova src," dst)
  8215. ((machine 16))
  8216. (.str "mova ${dst16-16-Mova-HI}," dst)
  8217. (+ (f-0-4 #xE) (f-4-4 #xB) dst16-16-Mova-HI (f-8-4 dstcode))
  8218. (sequence () (set HI (reg dstop) dst16-16-Mova-HI))
  8219. ())
  8220. )
  8221. (mov16a-defn r0 h-r0 0)
  8222. (mov16a-defn r1 h-r1 1)
  8223. (mov16a-defn r2 h-r2 2)
  8224. (mov16a-defn r3 h-r3 3)
  8225. (mov16a-defn a0 h-a0 4)
  8226. (mov16a-defn a1 h-a1 5)
  8227. (define-pmacro (mov32a-defn dst dstop dstcode)
  8228. (dni (.sym mova32. src - dst)
  8229. (.str "mova src," dst)
  8230. ((machine 32))
  8231. (.str "mova ${dst32-16-Unprefixed-Mova-SI}," dst)
  8232. (+ (f-0-4 #xD) dst32-16-Unprefixed-Mova-SI (f-7-1 1) (f-10-2 1) (f-12-1 1) (f-13-3 dstcode))
  8233. (sequence () (set SI (reg dstop) dst32-16-Unprefixed-Mova-SI))
  8234. ())
  8235. )
  8236. (mov32a-defn r2r0 h-r2r0 0)
  8237. (mov32a-defn r3r1 h-r3r1 1)
  8238. (mov32a-defn a0 h-a0 2)
  8239. (mov32a-defn a1 h-a1 3)
  8240. ;-------------------------------------------------------------
  8241. ; movDir - move nibble
  8242. ;-------------------------------------------------------------
  8243. (define-pmacro (movdir-sem nib src dst)
  8244. (sequence ((SI tmp))
  8245. (case DFLT nib
  8246. ((0) (set dst (or (and dst #xf0) (and src #xf))))
  8247. ((1) (set dst (or (and dst #x0f) (sll (and src #xf) 4))))
  8248. ((2) (set dst (or (and dst #xf0) (srl (and src #xf0) 4))))
  8249. ((3) (set dst (or (and dst #x0f) (and src #xf0))))
  8250. )
  8251. )
  8252. )
  8253. ; movDir src,dst
  8254. (define-pmacro (mov16dir-1-defn nib dircode dir)
  8255. (dni (.sym mov nib 16 ".r0l-dst")
  8256. (.str "mov" nib " r0l,dst")
  8257. ((machine 16))
  8258. (.str "mov" nib " r0l,${dst16-16-QI}")
  8259. (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 dir) dst16-16-QI)
  8260. (movdir-sem dircode (reg h-r0l) dst16-16-QI)
  8261. ())
  8262. )
  8263. (mov16dir-1-defn ll 0 8)
  8264. (mov16dir-1-defn lh 1 #xA)
  8265. (mov16dir-1-defn hl 2 9)
  8266. (mov16dir-1-defn hh 3 #xB)
  8267. (define-pmacro (mov16dir-2-defn nib dircode dir)
  8268. (dni (.sym mov nib 16 ".src-r0l")
  8269. (.str "mov" nib " src,r0l")
  8270. ((machine 16))
  8271. (.str "mov" nib " ${dst16-16-QI},r0l")
  8272. (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 dir) dst16-16-QI)
  8273. (movdir-sem dircode dst16-16-QI (reg h-r0l))
  8274. ())
  8275. )
  8276. (mov16dir-2-defn ll 0 0)
  8277. (mov16dir-2-defn lh 1 2)
  8278. (mov16dir-2-defn hl 2 1)
  8279. (mov16dir-2-defn hh 3 3)
  8280. (define-pmacro (mov32dir-1-defn nib o1o0)
  8281. (dni (.sym mov nib 32 ".r0l-dst")
  8282. (.str "mov" nib " r0l,dst")
  8283. ((machine 32))
  8284. (.str "mov" nib " r0l,${dst32-24-Prefixed-QI}")
  8285. (+ (f-0-4 #x0) (f-4-4 #x1) (f-8-4 #xB) dst32-24-Prefixed-QI (f-15-1 0) (f-18-2 o1o0) (f-20-4 #xE))
  8286. (movdir-sem o1o0 (reg h-r0l) dst32-24-Prefixed-QI)
  8287. ())
  8288. )
  8289. (mov32dir-1-defn ll 0)
  8290. (mov32dir-1-defn lh 1)
  8291. (mov32dir-1-defn hl 2)
  8292. (mov32dir-1-defn hh 3)
  8293. (define-pmacro (mov32dir-2-defn nib o1o0)
  8294. (dni (.sym mov nib 32 ".src-r0l")
  8295. (.str "mov" nib " src,r0l")
  8296. ((machine 32))
  8297. (.str "mov" nib " ${dst32-24-Prefixed-QI},r0l")
  8298. (+ (f-0-4 #x0) (f-4-4 #x1) (f-8-4 #xA) dst32-24-Prefixed-QI (f-15-1 0) (f-18-2 o1o0) (f-20-4 #xE))
  8299. (movdir-sem o1o0 dst32-24-Prefixed-QI (reg h-r0l))
  8300. ())
  8301. )
  8302. (mov32dir-2-defn ll 0)
  8303. (mov32dir-2-defn lh 1)
  8304. (mov32dir-2-defn hl 2)
  8305. (mov32dir-2-defn hh 3)
  8306. ;-------------------------------------------------------------
  8307. ; movx - move extend sign (m32)
  8308. ;-------------------------------------------------------------
  8309. (define-pmacro (movx-sem mode src dst)
  8310. (sequence ((SI source) (SI result))
  8311. (set SI result src)
  8312. (set-z-and-s result)
  8313. (set dst result))
  8314. )
  8315. ; movx #imm,dst
  8316. (binary-arith32-imm-dst-defn QI SI "" 0 movx X #xB #x1 #x1 movx-sem)
  8317. ;-------------------------------------------------------------
  8318. ; mul - multiply
  8319. ;-------------------------------------------------------------
  8320. (define-pmacro (mul-sem mode src1 dst)
  8321. (sequence ((mode result))
  8322. (set obit (add-oflag mode src1 dst 0))
  8323. (set result (mul mode src1 dst))
  8324. (set dst result))
  8325. )
  8326. ; mul.BW #imm,dst
  8327. (binary-arith-imm-dst mul G (f-0-4 7) (f-4-3 6) (f-8-4 5) #x8 #x1 #xF mul-sem)
  8328. ; mul.BW src,dst
  8329. (binary-arith-src-dst mul G (f-0-4 #x7) (f-4-3 4) #x1 #xC mul-sem)
  8330. (dni mul_l "mul.l src,r2r0" ((machine 32))
  8331. ("mul.l ${dst32-24-Prefixed-SI},r2r0")
  8332. (+ (f-0-4 #x0) (f-4-4 #x1) (f-8-4 #x8) (f-15-1 #x1) (f-18-2 #x1) (f-20-4 #xf)
  8333. dst32-24-Prefixed-SI)
  8334. () ())
  8335. (dni mulu_l "mulu.l src,r2r0" ((machine 32))
  8336. ("mulu.l ${dst32-24-Prefixed-SI},r2r0")
  8337. (+ (f-0-4 #x0) (f-4-4 #x1) (f-8-4 #x8) (f-15-1 #x1) (f-18-2 #x0) (f-20-4 #xf)
  8338. dst32-24-Prefixed-SI)
  8339. () ())
  8340. ;-------------------------------------------------------------
  8341. ; mulex - multiple extend sign (m32)
  8342. ;-------------------------------------------------------------
  8343. ; mulex src,dst
  8344. ; (dni mulex-absolute-indirect "mulex [src]" ((machine 32))
  8345. ; ("mulex ${dst32-24-absolute-indirect-HI}")
  8346. ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 #xC) dst32-24-absolute-indirect-HI (f-15-1 1) (f-18-2 3) (f-20-4 #xE))
  8347. ; (set R1R2R0 (mul DI (ext DI R2R0) (ext DI dst32-24-absolute-indirect-HI)))
  8348. ; ())
  8349. (dni mulex "mulex src" ((machine 32))
  8350. ("mulex ${dst32-16-Unprefixed-Mulex-HI}")
  8351. (+ (f-0-4 #xC) dst32-16-Unprefixed-Mulex-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xE))
  8352. (set R1R2R0 (mul DI (ext DI R2R0) (ext DI dst32-16-Unprefixed-Mulex-HI)))
  8353. ())
  8354. ; (dni mulex-indirect "mulex [src]" ((machine 32))
  8355. ; ("mulex ${dst32-24-indirect-HI}")
  8356. ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 #xC) dst32-24-indirect-HI (f-15-1 1) (f-18-2 3) (f-20-4 #xE))
  8357. ; (set R1R2R0 (mul DI (ext DI R2R0) (ext DI dst32-24-indirect-HI)))
  8358. ; ())
  8359. ;-------------------------------------------------------------
  8360. ; mulu - multiply unsigned
  8361. ;-------------------------------------------------------------
  8362. (define-pmacro (mulu-sem mode src1 dst)
  8363. (sequence ((mode result))
  8364. (set obit (add-oflag mode src1 dst 0))
  8365. (set result (mul mode src1 dst))
  8366. (set dst result))
  8367. )
  8368. ; mulu.BW #imm,dst
  8369. (binary-arith-imm-dst mulu G (f-0-4 7) (f-4-3 6) (f-8-4 4) #x8 #x0 #xF mulu-sem)
  8370. ; mulu.BW src,dst
  8371. (binary-arith-src-dst mulu G (f-0-4 #x7) (f-4-3 0) #x1 #x4 mulu-sem)
  8372. ;-------------------------------------------------------------
  8373. ; neg - twos complement
  8374. ;-------------------------------------------------------------
  8375. (define-pmacro (neg-sem mode dst)
  8376. (sequence ((mode result))
  8377. (set result (neg mode dst))
  8378. (set-z-and-s result)
  8379. (set dst result))
  8380. )
  8381. ; neg.BW:G
  8382. (unary-insn neg (f-0-4 7) (f-4-3 2) (f-8-4 #x5) #xA #x2 #xF neg-sem)
  8383. ;-------------------------------------------------------------
  8384. ; not - twos complement
  8385. ;-------------------------------------------------------------
  8386. (define-pmacro (not-sem mode dst)
  8387. (sequence ((mode result))
  8388. (set result (not mode dst))
  8389. (set-z-and-s result)
  8390. (set dst result))
  8391. )
  8392. ; not.BW:G
  8393. (unary-insn-g not (f-0-4 7) (f-4-3 2) (f-8-4 #x7) #xA #x1 #xE not-sem)
  8394. (dni not16.b.s
  8395. "not.b:s Dst16-3-S-8"
  8396. ((machine 16))
  8397. "not.b:s ${Dst16-3-S-8}"
  8398. (+ (f-0-4 #xb) (f-4-1 #x1) Dst16-3-S-8)
  8399. (not-sem QI Dst16-3-S-8)
  8400. ())
  8401. ;-------------------------------------------------------------
  8402. ; nop
  8403. ;-------------------------------------------------------------
  8404. (dni nop16
  8405. "nop"
  8406. ((machine 16))
  8407. "nop"
  8408. (+ (f-0-4 #x0) (f-4-4 #x4))
  8409. (nop)
  8410. ())
  8411. (dni nop32
  8412. "nop"
  8413. ((machine 32))
  8414. "nop"
  8415. (+ (f-0-4 #xD) (f-4-4 #xE))
  8416. (nop)
  8417. ())
  8418. ;-------------------------------------------------------------
  8419. ; or - logical or
  8420. ;-------------------------------------------------------------
  8421. (define-pmacro (or-sem mode src1 dst)
  8422. (sequence ((mode result))
  8423. (set result (or mode src1 dst))
  8424. (set-z-and-s result)
  8425. (set dst result))
  8426. )
  8427. ; or.BW #imm,dst (m16 #1 m32 #1)
  8428. (binary-arith-imm-dst or G (f-0-4 7) (f-4-3 3) (f-8-4 3) #x8 #x2 #xF or-sem)
  8429. ; or.b:S #imm8,dst3 (m16 #2 m32 #2)
  8430. (binary-arith16-b-S-imm8-dst3 or ".b" (f-0-4 9) (f-4-1 1) or-sem)
  8431. (binary-arith32-s-imm-dst QI .b 0 or #x1 #x2 or-sem)
  8432. (binary-arith32-s-imm-dst HI .w 1 or #x1 #x2 or-sem)
  8433. ; or.BW src,dst (m16 #3 m32 #3)
  8434. (binary-arith-src-dst or G (f-0-4 #x9) (f-4-3 4) #x1 #x5 or-sem)
  8435. ; or.b:S src,r0[lh] (m16)
  8436. (binary-arith16-b-S-src2 or (f-0-4 1) (f-4-1 1) or-sem)
  8437. ;-------------------------------------------------------------
  8438. ; pop - restore register/memory
  8439. ;-------------------------------------------------------------
  8440. ; TODO future: split this into .b and .w semantics
  8441. (define-pmacro (pop-sem-mach mach mode dst)
  8442. (sequence ((mode b_or_w) (SI length))
  8443. (set b_or_w -1)
  8444. (set b_or_w (srl b_or_w #x8))
  8445. (if (eq b_or_w #x0)
  8446. (set length 1) ; .b
  8447. (set length 2)) ; .w
  8448. (case DFLT length
  8449. ((1) (set dst (mem-mach mach QI (reg h-sp))))
  8450. ((2) (set dst (mem-mach mach HI (reg h-sp)))))
  8451. (set (reg h-sp) (add (reg h-sp) length))
  8452. )
  8453. )
  8454. (define-pmacro (pop-sem16 mode dest) (pop-sem-mach 16 mode dest))
  8455. (define-pmacro (pop-sem32 mode dest) (pop-sem-mach 32 mode dest))
  8456. ; pop.BW:G (m16 #1)
  8457. (unary-insn-mach-g 16 pop (f-0-4 7) (f-4-3 2) (f-8-4 #xD) pop-sem16 $G)
  8458. ; pop.BW:G (m32 #1)
  8459. (unary-insn-mach 32 pop #xB #x2 #xF pop-sem32)
  8460. ; pop.b:S r0l/r0h
  8461. (dni pop16.b-s-rn "pop.b:S r0[lh]" ((machine 16))
  8462. "pop.b$S ${Rn16-push-S-anyof}"
  8463. (+ (f-0-4 #x9) Rn16-push-S-anyof (f-5-3 #x2))
  8464. (pop-sem16 QI Rn16-push-S-anyof)
  8465. ())
  8466. ; pop.w:S a0/a1
  8467. (dni pop16.b-s-an "pop.w:S a[01]" ((machine 16))
  8468. "pop.w$S ${An16-push-S-anyof}"
  8469. (+ (f-0-4 #xD) An16-push-S-anyof (f-5-3 #x2))
  8470. (pop-sem16 HI An16-push-S-anyof)
  8471. ())
  8472. ;-------------------------------------------------------------
  8473. ; popc - pop control register
  8474. ; pushc - push control register
  8475. ;-------------------------------------------------------------
  8476. (define-pmacro (popc32-cr1-sem mode dst)
  8477. (sequence ()
  8478. (case DFLT dst
  8479. ((#x0) (set (reg h-dct0) (mem32 mode (reg h-sp))))
  8480. ((#x1) (set (reg h-dct1) (mem32 mode (reg h-sp))))
  8481. ((#x2) (sequence ((HI tflag))
  8482. (set tflag (mem32 mode (reg h-sp)))
  8483. (if (and tflag #x1) (set cbit 1))
  8484. (if (and tflag #x2) (set dbit 1))
  8485. (if (and tflag #x4) (set zbit 1))
  8486. (if (and tflag #x8) (set sbit 1))
  8487. (if (and tflag #x10) (set bbit 1))
  8488. (if (and tflag #x20) (set obit 1))
  8489. (if (and tflag #x40) (set ibit 1))
  8490. (if (and tflag #x80) (set ubit 1))))
  8491. ((#x3) (set (reg h-svf) (mem32 mode (reg h-sp))))
  8492. ((#x4) (set (reg h-drc0) (mem32 mode (reg h-sp))))
  8493. ((#x5) (set (reg h-drc1) (mem32 mode (reg h-sp))))
  8494. ((#x6) (set (reg h-dmd0) (mem32 mode (reg h-sp))))
  8495. ((#x7) (set (reg h-dmd1) (mem32 mode (reg h-sp))))
  8496. )
  8497. (set (reg h-sp) (add (reg h-sp) 2))
  8498. )
  8499. )
  8500. (define-pmacro (popc32-cr2-sem mode dst)
  8501. (sequence ()
  8502. (case DFLT dst
  8503. ((#x0) (set (reg h-intb) (mem32 mode (reg h-sp))))
  8504. ((#x1) (set (reg h-sp) (mem32 mode (reg h-sp))))
  8505. ((#x2) (set (reg h-sb) (mem32 mode (reg h-sp))))
  8506. ((#x3) (set (reg h-fb) (mem32 mode (reg h-sp))))
  8507. ((#x7) (set (reg h-isp) (mem32 mode (reg h-sp))))
  8508. )
  8509. (set (reg h-sp) (add (reg h-sp) 4))
  8510. )
  8511. )
  8512. (define-pmacro (popc16-sem mode dst)
  8513. (sequence ()
  8514. (case DFLT dst
  8515. ((#x1) (set (reg h-intb) (or (and (reg h-intb) #x0000)
  8516. (mem16 mode (reg h-sp)))))
  8517. ((#x2) (set (reg h-intb) (or (and (reg h-intb) #xffff0000)
  8518. (mem16 mode (reg h-sp)))))
  8519. ((#x3) (sequence ((HI tflag))
  8520. (set tflag (mem16 mode (reg h-sp)))
  8521. (if (and tflag #x1) (set cbit 1))
  8522. (if (and tflag #x2) (set dbit 1))
  8523. (if (and tflag #x4) (set zbit 1))
  8524. (if (and tflag #x8) (set sbit 1))
  8525. (if (and tflag #x10) (set bbit 1))
  8526. (if (and tflag #x20) (set obit 1))
  8527. (if (and tflag #x40) (set ibit 1))
  8528. (if (and tflag #x80) (set ubit 1))))
  8529. ((#x4) (set (reg h-isp) (mem16 mode (reg h-sp))))
  8530. ((#x5) (set (reg h-sp) (mem16 mode (reg h-sp))))
  8531. ((#x6) (set (reg h-sb) (mem16 mode (reg h-sp))))
  8532. ((#x7) (set (reg h-fb) (mem16 mode (reg h-sp))))
  8533. )
  8534. (set (reg h-sp) (add (reg h-sp) 2))
  8535. )
  8536. )
  8537. ; popc dest (m16c #1)
  8538. (dni popc16.imm16 "popc dst" ((machine 16))
  8539. ("popc ${cr16}")
  8540. (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) (f-12-4 3) cr16)
  8541. (popc16-sem HI cr16)
  8542. ())
  8543. ; popc dest (m32c #1)
  8544. (dni popc32.imm16-cr1 "popc dst" ((machine 32))
  8545. ("popc ${cr1-Unprefixed-32}")
  8546. (+ (f-0-4 #xD) (f-4-4 3) (f-8-4 #xA) (f-12-1 1) cr1-Unprefixed-32)
  8547. (popc32-cr1-sem HI cr1-Unprefixed-32)
  8548. ())
  8549. ; popc dest (m32c #2)
  8550. (dni popc32.imm16-cr2 "popc dst" ((machine 32))
  8551. ("popc ${cr2-32}")
  8552. (+ (f-0-4 #xD) (f-4-4 3) (f-8-4 2) (f-12-1 1) cr2-32)
  8553. (popc32-cr2-sem SI cr2-32)
  8554. ())
  8555. (define-pmacro (pushc32-cr1-sem mode dst)
  8556. (sequence ()
  8557. (set (reg h-sp) (sub (reg h-sp) 2))
  8558. (case DFLT dst
  8559. ((#x0) (set (mem32 mode (reg h-sp)) (reg h-dct0)))
  8560. ((#x1) (set (mem32 mode (reg h-sp)) (reg h-dct1)))
  8561. ((#x2) (sequence ((HI tflag))
  8562. (set tflag 0)
  8563. (if (eq cbit 1) (set tflag (or tflag #x1)))
  8564. (if (eq dbit 1) (set tflag (or tflag #x2)))
  8565. (if (eq zbit 1) (set tflag (or tflag #x4)))
  8566. (if (eq sbit 1) (set tflag (or tflag #x8)))
  8567. (if (eq bbit 1) (set tflag (or tflag #x10)))
  8568. (if (eq obit 1) (set tflag (or tflag #x20)))
  8569. (if (eq ibit 1) (set tflag (or tflag #x40)))
  8570. (if (eq ubit 1) (set tflag (or tflag #x80)))
  8571. (set (mem32 mode (reg h-sp)) tflag)))
  8572. ((#x3) (set (mem32 mode (reg h-sp)) (reg h-svf)))
  8573. ((#x4) (set (mem32 mode (reg h-sp)) (reg h-drc0)))
  8574. ((#x5) (set (mem32 mode (reg h-sp)) (reg h-drc1)))
  8575. ((#x6) (set (mem32 mode (reg h-sp)) (reg h-dmd0)))
  8576. ((#x7) (set (mem32 mode (reg h-sp)) (reg h-dmd1)))
  8577. )
  8578. )
  8579. )
  8580. (define-pmacro (pushc32-cr2-sem mode dst)
  8581. (sequence ()
  8582. (set (reg h-sp) (sub (reg h-sp) 4))
  8583. (case DFLT dst
  8584. ((#x0) (set (mem32 mode (reg h-sp)) (reg h-intb)))
  8585. ((#x1) (set (mem32 mode (reg h-sp)) (reg h-sp)))
  8586. ((#x2) (set (mem32 mode (reg h-sp)) (reg h-sb)))
  8587. ((#x3) (set (mem32 mode (reg h-sp)) (reg h-fb)))
  8588. ((#x7) (set (mem32 mode (reg h-sp)) (reg h-isp)))
  8589. )
  8590. )
  8591. )
  8592. (define-pmacro (pushc16-sem mode dst)
  8593. (sequence ()
  8594. (set (reg h-sp) (sub (reg h-sp) 2))
  8595. (case DFLT dst
  8596. ((#x1) (set (mem16 mode (reg h-sp)) (and (reg h-intb) #xffff)))
  8597. ((#x2) (set (mem16 mode (reg h-sp)) (and (reg h-intb) #xffff0000)))
  8598. ((#x3) (sequence ((HI tflag))
  8599. (if (eq cbit 1) (set tflag (or tflag #x1)))
  8600. (if (eq dbit 1) (set tflag (or tflag #x2)))
  8601. (if (eq zbit 1) (set tflag (or tflag #x4)))
  8602. (if (eq sbit 1) (set tflag (or tflag #x8)))
  8603. (if (eq bbit 1) (set tflag (or tflag #x10)))
  8604. (if (eq obit 1) (set tflag (or tflag #x20)))
  8605. (if (eq ibit 1) (set tflag (or tflag #x40)))
  8606. (if (eq ubit 1) (set tflag (or tflag #x80)))
  8607. (set (mem16 mode (reg h-sp)) tflag)))
  8608. ((#x4) (set (mem16 mode (reg h-sp)) (reg h-isp)))
  8609. ((#x5) (set (mem16 mode (reg h-sp)) (reg h-sp)))
  8610. ((#x6) (set (mem16 mode (reg h-sp)) (reg h-sb)))
  8611. ((#x7) (set (mem16 mode (reg h-sp)) (reg h-fb)))
  8612. )
  8613. )
  8614. )
  8615. ; pushc src (m16c)
  8616. (dni pushc16.imm16 "pushc dst" ((machine 16))
  8617. ("pushc ${cr16}")
  8618. (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) (f-12-4 2) cr16)
  8619. (pushc16-sem HI cr16)
  8620. ())
  8621. ; pushc src (m32c #1)
  8622. (dni pushc32.imm16-cr1 "pushc dst" ((machine 32))
  8623. ("pushc ${cr1-Unprefixed-32}")
  8624. (+ (f-0-4 #xD) (f-4-4 1) (f-8-4 #xA) (f-12-1 1) cr1-Unprefixed-32)
  8625. (pushc32-cr1-sem HI cr1-Unprefixed-32)
  8626. ())
  8627. ; pushc src (m32c #2)
  8628. (dni pushc32.imm16-cr2 "pushc dst" ((machine 32))
  8629. ("pushc ${cr2-32}")
  8630. (+ (f-0-4 #xD) (f-4-4 1) (f-8-4 2) (f-12-1 1) cr2-32)
  8631. (pushc32-cr2-sem SI cr2-32)
  8632. ())
  8633. ;-------------------------------------------------------------
  8634. ; popm - pop multiple
  8635. ; pushm - push multiple
  8636. ;-------------------------------------------------------------
  8637. (define-pmacro (popm-sem machine dst)
  8638. (sequence ((SI addrlen))
  8639. (if (eq machine 16)
  8640. (set addrlen 2)
  8641. (set addrlen 4))
  8642. (if (and dst 1)
  8643. (sequence () (set R0 (mem-mach machine HI (reg h-sp)))
  8644. (set (reg h-sp) (add (reg h-sp) 2))))
  8645. (if (and dst 2)
  8646. (sequence () (set R1 (mem-mach machine HI (reg h-sp)))
  8647. (set (reg h-sp) (add (reg h-sp) 2))))
  8648. (if (and dst 4)
  8649. (sequence () (set R2 (mem-mach machine HI (reg h-sp)))
  8650. (set (reg h-sp) (add (reg h-sp) 2))))
  8651. (if (and dst 8)
  8652. (sequence () (set R3 (mem-mach machine HI (reg h-sp)))
  8653. (set (reg h-sp) (add (reg h-sp) 2))))
  8654. (if (and dst 16)
  8655. (sequence () (set A0 (mem-mach machine HI (reg h-sp)))
  8656. (set (reg h-sp) (add (reg h-sp) addrlen))))
  8657. (if (and dst 32)
  8658. (sequence () (set A1 (mem-mach machine HI (reg h-sp)))
  8659. (set (reg h-sp) (add (reg h-sp) addrlen))))
  8660. (if (and dst 64)
  8661. (sequence () (set (reg h-sb) (mem-mach machine HI (reg h-sp)))
  8662. (set (reg h-sp) (add (reg h-sp) addrlen))))
  8663. (if (eq dst 128)
  8664. (sequence () (set (reg h-fb) (mem-mach machine HI (reg h-sp)))
  8665. (set (reg h-sp) (add (reg h-sp) addrlen))))
  8666. )
  8667. )
  8668. (define-pmacro (pushm-sem machine dst)
  8669. (sequence ((SI count) (SI addrlen))
  8670. (if (eq machine 16)
  8671. (set addrlen 2)
  8672. (set addrlen 4))
  8673. (if (eq dst 1)
  8674. (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen))
  8675. (set (mem-mach machine HI (reg h-sp)) (reg h-fb))))
  8676. (if (and dst 2)
  8677. (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen))
  8678. (set (mem-mach machine HI (reg h-sp)) (reg h-sb))))
  8679. (if (and dst 4)
  8680. (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen))
  8681. (set (mem-mach machine HI (reg h-sp)) A1)))
  8682. (if (and dst 8)
  8683. (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen))
  8684. (set (mem-mach machine HI (reg h-sp)) A0)))
  8685. (if (and dst 16)
  8686. (sequence () (set (reg h-sp) (sub (reg h-sp) 2))
  8687. (set (mem-mach machine HI (reg h-sp)) R3)))
  8688. (if (and dst 32)
  8689. (sequence () (set (reg h-sp) (sub (reg h-sp) 2))
  8690. (set (mem-mach machine HI (reg h-sp)) R2)))
  8691. (if (and dst 64)
  8692. (sequence () (set (reg h-sp) (sub (reg h-sp) 2))
  8693. (set (mem-mach machine HI (reg h-sp)) R1)))
  8694. (if (and dst 128)
  8695. (sequence () (set (reg h-sp) (sub (reg h-sp) 2))
  8696. (set (mem-mach machine HI (reg h-sp)) R0)))
  8697. )
  8698. )
  8699. (dni popm16 "popm regs" ((machine 16))
  8700. ("popm ${Regsetpop}")
  8701. (+ (f-0-4 #xE) (f-4-4 #xD) Regsetpop)
  8702. (popm-sem 16 Regsetpop)
  8703. ())
  8704. (dni pushm16 "pushm regs" ((machine 16))
  8705. ("pushm ${Regsetpush}")
  8706. (+ (f-0-4 #xE) (f-4-4 #xC) Regsetpush)
  8707. (pushm-sem 16 Regsetpush)
  8708. ())
  8709. (dni popm "popm regs" ((machine 32))
  8710. ("popm ${Regsetpop}")
  8711. (+ (f-0-4 #x8) (f-4-4 #xE) Regsetpop)
  8712. (popm-sem 32 Regsetpop)
  8713. ())
  8714. (dni pushm "pushm regs" ((machine 32))
  8715. ("pushm ${Regsetpush}")
  8716. (+ (f-0-4 #x8) (f-4-4 #xF) Regsetpush)
  8717. (pushm-sem 32 Regsetpush)
  8718. ())
  8719. ;-------------------------------------------------------------
  8720. ; push - Save register/memory/immediate data
  8721. ;-------------------------------------------------------------
  8722. ; TODO future: split this into .b and .w semantics
  8723. (define-pmacro (push-sem-mach mach mode dst)
  8724. (sequence ((mode b_or_w) (SI length))
  8725. (set b_or_w -1)
  8726. (set b_or_w (srl b_or_w #x8))
  8727. (if (eq b_or_w #x0)
  8728. (set length 1) ; .b
  8729. (if (eq b_or_w #xff)
  8730. (set length 2) ; .w
  8731. (set length 4))) ; .l
  8732. (set (reg h-sp) (sub (reg h-sp) length))
  8733. (case DFLT length
  8734. ((1) (set (mem-mach mach QI (reg h-sp)) dst))
  8735. ((2) (set (mem-mach mach HI (reg h-sp)) dst))
  8736. ((4) (set (mem-mach mach SI (reg h-sp)) dst)))
  8737. )
  8738. )
  8739. (define-pmacro (push-sem16 mode dst) (push-sem-mach 16 mode dst))
  8740. (define-pmacro (push-sem32 mode dst) (push-sem-mach 32 mode dst))
  8741. ; push.BW:G imm (m16 #1 m32 #1)
  8742. (dni push16.b.G-imm "push.b:G #Imm-16-QI" ((machine 16))
  8743. ("push.b$G #${Imm-16-QI}")
  8744. (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 2) Imm-16-QI)
  8745. (push-sem16 QI Imm-16-QI)
  8746. ())
  8747. (dni push16.w.G-imm "push.w:G #Imm-16-HI" ((machine 16))
  8748. ("push.w$G #${Imm-16-HI}")
  8749. (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 2) Imm-16-HI)
  8750. (push-sem16 HI Imm-16-HI)
  8751. ())
  8752. (dni push32.b.imm "push.b #Imm-8-QI" ((machine 32))
  8753. ("push.b #${Imm-8-QI}")
  8754. (+ (f-0-4 #xA) (f-4-4 #xE) Imm-8-QI)
  8755. (push-sem32 QI Imm-8-QI)
  8756. ())
  8757. (dni push32.w.imm "push.w #Imm-8-HI" ((machine 32))
  8758. ("push.w #${Imm-8-HI}")
  8759. (+ (f-0-4 #xA) (f-4-4 #xF) Imm-8-HI)
  8760. (push-sem32 HI Imm-8-HI)
  8761. ())
  8762. ; push.BW:G src (m16 #2)
  8763. (unary-insn-mach-g 16 push (f-0-4 7) (f-4-3 2) (f-8-4 #x4) push-sem16 $G)
  8764. ; push.BW:G src (m32 #2)
  8765. (unary-insn-mach 32 push #xC #x0 #xE push-sem32)
  8766. ; push.b:S r0l/r0h (m16 #3)
  8767. (dni push16.b-s-rn "push.b:S r0[lh]" ((machine 16))
  8768. "push.b$S ${Rn16-push-S-anyof}"
  8769. (+ (f-0-4 #x8) Rn16-push-S-anyof (f-5-3 #x2))
  8770. (push-sem16 QI Rn16-push-S-anyof)
  8771. ())
  8772. ; push.w:S a0/a1 (m16 #4)
  8773. (dni push16.b-s-an "push.w:S a[01]" ((machine 16))
  8774. "push.w$S ${An16-push-S-anyof}"
  8775. (+ (f-0-4 #xC) An16-push-S-anyof (f-5-3 #x2))
  8776. (push-sem16 HI An16-push-S-anyof)
  8777. ())
  8778. ; push.l imm32 (m32 #3)
  8779. (dni push32.l.imm "push.l #Imm-16-SI" ((machine 32))
  8780. ("push.l #${Imm-16-SI}")
  8781. (+ (f-0-4 #xB) (f-4-4 6) (f-8-4 5) (f-12-4 3) Imm-16-SI)
  8782. (push-sem32 SI Imm-16-SI)
  8783. ())
  8784. ; push.l src (m32 #4)
  8785. (unary-insn-defn 32 16-Unprefixed SI .l push (+ (f-0-4 #xA) (f-7-1 0) dst32-16-Unprefixed-SI (f-10-2 0) (f-12-4 1)) push-sem32)
  8786. ;-------------------------------------------------------------
  8787. ; pusha - push effective address
  8788. ;------------------------------------------------------------
  8789. (define-pmacro (push16a-sem mode dst)
  8790. (sequence ()
  8791. (set (reg h-sp) (sub (reg h-sp) 2))
  8792. (set (mem16 HI (reg h-sp)) dst))
  8793. )
  8794. (define-pmacro (push32a-sem mode dst)
  8795. (sequence ()
  8796. (set (reg h-sp) (sub (reg h-sp) 4))
  8797. (set (mem32 SI (reg h-sp)) dst))
  8798. )
  8799. (unary-insn-defn 16 16-Mova HI "" pusha (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 9) dst16-16-Mova-HI) push16a-sem)
  8800. (unary-insn-defn 32 16-Unprefixed-Mova SI "" pusha (+ (f-0-4 #xB) (f-7-1 0) dst32-16-Unprefixed-Mova-SI (f-10-2 0) (f-12-4 1)) push32a-sem)
  8801. ;-------------------------------------------------------------
  8802. ; reit - return from interrupt
  8803. ;-------------------------------------------------------------
  8804. ; ??? semantics
  8805. (dni reit16 "REIT" ((machine 16))
  8806. ("reit")
  8807. (+ (f-0-4 #xF) (f-4-4 #xB))
  8808. (nop)
  8809. ())
  8810. (dni reit32 "REIT" ((machine 32))
  8811. ("reit")
  8812. (+ (f-0-4 9) (f-4-4 #xE))
  8813. (nop)
  8814. ())
  8815. ;-------------------------------------------------------------
  8816. ; rmpa - repeat multiple and addition
  8817. ;-------------------------------------------------------------
  8818. ; TODO semantics
  8819. (dni rmpa16.b "rmpa.size" ((machine 16))
  8820. ("rmpa.b")
  8821. (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 1))
  8822. (nop)
  8823. ())
  8824. (dni rmpa16.w "rmpa.size" ((machine 16))
  8825. ("rmpa.w")
  8826. (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 1))
  8827. (nop)
  8828. ())
  8829. (dni rmpa32.b "rmpa.size" ((machine 32))
  8830. ("rmpa.b")
  8831. (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 4) (f-12-4 3))
  8832. (nop)
  8833. ())
  8834. (dni rmpa32.w "rmpa.size" ((machine 32))
  8835. ("rmpa.w")
  8836. (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 5) (f-12-4 3))
  8837. (nop)
  8838. ())
  8839. ;-------------------------------------------------------------
  8840. ; rolc - rotate left with carry
  8841. ;-------------------------------------------------------------
  8842. ; TODO check semantics
  8843. ; TODO future: split this into .b and .w semantics
  8844. (define-pmacro (rolc-sem mode dst)
  8845. (sequence ((mode result) (SI ocbit) (mode b_or_w) (USI mask))
  8846. (set b_or_w -1)
  8847. (set b_or_w (srl b_or_w #x8))
  8848. (if (eq b_or_w #x0)
  8849. (set mask #x8000) ; .b
  8850. (set mask #x80000000)) ; .w
  8851. (set ocbit cbit)
  8852. (set cbit (and dst mask))
  8853. (set result (sll mode dst 1))
  8854. (set result (or result ocbit))
  8855. (set-z-and-s result)
  8856. (set dst result))
  8857. )
  8858. ; rolc.BW src,dst
  8859. (unary-insn rolc (f-0-4 7) (f-4-3 3) (f-8-4 #xA) #xB #x2 #xE rolc-sem)
  8860. ;-------------------------------------------------------------
  8861. ; rorc - rotate right with carry
  8862. ;-------------------------------------------------------------
  8863. ; TODO check semantics
  8864. ; TODO future: split this into .b and .w semantics
  8865. (define-pmacro (rorc-sem mode dst)
  8866. (sequence ((mode result) (SI ocbit) (mode b_or_w) (USI mask) (SI shamt))
  8867. (set b_or_w -1)
  8868. (set b_or_w (srl b_or_w #x8))
  8869. (if (eq b_or_w #x0)
  8870. (sequence () (set mask #x7fff) (set shamt 15)) ; .b
  8871. (sequence () (set mask #x7fffffff) (set shamt 31))) ; .w
  8872. (set ocbit cbit)
  8873. (set cbit (and dst #x1))
  8874. (set result (srl mode dst (const 1)))
  8875. (set result (or (and result mask) (sll ocbit shamt)))
  8876. (set-z-and-s result)
  8877. (set dst result))
  8878. )
  8879. ; rorc.BW src,dst
  8880. (unary-insn rorc (f-0-4 7) (f-4-3 3) (f-8-4 #xB) #xA #x2 #xE rorc-sem)
  8881. ;-------------------------------------------------------------
  8882. ; rot - rotate
  8883. ;-------------------------------------------------------------
  8884. ; TODO future: split this into .b and .w semantics
  8885. (define-pmacro (rot-1-sem mode src1 dst)
  8886. (sequence ((mode tmp) (mode b_or_w) (USI mask) (SI shift))
  8887. (case DFLT src1
  8888. ((#x0) (set shift 1))
  8889. ((#x1) (set shift 2))
  8890. ((#x2) (set shift 3))
  8891. ((#x3) (set shift 4))
  8892. ((#x4) (set shift 5))
  8893. ((#x5) (set shift 6))
  8894. ((#x6) (set shift 7))
  8895. ((#x7) (set shift 8))
  8896. ((-8) (set shift -1))
  8897. ((-7) (set shift -2))
  8898. ((-6) (set shift -3))
  8899. ((-5) (set shift -4))
  8900. ((-4) (set shift -5))
  8901. ((-3) (set shift -6))
  8902. ((-2) (set shift -7))
  8903. ((-1) (set shift -8))
  8904. (else (set shift 0))
  8905. )
  8906. (set b_or_w -1)
  8907. (set b_or_w (srl b_or_w #x8))
  8908. (if (eq b_or_w #x0)
  8909. (set mask #x7fff) ; .b
  8910. (set mask #x7fffffff)) ; .w
  8911. (set tmp dst)
  8912. (if (gt mode shift 0)
  8913. (sequence ()
  8914. (set tmp (rol mode tmp shift))
  8915. (set cbit (and tmp #x1)))
  8916. (sequence ()
  8917. (set tmp (ror mode tmp (mul shift -1)))
  8918. (set cbit (and tmp mask))))
  8919. (set-z-and-s tmp)
  8920. (set dst tmp))
  8921. )
  8922. (define-pmacro (rot-2-sem mode dst)
  8923. (sequence ((mode tmp) (mode b_or_w) (USI mask))
  8924. (set b_or_w -1)
  8925. (set b_or_w (srl b_or_w #x8))
  8926. (if (eq b_or_w #x0)
  8927. (set mask #x7fff) ; .b
  8928. (set mask #x7fffffff)) ; .w
  8929. (set tmp dst)
  8930. (if (gt mode (reg h-r1h) 0)
  8931. (sequence ()
  8932. (set tmp (rol mode tmp (reg h-r1h)))
  8933. (set cbit (and tmp #x1)))
  8934. (sequence ()
  8935. (set tmp (ror mode tmp (reg h-r1h)))
  8936. (set cbit (and tmp mask))))
  8937. (set-z-and-s tmp)
  8938. (set dst tmp))
  8939. )
  8940. ; rot.BW #imm4,dst
  8941. (binary-arith16-shimm4-dst-defn QI .b 0 0 rot (f-0-4 #xE) (f-4-3 0) rot-1-sem)
  8942. (binary-arith16-shimm4-dst-defn HI .w 0 1 rot (f-0-4 #xE) (f-4-3 0) rot-1-sem)
  8943. (binary-arith32-shimm4-dst-defn QI .b 0 0 rot #x7 #x2 rot-1-sem)
  8944. (binary-arith32-shimm4-dst-defn HI .w 0 1 rot #x7 #x2 rot-1-sem)
  8945. ; rot.BW src,dst
  8946. (dni rot16.b-dst "rot r1h,dest" ((machine 16))
  8947. ("rot.b r1h,${dst16-16-QI}")
  8948. (+ (f-0-4 7) (f-4-4 #x4) (f-8-4 #x6) dst16-16-QI)
  8949. (rot-2-sem QI dst16-16-QI)
  8950. ())
  8951. (dni rot16.w-dst "rot r1h,dest" ((machine 16))
  8952. ("rot.w r1h,${dst16-16-HI}")
  8953. (+ (f-0-4 7) (f-4-4 #x5) (f-8-4 #x6) dst16-16-HI)
  8954. (rot-2-sem HI dst16-16-HI)
  8955. ())
  8956. (dni rot32.b-dst "rot r1h,dest" ((machine 32))
  8957. ("rot.b r1h,${dst32-16-Unprefixed-QI}")
  8958. (+ (f-0-4 #xA) dst32-16-Unprefixed-QI (f-7-1 0) (f-10-2 3) (f-12-4 #xF))
  8959. (rot-2-sem QI dst32-16-Unprefixed-QI)
  8960. ())
  8961. (dni rot32.w-dst "rot r1h,dest" ((machine 32))
  8962. ("rot.w r1h,${dst32-16-Unprefixed-HI}")
  8963. (+ (f-0-4 #xA) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xF))
  8964. (rot-2-sem HI dst32-16-Unprefixed-HI)
  8965. ())
  8966. ;-------------------------------------------------------------
  8967. ; rts - return from subroutine
  8968. ;-------------------------------------------------------------
  8969. (define-pmacro (rts16-sem)
  8970. (sequence ((SI tpc))
  8971. (set tpc (mem16 HI (reg h-sp)))
  8972. (set (reg h-sp) (add (reg h-sp) 2))
  8973. (set tpc (or tpc (sll (mem16 QI (reg h-sp)) 16)))
  8974. (set (reg h-sp) (add (reg h-sp) 1))
  8975. (set pc tpc)
  8976. )
  8977. )
  8978. (define-pmacro (rts32-sem)
  8979. (sequence ((SI tpc))
  8980. (set tpc (mem32 HI (reg h-sp)))
  8981. (set (reg h-sp) (add (reg h-sp) 2))
  8982. (set tpc (or tpc (sll (mem32 HI (reg h-sp)) 16)))
  8983. (set (reg h-sp) (add (reg h-sp) 2))
  8984. (set pc tpc)
  8985. )
  8986. )
  8987. (dni rts16 "rts" ((machine 16))
  8988. ("rts")
  8989. (+ (f-0-4 #xF) (f-4-4 3))
  8990. (rts16-sem)
  8991. ())
  8992. (dni rts32 "rts" ((machine 32))
  8993. ("rts")
  8994. (+ (f-0-4 #xD) (f-4-4 #xF))
  8995. (rts32-sem)
  8996. ())
  8997. ;-------------------------------------------------------------
  8998. ; sbb - subtract with borrow
  8999. ;-------------------------------------------------------------
  9000. (define-pmacro (sbb-sem mode src dst)
  9001. (sequence ((mode result))
  9002. (set result (subc mode dst src cbit))
  9003. (set obit (add-oflag mode dst src cbit))
  9004. (set cbit (add-oflag mode dst src cbit))
  9005. (set-z-and-s result)
  9006. (set dst result))
  9007. )
  9008. ; sbb.size:G #imm,dst
  9009. (binary-arith16-imm-dst-defn QI QI .b 0 sbb X (f-0-4 7) (f-4-3 3) (f-8-4 7) sbb-sem)
  9010. (binary-arith16-imm-dst-defn HI HI .w 1 sbb X (f-0-4 7) (f-4-3 3) (f-8-4 7) sbb-sem)
  9011. (binary-arith32-imm-dst-Prefixed QI QI .b 0 sbb X #x9 #x2 #xE sbb-sem)
  9012. (binary-arith32-imm-dst-Prefixed HI HI .w 1 sbb X #x9 #x2 #xE sbb-sem)
  9013. ; sbb.BW:G src,dst
  9014. (binary-arith16-src-dst-defn QI QI .b 0 sbb X (f-0-4 #xB) (f-4-3 4) sbb-sem)
  9015. (binary-arith16-src-dst-defn HI HI .w 1 sbb X (f-0-4 #xB) (f-4-3 4) sbb-sem)
  9016. (binary-arith32-src-dst-Prefixed QI QI .b 0 sbb X #x1 #x6 sbb-sem)
  9017. (binary-arith32-src-dst-Prefixed HI HI .w 1 sbb X #x1 #x6 sbb-sem)
  9018. ;-------------------------------------------------------------
  9019. ; sbjnz - subtract then jump on not zero
  9020. ;-------------------------------------------------------------
  9021. (define-pmacro (sub-jnz-sem mode src dst label)
  9022. (sequence ((mode result))
  9023. (set result (sub mode dst src))
  9024. (set dst result)
  9025. (if (ne result 0)
  9026. (set pc label)))
  9027. )
  9028. ; sbjnz.size #imm4,dst,label
  9029. (arith-jnz-imm4-dst sbjnz s4n (f-0-4 #xF) (f-4-3 4) #xf #x1 sub-jnz-sem)
  9030. ;-------------------------------------------------------------
  9031. ; sccnd - store condition on condition (m32)
  9032. ;-------------------------------------------------------------
  9033. (define-pmacro (sccnd-sem cnd dst)
  9034. (sequence ()
  9035. (set dst 0)
  9036. (case DFLT cnd
  9037. ((#x00) (if (not cbit) (set dst 1))) ;ltu nc
  9038. ((#x01) (if (or cbit zbit) (set dst 1))) ;leu
  9039. ((#x02) (if (not zbit) (set dst 1))) ;ne nz
  9040. ((#x03) (if (not sbit) (set dst 1))) ;pz
  9041. ((#x04) (if (not obit) (set dst 1))) ;no
  9042. ((#x05) (if (not (or zbit (xor sbit obit))) (set dst 1))) ;gt
  9043. ((#x06) (if (xor sbit obit) (set dst 1))) ;ge
  9044. ((#x08) (if (trunc BI cbit) (set dst 1))) ;geu c
  9045. ((#x09) (if (not (or cbit zbit)) (set dst 1))) ;gtu
  9046. ((#x0a) (if (trunc BI zbit) (set dst 1))) ;eq z
  9047. ((#x0b) (if (trunc BI sbit) (set dst 1))) ;n
  9048. ((#x0c) (if (trunc BI obit) (set dst 1))) ;o
  9049. ((#x0d) (if (or zbit (xor sbit obit)) (set dst 1))) ;le
  9050. ((#x0e) (if (xor sbit obit) (set dst 1))) ;lt
  9051. )
  9052. )
  9053. )
  9054. ; scCND dst
  9055. (dni sccnd
  9056. "sccnd dst"
  9057. ((machine 32))
  9058. "sc$sccond32 ${dst32-16-Unprefixed-HI}"
  9059. (+ (f-0-4 #xD) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) sccond32)
  9060. (sccnd-sem sccond32 dst32-16-Unprefixed-HI)
  9061. ())
  9062. ;-------------------------------------------------------------
  9063. ; scmpu - string compare unequal (m32)
  9064. ;-------------------------------------------------------------
  9065. ; TODO semantics
  9066. (dni scmpu.b "scmpu.b" ((machine 32))
  9067. ("scmpu.b")
  9068. (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 #xC) (f-12-4 3))
  9069. (c-call VOID "scmpu_QI_semantics")
  9070. ())
  9071. (dni scmpu.w "scmpu.w" ((machine 32))
  9072. ("scmpu.w")
  9073. (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 #xD) (f-12-4 3))
  9074. (c-call VOID "scmpu_HI_semantics")
  9075. ())
  9076. ;-------------------------------------------------------------
  9077. ; sha - shift arithmetic
  9078. ;-------------------------------------------------------------
  9079. ; TODO future: split this into .b and .w semantics
  9080. (define-pmacro (sha-sem mode src1 dst)
  9081. (sequence ((mode result)(mode shift)(mode shmode))
  9082. (case DFLT src1
  9083. ((#x0) (set shift 1))
  9084. ((#x1) (set shift 2))
  9085. ((#x2) (set shift 3))
  9086. ((#x3) (set shift 4))
  9087. ((#x4) (set shift 5))
  9088. ((#x5) (set shift 6))
  9089. ((#x6) (set shift 7))
  9090. ((#x7) (set shift 8))
  9091. ((-8) (set shift -1))
  9092. ((-7) (set shift -2))
  9093. ((-6) (set shift -3))
  9094. ((-5) (set shift -4))
  9095. ((-4) (set shift -5))
  9096. ((-3) (set shift -6))
  9097. ((-2) (set shift -7))
  9098. ((-1) (set shift -8))
  9099. (else (set shift 0))
  9100. )
  9101. (set shmode -1)
  9102. (set shmode (srl shmode #x8))
  9103. (if (lt mode shift #x0) (set result (sra mode dst (mul shift -1))))
  9104. (if (gt mode shift 0) (set result (sll mode dst shift)))
  9105. (if (eq shmode #x0) ; QI
  9106. (sequence
  9107. ((mode cbitamt))
  9108. (if (lt mode shift #x0)
  9109. (set cbitamt (sub #x8 shift)) ; sra
  9110. (set cbitamt (sub shift 1))) ; sll
  9111. (set cbit (srl (and (sll dst cbitamt) #x80) #x7))
  9112. (set obit (ne (and dst #x80) (and result #x80)))
  9113. ))
  9114. (if (eq shmode #xff) ; HI
  9115. (sequence
  9116. ((mode cbitamt))
  9117. (if (lt mode shift #x0)
  9118. (set cbitamt (sub 16 shift)) ; sra
  9119. (set cbitamt (sub shift 1))) ; sll
  9120. (set cbit (srl (and (sll dst cbitamt) #x8000) #xf))
  9121. (set obit (ne (and dst #x8000) (and result #x8000)))
  9122. ))
  9123. (set-z-and-s result)
  9124. (set dst result))
  9125. )
  9126. (define-pmacro (shar1h-sem mode dst)
  9127. (sequence ((mode result)(mode shmode))
  9128. (set shmode -1)
  9129. (set shmode (srl shmode #x8))
  9130. (if (lt mode (reg h-r1h) 0) (set result (sra mode dst (reg h-r1h))))
  9131. (if (gt mode (reg h-r1h) 0) (set result (sll mode dst (reg h-r1h))))
  9132. (if (eq shmode #x0) ; QI
  9133. (sequence
  9134. ((mode cbitamt))
  9135. (if (lt mode (reg h-r1h) #x0)
  9136. (set cbitamt (sub #x8 (reg h-r1h))) ; sra
  9137. (set cbitamt (sub (reg h-r1h) 1))) ; sll
  9138. (set cbit (srl (and (sll dst cbitamt) #x80) #x7))
  9139. (set obit (ne (and dst #x80) (and result #x80)))
  9140. ))
  9141. (if (eq shmode #xff) ; HI
  9142. (sequence
  9143. ((mode cbitamt))
  9144. (if (lt mode (reg h-r1h) #x0)
  9145. (set cbitamt (sub 16 (reg h-r1h))) ; sra
  9146. (set cbitamt (sub (reg h-r1h) 1))) ; sll
  9147. (set cbit (srl (and (sll dst cbitamt) #x8000) #xf))
  9148. (set obit (ne (and dst #x8000) (and result #x8000)))
  9149. ))
  9150. (set-z-and-s result)
  9151. (set dst result))
  9152. )
  9153. ; sha.BW #imm4,dst (m16 #1 m32 #1)
  9154. (binary-arith16-shimm4-dst-defn QI .b 0 0 sha (f-0-4 #xF) (f-4-3 0) sha-sem)
  9155. (binary-arith16-shimm4-dst-defn HI .w 0 1 sha (f-0-4 #xF) (f-4-3 0) sha-sem)
  9156. (binary-arith32-shimm4-dst-defn QI .b 1 0 sha #x7 #x0 sha-sem)
  9157. (binary-arith32-shimm4-dst-defn HI .w 1 1 sha #x7 #x0 sha-sem)
  9158. ; sha.BW r1h,dst (m16 #2 m32 #3)
  9159. (dni sha16.b-dst "sha.b r1h,dest" ((machine 16))
  9160. ("sha.b r1h,${dst16-16-QI}")
  9161. (+ (f-0-4 7) (f-4-4 4) (f-8-4 #xF) dst16-16-QI)
  9162. (shar1h-sem HI dst16-16-QI)
  9163. ())
  9164. (dni sha16.w-dst "sha.w r1h,dest" ((machine 16))
  9165. ("sha.w r1h,${dst16-16-HI}")
  9166. (+ (f-0-4 7) (f-4-4 5) (f-8-4 #xF) dst16-16-HI)
  9167. (shar1h-sem HI dst16-16-HI)
  9168. ())
  9169. (dni sha32.b-dst "sha.b r1h,dest" ((machine 32))
  9170. ("sha.b r1h,${dst32-16-Unprefixed-QI}")
  9171. (+ (f-0-4 #xB) dst32-16-Unprefixed-QI (f-7-1 0) (f-10-2 3) (f-12-4 #xE))
  9172. (shar1h-sem QI dst32-16-Unprefixed-QI)
  9173. ())
  9174. (dni sha32.w-dst "sha.w r1h,dest" ((machine 32))
  9175. ("sha.w r1h,${dst32-16-Unprefixed-HI}")
  9176. (+ (f-0-4 #xB) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xE))
  9177. (shar1h-sem HI dst32-16-Unprefixed-HI)
  9178. ())
  9179. ; sha.L #imm,dst (m16 #3)
  9180. (dni sha16-L-imm-r2r0 "sha.L #Imm-sh-12-s4,r2r0" ((machine 16))
  9181. "sha.l #${Imm-sh-12-s4},r2r0"
  9182. (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #xA) Imm-sh-12-s4)
  9183. (sha-sem SI Imm-sh-12-s4 (reg h-r2r0))
  9184. ())
  9185. (dni sha16-L-imm-r3r1 "sha.L #Imm-sh-12-s4,r3r1" ((machine 16))
  9186. "sha.l #${Imm-sh-12-s4},r3r1"
  9187. (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #xB) Imm-sh-12-s4)
  9188. (sha-sem SI Imm-sh-12-s4 (reg h-r3r1))
  9189. ())
  9190. ; sha.L r1h,dst (m16 #4)
  9191. (dni sha16-L-r1h-r2r0 "sha.L r1h,r2r0" ((machine 16))
  9192. "sha.l r1h,r2r0"
  9193. (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 2) (f-12-4 1))
  9194. (sha-sem SI (reg h-r1h) (reg h-r2r0))
  9195. ())
  9196. (dni sha16-L-r1h-r3r1 "sha.L r1h,r3r1" ((machine 16))
  9197. "sha.l r1h,r3r1"
  9198. (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 3) (f-12-4 1))
  9199. (sha-sem SI (reg h-r1h) (reg h-r3r1))
  9200. ())
  9201. ; sha.L #imm8,dst (m32 #2)
  9202. (binary-arith32-imm-dst-defn QI SI .l 0 sha X #xA #x2 #x1 sha-sem)
  9203. ; sha.L r1h,dst (m32 #4)
  9204. (dni sha32.l-dst "sha.l r1h,dest" ((machine 32))
  9205. ("sha.l r1h,${dst32-16-Unprefixed-SI}")
  9206. (+ (f-0-4 #xC) dst32-16-Unprefixed-SI (f-7-1 0) (f-10-2 1) (f-12-4 1))
  9207. (shar1h-sem QI dst32-16-Unprefixed-SI)
  9208. ())
  9209. ;-------------------------------------------------------------
  9210. ; shanc - shift arithmetic non carry (m32)
  9211. ;-------------------------------------------------------------
  9212. ; TODO check semantics
  9213. ; shanc.L #imm8,dst
  9214. (binary-arith32-imm-dst-defn QI SI .l 0 shanc X #xC #x2 #x1 sha-sem)
  9215. ;-------------------------------------------------------------
  9216. ; shl - shift logical
  9217. ;-------------------------------------------------------------
  9218. ; TODO future: split this into .b and .w semantics
  9219. (define-pmacro (shl-sem mode src1 dst)
  9220. (sequence ((mode result)(mode shift)(mode shmode))
  9221. (case DFLT src1
  9222. ((#x0) (set shift 1))
  9223. ((#x1) (set shift 2))
  9224. ((#x2) (set shift 3))
  9225. ((#x3) (set shift 4))
  9226. ((#x4) (set shift 5))
  9227. ((#x5) (set shift 6))
  9228. ((#x6) (set shift 7))
  9229. ((#x7) (set shift 8))
  9230. ((-8) (set shift -1))
  9231. ((-7) (set shift -2))
  9232. ((-6) (set shift -3))
  9233. ((-5) (set shift -4))
  9234. ((-4) (set shift -5))
  9235. ((-3) (set shift -6))
  9236. ((-2) (set shift -7))
  9237. ((-1) (set shift -8))
  9238. (else (set shift 0))
  9239. )
  9240. (set shmode -1)
  9241. (set shmode (srl shmode #x8))
  9242. (if (lt mode shift #x0) (set result (srl mode dst (mul shift -1))))
  9243. (if (gt mode shift 0) (set result (sll mode dst shift)))
  9244. (if (eq shmode #x0) ; QI
  9245. (sequence
  9246. ((mode cbitamt))
  9247. (if (lt mode shift #x0)
  9248. (set cbitamt (sub #x8 shift)); srl
  9249. (set cbitamt (sub shift 1))) ; sll
  9250. (set cbit (srl (and (sll dst cbitamt) #x80) #x7))
  9251. (set obit (ne (and dst #x80) (and result #x80)))
  9252. ))
  9253. (if (eq shmode #xff) ; HI
  9254. (sequence
  9255. ((mode cbitamt))
  9256. (if (lt mode shift #x0)
  9257. (set cbitamt (sub 16 shift)) ; srl
  9258. (set cbitamt (sub shift 1))) ; sll
  9259. (set cbit (srl (and (sll dst cbitamt) #x8000) #xf))
  9260. (set obit (ne (and dst #x8000) (and result #x8000)))
  9261. ))
  9262. (set-z-and-s result)
  9263. (set dst result))
  9264. )
  9265. (define-pmacro (shlr1h-sem mode dst)
  9266. (sequence ((mode result)(mode shmode))
  9267. (set shmode -1)
  9268. (set shmode (srl shmode #x8))
  9269. (if (lt mode (reg h-r1h) 0) (set result (srl mode dst (reg h-r1h))))
  9270. (if (gt mode (reg h-r1h) 0) (set result (sll mode dst (reg h-r1h))))
  9271. (if (eq shmode #x0) ; QI
  9272. (sequence
  9273. ((mode cbitamt))
  9274. (if (lt mode (reg h-r1h) #x0)
  9275. (set cbitamt (sub #x8 (reg h-r1h))) ; srl
  9276. (set cbitamt (sub (reg h-r1h) 1))) ; sll
  9277. (set cbit (srl (and (sll dst cbitamt) #x80) #x7))
  9278. (set obit (ne (and dst #x80) (and result #x80)))
  9279. ))
  9280. (if (eq shmode #xff) ; HI
  9281. (sequence
  9282. ((mode cbitamt))
  9283. (if (lt mode (reg h-r1h) #x0)
  9284. (set cbitamt (sub 16 (reg h-r1h))) ; srl
  9285. (set cbitamt (sub (reg h-r1h) 1))) ; sll
  9286. (set cbit (srl (and (sll dst cbitamt) #x8000) #xf))
  9287. (set obit (ne (and dst #x8000) (and result #x8000)))
  9288. ))
  9289. (set-z-and-s result)
  9290. (set dst result))
  9291. )
  9292. ; shl.BW #imm4,dst (m16 #1 m32 #1)
  9293. (binary-arith16-shimm4-dst-defn QI .b 0 0 shl (f-0-4 #xE) (f-4-3 4) shl-sem)
  9294. (binary-arith16-shimm4-dst-defn HI .w 0 1 shl (f-0-4 #xE) (f-4-3 4) shl-sem)
  9295. (binary-arith32-shimm4-dst-defn QI .b 0 0 shl #x7 #x0 shl-sem)
  9296. (binary-arith32-shimm4-dst-defn HI .w 0 1 shl #x7 #x0 shl-sem)
  9297. ; shl.BW r1h,dst (m16 #2 m32 #3)
  9298. (dni shl16.b-dst "shl.b r1h,dest" ((machine 16))
  9299. ("shl.b r1h,${dst16-16-QI}")
  9300. (+ (f-0-4 7) (f-4-4 4) (f-8-4 #xE) dst16-16-QI)
  9301. (shlr1h-sem HI dst16-16-QI)
  9302. ())
  9303. (dni shl16.w-dst "shl.w r1h,dest" ((machine 16))
  9304. ("shl.w r1h,${dst16-16-HI}")
  9305. (+ (f-0-4 7) (f-4-4 5) (f-8-4 #xE) dst16-16-HI)
  9306. (shlr1h-sem HI dst16-16-HI)
  9307. ())
  9308. (dni shl32.b-dst "shl.b r1h,dest" ((machine 32))
  9309. ("shl.b r1h,${dst32-16-Unprefixed-QI}")
  9310. (+ (f-0-4 #xA) dst32-16-Unprefixed-QI (f-7-1 0) (f-10-2 3) (f-12-4 #xE))
  9311. (shlr1h-sem QI dst32-16-Unprefixed-QI)
  9312. ())
  9313. (dni shl32.w-dst "shl.w r1h,dest" ((machine 32))
  9314. ("shl.w r1h,${dst32-16-Unprefixed-HI}")
  9315. (+ (f-0-4 #xA) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xE))
  9316. (shlr1h-sem HI dst32-16-Unprefixed-HI)
  9317. ())
  9318. ; shl.L #imm,dst (m16 #3)
  9319. (dni shl16-L-imm-r2r0 "shl.L #Imm-sh-12-s4,r2r0" ((machine 16))
  9320. "shl.l #${Imm-sh-12-s4},r2r0"
  9321. (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #x8) Imm-sh-12-s4)
  9322. (shl-sem SI Imm-sh-12-s4 (reg h-r2r0))
  9323. ())
  9324. (dni shl16-L-imm-r3r1 "shl.L #Imm-sh-12-s4,r3r1" ((machine 16))
  9325. "shl.l #${Imm-sh-12-s4},r3r1"
  9326. (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #x9) Imm-sh-12-s4)
  9327. (shl-sem SI Imm-sh-12-s4 (reg h-r3r1))
  9328. ())
  9329. ; shl.L r1h,dst (m16 #4)
  9330. (dni shl16-L-r1h-r2r0 "shl.L r1h,r2r0" ((machine 16))
  9331. "shl.l r1h,r2r0"
  9332. (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 0) (f-12-4 1))
  9333. (shl-sem SI (reg h-r1h) (reg h-r2r0))
  9334. ())
  9335. (dni shl16-L-r1h-r3r1 "shl.L r1h,r3r1" ((machine 16))
  9336. "shl.l r1h,r3r1"
  9337. (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 1) (f-12-4 1))
  9338. (shl-sem SI (reg h-r1h) (reg h-r3r1))
  9339. ())
  9340. ; shl.L #imm8,dst (m32 #2)
  9341. (binary-arith32-imm-dst-defn QI SI .l 0 shl X #x9 #x2 #x1 shl-sem)
  9342. ; shl.L r1h,dst (m32 #4)
  9343. (dni shl32.l-dst "shl.l r1h,dest" ((machine 32))
  9344. ("shl.l r1h,${dst32-16-Unprefixed-SI}")
  9345. (+ (f-0-4 #xC) dst32-16-Unprefixed-SI (f-7-1 0) (f-10-2 0) (f-12-4 1))
  9346. (shlr1h-sem QI dst32-16-Unprefixed-SI)
  9347. ())
  9348. ;-------------------------------------------------------------
  9349. ; shlnc - shift logical non carry
  9350. ;-------------------------------------------------------------
  9351. ; TODO check semantics
  9352. ; shlnc.L #imm8,dst
  9353. (binary-arith32-imm-dst-defn QI SI .l 0 shlnc X #x8 #x2 #x1 shl-sem)
  9354. ;-------------------------------------------------------------
  9355. ; sin - string input (m32)
  9356. ;-------------------------------------------------------------
  9357. ; TODO semantics
  9358. (dni sin32.b "sin" ((machine 32))
  9359. ("sin.b")
  9360. (+ (f-0-4 #xB) (f-4-4 2) (f-8-4 8) (f-12-4 3))
  9361. (c-call VOID "sin_QI_semantics")
  9362. ())
  9363. (dni sin32.w "sin" ((machine 32))
  9364. ("sin.w")
  9365. (+ (f-0-4 #xB) (f-4-4 2) (f-8-4 9) (f-12-4 3))
  9366. (c-call VOID "sin_HI_semantics")
  9367. ())
  9368. ;-------------------------------------------------------------
  9369. ; smovb - string move backward
  9370. ;-------------------------------------------------------------
  9371. ; TODO semantics
  9372. (dni smovb16.b "smovb.b" ((machine 16))
  9373. ("smovb.b")
  9374. (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 9))
  9375. (c-call VOID "smovb_QI_semantics")
  9376. ())
  9377. (dni smovb16.w "smovb.w" ((machine 16))
  9378. ("smovb.w")
  9379. (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 9))
  9380. (c-call VOID "smovb_HI_semantics")
  9381. ())
  9382. (dni smovb32.b "smovb.b" ((machine 32))
  9383. ("smovb.b")
  9384. (+ (f-0-4 #xB) (f-4-4 6) (f-8-4 8) (f-12-4 3))
  9385. (c-call VOID "smovb_QI_semantics")
  9386. ())
  9387. (dni smovb32.w "smovb.w" ((machine 32))
  9388. ("smovb.w")
  9389. (+ (f-0-4 #xB) (f-4-4 6) (f-8-4 9) (f-12-4 3))
  9390. (c-call VOID "smovb_HI_semantics")
  9391. ())
  9392. ;-------------------------------------------------------------
  9393. ; smovf - string move forward (m32)
  9394. ;-------------------------------------------------------------
  9395. ; TODO semantics
  9396. (dni smovf16.b "smovf.b" ((machine 16))
  9397. ("smovf.b")
  9398. (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 8))
  9399. (c-call VOID "smovf_QI_semantics")
  9400. ())
  9401. (dni smovf16.w "smovf.w" ((machine 16))
  9402. ("smovf.w")
  9403. (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 8))
  9404. (c-call VOID "smovf_HI_semantics")
  9405. ())
  9406. (dni smovf32.b "smovf.b" ((machine 32))
  9407. ("smovf.b")
  9408. (+ (f-0-4 #xB) (f-4-4 0) (f-8-4 8) (f-12-4 3))
  9409. (c-call VOID "smovf_QI_semantics")
  9410. ())
  9411. (dni smovf32.w "smovf.w" ((machine 32))
  9412. ("smovf.w")
  9413. (+ (f-0-4 #xB) (f-4-4 0) (f-8-4 9) (f-12-4 3))
  9414. (c-call VOID "smovf_HI_semantics")
  9415. ())
  9416. ;-------------------------------------------------------------
  9417. ; smovu - string move unequal (m32)
  9418. ;-------------------------------------------------------------
  9419. ; TODO semantics
  9420. (dni smovu.b "smovu.b" ((machine 32))
  9421. ("smovu.b")
  9422. (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 8) (f-12-4 3))
  9423. (c-call VOID "smovu_QI_semantics")
  9424. ())
  9425. (dni smovu.w "smovu.w" ((machine 32))
  9426. ("smovu.w")
  9427. (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 9) (f-12-4 3))
  9428. (c-call VOID "smovu_HI_semantics")
  9429. ())
  9430. ;-------------------------------------------------------------
  9431. ; sout - string output (m32)
  9432. ;-------------------------------------------------------------
  9433. ; TODO semantics
  9434. (dni sout.b "sout.b" ((machine 32))
  9435. ("sout.b")
  9436. (+ (f-0-4 #xB) (f-4-4 4) (f-8-4 8) (f-12-4 3))
  9437. (c-call VOID "sout_QI_semantics")
  9438. ())
  9439. (dni sout.w "sout" ((machine 32))
  9440. ("sout.w")
  9441. (+ (f-0-4 #xB) (f-4-4 4) (f-8-4 9) (f-12-4 3))
  9442. (c-call VOID "sout_HI_semantics")
  9443. ())
  9444. ;-------------------------------------------------------------
  9445. ; sstr - string store
  9446. ;-------------------------------------------------------------
  9447. ; TODO semantics
  9448. (dni sstr16.b "sstr.b" ((machine 16))
  9449. ("sstr.b")
  9450. (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 #xA))
  9451. (c-call VOID "sstr_QI_semantics")
  9452. ())
  9453. (dni sstr16.w "sstr.w" ((machine 16))
  9454. ("sstr.w")
  9455. (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 #xA))
  9456. (c-call VOID "sstr_HI_semantics")
  9457. ())
  9458. (dni sstr.b "sstr" ((machine 32))
  9459. ("sstr.b")
  9460. (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 0) (f-12-4 3))
  9461. (c-call VOID "sstr_QI_semantics")
  9462. ())
  9463. (dni sstr.w "sstr" ((machine 32))
  9464. ("sstr.w")
  9465. (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 1) (f-12-4 3))
  9466. (c-call VOID "sstr_HI_semantics")
  9467. ())
  9468. ;-------------------------------------------------------------
  9469. ; stnz - store on not zero
  9470. ;-------------------------------------------------------------
  9471. (define-pmacro (stnz-sem mode src dst)
  9472. (sequence ()
  9473. (if (ne zbit (const 1))
  9474. (set dst src)))
  9475. )
  9476. ; stnz #imm8,dst3 (m16)
  9477. (binary-arith16-b-S-imm8-dst3 stnz "" (f-0-4 #xD) (f-4-1 0) stnz-sem)
  9478. ; stnz.BW #imm,dst (m32)
  9479. (binary-arith32-imm-dst-defn QI QI .b 0 stnz X #x9 #x1 #xF stnz-sem)
  9480. (binary-arith32-imm-dst-defn HI HI .w 1 stnz X #x9 #x1 #xF stnz-sem)
  9481. ;-------------------------------------------------------------
  9482. ; stz - store on zero
  9483. ;-------------------------------------------------------------
  9484. (define-pmacro (stz-sem mode src dst)
  9485. (sequence ()
  9486. (if (eq zbit (const 1))
  9487. (set dst src)))
  9488. )
  9489. ; stz #imm8,dst3 (m16)
  9490. (binary-arith16-b-S-imm8-dst3 stz "" (f-0-4 #xC) (f-4-1 1) stz-sem)
  9491. ; stz.BW #imm,dst (m32)
  9492. (binary-arith32-imm-dst-defn QI QI .b 0 stz X #x9 #x0 #xF stz-sem)
  9493. (binary-arith32-imm-dst-defn HI HI .w 1 stz X #x9 #x0 #xF stz-sem)
  9494. ;-------------------------------------------------------------
  9495. ; stzx - store on zero extention
  9496. ;-------------------------------------------------------------
  9497. (define-pmacro (stzx-sem mode src1 src2 dst)
  9498. (sequence ()
  9499. (if (eq zbit (const 1))
  9500. (set dst src1)
  9501. (set dst src2)))
  9502. )
  9503. ; stzx #imm8,dst3 (m16)
  9504. (dni stzx16-imm8-imm8-r0h "stzx #Imm8,#Imm8,r0h" ((machine 16))
  9505. ("stzx #${Imm-8-QI},#${Imm-16-QI},r0h")
  9506. (+ (f-0-4 #xD) (f-4-4 #xB) Imm-8-QI Imm-16-QI)
  9507. (stzx-sem QI Imm-8-QI Imm-16-QI (reg h-r0h))
  9508. ())
  9509. (dni stzx16-imm8-imm8-r0l "stzx #Imm8,#Imm8,r0l" ((machine 16))
  9510. ("stzx #${Imm-8-QI},#${Imm-16-QI},r0l")
  9511. (+ (f-0-4 #xD) (f-4-4 #xC) Imm-8-QI Imm-16-QI)
  9512. (stzx-sem QI Imm-8-QI Imm-16-QI (reg h-r0l))
  9513. ())
  9514. (dni stzx16-imm8-imm8-dsp8sb "stzx #Imm8,#Imm8,dsp8[sb]" ((machine 16))
  9515. ("stzx #${Imm-8-QI},#${Imm-24-QI},${Dsp-16-u8}[sb]")
  9516. (+ (f-0-4 #xD) (f-4-4 #xD) Imm-8-QI Dsp-16-u8 Imm-24-QI)
  9517. (stzx-sem QI Imm-8-QI Imm-16-QI (mem16 QI (add (reg h-sb) Dsp-24-u8)))
  9518. ())
  9519. (dni stzx16-imm8-imm8-dsp8fb "stzx #Imm8,#Imm8,dsp8[fb]" ((machine 16))
  9520. ("stzx #${Imm-8-QI},#${Imm-24-QI},${Dsp-16-s8}[fb]")
  9521. (+ (f-0-4 #xD) (f-4-4 #xE) Imm-8-QI Dsp-16-s8 Imm-24-QI)
  9522. (stzx-sem QI Imm-8-QI Imm-24-QI (mem16 QI (add (reg h-fb) Dsp-16-s8)))
  9523. ())
  9524. (dni stzx16-imm8-imm8-abs16 "stzx #Imm8,#Imm8,abs16" ((machine 16))
  9525. ("stzx #${Imm-8-QI},#${Imm-32-QI},${Dsp-16-u16}")
  9526. (+ (f-0-4 #xD) (f-4-4 #xF) Imm-8-QI Dsp-16-u16 Imm-32-QI)
  9527. (stzx-sem QI Imm-8-QI Imm-32-QI (mem16 QI Dsp-16-u16))
  9528. ())
  9529. ; stzx.BW #imm,dst (m32)
  9530. (insn-imm1-imm2-dst-Unprefixed stzx #x9 #x3 #xF stzx-sem)
  9531. ;-------------------------------------------------------------
  9532. ; subx - subtract extend (m32)
  9533. ;-------------------------------------------------------------
  9534. (define-pmacro (subx-sem mode src1 dst)
  9535. (sequence ((mode result))
  9536. (set result (sub mode dst (ext mode src1)))
  9537. (set obit (sub-oflag mode dst (ext mode src1) 0))
  9538. (set cbit (sub-cflag mode dst (ext mode src1) 0))
  9539. (set dst result)
  9540. (set-z-and-s result)))
  9541. ; subx #imm8,dst
  9542. (binary-arith32-imm-dst-defn QI SI "" 0 subx G #x9 #x1 #x1 subx-sem)
  9543. ; subx src,dst
  9544. (binary-arith32-src-dst-defn QI SI "" 0 subx G #x1 #x0 subx-sem)
  9545. ;-------------------------------------------------------------
  9546. ; tst - test
  9547. ;-------------------------------------------------------------
  9548. (define-pmacro (tst-sem mode src1 dst)
  9549. (sequence ((mode result))
  9550. (set result (and mode dst src1))
  9551. (set-z-and-s result))
  9552. )
  9553. ; tst.BW #imm,dst (m16 #1 m32 #1)
  9554. (binary-arith-imm-dst tst G (f-0-4 7) (f-4-3 3) (f-8-4 0) #x9 #x3 #xE tst-sem)
  9555. ; tst.BW src,dst (m16 #2 m32 #3)
  9556. (binary-arith16-src-dst-defn QI QI .b 0 tst X (f-0-4 #x8) (f-4-3 0) tst-sem)
  9557. (binary-arith16-src-dst-defn HI HI .w 1 tst X (f-0-4 #x8) (f-4-3 0) tst-sem)
  9558. (binary-arith32-src-dst-Prefixed QI QI .b 0 tst G #x1 #x9 tst-sem)
  9559. (binary-arith32-src-dst-Prefixed HI HI .w 1 tst G #x1 #x9 tst-sem)
  9560. ; tst.BW:S #imm,dst2 (m32 #2)
  9561. (binary-arith32-s-imm-dst QI .b 0 tst #x0 #x6 tst-sem)
  9562. (binary-arith32-s-imm-dst HI .w 1 tst #x0 #x6 tst-sem)
  9563. ;-------------------------------------------------------------
  9564. ; und - undefined
  9565. ;-------------------------------------------------------------
  9566. (dni und16 "und" ((machine 16))
  9567. ("und")
  9568. (+ (f-0-4 #xF) (f-4-4 #xF))
  9569. (nop)
  9570. ())
  9571. (dni und32 "und" ((machine 32))
  9572. ("und")
  9573. (+ (f-0-4 #xF) (f-4-4 #xF))
  9574. (nop)
  9575. ())
  9576. ;-------------------------------------------------------------
  9577. ; wait
  9578. ;-------------------------------------------------------------
  9579. ; ??? semantics
  9580. (dni wait16 "wait" ((machine 16))
  9581. ("wait")
  9582. (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 3))
  9583. (nop)
  9584. ())
  9585. (dni wait "wait" ((machine 32))
  9586. ("wait")
  9587. (+ (f-0-4 #xB) (f-4-4 2) (f-8-4 0) (f-12-4 3))
  9588. (nop)
  9589. ())
  9590. ;-------------------------------------------------------------
  9591. ; xchg - exchange
  9592. ;-------------------------------------------------------------
  9593. (define-pmacro (xchg-sem mode src dst)
  9594. (sequence ((mode result))
  9595. (set result src)
  9596. (set src dst)
  9597. (set dst result))
  9598. )
  9599. (define-pmacro (xchg16-defn mode sz szc src srcreg)
  9600. (dni (.sym xchg16 sz - srcreg)
  9601. (.str "xchg" sz "-" srcreg ",dst16-16-" mode)
  9602. ((machine 16))
  9603. (.str "xchg." sz " " srcreg ",${dst16-16-" mode "}")
  9604. (+ (f-0-4 #x7) (f-4-3 #x5) (f-7-1 szc) (f-8-2 0) (f-10-2 src) (.sym dst16-16- mode))
  9605. (xchg-sem mode (reg (.sym h- srcreg)) (.sym dst16-16- mode))
  9606. ())
  9607. )
  9608. (xchg16-defn QI b 0 0 r0l)
  9609. (xchg16-defn QI b 0 1 r0h)
  9610. (xchg16-defn QI b 0 2 r1l)
  9611. (xchg16-defn QI b 0 3 r1h)
  9612. (xchg16-defn HI w 1 0 r0)
  9613. (xchg16-defn HI w 1 1 r1)
  9614. (xchg16-defn HI w 1 2 r2)
  9615. (xchg16-defn HI w 1 3 r3)
  9616. (define-pmacro (xchg32-defn mode sz szc src srcreg)
  9617. (dni (.sym xchg32 sz - srcreg)
  9618. (.str "xchg" sz "-" srcreg ",dst32-16-Unprefixed-" mode)
  9619. ((machine 32))
  9620. (.str "xchg." sz " " srcreg ",${dst32-16-Unprefixed-" mode "}")
  9621. (+ (f-0-4 #xD) (.sym dst32-16-Unprefixed- mode) (f-7-1 szc) (f-10-2 0) (f-12-1 1) (f-13-3 src))
  9622. (xchg-sem mode (reg (.sym h- srcreg)) (.sym dst32-16-Unprefixed- mode))
  9623. ())
  9624. )
  9625. (xchg32-defn QI b 0 0 r0l)
  9626. (xchg32-defn QI b 0 1 r1l)
  9627. (xchg32-defn QI b 0 2 a0)
  9628. (xchg32-defn QI b 0 3 a1)
  9629. (xchg32-defn QI b 0 4 r0h)
  9630. (xchg32-defn QI b 0 5 r1h)
  9631. (xchg32-defn HI w 1 0 r0)
  9632. (xchg32-defn HI w 1 1 r1)
  9633. (xchg32-defn HI w 1 2 a0)
  9634. (xchg32-defn HI w 1 3 a1)
  9635. (xchg32-defn HI w 1 4 r2)
  9636. (xchg32-defn HI w 1 5 r3)
  9637. ;-------------------------------------------------------------
  9638. ; xor - exclusive or
  9639. ;-------------------------------------------------------------
  9640. (define-pmacro (xor-sem mode src1 dst)
  9641. (sequence ((mode result))
  9642. (set result (xor mode src1 dst))
  9643. (set-z-and-s result)
  9644. (set dst result))
  9645. )
  9646. ; xor.BW #imm,dst (m16 #1 m32 #1)
  9647. (binary-arith-imm-dst xor G (f-0-4 7) (f-4-3 3) (f-8-4 1) #x9 #x0 #xE xor-sem)
  9648. ; xor.BW src,dst (m16 #3 m32 #3)
  9649. (binary-arith-src-dst xor G (f-0-4 #x8) (f-4-3 4) #x1 #x9 xor-sem)
  9650. ;-------------------------------------------------------------
  9651. ; Widening
  9652. ;-------------------------------------------------------------
  9653. (define-pmacro (exts-sem smode dmode src dst)
  9654. (set dst (ext dmode (trunc smode src)))
  9655. )
  9656. (define-pmacro (extz-sem smode dmode src dst)
  9657. (set dst (zext dmode (trunc smode src)))
  9658. )
  9659. ; exts.b dst for m16c
  9660. (ext16-defn QI HI .b 0 exts (f-0-4 7) (f-4-3 6) (f-8-4 6) exts-sem)
  9661. ; exts.w r0 for m16c
  9662. (dni exts16.w-r0
  9663. "exts.w r0"
  9664. ((machine 16))
  9665. "exts.w r0"
  9666. (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 3))
  9667. (exts-sem HI SI R0 R2R0)
  9668. ())
  9669. ; exts.size dst for m32c
  9670. (ext32-defn QI HI .b 0 exts (f-0-4 #xC) (f-10-2 1) (f-12-4 #xE) exts-sem)
  9671. (ext32-defn HI SI .w 1 exts (f-0-4 #xC) (f-10-2 1) (f-12-4 #xE) exts-sem)
  9672. ; exts.b src,dst for m32c
  9673. (ext32-binary-defn exts .b #x1 #x7 exts-sem)
  9674. ; extz.b src,dst for m32c
  9675. (ext32-binary-defn extz "" #x1 #xB extz-sem)
  9676. ;-------------------------------------------------------------
  9677. ; Indirect
  9678. ;-------------------------------------------------------------
  9679. ; TODO semantics
  9680. (dni srcind "SRC-INDIRECT" ((machine 32))
  9681. ("src-indirect")
  9682. (+ (f-0-4 4) (f-4-4 1))
  9683. (set (reg h-src-indirect) 1)
  9684. ())
  9685. (dni destind "DEST-INDIRECT" ((machine 32))
  9686. ("dest-indirect")
  9687. (+ (f-0-4 0) (f-4-4 9))
  9688. (set (reg h-dst-indirect) 1)
  9689. ())
  9690. (dni srcdestind "SRC-DEST-INDIRECT" ((machine 32))
  9691. ("src-dest-indirect")
  9692. (+ (f-0-4 4) (f-4-4 9))
  9693. (sequence () (set (reg h-src-indirect) 1) (set (reg h-dst-indirect) 1))
  9694. ())