|
|
1.1 root 1: //
2: // nono
1.1.1.2 root 3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
1.1 root 5: //
6:
7: #pragma once
8:
9: #include "disasm.h"
10: #include "m68030.h"
11:
12: // 逆アセンブル
1.1.1.7 root 13: class m680x0disasm final : public DisasmLine
1.1 root 14: {
1.1.1.7 root 15: using inherited = DisasmLine;
1.1 root 16: public:
1.1.1.7 root 17: m680x0disasm();
1.1.1.2 root 18: ~m680x0disasm() override;
1.1 root 19:
20: // 逆アセンブルを実行
1.1.1.7 root 21: bool Exec(DebuggerMemoryStream *mem_) override;
1.1 root 22:
1.1.1.8 ! root 23: // IOCS コール名を返す。なければ NULL を返す。(分岐履歴から呼ばれる)
! 24: static const char *GetIOCSName(int n) { return x68k_iocscall[n]; }
! 25:
1.1 root 26: private:
1.1.1.4 root 27: uint32 pc0 {}; // 命令先頭アドレス
1.1 root 28:
29: enum Reg {
30: CCR,
31: SR,
32: PC,
33: USP,
34:
35: MSP,
36: ISP,
37: VBR,
38: SFC,
39: DFC,
40: CACR,
41: CAAR,
42:
43: TC,
44: MMUSR,
45: SRP,
46: CRP,
47: TT0,
48: TT1,
49:
50: FPCR,
51: FPSR,
52: FPIAR,
53:
54: URP,
55: ITT0,
56: ITT1,
57: DTT0,
58: DTT1,
1.1.1.3 root 59:
60: MaxReg,
1.1 root 61: };
62:
63: // L/S/X/P/W/D/B/(Pk) は FMOVE <ea>,FPn の時の並び順。
64: enum Size {
65: L = 0, // Long
66: S, // Single
67: X, // eXtended
68: P, // Packed
69: W, // Word
70: D, // Double
71: B, // Byte
72: Pk, // Packed with dynamic k-factor
73: Q, // Quad
74: None,
75: };
76:
1.1.1.6 root 77: uint32 fetch16();
78: uint32 peek16(); // PC を進めずワードを取得 (IOCSコール用)
1.1 root 79: uint32 fetch32();
80:
81: std::string make_reg(Reg);
82:
83: std::string hex8(uint32);
84: std::string hex16(uint32);
85: std::string hex32(uint32);
86: std::string shex8(uint32);
87: std::string shex16(uint32);
88: std::string shex32(uint32);
89: std::string make_ea();
90: std::string make_ea(uint);
91: std::string make_eaix(std::string basereg);
92:
93: std::string addr16(uint32 addr); // addr をワードアドレスとして
94: std::string addr32(uint32 addr); // addr をロングワードアドレスとして
95: std::string addr16(); // フェッチした値をワードアドレスとして
96: std::string addr32(); // フェッチした値をロングワードアドレスとして
97: std::string disp16(); // フェッチしたワードディスプレースメント
98: std::string disp32(); // フェッチしたロングワードディスプレースメント
99: std::string imm8();
100: std::string imm16();
101: std::string imm32();
102: std::string make_dn(uint);
103: std::string make_an(uint);
104: std::string make_rn(uint);
105: std::string make_anin(uint);
106: std::string make_anpd(uint);
107: std::string make_anpi(uint);
108: std::string make_q8();
109: std::string make_reglist();
110: void make_reglist_half(std::string& s, const char *reg, uint16 mask);
111: std::string make_bf();
112: std::string make_fc();
113: std::string make_movec();
114: std::string make_fpgen();
115: std::string make_fpn(uint n);
116: std::string make_fpcc(uint16 ir);
117: uint make_fpctls(std::string& s);
118: std::string make_fpnlist();
119:
120: static const char * const reg_names[];
121: static const char * const size_str[];
122: static const char * const conditions[];
123: static const char * const fpconditions[];
124: static const char * const btst_names[];
125: static const char * const fpgen_names[0x3b];
126: static const char * const fmovecr_text[];
127: static const char * const x68k_doscall[256];
128: static const char * const x68k_fpcall[256];
129: static const char * const x68k_iocscall[256];
130: void ops_cmp2chk2(Size sz);
131: void ops_btst_movep();
132: void ops_cas(Size sz);
133: void ops_cas2(Size sz);
134: void ops_moves(Size sz);
135: void ops_movep();
136: void ops_btst_imm_ea();
137: void ops_move(Size sz);
138: void ops_movem_ext(Size sz);
139: void ops_bcc();
140: void ops_sub(Size sz);
141: void ops_add(Size sz);
142: void ops_eor_cmpm(Size sz);
143: void ops_rotate(std::string dir, Size sz);
144: void ops_pmove(Reg reg, Size sz);
145: void ops_fpgen_fpn_fpn();
146: void ops_fpgen_ea_fpn();
147: void ops_fmovecr();
148: void ops_fmove_fpn_ea();
149: void ops_fmovem_ea_ctl();
150: void ops_fmovem_ctl_ea();
151: void ops_fmovem_ea_fpn();
152: void ops_fmovem_fpn_ea();
153:
154: std::vector<uint16> ir {};
155:
1.1.1.4 root 156: std::string name {};
1.1 root 157: Size size {};
1.1.1.4 root 158: std::string src {};
159: std::string dst {};
1.1 root 160:
161: #define OP_PROTO(name) void __CONCAT(op_,name)()
162: #define OP_DEF(name) void __CONCAT(m680x0disasm::op_,name)()
163: #define OP_FUNC(name) __CONCAT(op_,name)()
164: #include "m68030ops.h"
165: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.