1 // license:BSD-3-Clause 2 // copyright-holders:Peter Trauner 3 /***************************************************************************** 4 * 5 * disasm.c 6 * portable lh5801 emulator interface 7 * 8 * 9 *****************************************************************************/ 10 11 #ifndef MAME_CPU_LH5801_5801DASM_H 12 #define MAME_CPU_LH5801_5801DASM_H 13 #ifdef __sun 14 #undef SEC 15 #endif 16 #pragma once 17 18 class lh5801_disassembler : public util::disasm_interface 19 { 20 public: 21 lh5801_disassembler() = default; 22 virtual ~lh5801_disassembler() = default; 23 24 virtual u32 opcode_alignment() const override; 25 virtual offs_t disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer ¶ms) override; 26 27 private: 28 enum Ins 29 { 30 ILL, ILL2, PREFD, NOP, 31 32 LDA, STA, LDI, LDX, STX, 33 LDE, SDE, LIN, SIN, 34 TIN, // (x++)->(y++) 35 ADC, ADI, ADR, SBC, SBI, 36 DCA, DCS, // bcd add and sub 37 CPA, CPI, CIN, // A compared with (x++) 38 AND, ANI, ORA, ORI, EOR, EAI, BIT, BII, 39 INC, DEC, 40 DRL, DRR, // digit rotates 41 ROL, ROR, 42 SHL, SHR, 43 AEX, // A nibble swap 44 45 BCR, BCS, BHR, BHS, BZR, BZS, BVR, BVS, 46 BCH, LOP, // loop with ul 47 JMP, SJP, RTN, RTI, HLT, 48 VCR, VCS, VHR, VHS, VVS, VZR, VZS, 49 VMJ, VEJ, 50 PSH, POP, ATT, TTA, 51 REC, SEC, RIE, SIE, 52 53 AM0, AM1, // load timer reg 54 ITA, // reads input port 55 ATP, // akku send to data bus 56 CDV, // clears internal divider 57 OFF, // clears bf flip flop 58 RDP, SDP,// reset display flip flop 59 RPU, SPU,// flip flop pu off 60 RPV, SPV // flip flop pv off 61 }; 62 63 enum Adr 64 { 65 Imp, 66 Reg, 67 Vec, // imm byte (vector at 0xffxx) 68 Vej, 69 Imm, 70 RegImm, 71 Imm16, 72 RegImm16, 73 ME0, 74 ME0Imm, 75 Abs, 76 AbsImm, 77 ME1, 78 ME1Imm, 79 ME1Abs, 80 ME1AbsImm, 81 RelP, 82 RelM 83 }; 84 85 enum Regs 86 { 87 RegNone, 88 A, 89 XL, XH, X, 90 YL, YH, Y, 91 UL, UH, U, 92 P, S 93 }; 94 95 struct Entry { 96 Ins ins; 97 Adr adr; 98 Regs reg; 99 ins_nameEntry100 const char *ins_name() const { return ins_names[ins]; } reg_nameEntry101 const char *reg_name() const { return reg_names[reg]; } insEntry102 Entry(Ins i, Adr a = Imp, Regs r = RegNone) : ins(i), adr(a), reg(r) { } 103 }; 104 105 static const char *const ins_names[]; 106 static const char *const reg_names[]; 107 108 static const Entry table[0x100]; 109 static const Entry table_fd[0x100]; 110 }; 111 112 #endif 113