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