📄 jump_instruction.cpp
字号:
/*
* Copyright (c) 2005 Zhejiang University, P.R.China
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
//=============================================================================
/**
* \file ARM/Jump_Instruction.cpp
*
* $Id: Jump_Instruction.cpp,v 1.3 2005/06/08 07:40:45 qilj Exp $
*
* \author Lingjie Qi <lingjie_qi@163.com>
*/
//=============================================================================
#include "./Jump_Instruction.h"
namespace ARM {
DEFINE_SINGLETON(Jump_Instruction)
s32 Jump_Instruction::signed_immed_24(Core::Instruction_Unit & binary)
{
if(binary & 0x00800000)
{
return (s32)(binary | 0xFF000000 );
}
else
{
return (s32)( binary & 0x00ffffff );
}
}
void Jump_Instruction::execute(Core::Instruction_Unit binary)
{
Core::Binary_32Bit bits(binary);
u32 opcode = bits.convert_to_int(24,27);
u32 val, Rm, operand = (u32)bits.convert_to_int(0,23);
switch(opcode)
{
//! This is a B instruction
case BINARY4(1010):
get_cpu()->read_register(15, val);
val = val + 4 + (signed_immed_24(operand)<<2);
get_cpu()->write_register( 15, val );
break;
//! This is a BL instruction
case BINARY4(1011):
get_cpu()->read_register(15, val);
get_cpu()->write_register( 14, val );
val = val + 4 + (signed_immed_24(operand)<<2);
get_cpu()->write_register( 15, val );
break;
//! This is a BX instruction
case BINARY4(0001):
Core::u32 Rm_index = bits.convert_to_int(0,3);
get_cpu()->read_register(Rm_index, Rm);
val = Rm & 0x1;
assign( get_cpu()->get_cpsr(), 5, 5, val);
val = Rm & 0xFFFFFFFE;
get_cpu()->write_register( 15, val );
}
return ;
}
} //namespace
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -