123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589 |
- package disasm
-
- import (
- "encoding/binary"
- "fmt"
- "sort"
- "strconv"
- )
-
- const (
- M68K_CPU_TYPE_68000 Type = iota
- M68K_CPU_TYPE_68010
- M68K_CPU_TYPE_68EC020
- M68K_CPU_TYPE_68020
- M68K_CPU_TYPE_68EC030
- M68K_CPU_TYPE_68030
- M68K_CPU_TYPE_68EC040
- M68K_CPU_TYPE_68LC040
- M68K_CPU_TYPE_68040
- M68K_CPU_TYPE_SCC68070
- )
-
- const (
- dasm68000 = 1
- dasm68010 = 2
- dasm68020 = 4
- dasm68030 = 8
- dasm68040 = 16
- dasmAll = dasm68000 | dasm68010 | dasm68020 | dasm68030 | dasm68040
- )
-
- type dasmOpcode struct {
- dasmHandler func(*dasmInfo) string
- mask uint16
- match uint16
- eaMask uint16
- cpuTypes uint16
- }
-
- type dasmInfo struct {
- cpuType uint16
- bus AddressBus
- pc int32
- ir uint16
- helper string
- }
-
- func NewAddressBus(mem []byte) FunBar {
- return FunBar(mem)
- }
-
- type FunBar []byte
-
- func (f FunBar) read(address int32, s *Size) int32 {
- return s.read(f[address:])
- }
-
- func (f FunBar) write(address int32, s *Size, value int32) {
- s.write(f[address:], value)
- }
-
- func (f FunBar) reset() {
- panic("no funbar reset!")
- }
-
- type AddressBus interface {
- read(address int32, s *Size) int32
- write(address int32, s *Size, value int32)
- reset()
- }
-
- var (
- dasmTable = make([]func(*dasmInfo) string, 0x10000)
- dasmSupportedTypes = make([]uint16, 0x10000)
-
- g3bitQDataTable = []int32{8, 1, 2, 3, 4, 5, 6, 7}
- g5bitQDataTable = []int32{32, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}
- gCCTable = []string{"t", "f", "hi", "ls", "cc", "cs", "ne", "eq", "vc", "vs", "pl", "mi", "ge", "lt", "gt", "le"}
- gCPCCTable = []string{"f", "eq", "ogt", "oge", "olt", "ole", "ogl", "or", "un", "ueq", "ugt", "uge", "ult", "ule", "ne", "t", "sf", "seq", "gt", "ge", "lt", "le", "glgle", "ngle", "ngl", "nle", "nlt", "nge", "ngt", "sne", "st", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?"}
- gMMURegs = []string{"tc", "drp", "srp", "crp", "cal", "val", "sccr", "acr"}
- gMMUCond = []string{"bs", "bc", "ls", "lc", "ss", "sc", "as", "ac", "ws", "wc", "is", "ic", "gs", "gc", "cs", "cc"}
- gFPUDataFormatTable = []string{".l", ".s", ".x", ".p", ".w", ".d", ".b", ".p"}
- )
-
- func (d *dasmInfo) readImm(advance *Size) int32 {
- result := d.bus.read(d.pc, advance)
- d.pc += advance.align
- return result
- }
-
- func (d *dasmInfo) getImmStrSigned(size *Size) string {
- return size.SignedHexString(d.readImm(size))
- }
-
- func (d *dasmInfo) getImmStrUnsigned(size *Size) string {
- return size.HexString(d.readImm(size))
- }
-
- func (d *dasmInfo) getEaModeStr(size *Size) string {
- // Make string of effective address mode
- switch d.ir & 0x3f {
- case 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07: // data register direct
- return fmt.Sprintf("D%d", y(d.ir))
- case 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f: // address register direct
- return fmt.Sprintf("A%d", y(d.ir))
- case 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17: // address register indirect
- return fmt.Sprintf("(A%d)", y(d.ir))
- case 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f: // address register indirect with postincrement
- return fmt.Sprintf("(A%d)+", y(d.ir))
- case 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27: // address register indirect with predecrement
- return fmt.Sprintf("-(A%d)", y(d.ir))
- case 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f: // address register indirect with displacement
- return fmt.Sprintf("(%s,A%d)", Word.SignedHexString(d.readImm(Word)), y(d.ir))
- case 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37:
- // address register indirect with index
- mode := ""
- extension := d.readImm(Word)
- if extension&0x100 != 0 {
- if extension&0xE4 == 0xC4 || extension&0xE2 == 0xC0 {
- return ""
- }
- base := int32(0)
- if extension&0x30 > 16 {
- if extension&0x30 == 0x30 {
- base = d.readImm(Long)
- } else {
- base = d.readImm(Word)
- }
- }
- outer := int32(0)
- if extension&3 > 1 && extension&71 < 68 {
- if extension&3 == 3 && extension&71 < 68 {
- outer = d.readImm(Long)
- } else {
- outer = d.readImm(Word)
- }
- }
- baseReg, indexReg := "", ""
- if extension&128 == 0 {
- baseReg = fmt.Sprintf("A%d", y(d.ir))
- }
- if extension&64 == 0 {
- indexReg = "D"
- if extension&0x8000 != 0 {
- indexReg = "A"
- }
- indexReg += strconv.Itoa(int((extension >> 12) & 7))
- if extension&0x800 != 0 {
- indexReg += Long.ext
- } else {
- indexReg += Word.ext
- }
- if extension>>uint64(9)&3 != 0 {
- indexReg += "*" + strconv.Itoa(int(1<<((extension>>9)&3)))
- }
- }
- preindex := extension&7 > 0 && extension&7 < 4
- postindex := extension&7 > 4
- comma := false
- if base != 0 {
- if extension&0x30 == 0x30 {
- mode += Long.SignedHexString(base)
- } else {
- mode += Word.SignedHexString(base)
- }
- comma = true
- }
- if baseReg[0] != 0 {
- mode += baseReg
- comma = true
- }
- if postindex {
- mode += "]"
- comma = true
- }
- if indexReg[0] != 0 {
- if comma {
- mode += ","
- }
- mode += indexReg
- comma = true
- }
- if preindex {
- mode += "]"
- comma = true
- }
- if outer != 0 {
- if comma {
- mode += ","
- }
- mode += Word.SignedHexString(outer)
- }
- return mode
- }
- if extension&0xFF == 0 {
- mode = fmt.Sprintf("(A%d,", y(d.ir))
- if extension&0x8000 != 0 {
- mode += "A"
- } else {
- mode += "D"
- }
- mode += strconv.Itoa(int((extension >> 12) & 7))
- if extension&0x800 != 0 {
- mode += Long.ext
- } else {
- mode += Word.ext
- }
- } else {
- mode = fmt.Sprintf("(%s,A%d,", Byte.SignedHexString(extension), y(d.ir))
- if extension&0x8000 != 0 {
- mode += "A"
- } else {
- mode += "D"
- }
- mode += strconv.Itoa(int((extension >> 12) & 7))
- if extension&0x800 != 0 {
- mode += Long.ext
- } else {
- mode += Word.ext
- }
- }
- if (extension>>9)&3 != 0 {
- mode += fmt.Sprintf("*%d", 1<<uint64(extension>>uint64(9)&3))
- }
- return mode
- case 56:
- // absolute short address
- return fmt.Sprintf("$%x.w", d.readImm(Word))
- case 57:
- // absolute long address
- return fmt.Sprintf("$%x.l", d.readImm(Long))
- case 58:
- // program counter with displacement
- tempValue := d.readImm(Word)
- d.helper = fmt.Sprintf("; ($%x)", tempValue+d.pc-2)
- return fmt.Sprintf("(%s,PC)", Word.SignedHexString(tempValue))
- case 59:
- // program counter with index
- mode := ""
- extension := d.readImm(Word)
- if extension&0x100 != 0 {
- if extension&0xE4 == 0xC4 || extension&0xE2 == 0xC0 {
- return ""
- }
- base := int32(0)
- if extension&0x30 > 0x10 {
- if extension&0x30 == 0x30 {
- base = d.readImm(Long)
- } else {
- base = d.readImm(Word)
- }
- }
- outer := int32(0)
- if extension&3 > 1 && extension&71 < 68 {
- if extension&3 == 3 && extension&71 < 68 {
- outer = d.readImm(Long)
- } else {
- outer = d.readImm(Word)
- }
- }
- baseReg := ""
- if extension&128 == 0 {
- baseReg = "PC"
- }
- indexReg := ""
- if extension&64 == 0 {
- indexReg = "D"
- if extension&0x8000 != 0 {
- indexReg = "A"
- }
- indexReg += strconv.Itoa(int((extension >> 12) & 7))
- if extension&0x800 != 0 {
- indexReg += Long.ext
- } else {
- indexReg += Word.ext
- }
- if extension>>uint64(9)&3 != 0 {
- indexReg += "*" + strconv.Itoa(int(1<<((extension>>9)&3)))
- }
- }
- preindex := extension&7 > 0 && extension&7 < 4
- postindex := extension&7 > 4
- comma := false
- mode = "("
- if preindex || postindex {
- mode += "["
- }
- if base != 0 {
- mode += Word.SignedHexString(base)
- comma = true
- }
- if baseReg != "" {
- if comma {
- mode += ","
- }
- mode += baseReg
- comma = true
- }
- if postindex {
- mode += "]"
- comma = true
- }
- if indexReg != "" {
- if comma {
- mode += ","
- }
- mode += indexReg
- comma = true
- }
- if preindex {
- mode += "]"
- comma = true
- }
- if outer != 0 {
- if comma {
- mode += ","
- }
- mode += Word.SignedHexString(outer)
- }
- return mode
- }
- if extension&0xFF == 0 {
- mode = "(PC,"
- if extension&0x8000 != 0 {
- mode += "A"
- } else {
- mode += "D"
- }
- mode += strconv.Itoa(int((extension >> 12) & 7))
- if extension&0x800 != 0 {
- mode += Long.ext
- } else {
- mode += Word.ext
- }
- } else {
- mode = fmt.Sprintf("(%s,PC,", Byte.SignedHexString(extension))
- if extension&0x8000 != 0 {
- mode += "A"
- } else {
- mode += "D"
- }
- mode += strconv.Itoa(int((extension >> 12) & 7))
- if extension&0x800 != 0 {
- mode += Long.ext
- } else {
- mode += Word.ext
- }
- }
- if (extension>>9)&3 != 0 {
- mode += fmt.Sprintf("*%d", 1<<uint64(extension>>uint64(9)&3))
- }
- return mode
- case 60:
- // Immediate
- return d.getImmStrUnsigned(size)
- default:
- return fmt.Sprintf("INVALID %x", d.ir&0x3f)
- }
- }
-
- // func d68000Illegal(d *dasmInfo) string {
- // return fmt.Sprintf("dc.w $%04x; ILLEGAL", d.ir)
- // }
-
- func d68000_illegal(d *dasmInfo) string {
- return fmt.Sprintf("dc.w $%04x; ILLEGAL", d.ir)
- }
-
- func d68000_a_line(d *dasmInfo) string {
- return fmt.Sprintf("dc.w $%04x; opcode 1010", d.ir)
- }
-
- func d68000_f_line(d *dasmInfo) string {
- return fmt.Sprintf("dc.w $%04x; opcode 1111", d.ir)
- }
-
- func d68000_abcd_rr(d *dasmInfo) string {
- return fmt.Sprintf("abcd D%d, D%d", y(d.ir), x(d.ir))
- }
-
- func d68000_abcd_mm(d *dasmInfo) string {
- return fmt.Sprintf("abcd -(A%d), -(A%d)", y(d.ir), x(d.ir))
- }
-
- func d68000_add_er_8(d *dasmInfo) string {
- return fmt.Sprintf("add.b %s, D%d", d.getEaModeStr(Byte), x(d.ir))
- }
-
- func d68000_add_er_16(d *dasmInfo) string {
- return fmt.Sprintf("add.w %s, D%d", d.getEaModeStr(Word), x(d.ir))
- }
-
- func d68000_add_er_32(d *dasmInfo) string {
- return fmt.Sprintf("add.l %s, D%d", d.getEaModeStr(Long), x(d.ir))
- }
-
- func d68000_add_re_8(d *dasmInfo) string {
- return fmt.Sprintf("add.b D%d, %s", x(d.ir), d.getEaModeStr(Byte))
- }
-
- func d68000_add_re_16(d *dasmInfo) string {
- return fmt.Sprintf("add.w D%d, %s", x(d.ir), d.getEaModeStr(Word))
- }
-
- func d68000_add_re_32(d *dasmInfo) string {
- return fmt.Sprintf("add.l D%d, %s", x(d.ir), d.getEaModeStr(Long))
- }
- func d68000_adda_16(d *dasmInfo) string {
- return fmt.Sprintf("adda.w %s, A%d", d.getEaModeStr(Word), x(d.ir))
- }
-
- func d68000_adda_32(d *dasmInfo) string {
- return fmt.Sprintf("adda.l %s, A%d", d.getEaModeStr(Long), x(d.ir))
- }
-
- func d68000_addi_8(d *dasmInfo) string {
- return fmt.Sprintf("addi.b %s, %s", d.getImmStrSigned(Byte), d.getEaModeStr(Byte))
- }
-
- func d68000_addi_16(d *dasmInfo) string {
- return fmt.Sprintf("addi.w %s, %s", d.getImmStrSigned(Word), d.getEaModeStr(Word))
- }
-
- func d68000_addi_32(d *dasmInfo) string {
- return fmt.Sprintf("addi.l %s, %s", d.getImmStrSigned(Long), d.getEaModeStr(Long))
- }
-
- func d68000_addq_8(d *dasmInfo) string {
- return fmt.Sprintf("addq.b #%d, %s", g3bitQDataTable[x(d.ir)], d.getEaModeStr(Byte))
- }
-
- func d68000_addq_16(d *dasmInfo) string {
- return fmt.Sprintf("addq.w #%d, %s", g3bitQDataTable[x(d.ir)], d.getEaModeStr(Word))
- }
-
- func d68000_addq_32(d *dasmInfo) string {
- return fmt.Sprintf("addq.l #%d, %s", g3bitQDataTable[x(d.ir)], d.getEaModeStr(Long))
- }
-
- func d68000_addx_rr_8(d *dasmInfo) string {
- return fmt.Sprintf("addx.b D%d, D%d", y(d.ir), x(d.ir))
- }
-
- func d68000_addx_rr_16(d *dasmInfo) string {
- return fmt.Sprintf("addx.w D%d, D%d", y(d.ir), x(d.ir))
- }
-
- func d68000_addx_rr_32(d *dasmInfo) string {
- return fmt.Sprintf("addx.l D%d, D%d", y(d.ir), x(d.ir))
- }
-
- func d68000_addx_mm_8(d *dasmInfo) string {
- return fmt.Sprintf("addx.b -(A%d), -(A%d)", y(d.ir), x(d.ir))
- }
-
- func d68000_addx_mm_16(d *dasmInfo) string {
- return fmt.Sprintf("addx.w -(A%d), -(A%d)", y(d.ir), x(d.ir))
- }
-
- func d68000_addx_mm_32(d *dasmInfo) string {
- return fmt.Sprintf("addx.l -(A%d), -(A%d)", y(d.ir), x(d.ir))
- }
-
- func d68000_and_er_8(d *dasmInfo) string {
- return fmt.Sprintf("and.b %s, D%d", d.getEaModeStr(Byte), x(d.ir))
- }
-
- func d68000_and_er_16(d *dasmInfo) string {
- return fmt.Sprintf("and.w %s, D%d", d.getEaModeStr(Word), x(d.ir))
- }
-
- func d68000_and_er_32(d *dasmInfo) string {
- return fmt.Sprintf("and.l %s, D%d", d.getEaModeStr(Long), x(d.ir))
- }
-
- func d68000_and_re_8(d *dasmInfo) string {
- return fmt.Sprintf("and.b D%d, %s", x(d.ir), d.getEaModeStr(Byte))
- }
-
- func d68000_and_re_16(d *dasmInfo) string {
- return fmt.Sprintf("and.w D%d, %s", x(d.ir), d.getEaModeStr(Word))
- }
-
- func d68000_and_re_32(d *dasmInfo) string {
- return fmt.Sprintf("and.l D%d, %s", x(d.ir), d.getEaModeStr(Long))
- }
-
- func d68000_andi_8(d *dasmInfo) string {
- return fmt.Sprintf("andi.b %s, %s", d.getImmStrUnsigned(Byte), d.getEaModeStr(Byte))
- }
-
- func d68000_andi_16(d *dasmInfo) string {
- return fmt.Sprintf("andi.w %s, %s", d.getImmStrUnsigned(Word), d.getEaModeStr(Word))
- }
-
- func d68000_andi_32(d *dasmInfo) string {
- return fmt.Sprintf("andi.l %s, %s", d.getImmStrUnsigned(Long), d.getEaModeStr(Long))
- }
-
- func d68000_andi_to_ccr(d *dasmInfo) string {
- return fmt.Sprintf("andi %s, CCR", d.getImmStrUnsigned(Byte))
- }
-
- func d68000_andi_to_sr(d *dasmInfo) string {
- return fmt.Sprintf("andi %s, SR", d.getImmStrUnsigned(Word))
- }
-
- func d68000_asr_s_8(d *dasmInfo) string {
- return fmt.Sprintf("asr.b #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_asr_s_16(d *dasmInfo) string {
- return fmt.Sprintf("asr.w #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_asr_s_32(d *dasmInfo) string {
- return fmt.Sprintf("asr.l #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_asr_r_8(d *dasmInfo) string {
- return fmt.Sprintf("asr.b D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_asr_r_16(d *dasmInfo) string {
- return fmt.Sprintf("asr.w D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_asr_r_32(d *dasmInfo) string {
- return fmt.Sprintf("asr.l D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_asr_ea(d *dasmInfo) string {
- return fmt.Sprintf("asr.w %s", d.getEaModeStr(Word))
- }
-
- func d68000_asl_s_8(d *dasmInfo) string {
- return fmt.Sprintf("asl.b #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_asl_s_16(d *dasmInfo) string {
- return fmt.Sprintf("asl.w #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_asl_s_32(d *dasmInfo) string {
- return fmt.Sprintf("asl.l #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_asl_r_8(d *dasmInfo) string {
- return fmt.Sprintf("asl.b D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_asl_r_16(d *dasmInfo) string {
- return fmt.Sprintf("asl.w D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_asl_r_32(d *dasmInfo) string {
- return fmt.Sprintf("asl.l D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_asl_ea(d *dasmInfo) string {
- return fmt.Sprintf("asl.w %s", d.getEaModeStr(Word))
- }
-
- func d68000_bcc_8(d *dasmInfo) string {
- return fmt.Sprintf("b%-2s $%x", gCCTable[(d.ir>>8)&15], d.pc+int32(int8(d.ir)))
- }
-
- func d68000_bcc_16(d *dasmInfo) string {
- return fmt.Sprintf("b%-2s $%x", gCCTable[d.ir>>uint64(8)&15], d.pc+d.readImm(Word))
- }
-
- func d68020_bcc_32(d *dasmInfo) string {
- return fmt.Sprintf("b%-2s $%x; (2+)", gCCTable[d.ir>>uint64(8)&15], d.pc+d.readImm(Long))
- }
-
- func d68000_bchg_r(d *dasmInfo) string {
- return fmt.Sprintf("bchg D%d, %s", x(d.ir), d.getEaModeStr(Byte))
- }
-
- func d68000_bchg_s(d *dasmInfo) string {
- return fmt.Sprintf("bchg %s, %s", d.getImmStrUnsigned(Byte), d.getEaModeStr(Byte))
- }
-
- func d68000_bclr_r(d *dasmInfo) string {
- return fmt.Sprintf("bclr D%d, %s", x(d.ir), d.getEaModeStr(Byte))
- }
-
- func d68000_bclr_s(d *dasmInfo) string {
- return fmt.Sprintf("bclr %s, %s", d.getImmStrUnsigned(Byte), d.getEaModeStr(Byte))
- }
-
- func d68010_bkpt(d *dasmInfo) string {
- return fmt.Sprintf("bkpt #%d; (1+)", y(d.ir))
- }
-
- func d68020_bfchg(d *dasmInfo) string {
- extension := d.readImm(Word)
- offset := ""
- width := ""
- if extension&0x800 != 0 {
- offset = fmt.Sprintf("D%d", (extension>>6)&7)
- } else {
- offset = fmt.Sprintf("%d", (extension>>6)&31)
- }
- if extension&32 != 0 {
- width = fmt.Sprintf("D%d", extension&7)
- } else {
- width = fmt.Sprintf("%d", g5bitQDataTable[extension&31])
- }
- return fmt.Sprintf("bfchg %s {%s:%s}; (2+)", d.getEaModeStr(Byte), offset, width)
- }
-
- func d68020_bfclr(d *dasmInfo) string {
- extension := d.readImm(Word)
- offset := ""
- width := ""
- if extension&0x800 != 0 {
- offset = fmt.Sprintf("D%d", (extension>>6)&7)
- } else {
- offset = fmt.Sprintf("%d", (extension>>6)&31)
- }
- if extension&32 != 0 {
- width = fmt.Sprintf("D%d", extension&7)
- } else {
- width = fmt.Sprintf("%d", g5bitQDataTable[extension&31])
- }
- return fmt.Sprintf("bfclr %s {%s:%s}; (2+)", d.getEaModeStr(Byte), offset, width)
- }
-
- func d68020_bfexts(d *dasmInfo) string {
- extension := d.readImm(Word)
- offset := ""
- width := ""
- if extension&0x800 != 0 {
- offset = fmt.Sprintf("D%d", (extension>>6)&7)
- } else {
- offset = fmt.Sprintf("%d", (extension>>6)&31)
- }
- if extension&32 != 0 {
- width = fmt.Sprintf("D%d", extension&7)
- } else {
- width = fmt.Sprintf("%d", g5bitQDataTable[extension&31])
- }
- return fmt.Sprintf("bfexts %s {%s:%s}; (2+)", d.getEaModeStr(Byte), offset, width)
- }
-
- func d68020_bfextu(d *dasmInfo) string {
- extension := d.readImm(Word)
- offset := ""
- width := ""
- if extension&0x800 != 0 {
- offset = fmt.Sprintf("D%d", (extension>>6)&7)
- } else {
- offset = fmt.Sprintf("%d", (extension>>6)&31)
- }
- if extension&32 != 0 {
- width = fmt.Sprintf("D%d", extension&7)
- } else {
- width = fmt.Sprintf("%d", g5bitQDataTable[extension&31])
- }
- return fmt.Sprintf("bfextu %s {%s:%s}; (2+)", d.getEaModeStr(Byte), offset, width)
- }
-
- func d68020_bfffo(d *dasmInfo) string {
- extension := d.readImm(Word)
- offset := ""
- width := ""
- if extension&0x800 != 0 {
- offset = fmt.Sprintf("D%d", (extension>>6)&7)
- } else {
- offset = fmt.Sprintf("%d", (extension>>6)&31)
- }
- if extension&32 != 0 {
- width = fmt.Sprintf("D%d", extension&7)
- } else {
- width = fmt.Sprintf("%d", g5bitQDataTable[extension&31])
- }
- return fmt.Sprintf("bfffo %s {%s:%s}; (2+)", d.getEaModeStr(Byte), offset, width)
- }
-
- func d68020_bfins(d *dasmInfo) string {
- extension := d.readImm(Word)
- offset := ""
- width := ""
- if extension&0x800 != 0 {
- offset = fmt.Sprintf("D%d", (extension>>6)&7)
- } else {
- offset = fmt.Sprintf("%d", (extension>>6)&31)
- }
- if extension&32 != 0 {
- width = fmt.Sprintf("D%d", extension&7)
- } else {
- width = fmt.Sprintf("%d", g5bitQDataTable[extension&31])
- }
- return fmt.Sprintf("bfins %s {%s:%s}; (2+)", d.getEaModeStr(Byte), offset, width)
- }
-
- func d68020_bfset(d *dasmInfo) string {
- extension := d.readImm(Word)
- offset := ""
- width := ""
- if extension&0x800 != 0 {
- offset = fmt.Sprintf("D%d", (extension>>6)&7)
- } else {
- offset = fmt.Sprintf("%d", (extension>>6)&31)
- }
- if extension&32 != 0 {
- width = fmt.Sprintf("D%d", extension&7)
- } else {
- width = fmt.Sprintf("%d", g5bitQDataTable[extension&31])
- }
- return fmt.Sprintf("bfset %s {%s:%s}; (2+)", d.getEaModeStr(Byte), offset, width)
- }
-
- func d68020_bftst(d *dasmInfo) string {
- var offset string
- var width string
- extension := d.readImm(Word)
- if extension&0x800 != 0 {
- offset = fmt.Sprintf("D%d", (extension>>6)&7)
- } else {
- offset = fmt.Sprintf("%d", (extension>>6)&31)
- }
- if extension&32 != 0 {
- width = fmt.Sprintf("D%d", extension&7)
- } else {
- width = fmt.Sprintf("%d", g5bitQDataTable[extension&31])
- }
- return fmt.Sprintf("bftst %s {%s:%s}; (2+)", d.getEaModeStr(Byte), offset, width)
- }
-
- func d68000_bra_8(d *dasmInfo) string {
- return fmt.Sprintf("bra $%x", d.pc+int32(int8(d.ir)))
- }
-
- func d68000_bra_16(d *dasmInfo) string {
- return fmt.Sprintf("bra $%x", d.pc+int32(int16(d.readImm(Word))))
- }
-
- func d68020_bra_32(d *dasmInfo) string {
- return fmt.Sprintf("bra $%x; (2+)", d.pc+d.readImm(Long))
- }
-
- func d68000_bset_r(d *dasmInfo) string {
- return fmt.Sprintf("bset D%d, %s", x(d.ir), d.getEaModeStr(Byte))
- }
-
- func d68000_bset_s(d *dasmInfo) string {
- return fmt.Sprintf("bset %s, %s", d.getImmStrUnsigned(Byte), d.getEaModeStr(Byte))
- }
-
- func d68000_bsr_8(d *dasmInfo) string {
- return fmt.Sprintf("bsr $%x", d.pc+int32(int8(d.ir)))
- }
-
- func d68000_bsr_16(d *dasmInfo) string {
- return fmt.Sprintf("bsr $%x", d.pc+int32(int16(d.readImm(Word))))
- }
-
- func d68020_bsr_32(d *dasmInfo) string {
- return fmt.Sprintf("bsr $%x; (2+)", d.pc+d.readImm(Long))
- }
-
- func d68000_btst_r(d *dasmInfo) string {
- return fmt.Sprintf("btst D%d, %s", x(d.ir), d.getEaModeStr(Byte))
- }
-
- func d68000_btst_s(d *dasmInfo) string {
- return fmt.Sprintf("btst %s, %s", d.getImmStrUnsigned(Byte), d.getEaModeStr(Byte))
- }
-
- func d68020_callm(d *dasmInfo) string {
- return fmt.Sprintf("callm %s, %s; (2)", d.getImmStrUnsigned(Byte), d.getEaModeStr(Byte))
- }
-
- func d68020_cas_8(d *dasmInfo) string {
- extension := d.readImm(Word)
- return fmt.Sprintf("cas.b D%d, D%d, %s; (2+)", extension&7, extension>>uint64(6)&7, d.getEaModeStr(Byte))
- }
-
- func d68020_cas_16(d *dasmInfo) string {
- extension := d.readImm(Word)
- return fmt.Sprintf("cas.w D%d, D%d, %s; (2+)", extension&7, extension>>uint64(6)&7, d.getEaModeStr(Word))
- }
-
- func d68020_cas_32(d *dasmInfo) string {
- extension := d.readImm(Word)
- return fmt.Sprintf("cas.l D%d, D%d, %s; (2+)", extension&7, (extension>>6)&7, d.getEaModeStr(Long))
- }
-
- func d68020_cas2_16(d *dasmInfo) string {
- extension := d.readImm(Long)
- return fmt.Sprintf("cas2.w D%d:D%d, D%d:D%d, (%c%d):(%c%d); (2+)", (extension>>16)&7, extension&7, (extension>>22)&7, (extension>>6)&7,
- func() int32 {
- if Long.IsNegative(extension) {
- return int32('A')
- }
- return int32('D')
- }(), extension>>uint64(28)&7, func() int32 {
- if extension&0x8000 != 0 {
- return int32('A')
- }
- return int32('D')
- }(), extension>>uint64(12)&7)
- }
-
- func d68020_cas2_32(d *dasmInfo) string {
- extension := d.readImm(Long)
- return fmt.Sprintf("cas2.l D%d:D%d, D%d:D%d, (%c%d):(%c%d); (2+)", extension>>uint64(16)&7, extension&7, extension>>uint64(22)&7, extension>>uint64(6)&7, func() int32 {
- if Long.IsNegative(extension) {
- return int32('A')
- }
- return int32('D')
- }(), extension>>uint64(28)&7, func() int32 {
- if extension&0x8000 != 0 {
- return int32('A')
- }
- return int32('D')
- }(), extension>>uint64(12)&7)
- }
-
- func d68000_chk_16(d *dasmInfo) string {
- return fmt.Sprintf("chk.w %s, D%d", d.getEaModeStr(Word), x(d.ir))
- }
-
- func d68020_chk_32(d *dasmInfo) string {
- return fmt.Sprintf("chk.l %s, D%d; (2+)", d.getEaModeStr(Long), x(d.ir))
- }
-
- func d68020_chk2_cmp2_8(d *dasmInfo) string {
- extension := d.readImm(Word)
- return fmt.Sprintf("%s.b %s, %c%d; (2+)", func() string {
- if extension&0x800 != 0 {
- return "chk2"
- }
- return "cmp2"
- }(), d.getEaModeStr(Byte), func() int32 {
- if extension&0x8000 != 0 {
- return int32('A')
- }
- return int32('D')
- }(), (extension>>12)&7)
- }
-
- func d68020_chk2_cmp2_16(d *dasmInfo) string {
- extension := d.readImm(Word)
- return fmt.Sprintf("%s.w %s, %c%d; (2+)", func() string {
- if extension&0x800 != 0 {
- return "chk2"
- }
- return "cmp2"
- }(), d.getEaModeStr(Word), func() int32 {
- if extension&0x8000 != 0 {
- return int32('A')
- }
- return int32('D')
- }(), extension>>uint64(12)&7)
- }
-
- func d68020_chk2_cmp2_32(d *dasmInfo) string {
- extension := d.readImm(Word)
- return fmt.Sprintf("%s.l %s, %c%d; (2+)", func() string {
- if extension&0x800 != 0 {
- return "chk2"
- }
- return "cmp2"
- }(), d.getEaModeStr(Long), func() int32 {
- if extension&0x8000 != 0 {
- return int32('A')
- }
- return int32('D')
- }(), (extension>>12)&7)
- }
-
- func d68040_cinv(d *dasmInfo) string {
- switch (d.ir >> 3) & 3 {
- case 0:
- return "cinv (illegal scope); (4)"
- case 1:
- return fmt.Sprintf("cinvl %d, (A%d); (4)", (d.ir>>6)&3, y(d.ir))
- case 2:
- return fmt.Sprintf("cinvp %d, (A%d); (4)", (d.ir>>6)&3, y(d.ir))
- default:
- return fmt.Sprintf("cinva %d; (4)", (d.ir>>6)&3)
- }
- }
-
- func d68000_clr_8(d *dasmInfo) string {
- return fmt.Sprintf("clr.b %s", d.getEaModeStr(Byte))
- }
-
- func d68000_clr_16(d *dasmInfo) string {
- return fmt.Sprintf("clr.w %s", d.getEaModeStr(Word))
- }
-
- func d68000_clr_32(d *dasmInfo) string {
- return fmt.Sprintf("clr.l %s", d.getEaModeStr(Long))
- }
-
- func d68000_cmp_8(d *dasmInfo) string {
- return fmt.Sprintf("cmp.b %s, D%d", d.getEaModeStr(Byte), x(d.ir))
- }
-
- func d68000_cmp_16(d *dasmInfo) string {
- return fmt.Sprintf("cmp.w %s, D%d", d.getEaModeStr(Word), x(d.ir))
- }
-
- func d68000_cmp_32(d *dasmInfo) string {
- return fmt.Sprintf("cmp.l %s, D%d", d.getEaModeStr(Long), x(d.ir))
- }
-
- func d68000_cmpa_16(d *dasmInfo) string {
- return fmt.Sprintf("cmpa.w %s, A%d", d.getEaModeStr(Word), x(d.ir))
- }
-
- func d68000_cmpa_32(d *dasmInfo) string {
- return fmt.Sprintf("cmpa.l %s, A%d", d.getEaModeStr(Long), x(d.ir))
- }
-
- func d68000_cmpi_8(d *dasmInfo) string {
- return fmt.Sprintf("cmpi.b %s, %s", d.getImmStrSigned(Byte), d.getEaModeStr(Byte))
- }
-
- func d68020_cmpi_pcdi_8(d *dasmInfo) string {
- return fmt.Sprintf("cmpi.b %s, %s; (2+)", d.getImmStrSigned(Byte), d.getEaModeStr(Byte))
- }
-
- func d68020_cmpi_pcix_8(d *dasmInfo) string {
- return fmt.Sprintf("cmpi.b %s, %s; (2+)", d.getImmStrSigned(Byte), d.getEaModeStr(Byte))
- }
-
- func d68000_cmpi_16(d *dasmInfo) string {
- return fmt.Sprintf("cmpi.w %s, %s", d.getImmStrSigned(Word), d.getEaModeStr(Word))
- }
-
- func d68020_cmpi_pcdi_16(d *dasmInfo) string {
- return fmt.Sprintf("cmpi.w %s, %s; (2+)", d.getImmStrSigned(Word), d.getEaModeStr(Word))
- }
-
- func d68020_cmpi_pcix_16(d *dasmInfo) string {
- return fmt.Sprintf("cmpi.w %s, %s; (2+)", d.getImmStrSigned(Word), d.getEaModeStr(Word))
- }
-
- func d68000_cmpi_32(d *dasmInfo) string {
- return fmt.Sprintf("cmpi.l %s, %s", d.getImmStrSigned(Long), d.getEaModeStr(Long))
- }
-
- func d68020_cmpi_pcdi_32(d *dasmInfo) string {
- return fmt.Sprintf("cmpi.l %s, %s; (2+)", d.getImmStrSigned(Long), d.getEaModeStr(Long))
- }
-
- func d68020_cmpi_pcix_32(d *dasmInfo) string {
- return fmt.Sprintf("cmpi.l %s, %s; (2+)", d.getImmStrSigned(Long), d.getEaModeStr(Long))
- }
-
- func d68000_cmpm_8(d *dasmInfo) string {
- return fmt.Sprintf("cmpm.b (A%d)+, (A%d)+", y(d.ir), x(d.ir))
- }
-
- func d68000_cmpm_16(d *dasmInfo) string {
- return fmt.Sprintf("cmpm.w (A%d)+, (A%d)+", y(d.ir), x(d.ir))
- }
-
- func d68000_cmpm_32(d *dasmInfo) string {
- return fmt.Sprintf("cmpm.l (A%d)+, (A%d)+", y(d.ir), x(d.ir))
- }
-
- func d68020_cpbcc_16(d *dasmInfo) string {
- extension := d.readImm(Word)
- new_pc := d.pc + int32(int16(d.readImm(Word)))
- return fmt.Sprintf("%db%-4s %s; %x (extension = %x) (2-3)", x(d.ir), gCPCCTable[d.ir&63], d.getImmStrSigned(Word), new_pc, extension)
- }
-
- func d68020_cpbcc_32(d *dasmInfo) string {
- extension := d.readImm(Word)
- new_pc := d.pc + d.readImm(Long)
- return fmt.Sprintf("%db%-4s %s; %x (extension = %x) (2-3)", x(d.ir), gCPCCTable[d.ir&63], d.getImmStrSigned(Word), new_pc, extension)
- }
-
- func d68020_cpdbcc(d *dasmInfo) string {
- extension1 := d.readImm(Word)
- extension2 := d.readImm(Word)
- new_pc := d.pc + int32(int16(d.readImm(Word)))
- return fmt.Sprintf("%ddb%-4s D%d,%s; %x (extension = %x) (2-3)", x(d.ir), gCPCCTable[extension1&63], y(d.ir), d.getImmStrSigned(Word), new_pc, extension2)
- }
-
- func d68020_cpgen(d *dasmInfo) string {
- return fmt.Sprintf("%dgen %s; (2-3)", x(d.ir), d.getImmStrUnsigned(Long))
- }
-
- func d68020_cprestore(d *dasmInfo) string {
- if x(d.ir) == 1 {
- return fmt.Sprintf("frestore %s", d.getEaModeStr(Byte))
- } else {
- return fmt.Sprintf("%drestore %s; (2-3)", x(d.ir), d.getEaModeStr(Byte))
- }
- }
-
- func d68020_cpsave(d *dasmInfo) string {
- if x(d.ir) == 1 {
- return fmt.Sprintf("fsave %s", d.getEaModeStr(Byte))
- } else {
- return fmt.Sprintf("%dsave %s; (2-3)", x(d.ir), d.getEaModeStr(Byte))
- }
- }
-
- func d68020_cpscc(d *dasmInfo) string {
- extension1 := d.readImm(Word)
- extension2 := d.readImm(Word)
- return fmt.Sprintf("%ds%-4s %s; (extension = %x) (2-3)", x(d.ir), gCPCCTable[extension1&63], d.getEaModeStr(Byte), extension2)
- }
-
- func d68020_cptrapcc_0(d *dasmInfo) string {
- extension1 := d.readImm(Word)
- extension2 := d.readImm(Word)
- return fmt.Sprintf("%dtrap%-4s; (extension = %x) (2-3)", x(d.ir), gCPCCTable[extension1&63], extension2)
- }
-
- func d68020_cptrapcc_16(d *dasmInfo) string {
- extension1 := d.readImm(Word)
- extension2 := d.readImm(Word)
- return fmt.Sprintf("%dtrap%-4s %s; (extension = %x) (2-3)", x(d.ir), gCPCCTable[extension1&63], d.getImmStrUnsigned(Word), extension2)
- }
-
- func d68020_cptrapcc_32(d *dasmInfo) string {
- extension1 := d.readImm(Word)
- extension2 := d.readImm(Word)
- return fmt.Sprintf("%dtrap%-4s %s; (extension = %x) (2-3)", x(d.ir), gCPCCTable[extension1&63], d.getImmStrUnsigned(Long), extension2)
- }
-
- func d68040_cpush(d *dasmInfo) string {
- switch (d.ir >> 3) & 3 {
- case 0:
- return fmt.Sprintf("cpush (illegal scope); (4)")
- case 1:
- return fmt.Sprintf("cpushl %d, (A%d); (4)", d.ir>>uint64(6)&3, y(d.ir))
- case 2:
- return fmt.Sprintf("cpushp %d, (A%d); (4)", d.ir>>uint64(6)&3, y(d.ir))
- default:
- return fmt.Sprintf("cpusha %d; (4)", d.ir>>uint64(6)&3)
- }
- }
-
- func d68000_dbra(d *dasmInfo) string {
- return fmt.Sprintf("dbra D%d, $%x", y(d.ir), d.pc+int32(int16(d.readImm(Word))))
- }
-
- func d68000_dbcc(d *dasmInfo) string {
- return fmt.Sprintf("db%-2s D%d, $%x", gCCTable[d.ir>>uint64(8)&15], y(d.ir), d.pc+int32(int16(d.readImm(Word))))
- }
-
- func d68000_divs(d *dasmInfo) string {
- return fmt.Sprintf("divs.w %s, D%d", d.getEaModeStr(Word), x(d.ir))
- }
-
- func d68000_divu(d *dasmInfo) string {
- return fmt.Sprintf("divu.w %s, D%d", d.getEaModeStr(Word), x(d.ir))
- }
-
- func d68020_divl(d *dasmInfo) string {
- extension := d.readImm(Word)
- if extension&1024 != 0 {
- return fmt.Sprintf("div%c.l %s, D%d:D%d; (2+)", func() int32 {
- if extension&0x800 != 0 {
- return int32('s')
- }
- return int32('u')
- }(), d.getEaModeStr(Long), extension&7, extension>>uint64(12)&7)
- } else if extension&7 == extension>>uint64(12)&7 {
- return fmt.Sprintf("div%c.l %s, D%d; (2+)", func() int32 {
- if extension&0x800 != 0 {
- return int32('s')
- }
- return int32('u')
- }(), d.getEaModeStr(Long), extension>>uint64(12)&7)
- } else {
- return fmt.Sprintf("div%cl.l %s, D%d:D%d; (2+)", func() int32 {
- if extension&0x800 != 0 {
- return int32('s')
- }
- return int32('u')
- }(), d.getEaModeStr(Long), extension&7, extension>>uint64(12)&7)
- }
- }
-
- func d68000_eor_8(d *dasmInfo) string {
- return fmt.Sprintf("eor.b D%d, %s", x(d.ir), d.getEaModeStr(Byte))
- }
- func d68000_eor_16(d *dasmInfo) string {
- return fmt.Sprintf("eor.w D%d, %s", x(d.ir), d.getEaModeStr(Word))
- }
- func d68000_eor_32(d *dasmInfo) string {
- return fmt.Sprintf("eor.l D%d, %s", x(d.ir), d.getEaModeStr(Long))
- }
-
- func d68000_eori_8(d *dasmInfo) string {
- return fmt.Sprintf("eori.b %s, %s", d.getImmStrUnsigned(Byte), d.getEaModeStr(Byte))
- }
-
- func d68000_eori_16(d *dasmInfo) string {
- return fmt.Sprintf("eori.w %s, %s", d.getImmStrUnsigned(Word), d.getEaModeStr(Word))
- }
-
- func d68000_eori_32(d *dasmInfo) string {
- return fmt.Sprintf("eori.l %s, %s", d.getImmStrUnsigned(Long), d.getEaModeStr(Long))
- }
-
- func d68000_eori_to_ccr(d *dasmInfo) string {
- return fmt.Sprintf("eori %s, CCR", d.getImmStrUnsigned(Byte))
- }
-
- func d68000_eori_to_sr(d *dasmInfo) string {
- return fmt.Sprintf("eori %s, SR", d.getImmStrUnsigned(Word))
- }
-
- func d68000_exg_dd(d *dasmInfo) string {
- return fmt.Sprintf("exg D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_exg_aa(d *dasmInfo) string {
- return fmt.Sprintf("exg A%d, A%d", x(d.ir), y(d.ir))
- }
-
- func d68000_exg_da(d *dasmInfo) string {
- return fmt.Sprintf("exg D%d, A%d", x(d.ir), y(d.ir))
- }
-
- func d68000_ext_16(d *dasmInfo) string {
- return fmt.Sprintf("ext.w D%d", y(d.ir))
- }
-
- func d68000_ext_32(d *dasmInfo) string {
- return fmt.Sprintf("ext.l D%d", y(d.ir))
- }
-
- func d68020_extb_32(d *dasmInfo) string {
- return fmt.Sprintf("extb.l D%d; (2+)", y(d.ir))
- }
-
- var fpu_ukn = "FPU (?)"
- var float_mnemonics = map[int32]string{
- 0: "fmove", 1: "fint", 2: "fsinh", 3: "fintrz",
- 4: "fsqrt", 6: "flognp1", 8: "fetoxml", 9: "ftanh1",
- 10: "fatan", 12: "fasin", 13: "fatanh", 14: "fsin",
- 15: "ftan", 16: "fetox", 17: "ftwotox", 18: "ftentox",
- 20: "flogn", 21: "flog10", 22: "flog2", 24: "fabs",
- 25: "fcosh", 26: "fneg", 28: "facos", 29: "fcos",
- 30: "fgetexp", 31: "fgetman", 32: "fdiv", 33: "fmod",
- 34: "fadd", 35: "fmul", 36: "fsgldiv", 37: "frem",
- 38: "fscale", 39: "fsglmul", 40: "fsub", 0x30: "fsincos",
- 49: "fsincos", 50: "fsincos", 51: "fsincos", 52: "fsincos",
- 53: "fsincos", 54: "fsincos", 55: "fsincos", 56: "fcmp",
- 58: "ftst", 65: "fssqrt", 69: "fdsqrt", 88: "fsabs",
- 90: "fsneg", 92: "fdabs", 94: "fdneg", 96: "fsdiv",
- 98: "fsadd", 99: "fsmul", 100: "fddiv", 102: "fdadd",
- 103: "fdmul", 104: "fssub", 108: "fdsub",
- }
-
- func d68040_fpu(d *dasmInfo) string {
- w2 := d.readImm(Word)
- src := (w2 >> 10) & 7
- destReg := (w2 >> 7) & 7
- if (w2>>13)&7 == 2 && (w2>>10)&7 == 7 {
- // special override for FMOVECR
- return fmt.Sprintf("fmovecr #$%0x, fp%d", w2&127, destReg)
- }
- switch (w2 >> 13) & 0x07 {
- case 0, 2:
- if mnemonic, ok := float_mnemonics[w2&0x7f]; ok {
- if w2&0x4000 != 0 {
- return fmt.Sprintf("%s%s %s, FP%d", mnemonic, gFPUDataFormatTable[src], d.getEaModeStr(Long), destReg)
- }
- return fmt.Sprintf("%s.x FP%d, FP%d", mnemonic, src, destReg)
- }
- return fpu_ukn
- case 3:
- switch (w2 >> 10) & 0x07 {
- case 3:
- // packed decimal w/fixed k-factor
- return fmt.Sprintf("fmove%s FP%d, %s {#%d}", gFPUDataFormatTable[w2>>uint64(10)&7], destReg, d.getEaModeStr(Long), int32(int8(w2&127)))
- case 7:
- // packed decimal w/dynamic k-factor (register)
- return fmt.Sprintf("fmove%s FP%d, %s {D%d}", gFPUDataFormatTable[w2>>uint64(10)&7], destReg, d.getEaModeStr(Long), (w2>>4)&7)
- default:
- return fmt.Sprintf("fmove%s FP%d, %s", gFPUDataFormatTable[w2>>uint64(10)&7], destReg, d.getEaModeStr(Long))
- }
- case 4:
- // ea to control
- if w2&4096 != 0 {
- return fmt.Sprintf("fmovem.l %s, fpcr", d.getEaModeStr(Long))
- }
- if w2&0x800 != 0 {
- return fmt.Sprintf("fmovem.l %s, /fpsr", d.getEaModeStr(Long))
- }
- if w2&1024 != 0 {
- return fmt.Sprintf("fmovem.l %s, /fpiar", d.getEaModeStr(Long))
- }
- case 5:
- // control to ea
- if w2&4096 != 0 {
- return fmt.Sprintf("fmovem.l fpcr, %s", d.getEaModeStr(Long))
- }
- if w2&0x800 != 0 {
- return fmt.Sprintf("fmovem.l /fpsr, %s", d.getEaModeStr(Long))
- }
- if w2&1024 != 0 {
- return fmt.Sprintf("fmovem.l /fpiar, %s", d.getEaModeStr(Long))
- }
- case 6:
- if (w2>>11)&1 != 0 {
- // memory to FPU, list
- // dynamic register list
- return fmt.Sprintf("fmovem.x %s, D%d", d.getEaModeStr(Long), (w2>>4)&7)
- } else {
- // static register list
- str := fmt.Sprintf("fmovem.x %s, ", d.getEaModeStr(Long))
- for i := 0; i < 8; i++ {
- if w2&(1<<i) != 0 {
- if (w2>>12)&1 != 0 {
- // postincrement or control
- str += fmt.Sprintf("FP%d ", 7-i)
- } else {
- // predecrement
- str += fmt.Sprintf("FP%d ", i)
- }
- }
- }
- return str
- }
- case 7:
- if (w2>>11)&1 != 0 {
- // FPU to memory, list
- // dynamic register list
- return fmt.Sprintf("fmovem.x D%d, %s", w2>>uint64(4)&7, d.getEaModeStr(Long))
- } else {
- // static register list
- str := "fmovem.x "
- for i := 0; i < 8; i++ {
- if w2&(1<<i) != 0 {
- if (w2>>12)&1 != 0 {
- // postincrement or control
- str += fmt.Sprintf("FP%d ", 7-i)
- } else {
- // predecrement
- str += fmt.Sprintf("FP%d ", i)
- }
- }
- }
- return str + ", " + d.getEaModeStr(Long)
- }
- }
- return fpu_ukn
- }
-
- func d68000_jmp(d *dasmInfo) string {
- return fmt.Sprintf("jmp %s", d.getEaModeStr(Long))
- }
-
- func d68000_jsr(d *dasmInfo) string {
- return fmt.Sprintf("jsr %s", d.getEaModeStr(Long))
- }
-
- func d68000_lea(d *dasmInfo) string {
- return fmt.Sprintf("lea %s, A%d", d.getEaModeStr(Long), x(d.ir))
- }
-
- func d68000_link_16(d *dasmInfo) string {
- return fmt.Sprintf("link A%d, %s", y(d.ir), d.getImmStrSigned(Word))
- }
-
- func d68020_link_32(d *dasmInfo) string {
- return fmt.Sprintf("link A%d, %s; (2+)", y(d.ir), d.getImmStrSigned(Long))
- }
-
- func d68000_lsr_s_8(d *dasmInfo) string {
- return fmt.Sprintf("lsr.b #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_lsr_s_16(d *dasmInfo) string {
- return fmt.Sprintf("lsr.w #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_lsr_s_32(d *dasmInfo) string {
- return fmt.Sprintf("lsr.l #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_lsr_r_8(d *dasmInfo) string {
- return fmt.Sprintf("lsr.b D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_lsr_r_16(d *dasmInfo) string {
- return fmt.Sprintf("lsr.w D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_lsr_r_32(d *dasmInfo) string {
- return fmt.Sprintf("lsr.l D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_lsr_ea(d *dasmInfo) string {
- return fmt.Sprintf("lsr.w %s", d.getEaModeStr(Long))
- }
-
- func d68000_lsl_s_8(d *dasmInfo) string {
- return fmt.Sprintf("lsl.b #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_lsl_s_16(d *dasmInfo) string {
- return fmt.Sprintf("lsl.w #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_lsl_s_32(d *dasmInfo) string {
- return fmt.Sprintf("lsl.l #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_lsl_r_8(d *dasmInfo) string {
- return fmt.Sprintf("lsl.b D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_lsl_r_16(d *dasmInfo) string {
- return fmt.Sprintf("lsl.w D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_lsl_r_32(d *dasmInfo) string {
- return fmt.Sprintf("lsl.l D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_lsl_ea(d *dasmInfo) string {
- return fmt.Sprintf("lsl.w %s", d.getEaModeStr(Long))
- }
-
- func d68000_move_8(d *dasmInfo) string {
- d.ir = x(d.ir) | d.ir>>3&0x38
- return fmt.Sprintf("move.b %s, %s", d.getEaModeStr(Byte), d.getEaModeStr(Byte))
- }
-
- func d68000_move_16(d *dasmInfo) string {
- d.ir = x(d.ir) | d.ir>>3&0x38
- return fmt.Sprintf("move.w %s, %s", d.getEaModeStr(Word), d.getEaModeStr(Word))
- }
-
- func d68000_move_32(d *dasmInfo) string {
- d.ir = x(d.ir) | d.ir>>3&0x38
- return fmt.Sprintf("move.l %s, %s", d.getEaModeStr(Long), d.getEaModeStr(Long))
- }
-
- func d68000_movea_16(d *dasmInfo) string {
- return fmt.Sprintf("movea.w %s, A%d", d.getEaModeStr(Word), x(d.ir))
- }
-
- func d68000_movea_32(d *dasmInfo) string {
- return fmt.Sprintf("movea.l %s, A%d", d.getEaModeStr(Long), x(d.ir))
- }
-
- func d68000_move_to_ccr(d *dasmInfo) string {
- return fmt.Sprintf("move %s, CCR", d.getEaModeStr(Byte))
- }
-
- func d68010_move_fr_ccr(d *dasmInfo) string {
- return fmt.Sprintf("move CCR, %s; (1+)", d.getEaModeStr(Byte))
- }
-
- func d68000_move_fr_sr(d *dasmInfo) string {
- return fmt.Sprintf("move SR, %s", d.getEaModeStr(Word))
- }
-
- func d68000_move_to_sr(d *dasmInfo) string {
- return fmt.Sprintf("move %s, SR", d.getEaModeStr(Word))
- }
-
- func d68000_move_fr_usp(d *dasmInfo) string {
- return fmt.Sprintf("move USP, A%d", y(d.ir))
- }
-
- func d68000_move_to_usp(d *dasmInfo) string {
- return fmt.Sprintf("move A%d, USP", y(d.ir))
- }
-
- func d68010_movec(d *dasmInfo) string {
- var reg_name, processor string
- extension := d.readImm(Word)
- switch extension & 4095 {
- case (0):
- reg_name = "SFC"
- processor = "1+"
- case (1):
- reg_name = "DFC"
- processor = "1+"
- case (0x800):
- reg_name = "USP"
- processor = "1+"
- case (2049):
- reg_name = "VBR"
- processor = "1+"
- case (2):
- reg_name = "CACR"
- processor = "2+"
- case (2050):
- reg_name = "CAAR"
- processor = "2,3"
- case (2051):
- reg_name = "MSP"
- processor = "2+"
- case (2052):
- reg_name = "ISP"
- processor = "2+"
- case (3):
- reg_name = "TC"
- processor = "4+"
- case (4):
- reg_name = "ITT0"
- processor = "4+"
- case (5):
- reg_name = "ITT1"
- processor = "4+"
- case (6):
- reg_name = "DTT0"
- processor = "4+"
- case (7):
- reg_name = "DTT1"
- processor = "4+"
- case 2053:
- reg_name = "MMUSR"
- processor = "4+"
- case (2054):
- reg_name = "URP"
- processor = "4+"
- case (2055):
- reg_name = "SRP"
- processor = "4+"
- default:
- reg_name = Word.SignedHexString(extension & 4095)
- processor = "?"
- }
- if d.ir&1 != 0 {
- return fmt.Sprintf("movec %c%d, %s; (%s)", func() int32 {
- if extension&0x8000 != 0 {
- return int32('A')
- }
- return int32('D')
- }(), extension>>uint64(12)&7, reg_name, processor)
- } else {
- return fmt.Sprintf("movec %s, %c%d; (%s)", reg_name, func() int32 {
- if extension&0x8000 != 0 {
- return int32('A')
- }
- return int32('D')
- }(), extension>>uint64(12)&7, processor)
- }
- }
-
- func d68000_movem_pd_16(d *dasmInfo) string {
- data := d.readImm(Word)
- buffer := ""
- for i := 0; i < 8; i++ {
- if data&(1<<(15-i)) != 0 {
- first := i
- rl := 0
- for i < 7 && data&(1<<(15-(i+1))) != 0 {
- i++
- rl++
- }
- if len(buffer) > 0 {
- buffer += "/"
- }
- buffer += fmt.Sprintf("D%d", first)
- if rl > 0 {
- buffer += fmt.Sprintf("-D%d", first+rl)
- }
- }
- }
- for i := 0; i < 8; i++ {
- if data&(1<<(7-i)) != 0 {
- first := i
- rl := 0
- for i < 7 && data&(1<<(7-(i+1))) != 0 {
- i++
- rl++
- }
- if len(buffer) > 0 {
- buffer += "/"
- }
- buffer += fmt.Sprintf("A%d", first)
- if rl > 0 {
- buffer += fmt.Sprintf("-A%d", first+rl)
- }
- }
- }
- return fmt.Sprintf("movem.w %s, %s", buffer, d.getEaModeStr(Word))
- }
-
- func d68000_movem_pd_32(d *dasmInfo) string {
- data := d.readImm(Word)
- buffer := ""
-
- for i := 0; i < 8; i++ {
- if data&(1<<(15-i)) != 0 {
- first := i
- rl := 0
- for i < 7 && data&(1<<(15-(i+1))) != 0 {
- i++
- rl++
- }
- if len(buffer) > 0 {
- buffer += "/"
- }
- buffer += fmt.Sprintf("D%d", first)
- if rl > 0 {
- buffer += fmt.Sprintf("-D%d", first+rl)
- }
- }
- }
- for i := 0; i < 8; i++ {
- if data&(1<<(7-i)) != 0 {
- first := i
- rl := 0
- for i < 7 && data&(1<<(7-(i+1))) != 0 {
- i++
- rl++
- }
- if len(buffer) > 0 {
- buffer += "/"
- }
- buffer += fmt.Sprintf("A%d", first)
- if rl > 0 {
- buffer += fmt.Sprintf("-A%d", first+rl)
- }
- }
- }
- return fmt.Sprintf("movem.l %s, %s", buffer, d.getEaModeStr(Long))
- }
-
- // d68000_movem_er_16 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:0xE27
- func d68000_movem_er_16(d *dasmInfo) string {
- data := d.readImm(Word)
- buffer := ""
- for i := 0; i < 8; i++ {
- if data&(1<<i) != 0 {
- first := i
- rl := 0
- for i < 7 && data&(1<<(i+1)) != 0 {
- i++
- rl++
- }
- if len(buffer) > 0 {
- buffer += "/"
- }
- buffer += fmt.Sprintf("D%d", first)
- if rl > 0 {
- buffer += fmt.Sprintf("-D%d", first+rl)
- }
- }
- }
- for i := 0; i < 8; i++ {
- if data&(1<<(i+8)) != 0 {
- first := i
- rl := 0
- for i < 7 && data&(1<<(i+8+1)) != 0 {
- i++
- rl++
- }
- if len(buffer) > 0 {
- buffer += "/"
- }
- buffer += fmt.Sprintf("A%d", first)
- if rl > 0 {
- buffer += fmt.Sprintf("-A%d", first+rl)
- }
- }
- }
- return fmt.Sprintf("movem.w %s, %s", d.getEaModeStr(Word), buffer)
- }
-
- // d68000_movem_er_32 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2315
- func d68000_movem_er_32(d *dasmInfo) string {
- data := d.readImm(Word)
- buffer := ""
- for i := 0; i < 8; i++ {
- if data&(1<<i) != 0 {
- first := i
- rl := 0
- for i < 7 && data&(1<<(i+1)) != 0 {
- i++
- rl++
- }
- if len(buffer) > 0 {
- buffer += "/"
- }
- buffer += fmt.Sprintf("D%d", first)
- if rl > 0 {
- buffer += fmt.Sprintf("-D%d", first+rl)
- }
- }
- }
- for i := 0; i < 8; i++ {
- if data&(1<<(i+8)) != 0 {
- first := i
- rl := 0
- for i < 7 && data&(1<<uint64(i+8+1)) != 0 {
- i++
- rl++
- }
- if len(buffer) > 0 {
- buffer += "/"
- }
- buffer += fmt.Sprintf("A%d", first)
- if rl > 0 {
- buffer += fmt.Sprintf("-A%d", first+rl)
- }
- }
- }
- return fmt.Sprintf("movem.l %s, %s", d.getEaModeStr(Long), buffer)
- }
-
- func d68000_movem_re_16(d *dasmInfo) string {
- data := d.readImm(Word)
- buffer := ""
- for i := 0; i < 8; i++ {
- if data&(1<<i) != 0 {
- first := i
- rl := 0
- for i < 7 && data&(1<<uint64(i+1)) != 0 {
- i++
- rl++
- }
- if len(buffer) > 0 {
- buffer += "/"
- }
- buffer += fmt.Sprintf("D%d", first)
- if rl > 0 {
- buffer += fmt.Sprintf("-D%d", first+rl)
- }
- }
- }
- for i := 0; i < 8; i++ {
- if data&(1<<(i+8)) != 0 {
- first := i
- rl := 0
- for i < 7 && data&(1<<uint64(i+8+1)) != 0 {
- i++
- rl++
- }
- if len(buffer) > 0 {
- buffer += "/"
- }
- buffer += fmt.Sprintf("A%d", first)
- if rl > 0 {
- buffer += fmt.Sprintf("-A%d", first+rl)
- }
- }
- }
- return fmt.Sprintf("movem.w %s, %s", buffer, d.getEaModeStr(Word))
- }
-
- // d68000_movem_re_32 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2411
- func d68000_movem_re_32(d *dasmInfo) string {
- data := d.readImm(Word)
- buffer := ""
- for i := 0; i < 8; i++ {
- if data&(1<<(i)) != 0 {
- first := i
- rl := 0
- for i < 7 && data&(1<<(i+1)) != 0 {
- i++
- rl++
- }
- if len(buffer) > 0 {
- buffer += "/"
- }
- buffer += fmt.Sprintf("D%d", first)
- if rl > 0 {
- buffer += fmt.Sprintf("-D%d", first+rl)
- }
- }
- }
- for i := 0; i < 8; i++ {
- if data&(1<<(i+8)) != 0 {
- first := i
- rl := 0
- for i < 7 && data&(1<<uint64(i+8+1)) != 0 {
- i++
- rl++
- }
- if len(buffer) > 0 {
- buffer += "/"
- }
- buffer += fmt.Sprintf("A%d", first)
- if rl > 0 {
- buffer += fmt.Sprintf("-A%d", first+rl)
- }
- }
- }
- return fmt.Sprintf("movem.l %s, %s", buffer, d.getEaModeStr(Long))
- }
-
- func d68000_movep_re_16(d *dasmInfo) string {
- return fmt.Sprintf("movep.w D%d, ($%x,A%d)", x(d.ir), d.readImm(Word), y(d.ir))
- }
-
- func d68000_movep_re_32(d *dasmInfo) string {
- return fmt.Sprintf("movep.l D%d, ($%x,A%d)", x(d.ir), d.readImm(Word), y(d.ir))
- }
-
- func d68000_movep_er_16(d *dasmInfo) string {
- return fmt.Sprintf("movep.w ($%x,A%d), D%d", d.readImm(Word), y(d.ir), x(d.ir))
- }
-
- func d68000_movep_er_32(d *dasmInfo) string {
- return fmt.Sprintf("movep.l ($%x,A%d), D%d", d.readImm(Word), y(d.ir), x(d.ir))
- }
-
- func d68010_moves_8(d *dasmInfo) string {
- extension := d.readImm(Word)
- if extension&0x800 != 0 {
- return fmt.Sprintf("moves.b %c%d, %s; (1+)", func() int32 {
- if extension&0x8000 != 0 {
- return int32('A')
- }
- return int32('D')
- }(), extension>>uint64(12)&7, d.getEaModeStr(Byte))
- } else {
- return fmt.Sprintf("moves.b %s, %c%d; (1+)", d.getEaModeStr(Byte), func() int32 {
- if extension&0x8000 != 0 {
- return int32('A')
- }
- return int32('D')
- }(), (extension>>12)&7)
- }
- }
-
- func d68010_moves_16(d *dasmInfo) string {
- extension := d.readImm(Word)
- if extension&0x800 != 0 {
- return fmt.Sprintf("moves.w %c%d, %s; (1+)", func() int32 {
- if extension&0x8000 != 0 {
- return int32('A')
- }
- return int32('D')
- }(), extension>>uint64(12)&7, d.getEaModeStr(Word))
- } else {
- return fmt.Sprintf("moves.w %s, %c%d; (1+)", d.getEaModeStr(Word), func() int32 {
- if extension&0x8000 != 0 {
- return int32('A')
- }
- return int32('D')
- }(), (extension>>12)&7)
- }
- }
-
- func d68010_moves_32(d *dasmInfo) string {
- extension := d.readImm(Word)
- if extension&0x800 != 0 {
- return fmt.Sprintf("moves.l %c%d, %s; (1+)", func() int32 {
- if extension&0x8000 != 0 {
- return int32('A')
- }
- return int32('D')
- }(), extension>>uint64(12)&7, d.getEaModeStr(Long))
- } else {
- return fmt.Sprintf("moves.l %s, %c%d; (1+)", d.getEaModeStr(Long), func() int32 {
- if extension&0x8000 != 0 {
- return int32('A')
- }
- return int32('D')
- }(), extension>>uint64(12)&7)
- }
- }
-
- // d68000_moveq - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2512
- func d68000_moveq(d *dasmInfo) string {
- return fmt.Sprintf("moveq #%s, D%d", Byte.SignedHexString(int32(d.ir)), x(d.ir))
- }
-
- // d68040_move16_pi_pi - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2517
- func d68040_move16_pi_pi(d *dasmInfo) string {
- return fmt.Sprintf("move16 (A%d)+, (A%d)+; (4)", y(d.ir), d.readImm(Word)>>uint64(12)&7)
- }
-
- // d68040_move16_pi_al - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2523
- func d68040_move16_pi_al(d *dasmInfo) string {
- return fmt.Sprintf("move16 (A%d)+, %s; (4)", y(d.ir), d.getImmStrUnsigned(Long))
- }
-
- // d68040_move16_al_pi - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2529
- func d68040_move16_al_pi(d *dasmInfo) string {
- return fmt.Sprintf("move16 %s, (A%d)+; (4)", d.getImmStrUnsigned(Long), y(d.ir))
- }
-
- // d68040_move16_ai_al - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2535
- func d68040_move16_ai_al(d *dasmInfo) string {
- return fmt.Sprintf("move16 (A%d), %s; (4)", y(d.ir), d.getImmStrUnsigned(Long))
- }
-
- // d68040_move16_al_ai - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2541
- func d68040_move16_al_ai(d *dasmInfo) string {
- return fmt.Sprintf("move16 %s, (A%d); (4)", d.getImmStrUnsigned(Long), y(d.ir))
- }
-
- // d68000_muls - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2547
- func d68000_muls(d *dasmInfo) string {
- return fmt.Sprintf("muls.w %s, D%d", d.getEaModeStr(Word), x(d.ir))
- }
-
- // d68000_mulu - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:0xFF2
- func d68000_mulu(d *dasmInfo) string {
- return fmt.Sprintf("mulu.w %s, D%d", d.getEaModeStr(Word), x(d.ir))
- }
-
- // d68020_mull - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:0xFF7
- func d68020_mull(d *dasmInfo) string {
- extension := d.readImm(Word)
- if extension&1024 != 0 {
- return fmt.Sprintf("mul%c.l %s, D%d:D%d; (2+)", func() int32 {
- if extension&0x800 != 0 {
- return int32('s')
- }
- return int32('u')
- }(), d.getEaModeStr(Long), extension&7, extension>>uint64(12)&7)
- } else {
- return fmt.Sprintf("mul%c.l %s, D%d; (2+)", func() int32 {
- if extension&0x800 != 0 {
- return int32('s')
- }
- return int32('u')
- }(), d.getEaModeStr(Long), extension>>uint64(12)&7)
- }
- }
-
- // d68000_nbcd - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:0x1009
- func d68000_nbcd(d *dasmInfo) string {
- return fmt.Sprintf("nbcd %s", d.getEaModeStr(Byte))
- }
-
- // d68000_neg_8 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2574
- func d68000_neg_8(d *dasmInfo) string {
- return fmt.Sprintf("neg.b %s", d.getEaModeStr(Byte))
- }
-
- // d68000_neg_16 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2579
- func d68000_neg_16(d *dasmInfo) string {
- return fmt.Sprintf("neg.w %s", d.getEaModeStr(Word))
- }
-
- // d68000_neg_32 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2584
- func d68000_neg_32(d *dasmInfo) string {
- return fmt.Sprintf("neg.l %s", d.getEaModeStr(Long))
- }
-
- // d68000_negx_8 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2589
- func d68000_negx_8(d *dasmInfo) string {
- return fmt.Sprintf("negx.b %s", d.getEaModeStr(Byte))
- }
-
- // d68000_negx_16 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2594
- func d68000_negx_16(d *dasmInfo) string {
- return fmt.Sprintf("negx.w %s", d.getEaModeStr(Word))
- }
-
- // d68000_negx_32 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2599
- func d68000_negx_32(d *dasmInfo) string {
- return fmt.Sprintf("negx.l %s", d.getEaModeStr(Long))
- }
-
- // d68000_nop - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2604
- func d68000_nop(d *dasmInfo) string {
- return fmt.Sprintf("nop")
- }
-
- // d68000_not_8 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2609
- func d68000_not_8(d *dasmInfo) string {
- return fmt.Sprintf("not.b %s", d.getEaModeStr(Byte))
- }
-
- // d68000_not_16 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2614
- func d68000_not_16(d *dasmInfo) string {
- return fmt.Sprintf("not.w %s", d.getEaModeStr(Word))
- }
-
- // d68000_not_32 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2619
- func d68000_not_32(d *dasmInfo) string {
- return fmt.Sprintf("not.l %s", d.getEaModeStr(Long))
- }
-
- // d68000_or_er_8 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2624
- func d68000_or_er_8(d *dasmInfo) string {
- return fmt.Sprintf("or.b %s, D%d", d.getEaModeStr(Byte), x(d.ir))
- }
-
- // d68000_or_er_16 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2629
- func d68000_or_er_16(d *dasmInfo) string {
- return fmt.Sprintf("or.w %s, D%d", d.getEaModeStr(Word), x(d.ir))
- }
-
- // d68000_or_er_32 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2634
- func d68000_or_er_32(d *dasmInfo) string {
- return fmt.Sprintf("or.l %s, D%d", d.getEaModeStr(Long), x(d.ir))
- }
-
- // d68000_or_re_8 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2639
- func d68000_or_re_8(d *dasmInfo) string {
- return fmt.Sprintf("or.b D%d, %s", x(d.ir), d.getEaModeStr(Byte))
- }
-
- // d68000_or_re_16 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2644
- func d68000_or_re_16(d *dasmInfo) string {
- return fmt.Sprintf("or.w D%d, %s", x(d.ir), d.getEaModeStr(Word))
- }
-
- // d68000_or_re_32 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2649
- func d68000_or_re_32(d *dasmInfo) string {
- return fmt.Sprintf("or.l D%d, %s", x(d.ir), d.getEaModeStr(Long))
- }
-
- // d68000_ori_8 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2654
- func d68000_ori_8(d *dasmInfo) string {
- var str []byte
- return fmt.Sprintf("ori.b %s, %s", str, d.getEaModeStr(Byte))
- }
-
- // d68000_ori_16 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2660
- func d68000_ori_16(d *dasmInfo) string {
- return fmt.Sprintf("ori.w %s, %s", d.getImmStrUnsigned(Word), d.getEaModeStr(Word))
- }
-
- // d68000_ori_32 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2666
- func d68000_ori_32(d *dasmInfo) string {
- return fmt.Sprintf("ori.l %s, %s", d.getImmStrUnsigned(Long), d.getEaModeStr(Long))
- }
-
- // d68000_ori_to_ccr - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2672
- func d68000_ori_to_ccr(d *dasmInfo) string {
- return fmt.Sprintf("ori %s, CCR", d.getImmStrUnsigned(Byte))
- }
-
- // d68000_ori_to_sr - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2677
- func d68000_ori_to_sr(d *dasmInfo) string {
- return fmt.Sprintf("ori %s, SR", d.getImmStrUnsigned(Word))
- }
-
- func d68020_pack_rr(d *dasmInfo) string {
- return fmt.Sprintf("pack D%d, D%d, %s; (2+)", y(d.ir), x(d.ir), d.getImmStrUnsigned(Word))
- }
-
- func d68020_pack_mm(d *dasmInfo) string {
- return fmt.Sprintf("pack -(A%d), -(A%d), %s; (2+)", y(d.ir), x(d.ir), d.getImmStrUnsigned(Word))
- }
-
- func d68000_pea(d *dasmInfo) string {
- return fmt.Sprintf("pea %s", d.getEaModeStr(Long))
- }
-
- func d68040_pflush(d *dasmInfo) string {
- ext := ""
- if d.ir&8 == 0 {
- ext = "n"
- }
- if d.ir&16 != 0 {
- return fmt.Sprintf("pflusha%s", ext)
- }
- return fmt.Sprintf("pflush%s(A%d)", ext, y(d.ir))
- }
-
- func d68000_reset(d *dasmInfo) string {
- return "reset"
- }
-
- func d68000_ror_s_8(d *dasmInfo) string {
- return fmt.Sprintf("ror.b #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_ror_s_16(d *dasmInfo) string {
- return fmt.Sprintf("ror.w #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_ror_s_32(d *dasmInfo) string {
- return fmt.Sprintf("ror.l #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_ror_r_8(d *dasmInfo) string {
- return fmt.Sprintf("ror.b D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_ror_r_16(d *dasmInfo) string {
- return fmt.Sprintf("ror.w D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_ror_r_32(d *dasmInfo) string {
- return fmt.Sprintf("ror.l D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_ror_ea(d *dasmInfo) string {
- return fmt.Sprintf("ror.w %s", d.getEaModeStr(Long))
- }
-
- func d68000_rol_s_8(d *dasmInfo) string {
- return fmt.Sprintf("rol.b #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_rol_s_16(d *dasmInfo) string {
- return fmt.Sprintf("rol.w #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_rol_s_32(d *dasmInfo) string {
- return fmt.Sprintf("rol.l #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_rol_r_8(d *dasmInfo) string {
- return fmt.Sprintf("rol.b D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_rol_r_16(d *dasmInfo) string {
- return fmt.Sprintf("rol.w D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_rol_r_32(d *dasmInfo) string {
- return fmt.Sprintf("rol.l D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_rol_ea(d *dasmInfo) string {
- return fmt.Sprintf("rol.w %s", d.getEaModeStr(Long))
- }
-
- func d68000_roxr_s_8(d *dasmInfo) string {
- return fmt.Sprintf("roxr.b #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_roxr_s_16(d *dasmInfo) string {
- return fmt.Sprintf("roxr.w #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_roxr_s_32(d *dasmInfo) string {
- return fmt.Sprintf("roxr.l #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_roxr_r_8(d *dasmInfo) string {
- return fmt.Sprintf("roxr.b D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_roxr_r_16(d *dasmInfo) string {
- return fmt.Sprintf("roxr.w D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_roxr_r_32(d *dasmInfo) string {
- return fmt.Sprintf("roxr.l D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_roxr_ea(d *dasmInfo) string {
- return fmt.Sprintf("roxr.w %s", d.getEaModeStr(Long))
- }
-
- func d68000_roxl_s_8(d *dasmInfo) string {
- return fmt.Sprintf("roxl.b #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_roxl_s_16(d *dasmInfo) string {
- return fmt.Sprintf("roxl.w #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_roxl_s_32(d *dasmInfo) string {
- return fmt.Sprintf("roxl.l #%d, D%d", g3bitQDataTable[x(d.ir)], y(d.ir))
- }
-
- func d68000_roxl_r_8(d *dasmInfo) string {
- return fmt.Sprintf("roxl.b D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_roxl_r_16(d *dasmInfo) string {
- return fmt.Sprintf("roxl.w D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_roxl_r_32(d *dasmInfo) string {
- return fmt.Sprintf("roxl.l D%d, D%d", x(d.ir), y(d.ir))
- }
-
- func d68000_roxl_ea(d *dasmInfo) string {
- return fmt.Sprintf("roxl.w %s", d.getEaModeStr(Long))
- }
-
- func d68010_rtd(d *dasmInfo) string {
- return fmt.Sprintf("rtd %s; (1+)", d.getImmStrSigned(Word))
- }
-
- func d68000_rte(d *dasmInfo) string {
- return "rte"
- }
-
- func d68020_rtm(d *dasmInfo) string {
- return fmt.Sprintf("rtm %c%d; (2+)",
- func() int32 {
- if d.ir&8 != 0 {
- return int32('A')
- }
- return int32('D')
- }(), y(d.ir))
- }
-
- func d68000_rtr(d *dasmInfo) string {
- return "rtr"
- }
-
- func d68000_rts(d *dasmInfo) string {
- return "rts"
- }
-
- func d68000_sbcd_rr(d *dasmInfo) string {
- return fmt.Sprintf("sbcd D%d, D%d", y(d.ir), x(d.ir))
- }
-
- func d68000_sbcd_mm(d *dasmInfo) string {
- return fmt.Sprintf("sbcd -(A%d), -(A%d)", y(d.ir), x(d.ir))
- }
-
- func d68000_scc(d *dasmInfo) string {
- return fmt.Sprintf("s%-2s %s", gCCTable[d.ir>>uint64(8)&15], d.getEaModeStr(Byte))
- }
-
- func d68000_stop(d *dasmInfo) string {
- return fmt.Sprintf("stop %s", d.getImmStrSigned(Word))
- }
-
- func d68000_sub_er_8(d *dasmInfo) string {
- return fmt.Sprintf("sub.b %s, D%d", d.getEaModeStr(Byte), x(d.ir))
- }
-
- func d68000_sub_er_16(d *dasmInfo) string {
- return fmt.Sprintf("sub.w %s, D%d", d.getEaModeStr(Word), x(d.ir))
- }
-
- func d68000_sub_er_32(d *dasmInfo) string {
- return fmt.Sprintf("sub.l %s, D%d", d.getEaModeStr(Long), x(d.ir))
- }
-
- func d68000_sub_re_8(d *dasmInfo) string {
- return fmt.Sprintf("sub.b D%d, %s", x(d.ir), d.getEaModeStr(Byte))
- }
-
- // d68000_sub_re_16 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2932
- func d68000_sub_re_16(d *dasmInfo) string {
- return fmt.Sprintf("sub.w D%d, %s", x(d.ir), d.getEaModeStr(Word))
- }
-
- // d68000_sub_re_32 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2937
- func d68000_sub_re_32(d *dasmInfo) string {
- return fmt.Sprintf("sub.l D%d, %s", x(d.ir), d.getEaModeStr(Long))
- }
-
- // d68000_suba_16 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2942
- func d68000_suba_16(d *dasmInfo) string {
- return fmt.Sprintf("suba.w %s, A%d", d.getEaModeStr(Word), x(d.ir))
- }
-
- // d68000_suba_32 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2947
- func d68000_suba_32(d *dasmInfo) string {
- return fmt.Sprintf("suba.l %s, A%d", d.getEaModeStr(Long), x(d.ir))
- }
-
- // d68000_subi_8 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2952
- func d68000_subi_8(d *dasmInfo) string {
- var str []byte
- return fmt.Sprintf("subi.b %s, %s", str, d.getEaModeStr(Byte))
- }
-
- // d68000_subi_16 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2958
- func d68000_subi_16(d *dasmInfo) string {
- return fmt.Sprintf("subi.w %s, %s", d.getImmStrSigned(Word), d.getEaModeStr(Word))
- }
-
- // d68000_subi_32 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2964
- func d68000_subi_32(d *dasmInfo) string {
- return fmt.Sprintf("subi.l %s, %s", d.getImmStrSigned(Long), d.getEaModeStr(Long))
- }
-
- // d68000_subq_8 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2970
- func d68000_subq_8(d *dasmInfo) string {
- return fmt.Sprintf("subq.b #%d, %s", g3bitQDataTable[x(d.ir)], d.getEaModeStr(Byte))
- }
-
- // d68000_subq_16 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2975
- func d68000_subq_16(d *dasmInfo) string {
- return fmt.Sprintf("subq.w #%d, %s", g3bitQDataTable[x(d.ir)], d.getEaModeStr(Word))
- }
-
- // d68000_subq_32 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2980
- func d68000_subq_32(d *dasmInfo) string {
- return fmt.Sprintf("subq.l #%d, %s", g3bitQDataTable[x(d.ir)], d.getEaModeStr(Long))
- }
-
- // d68000_subx_rr_8 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2985
- func d68000_subx_rr_8(d *dasmInfo) string {
- return fmt.Sprintf("subx.b D%d, D%d", y(d.ir), x(d.ir))
- }
-
- // d68000_subx_rr_16 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2990
- func d68000_subx_rr_16(d *dasmInfo) string {
- return fmt.Sprintf("subx.w D%d, D%d", y(d.ir), x(d.ir))
- }
-
- // d68000_subx_rr_32 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:2995
- func d68000_subx_rr_32(d *dasmInfo) string {
- return fmt.Sprintf("subx.l D%d, D%d", y(d.ir), x(d.ir))
- }
-
- // d68000_subx_mm_8 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:3000
- func d68000_subx_mm_8(d *dasmInfo) string {
- return fmt.Sprintf("subx.b -(A%d), -(A%d)", y(d.ir), x(d.ir))
- }
-
- // d68000_subx_mm_16 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:3005
- func d68000_subx_mm_16(d *dasmInfo) string {
- return fmt.Sprintf("subx.w -(A%d), -(A%d)", y(d.ir), x(d.ir))
- }
-
- func d68000_subx_mm_32(d *dasmInfo) string {
- return fmt.Sprintf("subx.l -(A%d), -(A%d)", y(d.ir), x(d.ir))
- }
-
- func d68000_swap(d *dasmInfo) string {
- return fmt.Sprintf("swap D%d", y(d.ir))
- }
-
- func d68000_tas(d *dasmInfo) string {
- return fmt.Sprintf("tas %s", d.getEaModeStr(Byte))
- }
-
- func d68000_trap(d *dasmInfo) string {
- return fmt.Sprintf("trap #$%x", d.ir&15)
- }
-
- func d68020_trapcc_0(d *dasmInfo) string {
- return fmt.Sprintf("trap%-2s; (2+)", gCCTable[d.ir>>uint64(8)&15])
- }
-
- func d68020_trapcc_16(d *dasmInfo) string {
- return fmt.Sprintf("trap%-2s %s; (2+)", gCCTable[d.ir>>uint64(8)&15], d.getImmStrUnsigned(Word))
- }
-
- func d68020_trapcc_32(d *dasmInfo) string {
- return fmt.Sprintf("trap%-2s %s; (2+)", gCCTable[d.ir>>uint64(8)&15], d.getImmStrUnsigned(Long))
- }
-
- func d68000_trapv(d *dasmInfo) string {
- return "trapv"
- }
-
- func d68000_tst_8(d *dasmInfo) string {
- return fmt.Sprintf("tst.b %s", d.getEaModeStr(Byte))
- }
-
- func d68020_tst_pcdi_8(d *dasmInfo) string {
- return fmt.Sprintf("tst.b %s; (2+)", d.getEaModeStr(Byte))
- }
-
- func d68020_tst_pcix_8(d *dasmInfo) string {
- return fmt.Sprintf("tst.b %s; (2+)", d.getEaModeStr(Byte))
- }
-
- func d68020_tst_i_8(d *dasmInfo) string {
- return fmt.Sprintf("tst.b %s; (2+)", d.getEaModeStr(Byte))
- }
-
- func d68000_tst_16(d *dasmInfo) string {
- return fmt.Sprintf("tst.w %s", d.getEaModeStr(Word))
- }
-
- func d68020_tst_a_16(d *dasmInfo) string {
- return fmt.Sprintf("tst.w %s; (2+)", d.getEaModeStr(Word))
- }
-
- func d68020_tst_pcdi_16(d *dasmInfo) string {
- return fmt.Sprintf("tst.w %s; (2+)", d.getEaModeStr(Word))
- }
-
- func d68020_tst_pcix_16(d *dasmInfo) string {
- return fmt.Sprintf("tst.w %s; (2+)", d.getEaModeStr(Word))
- }
-
- func d68020_tst_i_16(d *dasmInfo) string {
- return fmt.Sprintf("tst.w %s; (2+)", d.getEaModeStr(Word))
- }
-
- func d68000_tst_32(d *dasmInfo) string {
- return fmt.Sprintf("tst.l %s", d.getEaModeStr(Long))
- }
-
- func d68020_tst_a_32(d *dasmInfo) string {
- return fmt.Sprintf("tst.l %s; (2+)", d.getEaModeStr(Long))
- }
-
- // d68020_tst_pcdi_32 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:3120
- func d68020_tst_pcdi_32(d *dasmInfo) string {
- return fmt.Sprintf("tst.l %s; (2+)", d.getEaModeStr(Long))
- }
-
- // d68020_tst_pcix_32 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:3126
- func d68020_tst_pcix_32(d *dasmInfo) string {
- return fmt.Sprintf("tst.l %s; (2+)", d.getEaModeStr(Long))
- }
-
- // d68020_tst_i_32 - transpiled function from /home/jens/projects/Musashi/m68kdasm.c:3132
- func d68020_tst_i_32(d *dasmInfo) string {
- return fmt.Sprintf("tst.l %s; (2+)", d.getEaModeStr(Long))
- }
-
- func d68000_unlk(d *dasmInfo) string {
- return fmt.Sprintf("unlk A%d", y(d.ir))
- }
-
- func d68020_unpk_rr(d *dasmInfo) string {
- return fmt.Sprintf("unpk D%d, D%d, %s; (2+)", y(d.ir), x(d.ir), d.getImmStrUnsigned(Word))
- }
-
- func d68020_unpk_mm(d *dasmInfo) string {
- return fmt.Sprintf("unpk -(A%d), -(A%d), %s; (2+)", y(d.ir), x(d.ir), d.getImmStrUnsigned(Word))
- }
-
- func d68851_p000(d *dasmInfo) string {
- modes := d.readImm(Word)
- // PFLUSH: 001xxx0xxxxxxxxx
- // PLOAD: 001000x0000xxxxx
- // PVALID1: 0010100000000000
- // PVALID2: 0010110000000xxx
- // PMOVE 1: 010xxxx000000000
- // PMOVE 2: 011xxxx0000xxx00
- // PMOVE 3: 011xxxx000000000
- // PTEST: 100xxxxxxxxxxxxx
- // PFLUSHR: 1010000000000000
- // do this after fetching the second PMOVE word so we properly get the 3rd if necessary
- str := d.getEaModeStr(Long)
- if modes&0xfde0 == 0x2000 {
- if modes&200 != 0 {
- // PLOAD
- return fmt.Sprintf("pload #%d, %s", (modes>>10)&7, str)
- }
- return fmt.Sprintf("pload %s, #%d", str, (modes>>10)&7)
- }
- if modes&0xe200 == 0x2000 {
- // PFLUSH
- return fmt.Sprintf("pflushr %x, %x, %s", modes&31, (modes>>5)&15, str)
- }
- if modes == 0xa000 {
- // PFLUSHR
- return fmt.Sprintf("pflushr %s", str)
- }
- if modes == 0x2800 {
- // PVALID (FORMAT 1)
- return fmt.Sprintf("pvalid VAL, %s", str)
- }
- if modes&0xfff8 == 0x2c00 {
- // PVALID (FORMAT 2)
- return fmt.Sprintf("pvalid A%d, %s", modes&15, str)
- }
- if modes&0xe000 == 0x8000 {
- // PTEST
- return fmt.Sprintf("ptest #%d, %s", modes&31, str)
- }
- switch (modes >> 13) & 7 {
- case 0, 2:
- if modes&0x100 != 0 {
- if modes&0x200 != 0 {
- // MC68030/040 form with FD bit
- // MC68881 form, FD never set
- return fmt.Sprintf("pmovefd %s, %s", gMMURegs[(modes>>10)&7], str)
- }
- return fmt.Sprintf("pmovefd %s, %s", str, gMMURegs[(modes>>10)&7])
- } else {
- if modes&0x200 != 0 {
- return fmt.Sprintf("pmove %s, %s", gMMURegs[modes>>uint64(10)&7], str)
- }
- return fmt.Sprintf("pmove %s, %s", str, gMMURegs[modes>>uint64(10)&7])
- }
- case 3:
- if modes&512 != 0 {
- // MC68030 to/from status reg
- return fmt.Sprintf("pmove mmusr, %s", str)
- }
- return fmt.Sprintf("pmove %s, mmusr", str)
- default:
- return fmt.Sprintf("pmove [unknown form] %s", str)
- }
- }
-
- func d68851_pbcc16(d *dasmInfo) string {
- return fmt.Sprintf("pb%s %x", gMMUCond[d.ir&15], d.pc+int32(int16(d.readImm(Word))))
- }
-
- func d68851_pbcc32(d *dasmInfo) string {
- return fmt.Sprintf("pb%s %x", gMMUCond[d.ir&15], d.pc+int32(d.readImm(Long)))
- }
-
- func d68851_pdbcc(d *dasmInfo) string {
- return fmt.Sprintf("pb%s %x", gMMUCond[uint16(d.readImm(Word))&0x0f], d.pc+d.readImm(Word))
- }
-
- func d68851_p001(d *dasmInfo) string {
- // PScc: 0000000000xxxxxx
- return "MMU 001 group"
- }
-
- func compare_nof_true_bits(a uint16, b uint16) bool {
- // Used by qsort
- a = a&0xaaaa>>1 + a&0x5555
- a = a&0xcccc>>2 + a&0x3333
- a = a&0xf0f0>>4 + a&0x0f0f
- a = a&0xff00>>8 + a&0x00ff
-
- b = b&0xaaaa>>1 + b&0x5555
- b = b&0xcccc>>2 + b&0x3333
- b = b&0xf0f0>>4 + b&0x0f0f
- b = b&0xff00>>8 + b&0x00ff
- // reversed to get greatest to least sorting
- return b-a <= 0
- }
-
- func init() {
- // build the opcode handler jump table
- sort.SliceStable(dasmOpcodeTable, func(i, j int) bool {
- return compare_nof_true_bits(dasmOpcodeTable[i].mask, dasmOpcodeTable[j].mask)
- })
-
- for i := 0; i < 0x10000; i++ {
- // default to illegal
- dasmTable[i] = d68000_illegal
- opcode := uint16(i)
- // search through opcode info for a match
- for _, ostruct := range dasmOpcodeTable {
- if opcode&ostruct.mask == ostruct.match {
- // match opcode mask and allowed ea modes
- // Handle destination ea for move instructions
- if validEA(opcode, ostruct.eaMask) {
- dasmTable[i] = ostruct.dasmHandler
- }
- }
- }
- }
- }
-
- func Disassemble(cpuType Type, pc int32, bus AddressBus) (string, int32) {
-
- d := &dasmInfo{pc: pc, helper: "", bus: bus}
- d.ir = uint16(d.readImm(Word))
-
- return dasmTable[d.ir](d), d.pc - pc
- }
-
- type Size struct {
- size int32
- align int32
- mask uint32
- bits uint32
- msb uint32
- fmt string
- ext string
- write func([]byte, int32)
- read func([]byte) int32
- }
-
- var operands = []*Size{Byte, Word, Long}
-
- // Byte is an M68K operand
- var Byte = &Size{
- size: 1,
- align: 2,
- mask: 0x000000ff,
- bits: 8,
- msb: 0x00000080,
- fmt: "$%02x",
- ext: ".b",
- write: func(sclice []byte, value int32) {
- sclice[0] = byte(value)
- },
- read: func(slice []byte) int32 {
- return int32(slice[0])
- },
- }
-
- // Word is an M68K operand type
- var Word = &Size{
- size: 2,
- align: 2,
- mask: 0x0000ffff,
- bits: 16,
- msb: 0x00008000,
- fmt: "$%04x",
- ext: ".w",
- write: func(slice []byte, value int32) {
- binary.BigEndian.PutUint16(slice, uint16(value))
- },
- read: func(slice []byte) int32 {
- return int32(binary.BigEndian.Uint16(slice))
- },
- }
-
- // Long is an M68K operand type
- var Long = &Size{
- size: 4,
- align: 4,
- mask: 0xffffffff,
- bits: 32,
- msb: 0x80000000,
- fmt: "$%08x",
- ext: ".b",
-
- write: func(sclice []byte, value int32) {
- binary.BigEndian.PutUint32(sclice, uint32(value))
- },
- read: func(slice []byte) int32 {
- return int32(binary.BigEndian.Uint32(slice))
- },
- }
-
- // IsNegative tests an operand of a specifc size if it is negative
- func (s *Size) IsNegative(value int32) bool {
- return s.msb&uint32(value) != 0
- }
-
- // HexString returns an unsingned hex string with leading zeroes
- func (s *Size) HexString(value int32) string {
- v := uint32(value) & s.mask
- return fmt.Sprintf(s.fmt, v)
- }
-
- // SignedHexString returns a signed hex with leading zeroes (-$0001)
- func (s *Size) SignedHexString(value int32) string {
- if uint32(value) == s.msb {
- return s.HexString(value)
- } else if s.IsNegative(value) {
- return "-" + s.HexString(-value)
- }
- return s.HexString(value)
- }
-
- func (s *Size) set(value int32, target *int32) {
- result := (uint32(*target) & ^s.mask) | (uint32(value) & s.mask)
- *target = int32(result)
- }
-
- func x(ir uint16) uint16 { return (ir >> 9) & 0x7 }
- func y(ir uint16) uint16 { return ir & 0x7 }
-
- func validEA(opcode, mask uint16) bool {
- if mask == 0 {
- return true
- }
-
- switch opcode & 0x3f {
- case 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07:
- return (mask & eaMaskDataRegister) != 0
- case 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f:
- return (mask & eaMaskAddressRegister) != 0
- case 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17:
- return (mask & eaMaskIndirect) != 0
- case 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f:
- return (mask & eaMaskPostIncrement) != 0
- case 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27:
- return (mask & eaMaskPreDecrement) != 0
- case 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f:
- return (mask & eaMaskDisplacement) != 0
- case 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37:
- return (mask & eaMaskIndex) != 0
- case 0x38:
- return (mask & eaMaskAbsoluteShort) != 0
- case 0x39:
- return (mask & eaMaskAbsoluteLong) != 0
- case 0x3a:
- return (mask & eaMaskPCDisplacement) != 0
- case 0x3b:
- return (mask & eaMaskPCIndex) != 0
- case 0x3c:
- return (mask & eaMaskImmediate) != 0
- }
- return false
- }
-
- // EA Masks
- const (
- eaMaskDataRegister = 0x0800
- eaMaskAddressRegister = 0x0400
- eaMaskIndirect = 0x0200
- eaMaskPostIncrement = 0x0100
- eaMaskPreDecrement = 0x0080
- eaMaskDisplacement = 0x0040
- eaMaskIndex = 0x0020
- eaMaskAbsoluteShort = 0x0010
- eaMaskAbsoluteLong = 0x0008
- eaMaskImmediate = 0x0004
- eaMaskPCDisplacement = 0x0002
- eaMaskPCIndex = 0x0001
- )
-
- type Type int32
|