2 // This file is part of the PicoDrive Megadrive Emulator
\r
4 // Copyright (c) 2011 FinalDave (emudave (at) gmail.com)
\r
6 // This code is licensed under the GNU General Public License version 2.0 and the MAME License.
\r
7 // You can choose the license that has the most advantages for you.
\r
9 // SVN repository can be found at http://code.google.com/p/cyclone68000/
\r
11 // Disa 68000 Disassembler
\r
13 #pragma warning(disable:4115)
\r
16 #define _CRT_SECURE_NO_WARNINGS
\r
21 unsigned int DisaPc=0;
\r
22 char *DisaText=NULL; // Text buffer to write in
\r
23 static char Tasm[]="bwl?";
\r
24 static char Comment[64]="";
\r
25 unsigned short (CPU_CALL *DisaWord)(unsigned int a)=NULL;
\r
27 static unsigned int DisaLong(unsigned int a)
\r
30 if (DisaWord==NULL) return d;
\r
33 d|=DisaWord(a+2)&0xffff;
\r
37 // Get text version of the effective address
\r
38 int DisaGetEa(char *t,int ea,int size)
\r
41 if ((ea&0x38)==0x00) { sprintf(t,"d%d",ea ); return 0; } // 000rrr
\r
42 if ((ea&0x38)==0x08) { sprintf(t,"a%d",ea&7); return 0; } // 001rrr
\r
43 if ((ea&0x38)==0x10) { sprintf(t,"(a%d)",ea&7); return 0; } // 010rrr
\r
44 if ((ea&0x38)==0x18) { sprintf(t,"(a%d)+",ea&7); return 0; } // 011rrr
\r
45 if ((ea&0x38)==0x20) { sprintf(t,"-(a%d)",ea&7); return 0; } // 100rrr
\r
46 if ((ea&0x38)==0x28) { sprintf(t,"($%x,a%d)",DisaWord(DisaPc)&0xffff,ea&7); DisaPc+=2; return 0; } // 101rrr
\r
48 if ((ea&0x38)==0x30)
\r
50 // 110nnn - An + Disp + D/An
\r
51 int areg=0,ext=0,off=0,da=0,reg=0,wol=0,scale=0;
\r
52 ext=DisaWord(DisaPc)&0xffff;
\r
55 off=ext&0xff; da =ext&0x8000?'a':'d';
\r
56 reg=(ext>>12)&7; wol=ext&0x0800?'l':'w';
\r
57 scale=1<<((ext>>9)&3);
\r
59 if (scale<2) sprintf(t,"($%x,a%d,%c%d.%c)", off,areg,da,reg,wol);
\r
60 else sprintf(t,"($%x,a%d,%c%d.%c*%d)",off,areg,da,reg,wol,scale); // 68020
\r
66 if (ea==0x38) { sprintf(t,"$%x.w",DisaWord(DisaPc)&0xffff); DisaPc+=2; return 0; } // 111000 - Absolute short
\r
67 if (ea==0x39) { sprintf(t,"$%x.l",DisaLong(DisaPc)); DisaPc+=4; return 0; } // 111001 - Absolute long
\r
71 // 111010 - PC Relative
\r
72 int ext=DisaWord(DisaPc)&0xffff;
\r
73 sprintf(t,"($%x,pc)",ext);
\r
74 sprintf(Comment,"; =%x",DisaPc+(short)ext); // Comment where pc+ext is
\r
81 // 111011 - PC Relative + D/An
\r
82 int ext=0,off=0,da=0,reg=0,wol=0,scale=0;
\r
83 ext=DisaWord(DisaPc)&0xffff;
\r
85 off=ext&0xff; da =ext&0x8000?'a':'d';
\r
86 reg=(ext>>12)&7; wol=ext&0x0800?'l':'w';
\r
87 scale=1<<((ext>>9)&3);
\r
89 if (scale<2) sprintf(t,"($%x,pc,%c%d.%c)", off,da,reg,wol);
\r
90 else sprintf(t,"($%x,pc,%c%d.%c*%d)",off,da,reg,wol,scale); // 68020
\r
92 sprintf(Comment,"; =%x",DisaPc+(char)off); // Comment where pc+ext is
\r
99 // 111100 - Immediate
\r
102 case 0: sprintf(t,"#$%x",DisaWord(DisaPc)&0x00ff); DisaPc+=2; return 0;
\r
103 case 1: sprintf(t,"#$%x",DisaWord(DisaPc)&0xffff); DisaPc+=2; return 0;
\r
104 case 2: sprintf(t,"#$%x",DisaLong(DisaPc) ); DisaPc+=4; return 0;
\r
109 // Unknown effective address
\r
110 sprintf(t,"ea=(%d%d%d %d%d%d)",
\r
111 (ea>>5)&1,(ea>>4)&1,(ea>>3)&1,
\r
112 (ea>>2)&1,(ea>>1)&1, ea &1);
\r
116 static void GetOffset(char *text)
\r
118 int off=(short)DisaWord(DisaPc); DisaPc+=2;
\r
120 if (off<0) sprintf(text,"-$%x",-off);
\r
121 else sprintf(text,"$%x", off);
\r
124 // ================ Opcodes 0x0000+ ================
\r
125 static int DisaArithImm(int op)
\r
127 // Or/And/Sub/Add/Eor/Cmp Immediate 0000ttt0 xxDDDddd (tt=type, xx=size extension, DDDddd=Dest ea)
\r
129 char seat[64]="",deat[64]="";
\r
131 char *arith[8]={"or","and","sub","add","?","eor","cmp","?"};
\r
133 type=(op>>9)&7; if (type==4 || type>=7) return 1;
\r
134 size=(op>>6)&3; if (size>=3) return 1;
\r
135 dea=op&0x3f; if (dea==0x3c) return 1;
\r
137 DisaGetEa(seat,0x3c,size);
\r
138 DisaGetEa(deat,dea, size);
\r
140 sprintf(DisaText,"%si.%c %s, %s",arith[type],Tasm[size],seat,deat);
\r
144 // ================ Opcodes 0x0108+ ================
\r
145 static int DisaMovep(int op)
\r
147 // movep.x (Aa),Dn - 0000nnn1 dx001aaa nn
\r
148 int dn=0,dir=0,size=0,an=0;
\r
149 char offset[32]="";
\r
153 size=(op>>6)&1; size++;
\r
157 if (dir) sprintf(DisaText,"movep.%c d%d, (%s,a%d)",Tasm[size],dn,offset,an);
\r
158 else sprintf(DisaText,"movep.%c (%s,a%d), d%d",Tasm[size],offset,an,dn);
\r
163 // ================ Opcodes 0x007c+ ================
\r
164 static int DisaArithSr(int op)
\r
166 // Ori/Andi/Eori $nnnn,sr 0000t0tx 0s111100
\r
167 char *opcode[6]={"ori","andi","","","","eori"};
\r
174 DisaGetEa(seat,0x3c,size);
\r
175 sprintf(DisaText,"%s.%c %s, %s", opcode[type], Tasm[size], seat, size?"sr":"ccr");
\r
180 // ================ Opcodes 0x0100+ ================
\r
181 static int DisaBtstReg(int op)
\r
183 // Btst/Bchg/Bclr/Bset 0000nnn1 tteeeeee (nn=reg number, eeeeee=Dest ea)
\r
186 char seat[64]="",deat[64]="";
\r
187 char *opcode[4]={"btst","bchg","bclr","bset"};
\r
193 if ((dea&0x38)==0x08) return 1; // movep
\r
194 DisaGetEa(seat,sea,0);
\r
195 DisaGetEa(deat,dea,0);
\r
197 sprintf(DisaText,"%s %s, %s",opcode[type],seat,deat);
\r
201 // ================ Opcodes 0x0800+ ================
\r
202 static int DisaBtstImm(int op)
\r
204 // Btst/Bchg/Bclr/Bset 00001000 tteeeeee 00 nn (eeeeee=ea, nn=bit number)
\r
206 char seat[64]="",deat[64]="";
\r
207 char *opcode[4]={"btst","bchg","bclr","bset"};
\r
210 DisaGetEa(seat, 0x3c,0);
\r
211 DisaGetEa(deat,op&0x3f,0);
\r
213 sprintf(DisaText,"%s %s, %s",opcode[type],seat,deat);
\r
217 // ================ Opcodes 0x1000+ ================
\r
218 static int DisaMove(int op)
\r
220 // Move 00xxdddD DDssssss (xx=size extension, ssssss=Source EA, DDDddd=Dest ea)
\r
222 char inst[64]="",seat[64]="",deat[64]="";
\r
226 if ((op&0x01c0)==0x0040) movea="a"; // See if it's a movea opcode
\r
228 // Find size extension
\r
231 case 0x1000: size=0; break;
\r
232 case 0x3000: size=1; break;
\r
233 case 0x2000: size=2; break;
\r
238 DisaGetEa(seat,sea,size);
\r
240 dea =(op&0x01c0)>>3;
\r
241 dea|=(op&0x0e00)>>9;
\r
242 DisaGetEa(deat,dea,size);
\r
244 sprintf(inst,"move%s.%c",movea,Tasm[size]);
\r
245 sprintf(DisaText,"%s %s, %s",inst,seat,deat);
\r
249 // ================ Opcodes 0x4000+ ================
\r
250 static int DisaNeg(int op)
\r
252 // 01000tt0 xxeeeeee (tt=negx/clr/neg/not, xx=size, eeeeee=EA)
\r
255 char *opcode[4]={"negx","clr","neg","not"};
\r
258 size=(op>>6)&3; if (size>=3) return 1;
\r
259 DisaGetEa(eat,op&0x3f,size);
\r
261 sprintf(DisaText,"%s.%c %s",opcode[type],Tasm[size],eat);
\r
265 // ================ Opcodes 0x40c0+ ================
\r
266 static int DisaMoveSr(int op)
\r
268 // 01000tt0 11eeeeee (tt=type, xx=size, eeeeee=EA)
\r
274 DisaGetEa(eat,ea,1);
\r
278 default: sprintf(DisaText,"move sr, %s", eat); break;
\r
279 case 1: sprintf(DisaText,"move ccr, %s",eat); break;
\r
280 case 2: sprintf(DisaText,"move %s, ccr",eat); break;
\r
281 case 3: sprintf(DisaText,"move %s, sr", eat); break;
\r
286 // ================ Opcodes 0x41c0+ ================
\r
287 static int DisaLea(int op)
\r
289 // Lea 0100nnn1 11eeeeee (eeeeee=ea)
\r
291 char seat[64]="",deat[64]="";
\r
294 DisaGetEa(seat,sea,0);
\r
296 dea=(op>>9)&7; dea|=8;
\r
297 DisaGetEa(deat,dea,2);
\r
299 sprintf(DisaText,"lea %s, %s",seat,deat);
\r
303 static int MakeRegList(char *list,int mask,int ea)
\r
305 int reverse=0,i=0,low=0,len=0;
\r
307 if ((ea&0x38)==0x20) reverse=1; // -(An), bitfield is reversed
\r
309 mask&=0xffff; list[0]=0;
\r
316 if (reverse) bit=0x8000>>i; else bit=1<<i;
\r
319 if (bit==0 || i==8)
\r
321 // low to i-1 are a continuous section, add it:
\r
323 int ad=low&8?'a':'d';
\r
324 if (low==i-1) sprintf(add,"%c%d/", ad,low&7);
\r
325 if (low< i-1) sprintf(add,"%c%d-%c%d/",ad,low&7, ad,(i-1)&7);
\r
328 low=i; // Next section
\r
331 if (bit==0) low=i+1;
\r
334 // Knock off trailing '/'
\r
336 if (len>0) if (list[len-1]=='/') list[len-1]=0;
\r
340 // ================ Opcodes 0x4840+ ================
\r
341 static int DisaSwap(int op)
\r
343 // Swap, 01001000 01000nnn swap Dn
\r
344 sprintf(DisaText,"swap d%d",op&7);
\r
348 // ================ Opcodes 0x4850+ ================
\r
349 static int DisaPea(int op)
\r
351 // Pea 01001000 01eeeeee (eeeeee=ea) pea
\r
355 ea=op&0x003f; if (ea<0x10) return 1; // swap opcode
\r
356 DisaGetEa(eat,ea,2);
\r
358 sprintf(DisaText,"pea %s",eat);
\r
362 // ================ Opcodes 0x4880+ ================
\r
363 static int DisaExt(int op)
\r
365 // Ext 01001000 1x000nnn (x=size, eeeeee=EA)
\r
369 size=(op>>6)&1; size++;
\r
370 DisaGetEa(eat,op&0x3f,size);
\r
372 sprintf(DisaText,"ext.%c %s",Tasm[size],eat);
\r
376 // ================ Opcodes 0x4890+ ================
\r
377 static int DisaMovem(int op)
\r
379 // Movem 01001d00 1xeeeeee regmask d=direction, x=size, eeeeee=EA
\r
382 char list[64]="",eat[64]="";
\r
385 size=((op>>6)&1)+1;
\r
386 ea=op&0x3f; if (ea<0x10) return 1; // ext opcode
\r
388 mask=DisaWord(DisaPc)&0xffff; DisaPc+=2;
\r
390 MakeRegList(list,mask,ea); // Turn register mask into text
\r
391 DisaGetEa(eat,ea,size);
\r
393 if (dir) sprintf(DisaText,"movem.%c %s, %s",Tasm[size],eat,list);
\r
394 else sprintf(DisaText,"movem.%c %s, %s",Tasm[size],list,eat);
\r
398 // ================ Opcodes 0x4e40+ ================
\r
399 static int DisaTrap(int op)
\r
401 sprintf(DisaText,"trap #%d",op&0xf);
\r
405 // ================ Opcodes 0x4e50+ ================
\r
406 static int DisaLink(int op)
\r
408 // Link opcode, 01001110 01010nnn dd link An,#offset
\r
410 char offset[32]="";
\r
412 DisaGetEa(eat,(op&7)|8,0);
\r
415 sprintf(DisaText,"link %s,#%s",eat,offset);
\r
420 // ================ Opcodes 0x4e58+ ================
\r
421 static int DisaUnlk(int op)
\r
423 // Link opcode, 01001110 01011nnn dd unlk An
\r
426 DisaGetEa(eat,(op&7)|8,0);
\r
427 sprintf(DisaText,"unlk %s",eat);
\r
432 // ================ Opcodes 0x4e60+ ================
\r
433 static int DisaMoveUsp(int op)
\r
435 // Move USP opcode, 01001110 0110dnnn move An to/from USP (d=direction)
\r
441 DisaGetEa(eat,ea,0);
\r
443 if (dir) sprintf(DisaText,"move usp, %s",eat);
\r
444 else sprintf(DisaText,"move %s, usp",eat);
\r
448 // ================ Opcodes 0x4e70+ ================
\r
449 static int Disa4E70(int op)
\r
451 char *inst[8]={"reset","nop","stop","rte","rtd","rts","trapv","rtr"};
\r
456 sprintf(DisaText,"%s",inst[n]);
\r
458 //todo - 'stop' with 16 bit data
\r
463 // ================ Opcodes 0x4a00+ ================
\r
464 static int DisaTst(int op)
\r
466 // Tst 01001010 xxeeeeee (eeeeee=ea)
\r
472 DisaGetEa(eat,ea,0);
\r
473 size=(op>>6)&3; if (size>=3) return 1;
\r
475 sprintf(DisaText,"tst.%c %s",Tasm[size],eat);
\r
479 // ================ Opcodes 0x4e80+ ================
\r
480 static int DisaJsr(int op)
\r
482 // Jsr/Jmp 0100 1110 1mEE Eeee (eeeeee=ea m=1=jmp)
\r
487 DisaGetEa(seat,sea,0);
\r
489 sprintf(DisaText,"j%s %s", op&0x40?"mp":"sr", seat);
\r
493 // ================ Opcodes 0x5000+ ================
\r
494 static int DisaAddq(int op)
\r
496 // 0101nnnt xxeeeeee (nnn=#8,1-7 t=addq/subq xx=size, eeeeee=EA)
\r
497 int num=0,type=0,size=0,ea=0;
\r
500 num =(op>>9)&7; if (num==0) num=8;
\r
502 size=(op>>6)&3; if (size>=3) return 1;
\r
505 DisaGetEa(eat,ea,size);
\r
507 sprintf(DisaText,"%s.%c #%d, %s",type?"subq":"addq",Tasm[size],num,eat);
\r
511 // ================ Opcodes 0x50c0+ ================
\r
512 static int DisaSet(int op)
\r
514 // 0101cccc 11eeeeee (sxx ea)
\r
515 static char *cond[16]=
\r
516 {"t" ,"f", "hi","ls","cc","cs","ne","eq",
\r
517 "vc","vs","pl","mi","ge","lt","gt","le"};
\r
522 cc=cond[(op>>8)&0xf]; // Get condition code
\r
524 if ((ea&0x38)==0x08) return 1; // dbra, not scc
\r
526 DisaGetEa(eat,ea,0);
\r
527 sprintf(DisaText,"s%s %s",cc,eat);
\r
531 // ================ Opcodes 0x50c8+ ================
\r
532 static int DisaDbra(int op)
\r
534 // 0101cccc 11001nnn offset (dbra/dbxx Rn,offset)
\r
535 int dea=0; char deat[64]="";
\r
538 static char *BraCode[16]=
\r
539 {"bt" ,"bra","bhi","bls","bcc","bcs","bne","beq",
\r
540 "bvc","bvs","bpl","bmi","bge","blt","bgt","ble"};
\r
544 DisaGetEa(deat,dea,2);
\r
546 // Get condition code
\r
547 Bra=BraCode[(op>>8)&0xf];
\r
551 Offset=(short)DisaWord(DisaPc); DisaPc+=2;
\r
553 sprintf(DisaText,"d%s %s, %x",Bra,deat,pc+Offset);
\r
557 // ================ Opcodes 0x6000+ ================
\r
558 static int DisaBranch(int op)
\r
560 // Branch 0110cccc nn (cccc=condition)
\r
563 static char *BraCode[16]=
\r
564 {"bra","bsr","bhi","bls","bcc","bcs","bne","beq",
\r
565 "bvc","bvs","bpl","bmi","bge","blt","bgt","ble"};
\r
568 // Get condition code
\r
569 Bra=BraCode[(op>>8)&0x0f];
\r
573 Offset=(char)(op&0xff);
\r
574 if (Offset== 0) { Offset=(short)DisaWord(DisaPc); DisaPc+=2; }
\r
575 else if (Offset==-1) { Offset= DisaLong(DisaPc); DisaPc+=4; }
\r
577 sprintf(DisaText,"%s %x",Bra,pc+Offset);
\r
581 // ================ Opcodes 0x7000+ ================
\r
582 static int DisaMoveq(int op)
\r
584 // Moveq 0111rrr0 nn (rrr=Dest register, nn=data)
\r
586 int dea=0; char deat[64]="";
\r
587 char *inst="moveq";
\r
591 DisaGetEa(deat,dea,2);
\r
593 val=(char)(op&0xff);
\r
594 sprintf(DisaText,"%s #$%x, %s",inst,val,deat);
\r
598 // ================ Opcodes 0x8000+ ================
\r
599 static int DisaArithReg(int op)
\r
601 // 1t0tnnnd xxeeeeee (tt=type:or/sub/and/add xx=size, eeeeee=EA)
\r
602 int type=0,size=0,dir=0,rea=0,ea=0;
\r
603 char reat[64]="",eat[64]="";
\r
604 char *opcode[]={"or","sub","","","and","add"};
\r
609 size=(op>> 6)&3; if (size>=3) return 1;
\r
612 if (dir && ea<0x10) return 1; // addx opcode
\r
614 DisaGetEa(reat,rea,size);
\r
615 DisaGetEa( eat, ea,size);
\r
617 if (dir) sprintf(DisaText,"%s.%c %s, %s",opcode[type],Tasm[size],reat,eat);
\r
618 else sprintf(DisaText,"%s.%c %s, %s",opcode[type],Tasm[size],eat,reat);
\r
622 // ================ Opcodes 0x8100+ ================
\r
623 static int DisaAbcd(int op)
\r
625 // 1t00ddd1 0000asss - sbcd/abcd Ds,Dd or -(As),-(Ad)
\r
627 int dn=0,addr=0,sn=0;
\r
628 char *opcode[]={"sbcd","abcd"};
\r
635 if (addr) sprintf(DisaText,"%s -(a%d), -(a%d)",opcode[type],sn,dn);
\r
636 else sprintf(DisaText,"%s d%d, d%d", opcode[type],sn,dn);
\r
641 // ================ Opcodes 0x80c0+ ================
\r
642 static int DisaMul(int op)
\r
644 // Div/Mul: 1m00nnns 11eeeeee (m=Mul, nnn=Register Dn, s=signed, eeeeee=EA)
\r
645 int type=0,rea=0,sign=0,ea=0,size=1;
\r
646 char reat[64]="",eat[64]="";
\r
647 char *opcode[2]={"div","mul"};
\r
649 type=(op>>14)&1; // div/mul
\r
654 DisaGetEa(reat,rea,size);
\r
655 DisaGetEa( eat, ea,size);
\r
657 sprintf(DisaText,"%s%c.%c %s, %s",opcode[type],sign?'s':'u',Tasm[size],eat,reat);
\r
661 // ================ Opcodes 0x90c0+ ================
\r
662 static int DisaAritha(int op)
\r
664 // Suba/Cmpa/Adda 1tt1nnnx 11eeeeee (tt=type, x=size, eeeeee=Source EA)
\r
665 int type=0,size=0,sea=0,dea=0;
\r
666 char seat[64]="",deat[64]="";
\r
667 char *aritha[4]={"suba","cmpa","adda",""};
\r
669 type=(op>>13)&3; if (type>=3) return 1;
\r
670 size=(op>>8)&1; size++;
\r
671 dea =(op>>9)&7; dea|=8; // Dest=An
\r
672 sea = op&0x003f; // Source
\r
674 DisaGetEa(seat,sea,size);
\r
675 DisaGetEa(deat,dea,size);
\r
677 sprintf(DisaText,"%s.%c %s, %s",aritha[type],Tasm[size],seat,deat);
\r
681 // ================ Opcodes 0xb000+ ================
\r
682 static int DisaCmpEor(int op)
\r
684 // Cmp/Eor 1011rrrt xxeeeeee (rrr=Dn, t=cmp/eor, xx=size extension, eeeeee=ea)
\r
685 char reat[64]="",eat[64]="";
\r
689 size=(op>>6)&3; if (size>=3) return 1; // cmpa opcode
\r
690 if ((op&0xf138)==0xb108) return 1; // cmpm opcode
\r
692 DisaGetEa(reat,(op>>9)&7,size);
\r
693 DisaGetEa(eat, op&0x3f, size);
\r
695 if (type) sprintf(DisaText,"eor.%c %s, %s",Tasm[size],reat,eat);
\r
696 else sprintf(DisaText,"cmp.%c %s, %s",Tasm[size],eat,reat);
\r
700 // ================ Opcodes 0xb108+ ================
\r
701 static int DisaCmpm(int op)
\r
703 // Cmpm 1011ddd1 xx001sss
\r
704 int type=0,size=0,dea=0,sea=0;
\r
705 char deat[64]="",seat[64]="";
\r
708 dea =(op>> 9)&7; dea|=8;
\r
709 size=(op>> 6)&3; if (size>=3) return 1;
\r
712 DisaGetEa(deat,dea,size);
\r
713 DisaGetEa(seat,sea,size);
\r
715 sprintf(DisaText,"cmpm.%c (%s)+, (%s)+",Tasm[size],seat,deat);
\r
720 // ================ Opcodes 0xc140+ ================
\r
721 // 1100ttt1 01000sss exg ds,dt
\r
722 // 1100ttt1 01001sss exg as,at
\r
723 // 1100ttt1 10001sss exg as,dt
\r
724 static int DisaExg(int op)
\r
726 int tr=0,type=0,sr=0;
\r
732 if (type==0x40) sprintf(DisaText,"exg d%d, d%d",sr,tr);
\r
733 else if (type==0x48) sprintf(DisaText,"exg a%d, a%d",sr,tr);
\r
734 else if (type==0x88) sprintf(DisaText,"exg a%d, d%d",sr,tr);
\r
740 // ================ Opcodes 0xd100+ ================
\r
741 static int DisaAddx(int op)
\r
743 // 1t01ddd1 xx000sss addx
\r
744 int type=0,size=0,dea=0,sea=0;
\r
745 char deat[64]="",seat[64]="";
\r
746 char *opcode[6]={"","subx","","","","addx"};
\r
750 size=(op>> 6)&3; if (size>=3) return 1;
\r
753 DisaGetEa(deat,dea,size);
\r
754 DisaGetEa(seat,sea,size);
\r
756 sprintf(DisaText,"%s.%c %s, %s",opcode[type],Tasm[size],seat,deat);
\r
760 // ================ Opcodes 0xe000+ ================
\r
761 static char *AsrName[4]={"as","ls","rox","ro"};
\r
762 static int DisaAsr(int op)
\r
764 // Asr/l/Ror/l etc - 1110cccd xxuttnnn
\r
765 // (ccc=count, d=direction xx=size extension, u=use reg for count, tt=type, nnn=register Dn)
\r
766 int count=0,dir=0,size=0,usereg=0,type=0,num=0;
\r
770 size =(op>>6)&3; if (size>=3) return 1; // todo Asr EA
\r
773 num = op &7; // Register number
\r
775 if (usereg==0) count=((count-1)&7)+1; // because ccc=000 means 8
\r
777 sprintf(DisaText,"%s%c.%c %c%d, d%d",
\r
778 AsrName[type], dir?'l':'r', Tasm[size],
\r
779 usereg?'d':'#', count, num);
\r
783 static int DisaAsrEa(int op)
\r
785 // Asr/l/Ror/l etc EA - 11100ttd 11eeeeee
\r
786 int type=0,dir=0,size=1;
\r
791 DisaGetEa(eat,op&0x3f,size);
\r
793 sprintf(DisaText,"%s%c.w %s", AsrName[type], dir?'l':'r', eat);
\r
797 // =================================================================
\r
799 static int TryOp(int op)
\r
801 if ((op&0xf100)==0x0000) DisaArithImm(op); // Ori/And/Sub/Add/Eor/Cmp Immediate
\r
802 if ((op&0xf5bf)==0x003c) DisaArithSr(op); // Ori/Andi/Eori $nnnn,sr
\r
803 if ((op&0xf100)==0x0100) DisaBtstReg(op);
\r
804 if ((op&0xf138)==0x0108) DisaMovep(op);
\r
805 if ((op&0xff00)==0x0800) DisaBtstImm(op); // Btst/Bchg/Bclr/Bset
\r
806 if ((op&0xc000)==0x0000) DisaMove(op);
\r
807 if ((op&0xf900)==0x4000) DisaNeg(op); // Negx/Clr/Neg/Not
\r
808 if ((op&0xf1c0)==0x41c0) DisaLea(op);
\r
809 if ((op&0xf9c0)==0x40c0) DisaMoveSr(op);
\r
810 if ((op&0xfff8)==0x4840) DisaSwap(op);
\r
811 if ((op&0xffc0)==0x4840) DisaPea(op);
\r
812 if ((op&0xffb8)==0x4880) DisaExt(op);
\r
813 if ((op&0xfb80)==0x4880) DisaMovem(op);
\r
814 if ((op&0xff00)==0x4a00) DisaTst(op);
\r
815 if ((op&0xfff0)==0x4e40) DisaTrap(op);
\r
816 if ((op&0xfff8)==0x4e50) DisaLink(op);
\r
817 if ((op&0xfff8)==0x4e58) DisaUnlk(op);
\r
818 if ((op&0xfff0)==0x4e60) DisaMoveUsp(op);
\r
819 if ((op&0xfff8)==0x4e70) Disa4E70(op);
\r
820 if ((op&0xff80)==0x4e80) DisaJsr(op);
\r
821 if ((op&0xf000)==0x5000) DisaAddq(op);
\r
822 if ((op&0xf0c0)==0x50c0) DisaSet(op);
\r
823 if ((op&0xf0f8)==0x50c8) DisaDbra(op);
\r
824 if ((op&0xf000)==0x6000) DisaBranch(op);
\r
825 if ((op&0xa000)==0x8000) DisaArithReg(op); // Or/Sub/And/Add
\r
826 if ((op&0xb1f0)==0x8100) DisaAbcd(op);
\r
827 if ((op&0xb130)==0x9100) DisaAddx(op);
\r
828 if ((op&0xb0c0)==0x80c0) DisaMul(op);
\r
829 if ((op&0xf100)==0x7000) DisaMoveq(op);
\r
830 if ((op&0x90c0)==0x90c0) DisaAritha(op);
\r
831 if ((op&0xf000)==0xb000) DisaCmpEor(op);
\r
832 if ((op&0xf138)==0xb108) DisaCmpm(op);
\r
833 if ((op&0xf130)==0xc100) DisaExg(op);
\r
834 if ((op&0xf000)==0xe000) DisaAsr(op);
\r
835 if ((op&0xf8c0)==0xe0c0) DisaAsrEa(op);
\r
844 if (DisaWord==NULL) return 1;
\r
847 DisaText[0]=0; // Assume opcode unknown
\r
849 op=DisaWord(DisaPc)&0xffff; DisaPc+=2;
\r
851 strcat(DisaText,Comment);
\r