00001 /* 00002 * HT Editor 00003 * ppcdis.h 00004 * 00005 * Copyright (C) 1999-2002 Sebastian Biallas (sb@web-productions.de) 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License version 2 as 00009 * published by the Free Software Foundation. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 */ 00020 00021 #ifndef __PPC_DIS_H__ 00022 #define __PPC_DIS_H__ 00023 00024 #include "asm.h" 00025 #include "global.h" 00026 #include "ppcopc.h" 00027 00028 struct ppcdis_operand { 00029 int flags; 00030 const powerpc_operand *op; 00031 union { 00032 int reg; // general register 00033 int freg; // float register 00034 int creg; // condition register 00035 uint32 imm; 00036 struct { 00037 uint32 disp; 00038 int gr; 00039 } mem; 00040 struct { 00041 uint32 mem; 00042 } abs; 00043 struct { 00044 uint32 mem; 00045 } rel; 00046 }; 00047 }; 00048 00049 struct ppcdis_insn { 00050 bool valid; 00051 int size; 00052 const char * name; 00053 uint32 data; 00054 int ops; 00055 ppcdis_operand op[8]; 00056 }; 00057 00058 class PPCDisassembler: public Disassembler { 00059 protected: 00060 char insnstr[256]; 00061 ppcdis_insn insn; 00062 public: 00063 PPCDisassembler(); 00064 00065 virtual dis_insn *decode(byte *code, int maxlen, CPU_ADDR addr); 00066 virtual dis_insn *duplicateInsn(dis_insn *disasm_insn); 00067 virtual void getOpcodeMetrics(int &min_length, int &max_length, int &min_look_ahead, int &avg_look_ahead, int &addr_align); 00068 virtual byte getSize(dis_insn *disasm_insn); 00069 virtual char *getName(); 00070 virtual char *str(dis_insn *disasm_insn, int style); 00071 virtual char *strf(dis_insn *disasm_insn, int style, char *format); 00072 virtual OBJECT_ID object_id() const; 00073 virtual bool validInsn(dis_insn *disasm_insn); 00074 }; 00075 00076 #endif