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