Annotation of nono/m680x0/disasm.h, revision 1.1.1.1

1.1       root        1: //
                      2: // nono
                      3: // Copyright (C) 2017 [email protected]
                      4: //
                      5: 
                      6: #pragma once
                      7: 
                      8: #include <string>
                      9: #include <vector>
                     10: 
                     11: class m68kcpu;
                     12: 
                     13: // 逆アセンブル
                     14: class Disasm
                     15: {
                     16:  public:
                     17:        Disasm();
                     18:        virtual ~Disasm();
                     19: 
                     20:        // 逆アセンブル文字列を返す (物理アクセス)
                     21:        std::string Disassemble(uint32 paddr) {
                     22:                return Disassemble(paddr, paddr);
                     23:        }
                     24:        // ダンプ付きの逆アセンブル文字列を返す (物理アクセス)
                     25:        std::string DisassembleWithDump(uint32 paddr) {
                     26:                return DisassembleWithDump(paddr, paddr);
                     27:        }
                     28: 
                     29:        // 逆アセンブル文字列を返す (論理アクセス)
                     30:        std::string Disassemble(uint32 laddr, uint32 paddr);
                     31:        // ダンプ付きの逆アセンブル文字列を返す (論理アクセス)
                     32:        std::string DisassembleWithDump(uint32 laddr, uint32 paddr);
                     33: 
                     34:        // 次の開始アドレスを取得する
                     35:        uint32 GetNextAddr() const { return pc; }
                     36:        // 今処理した命令のバイト数を取得する
                     37:        uint32 GetLength() const { return pc - pc0; }
                     38: 
                     39:  private:
                     40:        uint32 pc = 0;                  // 現在の PC (論理アドレス)
                     41:        uint32 pc0 = 0;                 // 命令先頭  (論理アドレス)
                     42:        uint32 phys_pc = 0;             // pc に対応する物理アドレス
                     43: 
                     44:        enum Reg {
                     45:                CCR,
                     46:                SR,
                     47:                PC,
                     48:                USP,
                     49: 
                     50:                MSP,
                     51:                ISP,
                     52:                VBR,
                     53:                SFC,
                     54:                DFC,
                     55:                CACR,
                     56:                CAAR,
                     57: 
                     58:                TC,
                     59:                MMUSR,
                     60:                SRP,
                     61:                CRP,
                     62:                TT0,
                     63:                TT1,
                     64: 
                     65:                FPCR,
                     66:                FPSR,
                     67:                FPIAR,
                     68: 
                     69:                URP,
                     70:                ITT0,
                     71:                ITT1,
                     72:                DTT0,
                     73:                DTT1,
                     74:        };
                     75: 
                     76:        // L/S/X/P/W/D/B/(Pk) は FMOVE <ea>,FPn の時の並び順。
                     77:        enum Size {
                     78:                L = 0,  // Long
                     79:                S,              // Single
                     80:                X,              // eXtended
                     81:                P,              // Packed
                     82:                W,              // Word
                     83:                D,              // Double
                     84:                B,              // Byte
                     85:                Pk,             // Packed with dynamic k-factor
                     86:                Q,              // Quad
                     87:                None,
                     88:        };
                     89: 
                     90:        virtual uint32 fetch16();
                     91:        virtual uint32 peek16();                // PC を進めずワードを取得 (IOCSコール用)
                     92:        uint32 fetch32();
                     93: 
                     94:        // 1行逆アセンブル前の初期化
                     95:        void init();
                     96: 
                     97:        std::string make_reg(Reg);
                     98: 
                     99:        std::string hex8(uint32);
                    100:        std::string hex16(uint32);
                    101:        std::string hex32(uint32);
                    102:        std::string shex8(uint32);
                    103:        std::string shex16(uint32);
                    104:        std::string shex32(uint32);
                    105:        std::string make_ea();
                    106:        std::string make_ea(uint);
                    107:        std::string make_eaix(std::string basereg);
                    108: 
                    109:        std::string addr16(uint32 addr);        // addr をワードアドレスとして
                    110:        std::string addr32(uint32 addr);        // addr をロングワードアドレスとして
                    111:        std::string addr16();           // フェッチした値をワードアドレスとして
                    112:        std::string addr32();           // フェッチした値をロングワードアドレスとして
                    113:        std::string disp16();           // フェッチしたワードディスプレースメント
                    114:        std::string disp32();           // フェッチしたロングワードディスプレースメント
                    115:        std::string imm8();
                    116:        std::string imm16();
                    117:        std::string imm32();
                    118:        std::string make_dn(uint);
                    119:        std::string make_an(uint);
                    120:        std::string make_rn(uint);
                    121:        std::string make_anin(uint);
                    122:        std::string make_anpd(uint);
                    123:        std::string make_anpi(uint);
                    124:        std::string make_q8();
                    125:        std::string make_reglist();
                    126:        void make_reglist_half(std::string& s, const char *reg, uint16 mask);
                    127:        std::string make_bf();
                    128:        std::string make_fc();
                    129:        std::string make_movec();
                    130:        std::string make_fpgen();
                    131:        std::string make_fpn(uint n);
                    132:        std::string make_fpcc(uint16 ir);
                    133:        uint make_fpctls(std::string& s);
                    134:        std::string make_fpnlist();
                    135: 
                    136:        static const char * const reg_names[];
                    137:        static const char * const size_str[];
                    138:        static const char * const conditions[];
                    139:        static const char * const fpconditions[];
                    140:        static const char * const btst_names[];
                    141:        static const char * const fpgen_names[0x3b];
                    142:        static const char * const fmovecr_text[];
                    143:        static const char * const x68k_doscall[256];
                    144:        static const char * const x68k_fpcall[256];
                    145:        static const char * const x68k_iocscall[256];
                    146:        void ops_cmp2chk2(Size sz);
                    147:        void ops_btst_movep();
                    148:        void ops_cas(Size sz);
                    149:        void ops_cas2(Size sz);
                    150:        void ops_moves(Size sz);
                    151:        void ops_movep();
                    152:        void ops_btst_imm_ea();
                    153:        void ops_move(Size sz);
                    154:        void ops_movem_ext(Size sz);
                    155:        void ops_scc();
                    156:        void ops_bcc();
                    157:        void ops_sub(Size sz);
                    158:        void ops_add(Size sz);
                    159:        void ops_eor_cmpm(Size sz);
                    160:        void ops_rotate(std::string dir, Size sz);
                    161:        void ops_pmove(Reg reg, Size sz);
                    162:        void ops_fpgen_fpn_fpn();
                    163:        void ops_fpgen_ea_fpn();
                    164:        void ops_fmovecr();
                    165:        void ops_fmove_fpn_ea();
                    166:        void ops_fmovem_ea_ctl();
                    167:        void ops_fmovem_ctl_ea();
                    168:        void ops_fmovem_ea_fpn();
                    169:        void ops_fmovem_fpn_ea();
                    170: 
                    171:        std::vector<uint16> ir {};
                    172: 
                    173:        std::string name;
                    174:        Size size {};
                    175:        std::string src;
                    176:        std::string dst;
                    177: 
                    178: #define OP_PROTO(name) void __CONCAT(op_,name)()
                    179: #define OP_DEF(name)   void __CONCAT(Disasm::op_,name)()
                    180: #define OP_FUNC(name)  __CONCAT(op_,name)()
                    181: #include "m68030ops.h"
                    182: };

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.