00001 /* 00002 * HT Editor 00003 * analy_alpha.cc 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 #include <string.h> 00022 00023 #include "analy_alpha.h" 00024 #include "analy_register.h" 00025 #include "alphadis.h" 00026 #include "htiobox.h" 00027 #include "snprintf.h" 00028 00029 /* 00030 * 00031 */ 00032 void AnalyAlphaDisassembler::init(Analyser *A) 00033 { 00034 disasm = new Alphadis(); 00035 AnalyDisassembler::init(A); 00036 } 00037 00038 /* 00039 * 00040 */ 00041 int AnalyAlphaDisassembler::load(ht_object_stream *f) 00042 { 00043 return AnalyDisassembler::load(f); 00044 } 00045 00046 /* 00047 * 00048 */ 00049 void AnalyAlphaDisassembler::done() 00050 { 00051 AnalyDisassembler::done(); 00052 } 00053 00054 OBJECT_ID AnalyAlphaDisassembler::object_id() const 00055 { 00056 return ATOM_ANALY_ALPHA; 00057 } 00058 00059 /* 00060 * 00061 */ 00062 Address *AnalyAlphaDisassembler::branchAddr(OPCODE *opcode, branch_enum_t branchtype, bool examine) 00063 { 00064 Address *a = createAddress(((alphadis_insn *)opcode)->data); 00065 if (examine && analy->validAddress(a, scvalid)) { 00066 return a; 00067 } 00068 delete a; 00069 return new InvalidAddress(); 00070 } 00071 00072 Address *AnalyAlphaDisassembler::createAddress(dword offset) 00073 { 00074 return new AddressFlat32(offset); 00075 } 00076 00077 /* 00078 * 00079 */ 00080 void AnalyAlphaDisassembler::examineOpcode(OPCODE *opcode) 00081 { 00082 } 00083 00084 /* 00085 * 00086 */ 00087 branch_enum_t AnalyAlphaDisassembler::isBranch(OPCODE *opcode) 00088 { 00089 // FIXME: needs work!! 00090 alphadis_insn *alpha_insn = (alphadis_insn *) opcode; 00091 if (alpha_insn->valid) { 00092 switch ((alpha_insn->table+alpha_insn->code)->type) { 00093 case ALPHA_GROUP_BRA: 00094 if (alpha_insn->table == alpha_instr_tbl) { 00095 switch (alpha_insn->code) { 00096 case 0x30: 00097 return br_jump; 00098 case 0x34: 00099 return br_call; 00100 default: 00101 if (alpha_insn->code > 0x30) return br_jXX; 00102 } 00103 } 00104 return br_nobranch; 00105 case ALPHA_GROUP_JMP: { 00106 switch (alpha_insn->code) { 00107 case 0: 00108 case 3: 00109 case 1: 00110 return br_call; 00111 case 2: 00112 return br_return; 00113 } 00114 } 00115 } 00116 } 00117 return br_nobranch; 00118 } 00119 00120 /* 00121 * 00122 */ 00123 void AnalyAlphaDisassembler::store(ht_object_stream *f) 00124 { 00125 AnalyDisassembler::store(f); 00126 } 00127