📄 dsmlib.c
字号:
case itLink: case itDb: case itRTD: case itMovec: case itPack: case itImmCCR: case itImmTSR: return (2); case itLinkL: case itCas2: case itCpDbcc: return (3); case itBra: switch (binInst [0] & 0xff) { case 0: return (2); case 0xff: return (3); default: return (1); } case itTrapcc: return (((binInst [0] & 7) == 4) ? 1 : binInst [0] & 7); case itImm: return ((((binInst [0] & 0x0080) == 0) ? 2 : 3) + modeNwords ((binInst [0] & 0x0038) >> 3, binInst [0] & 7, 0, ((binInst [0] & 0x0080) == 0) ? &binInst [2] : &binInst [3])); case itMoveB: case itMoveW: { frstArg = modeNwords ((binInst [0] & 0x0038) >> 3, binInst [0] & 7, 1, &binInst [1]); return (1 + frstArg + modeNwords ((binInst [0] & 0x01c0) >> 6, (binInst [0] & 0x0e00) >> 9, 1, &binInst [1 + frstArg])); } case itMoveL: { frstArg = modeNwords ((binInst [0] & 0x0038) >> 3, binInst [0] & 7, 2, &binInst [1]); return (1 + frstArg + modeNwords ((binInst [0] & 0x01c0) >> 6, (binInst [0] & 0x0e00) >> 9, 2, &binInst [1 + frstArg])); } case itCpBcc: return ((binInst [0] & 0x40) ? 3 : 2); case itCpTrapcc: switch (binInst [0] & 7) { case 2: return (3); case 3: return (4); case 4: return (2); } /* fpp instructions */ case itFb: if (binInst[0] & 0x0040) return(3); else return(2); case itFrestore: case itFsave: return(1 + modeNwords((binInst[0] & 0x0038) >> 3, binInst[0] & 0x7, 0, &binInst[1])); case itFmovek: case itFmovel: case itFmovem: case itFmovemc: return(2 + fppNwords((binInst[0] & 0x0038) >> 3, binInst[0] & 0x7, 1, 0, &binInst[2])); case itFmovecr: return(2); case itFabs: case itFacos: case itFadd: case itFasin: case itFatan: case itFatanh: case itFcmp: case itFcos: case itFcosh: case itFdb: case itFdiv: case itFetox: case itFetoxm1: case itFgetexp: case itFgetman: case itFint: case itFintrz: case itFlog10: case itFlog2: case itFlogn: case itFlognp1: case itFmod: case itFmove: case itFmul: case itFneg: case itFnop: case itFrem: case itFscale: case itFs: case itFsgldiv: case itFsglmul: case itFsin: case itFsincos: case itFsinh: case itFsqrt: case itFsub: case itFtan: case itFtanh: case itFtentox: case itFtrap: case itFtst: case itFtwotox: return (2 + fppNwords ((binInst[0] & 0x0038) >> 3, binInst[0] & 0x7, (binInst[1] & 0x4000) >> 14, (binInst[1] & 0x1c00) >> 10, /* (binInst[1] & 0x0380) >> 7, XXX eliminate? */ &binInst[2])); case itWDebug: return (2 + modeNwords ((binInst [0] & 0x0038) >> 3, binInst [0] & 7, 2, &binInst [2])); case itSats: return 1; case itMove3q: return (1 + modeNwords((binInst [0] & 0x0038) >> 3 ,binInst [0] & 7 , 0, &binInst [1] ) ); case itMvs: case itMvz: return (1 + modeNwords((binInst [0] & 0x0038) >> 3 ,binInst [0] & 7 , 1, &binInst [1] ) ); } /* We never get here, but just for lint ... */ return (0); }/********************************************************************************* fppNwords - number of words of extension used by the mode for fpp instrutions*/LOCAL int fppNwords ( FAST USHORT mode, USHORT reg, USHORT rm, USHORT src, USHORT extension [] /* extension array for effective address */ ) { if (rm != 0) { if (mode == 0x7 && reg == 0x4) { switch (src) { case 0: case 1: return (2); case 2: case 3: return (6); case 4: return (1); case 5: return (4); case 6: return (1); } } else return (modeNwords (mode, reg, 0, extension)); } return (0); }/********************************************************************************* modeNwords - Figure out the number of words of extension needed for a mode*/LOCAL int modeNwords ( FAST USHORT mode, USHORT reg, int size, /* the size of an immediate operand in words */ USHORT extension [] /* extension array for effective address */ ) { switch (mode) { case 0x00: /* Dn */ case 0x01: /* An */ case 0x02: /* (An) */ case 0x03: /* (An)+ */ case 0x04: /* -(An) */ return (0); case 0x05: /* (d16,An) */ return (1); case 0x06: /* reg indirect w.index modes */ return (mode6And7Words (&extension [0])); case 0x07: /* memory indirect */ switch (reg) { /* With mode 7, sub-modes are determined by the register number */ case 0x0: /* abs.short */ case 0x2: /* PC + off */ return (1); case 0x3: /* PC + ind + off */ return (mode6And7Words (&extension [0])); case 0x1: /* abs.long */ return (2); case 0x4: /* imm. */ return (size); } } /* We never get here, but just for lint ... */ return (0); }/********************************************************************************* mode6And7Words - number of words of extension needed for modes 6 and 7*/LOCAL int mode6And7Words ( FAST USHORT extension [] ) { int count = 1; /* number of words in extension */ if ((extension [0] & 0x0100) == 0) /* (An) + (Xn) + d8 */ return (count); switch ((extension [0] & 0x30) >> 4) /* base displacement size */ { case 0: /* reserved or NULL displacement */ case 1: break; case 2: /* word displacement */ count += 1; break; case 3: /* long displacement */ count += 2; break; } if ((extension [0] & 0x40) == 0) /* index operand added */ { switch (extension [0] & 3) { case 0: /* reserved or NULL displacement */ case 1: break; case 2: /* word displacement */ count += 1; break; case 3: /* long displacement */ count += 2; break; } } return (count); }/********************************************************************************* prtArgs - Print the arguments for an instruction*/LOCAL void prtArgs ( USHORT binInst [], /* Pointer to the binary instruction */ FAST INST *iPtr, /* Pointer to the INST describing binInst */ int address, /* Address at which the instruction resides */ FUNCPTR prtAddress /* routine to print addresses. */ ) { int frstArg; int displacement; int sizeData; char *sourceYword, *sourceXword, *shift, *mam; switch (iPtr->type) { case itBra: switch (binInst [0] & 0xff) { case 0: displacement = (short) binInst[1]; break; case 0xff: displacement = (((short) binInst [1] << 16) | binInst [2]); break; default: displacement = (char) (binInst [0] & 0xff); break; } (*prtAddress) (address + 2 + displacement); printf ("\n"); break; case itDivW: prEffAddr ((binInst [0] & 0x38) >> 3, binInst [0] & 7, &binInst [1], 2, prtAddress); printf (",D%x\n", (binInst [0] & 0x0e00) >> 9); break; case itChk: prEffAddr ((binInst [0] & 0x38) >> 3, binInst [0] & 7, &binInst [1], (binInst [0] & 0x80) ? 2 : 4, prtAddress); printf (",D%x\n", (binInst [0] & 0x0e00) >> 9); break; case itChk2: prEffAddr ((binInst [0] & 0x38) >> 3, binInst [0] & 7, &binInst [2], 0, prtAddress); printf ((binInst [1] & 0x8000) ? ",A%x\n" : ",D%x\n", (binInst [1] & 0x7000) >> 12); break; case itLea: prEffAddr ((binInst [0] & 0x38) >> 3, binInst [0] & 0x7, &binInst [1], 2, prtAddress); printf (",A%x\n", (binInst [0] & 0x0e00) >> 9); break; case itComplete: /* No arguments */ printf ("\n"); break; case itStatBit: case itCallm: printf ("#%#x,", binInst [1]); prEffAddr ((binInst [0] & 0x38) >> 3, binInst [0] & 0x7, &binInst [2], 0, prtAddress); printf ("\n"); break; case itDynBit: printf ("D%x,", (binInst [0] & 0x0e00) >> 9); prEffAddr ((binInst [0] & 0x38) >> 3, binInst [0] & 0x7, &binInst [1], 0, prtAddress); printf ("\n"); break; case itExg: switch ((binInst [0] & 0x00f8) >> 3) { case 0x08: printf ("D%x,D%x\n", (binInst [0] & 0x0e00) >> 9, binInst [0] & 0x0007); break; case 0x09: printf ("A%x,A%x\n", (binInst [0] & 0x0e00) >> 9, binInst [0] & 0x0007); break; case 0x11: printf ("D%x,A%x\n", (binInst [0] & 0x0e00) >> 9, binInst [0] & 0x0007); break; } break; case itImm: switch ((binInst [0] & 0x00c0) >> 6) /* size */ { case 0: /* byte */ printf ("#%#x,", binInst [1] & 0x00ff);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -