📄 armdasm.h
字号:
/**************************************************************************
* DSemu - The Next Generation *
* Portable ARM cores: Common disassembler definition [armdasm.h] *
* Copyright Imran Nazar, 2005; released under the BSD public licence. *
**************************************************************************/
#ifndef __ARMDASM_H_
#define __ARMDASM_H_
#include <string>
#include "datadefs.h"
#include "armmasks.h"
// Defines to simplify the disassembly functions: ARM..
#define DASMOP_COND ((op&MSK_COND)>>SHFT_COND)
#define DASMOP_FUNC ((op&MSK_FUNC)>>SHFT_FUNC)
#define DASMOP_OP ((op&MSK_OP)>>SHFT_OP)
#define DASMOP_RN ((op&MSK_RN)>>SHFT_RN)
#define DASMOP_RD ((op&MSK_RD)>>SHFT_RD)
#define DASMOP_RS ((op&MSK_RS)>>SHFT_RS)
#define DASMOP_RM ((op&MSK_RM)>>SHFT_RM)
#define DASMOP_RO ((op&0x00F00000)>>20)
#define DASMOP_RP DASMOP_FUNC
#define DASMOP_EOP ((op&MSK_OP)>>16)|DASMOP_FUNC
// ..and Thumb
#define TDASMOP_RD (op&TMSK_RD)
#define TDASMOP_RN (op&TMSK_RN)>>TSHFT_RN
#define TDASMOP_RM (op&TMSK_RM)>>TSHFT_RM
#define TDASMOP_RS (op&0x0700)>>8
#define TDASMOP_RDH (op&0x0007)|((op&0x0080)>>4)
#define TDASMOP_RNH ((op&0x0078)>>3)
#define TDASMOP_IMM5 (op&TMSK_IMM5)>>TSHFT_IMM5
#define TDASMOP_IMM8 (op&TMSK_IMM8)
#define TDASMOP_IMM7 (op&TMSK_IMM7)
#define TDASMOP_IMM11 (op&TMSK_IMM11)
class ARMDasm
{
// Allow the world to run disassemblies through the top-level dispatch
public:
ARMDasm(u32 (*)(u32));
std::string disasm(u32,u32);
std::string tdisasm(u16,u32);
private:
static char dout[128];
struct DASMOP {
char str[28];
void (*addr)(u32,u32);
};
static u32 tmp1, tmp2, tmp3, tmp4;
// Pointer to the function used to read memory
static u32 (*rdW)(u32);
// The disassembly opcode tables
static const DASMOP ops[4096];
static const DASMOP tops[256];
static const char* condstr[16];
// Undefined opcode disassembly
static void opun(u32,u32);
// ARM disassemblies
static void opb(u32,u32), opbreg(u32,u32);
static void opreg(u32,u32);
static void opimm(u32,u32);
static void oplli(u32,u32), opllr(u32,u32);
static void oplri(u32,u32), oplrr(u32,u32);
static void opari(u32,u32), oparr(u32,u32);
static void oprri(u32,u32), oprrr(u32,u32);
static void opcimm(u32,u32);
static void opclli(u32,u32), opcllr(u32,u32);
static void opclri(u32,u32), opclrr(u32,u32);
static void opcari(u32,u32), opcarr(u32,u32);
static void opcrri(u32,u32), opcrrr(u32,u32);
static void opofim(u32,u32), opofip(u32,u32);
static void opofrm(u32,u32), opofrp(u32,u32);
static void opprim(u32,u32), opprip(u32,u32);
static void opprrm(u32,u32), opprrp(u32,u32);
static void opptim(u32,u32), opptip(u32,u32);
static void opptrm(u32,u32), opptrp(u32,u32);
static void oplmofim(u32,u32), oplmofip(u32,u32);
static void oplmprim(u32,u32), oplmprip(u32,u32);
static void oplmptim(u32,u32), oplmptip(u32,u32);
static void opofrmll(u32,u32), opofrpll(u32,u32);
static void opofrmlr(u32,u32), opofrplr(u32,u32);
static void opofrmar(u32,u32), opofrpar(u32,u32);
static void opofrmrr(u32,u32), opofrprr(u32,u32);
static void opprrmll(u32,u32), opprrpll(u32,u32);
static void opprrmlr(u32,u32), opprrplr(u32,u32);
static void opprrmar(u32,u32), opprrpar(u32,u32);
static void opprrmrr(u32,u32), opprrprr(u32,u32);
static void opptrmll(u32,u32), opptrpll(u32,u32);
static void opptrmlr(u32,u32), opptrplr(u32,u32);
static void opptrmar(u32,u32), opptrpar(u32,u32);
static void opptrmrr(u32,u32), opptrprr(u32,u32);
static void oplm(u32,u32);
static void opmrsrs(u32,u32), opmrsrc(u32,u32);
static void opmsrrs(u32,u32), opmsrrc(u32,u32);
static void opmsris(u32,u32), opmsric(u32,u32);
static void opswp(u32,u32);
static void opswi(u32,u32);
static void opmul(u32,u32);
static void opmla(u32,u32);
static void opmull(u32,u32);
static void opqadd(u32,u32), opclz(u32,u32);
static void opcpd(u32,u32), opmcr(u32,u32);
// Thumb disassemblies
static void topimm5(u32,u32), topimm5shft(u32,u32);
static void topimm3(u32,u32), topimm8(u32,u32);
static void topimm7(u32,u32);
static void topbc(u32,u32), topb(u32,u32);
static void topbl1(u32,u32), topbx(u32,u32);
static void topbl2(u32,u32);
static void topldm(u32,u32), toph(u32,u32);
static void topbkpt(u32,u32), topswi(u32,u32);
static void toppc(u32,u32), topsp(u32,u32);
static void topdp1(u32,u32), topdp2(u32,u32);
static void topdp3(u32,u32), topdp4(u32,u32);
static void topreg(u32,u32), topund(u32,u32);
};
#endif//__ARMDASM_H_
/*** EOF: armdasm.h ******************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -