📄 data_process_instruction.cpp
字号:
get_cpu()->get_cpsr().set(30,1);
else
get_cpu()->get_cpsr().set(30,0);
Core::Binary_32Bit rn_bits(rn_data);
if(rn_data >= shifter_operand)
get_cpu()->get_cpsr().set(29,1);
else
get_cpu()->get_cpsr().set(29,0);
if(rn_bits.get(31) != operand_bits.get(31) && fact_bits.get(31) != rn_bits.get(31))
get_cpu()->get_cpsr().set(28,1);
else
get_cpu()->get_cpsr().set(28,0);
}
return;
}
void Data_Process_Instruction::RSB(Core::Instruction_Unit & binary)
{
Core::Binary_32Bit bits(binary);
u32 rn_index = bits.convert_to_int(16,19);
u32 rd_index = bits.convert_to_int(12,15);
u32 rn_data;
get_cpu()->read_register(rn_index,rn_data);
u32 shifter_operand;
u32 extra = 0;
if(bits.get(25))
{
shifter_operand = this->immediate_generator(bits);
}
else
{
shifter_operand = this->shift_imm_generator(bits);
}
if(rn_index == 15)
extra = 4;
rn_data += extra;
Core::Binary_32Bit operand_bits(shifter_operand);
u32 fact = shifter_operand - rn_data;
Core::Binary_32Bit fact_bits(fact);
get_cpu()->write_register(rd_index,fact);
if(bits.get(20) && rd_index == 15) // if s ==1 && rd == r15
{
u32 spsr_data = get_cpu()->get_spsr().convert_to_int();
get_cpu()->get_cpsr().convert_from_int(spsr_data);
ARM_CPU::CPU_Interrupt temp_iter = get_cpu()->pop_exception();
get_cpu()->set_exp_priority(temp_iter);
get_cpu()->set_cpu_mode();
}
else
if(bits.get(20))
{
get_cpu()->get_cpsr().set(31,fact_bits.get(31));
if(fact == 0)
get_cpu()->get_cpsr().set(30,1);
else
get_cpu()->get_cpsr().set(30,0);
Core::Binary_32Bit rn_bits(rn_data);
if(shifter_operand >= rn_data)
get_cpu()->get_cpsr().set(29,1);
else
get_cpu()->get_cpsr().set(29,0);
if(rn_bits.get(31) != operand_bits.get(31) && fact_bits.get(31) != operand_bits.get(31))
get_cpu()->get_cpsr().set(28,1);
else
get_cpu()->get_cpsr().set(28,0);
}
return;
}
void Data_Process_Instruction::ADC(Core::Instruction_Unit & binary)
{
Core::Binary_32Bit bits(binary);
u32 rn_index = bits.convert_to_int(16,19);
u32 rd_index = bits.convert_to_int(12,15);
u32 rn_data;
get_cpu()->read_register(rn_index,rn_data);
u32 shifter_operand;
u32 extra = 0;
if(bits.get(25))
{
shifter_operand = this->immediate_generator(bits);
}
else
{
shifter_operand = this->shift_imm_generator(bits);
}
if(rn_index == 15)
extra = 4;
rn_data += extra;
Core::Binary_32Bit operand_bits(shifter_operand);
u32 fact = rn_data + shifter_operand + (u32)get_cpu()->get_cpsr().test(29);
Core::Binary_32Bit fact_bits(fact);
get_cpu()->write_register(rd_index,fact);
if(bits.get(20) && rd_index == 15) // if s ==1 && rd == r15
{
u32 spsr_data = get_cpu()->get_spsr().convert_to_int();
get_cpu()->get_cpsr().convert_from_int(spsr_data);
ARM_CPU::CPU_Interrupt temp_iter = get_cpu()->pop_exception();
get_cpu()->set_exp_priority(temp_iter);
get_cpu()->set_cpu_mode();
}
else
if(bits.get(20))
{
get_cpu()->get_cpsr().set(31,fact_bits.get(31));
if(fact == 0)
get_cpu()->get_cpsr().set(30,1);
else
get_cpu()->get_cpsr().set(30,0);
Core::Binary_32Bit rn_bits(rn_data);
if(fact < shifter_operand || fact < rn_data || fact < (u32)get_cpu()->get_cpsr().test(29))
get_cpu()->get_cpsr().set(29,1);
else
get_cpu()->get_cpsr().set(29,0);
if(rn_bits.get(31) == operand_bits.get(31) && fact_bits.get(31) != rn_bits.get(31))
get_cpu()->get_cpsr().set(28,1);
else
get_cpu()->get_cpsr().set(28,0);
}
return;
}
void Data_Process_Instruction::SBC(Core::Instruction_Unit & binary)
{
Core::Binary_32Bit bits(binary);
u32 rn_index = bits.convert_to_int(16,19);
u32 rd_index = bits.convert_to_int(12,15);
u32 rn_data;
get_cpu()->read_register(rn_index,rn_data);
u32 shifter_operand;
u32 extra = 0;
if(bits.get(25))
{
shifter_operand = this->immediate_generator(bits);
}
else
{
shifter_operand = this->shift_imm_generator(bits);
}
if(rn_index == 15)
extra = 4;
rn_data += extra;
Core::Binary_32Bit operand_bits(shifter_operand);
u32 fact = rn_data - shifter_operand - (u32)(1 - get_cpu()->get_cpsr().test(29));
Core::Binary_32Bit fact_bits(fact);
get_cpu()->write_register(rd_index,fact);
if(bits.get(20) && rd_index == 15) // if s ==1 && rd == r15
{
u32 spsr_data = get_cpu()->get_spsr().convert_to_int();
get_cpu()->get_cpsr().convert_from_int(spsr_data);
ARM_CPU::CPU_Interrupt temp_iter = get_cpu()->pop_exception();
get_cpu()->set_exp_priority(temp_iter);
get_cpu()->set_cpu_mode();
}
else
if(bits.get(20))
{
get_cpu()->get_cpsr().set(31,fact_bits.get(31));
if(fact == 0)
get_cpu()->get_cpsr().set(30,1);
else
get_cpu()->get_cpsr().set(30,0);
Core::Binary_32Bit rn_bits(rn_data);
if(rn_data >= shifter_operand + (u32)(1 - get_cpu()->get_cpsr().test(29)))
get_cpu()->get_cpsr().set(29,1);
else
get_cpu()->get_cpsr().set(29,0);
if(rn_bits.get(31) != operand_bits.get(31) && fact_bits.get(31) != rn_bits.get(31))
get_cpu()->get_cpsr().set(28,1);
else
get_cpu()->get_cpsr().set(28,0);
}
return;
}
void Data_Process_Instruction::RSC(Core::Instruction_Unit & binary)
{
Core::Binary_32Bit bits(binary);
u32 rn_index = bits.convert_to_int(16,19);
u32 rd_index = bits.convert_to_int(12,15);
u32 rn_data;
get_cpu()->read_register(rn_index,rn_data);
u32 shifter_operand;
u32 extra = 0;
if(bits.get(25))
{
shifter_operand = this->immediate_generator(bits);
}
else
{
shifter_operand = this->shift_imm_generator(bits);
}
if(rn_index == 15)
extra = 4;
rn_data += extra;
Core::Binary_32Bit operand_bits(shifter_operand);
u32 fact = shifter_operand - rn_data + (u32)(get_cpu()->get_cpsr().test(29)) - 1;
Core::Binary_32Bit fact_bits(fact);
get_cpu()->write_register(rd_index,fact);
if(bits.get(20) && rd_index == 15) // if s ==1 && rd == r15
{
u32 spsr_data = get_cpu()->get_spsr().convert_to_int();
get_cpu()->get_cpsr().convert_from_int(spsr_data);
ARM_CPU::CPU_Interrupt temp_iter = get_cpu()->pop_exception();
get_cpu()->set_exp_priority(temp_iter);
get_cpu()->set_cpu_mode();
}
else
if(bits.get(20))
{
get_cpu()->get_cpsr().set(31,fact_bits.get(31));
if(fact == 0)
get_cpu()->get_cpsr().set(30,1);
else
get_cpu()->get_cpsr().set(30,0);
Core::Binary_32Bit rn_bits(rn_data);
if(shifter_operand >= rn_data)
get_cpu()->get_cpsr().set(29,1);
else
get_cpu()->get_cpsr().set(29,0);
if(rn_bits.get(31) != operand_bits.get(31) && fact_bits.get(31) != operand_bits.get(31))
get_cpu()->get_cpsr().set(28,1);
else
get_cpu()->get_cpsr().set(28,0);
}
return;
}
void Data_Process_Instruction::AND(Core::Instruction_Unit & binary)
{
Core::Binary_32Bit bits(binary);
u32 rn_index = bits.convert_to_int(16,19);
u32 rd_index = bits.convert_to_int(12,15);
u32 rn_data;
get_cpu()->read_register(rn_index,rn_data);
u32 shifter_operand;
u32 extra = 0;
if(bits.get(25))
{
shifter_operand = this->immediate_generator(bits);
}
else
{
shifter_operand = this->shift_imm_generator(bits);
}
if(rn_index == 15)
extra = 4;
rn_data += extra;
u32 fact = rn_data & shifter_operand;
Core::Binary_32Bit fact_bits(fact);
get_cpu()->write_register(rd_index,fact);
if(bits.get(20) && rd_index == 15) // if s ==1 && rd == r15
{
u32 spsr_data = get_cpu()->get_spsr().convert_to_int();
get_cpu()->get_cpsr().convert_from_int(spsr_data);
ARM_CPU::CPU_Interrupt temp_iter = get_cpu()->pop_exception();
get_cpu()->set_exp_priority(temp_iter);
get_cpu()->set_cpu_mode();
}
else
if(bits.get(20))
{
get_cpu()->get_cpsr().set(31,fact_bits.get(31));
if(fact == 0)
get_cpu()->get_cpsr().set(30,1);
else
get_cpu()->get_cpsr().set(30,0);
get_cpu()->get_cpsr().set(29,get_cpu()->get_shifter_carry_out());
}
return ;
}
void Data_Process_Instruction::BIC(Core::Instruction_Unit & binary)
{
Core::Binary_32Bit bits(binary);
u32 rn_index = bits.convert_to_int(16,19);
u32 rd_index = bits.convert_to_int(12,15);
u32 rn_data;
get_cpu()->read_register(rn_index,rn_data);
u32 shifter_operand;
u32 extra = 0;
if(bits.get(25))
{
shifter_operand = this->immediate_generator(bits);
}
else
{
shifter_operand = this->shift_imm_generator(bits);
}
if(rn_index == 15)
extra = 4;
rn_data += extra;
u32 fact = rn_data & (~shifter_operand);
Core::Binary_32Bit fact_bits(fact);
get_cpu()->write_register(rd_index,fact);
if(bits.get(20) && rd_index == 15) // if s ==1 && rd == r15
{
u32 spsr_data = get_cpu()->get_spsr().convert_to_int();
get_cpu()->get_cpsr().convert_from_int(spsr_data);
ARM_CPU::CPU_Interrupt temp_iter = get_cpu()->pop_exception();
get_cpu()->set_exp_priority(temp_iter);
get_cpu()->set_cpu_mode();
}
else
if(bits.get(20))
{
get_cpu()->get_cpsr().set(31,fact_bits.get(31));
if(fact == 0)
get_cpu()->get_cpsr().set(30,1);
else
get_cpu()->get_cpsr().set(30,0);
get_cpu()->get_cpsr().set(29,get_cpu()->get_shifter_carry_out());
}
return;
}
void Data_Process_Instruction::EOR(Core::Instruction_Unit & binary)
{
Core::Binary_32Bit bits(binary);
u32 rn_index = bits.convert_to_int(16,19);
u32 rd_index = bits.convert_to_int(12,15);
u32 rn_data;
get_cpu()->read_register(rn_index,rn_data);
u32 shifter_operand;
u32 extra = 0;
if(bits.get(25))
{
shifter_operand = this->immediate_generator(bits);
}
else
{
shifter_operand = this->shift_imm_generator(bits);
}
if(rn_index == 15)
extra = 4;
rn_data += extra;
u32 fact = rn_data ^ shifter_operand;
Core::Binary_32Bit fact_bits(fact);
get_cpu()->write_register(rd_index,fact);
if(bits.get(20) && rd_index == 15) // if s ==1 && rd == r15
{
u32 spsr_data = get_cpu()->get_spsr().convert_to_int();
get_cpu()->get_cpsr().convert_from_int(spsr_data);
ARM_CPU::CPU_Interrupt temp_iter = get_cpu()->pop_exception();
get_cpu()->set_exp_priority(temp_iter);
get_cpu()->set_cpu_mode();
}
else
if(bits.get(20))
{
get_cpu()->get_cpsr().set(31,fact_bits.get(31));
if(fact == 0)
get_cpu()->get_cpsr().set(30,1);
else
get_cpu()->get_cpsr().set(30,0);
get_cpu()->get_cpsr().set(29,get_cpu()->get_shifter_carry_out());
}
return ;
}
void Data_Process_Instruction::ORR(Core::Instruction_Unit & binary)
{
Core::Binary_32Bit bits(binary);
u32 rn_index = bits.convert_to_int(16,19);
u32 rd_index = bits.convert_to_int(12,15);
u32 rn_data;
get_cpu()->read_register(rn_index,rn_data);
u32 shifter_operand;
u32 extra = 0;
if(bits.get(25))
{
shifter_operand = this->immediate_generator(bits);
}
else
{
shifter_operand = this->shift_imm_generator(bits);
}
if(rn_index == 15)
extra = 4;
rn_data += extra;
u32 fact = rn_data | shifter_operand;
Core::Binary_32Bit fact_bits(fact);
get_cpu()->write_register(rd_index,fact);
if(bits.get(20) && rd_index == 15) // if s ==1 && rd == r15
{
u32 spsr_data = get_cpu()->get_spsr().convert_to_int();
get_cpu()->get_cpsr().convert_from_int(spsr_data);
ARM_CPU::CPU_Interrupt temp_iter = get_cpu()->pop_exception();
get_cpu()->set_exp_priority(temp_iter);
get_cpu()->set_cpu_mode();
}
else
if(bits.get(20))
{
get_cpu()->get_cpsr().set(31,fact_bits.get(31));
if(fact == 0)
get_cpu()->get_cpsr().set(30,1);
else
get_cpu()->get_cpsr().set(30,0);
get_cpu()->get_cpsr().set(29,get_cpu()->get_shifter_carry_out());
}
return ;
}
void Data_Process_Instruction::SWP(Core::Instruction_Unit & binary)
{
Core::Binary_32Bit bits(binary);
Core::Bytecode_Type buffer;
u32 Rm, addr, value;
u32 Rm_index = bits.convert_to_int(0,3);
u32 Rn_index = bits.convert_to_int(16,19);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -