branch.cpp
来自「RISC processor ARM-7 emulator」· C++ 代码 · 共 59 行
CPP
59 行
/*************************************************************************
Copyright (C) 2002,2003,2004,2005 Wei Qin
See file COPYING for more information.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*************************************************************************/
#include <cstdio>
#include <armemul.h>
#include "branch.h"
using namespace emulator;
void impl_branch(IMPL_FORMALS)
{
SInt32 offset;
offset = (SInt32)(inst<<8)>>6;
WRITE_REG(PC_REAL_IND, PC + offset);
EMULATOR_STUB(branch,inst);
}
void impl_branch_link(IMPL_FORMALS)
{
SInt32 offset;
offset = (SInt32)(inst<<8)>>6;
WRITE_REG(LRIND, PC - 4);
WRITE_REG(PC_REAL_IND, PC + offset);
EMULATOR_STUB(branch_link,inst);
}
char *disasm_branch(arm_inst_t inst, arm_addr_t pc, char *buf)
{
SInt32 offset = (SInt32)(inst<<8)>>6;
buf += sprintf(buf, "b%s 0x%x;\n",
arm_conditional[COND], pc+8+offset);
return buf;
}
char *disasm_branch_link(arm_inst_t inst, arm_addr_t pc, char *buf)
{
SInt32 offset = (SInt32)(inst<<8)>>6;
buf += sprintf(buf, "bl%s 0x%x;\n",
arm_conditional[COND], pc+8+offset);
return buf;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?