forked from suyu/suyu
dyncom: Implement SADD8/SSUB8
This commit is contained in:
parent
08b6cf778d
commit
4e2cb06b81
1 changed files with 108 additions and 55 deletions
|
@ -2171,8 +2171,7 @@ ARM_INST_PTR INTERPRETER_TRANSLATE(rsc)(unsigned int inst, int index)
|
||||||
}
|
}
|
||||||
return inst_base;
|
return inst_base;
|
||||||
}
|
}
|
||||||
ARM_INST_PTR INTERPRETER_TRANSLATE(sadd8)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SADD8"); }
|
ARM_INST_PTR INTERPRETER_TRANSLATE(sadd8)(unsigned int inst, int index)
|
||||||
ARM_INST_PTR INTERPRETER_TRANSLATE(sadd16)(unsigned int inst, int index)
|
|
||||||
{
|
{
|
||||||
arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(generic_arm_inst));
|
arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(generic_arm_inst));
|
||||||
generic_arm_inst* const inst_cream = (generic_arm_inst*)inst_base->component;
|
generic_arm_inst* const inst_cream = (generic_arm_inst*)inst_base->component;
|
||||||
|
@ -2190,10 +2189,27 @@ ARM_INST_PTR INTERPRETER_TRANSLATE(sadd16)(unsigned int inst, int index)
|
||||||
|
|
||||||
return inst_base;
|
return inst_base;
|
||||||
}
|
}
|
||||||
|
ARM_INST_PTR INTERPRETER_TRANSLATE(sadd16)(unsigned int inst, int index)
|
||||||
|
{
|
||||||
|
return INTERPRETER_TRANSLATE(sadd8)(inst, index);
|
||||||
|
}
|
||||||
ARM_INST_PTR INTERPRETER_TRANSLATE(saddsubx)(unsigned int inst, int index)
|
ARM_INST_PTR INTERPRETER_TRANSLATE(saddsubx)(unsigned int inst, int index)
|
||||||
{
|
{
|
||||||
return INTERPRETER_TRANSLATE(sadd16)(inst, index);
|
return INTERPRETER_TRANSLATE(sadd8)(inst, index);
|
||||||
}
|
}
|
||||||
|
ARM_INST_PTR INTERPRETER_TRANSLATE(ssub8)(unsigned int inst, int index)
|
||||||
|
{
|
||||||
|
return INTERPRETER_TRANSLATE(sadd8)(inst, index);
|
||||||
|
}
|
||||||
|
ARM_INST_PTR INTERPRETER_TRANSLATE(ssub16)(unsigned int inst, int index)
|
||||||
|
{
|
||||||
|
return INTERPRETER_TRANSLATE(sadd8)(inst, index);
|
||||||
|
}
|
||||||
|
ARM_INST_PTR INTERPRETER_TRANSLATE(ssubaddx)(unsigned int inst, int index)
|
||||||
|
{
|
||||||
|
return INTERPRETER_TRANSLATE(sadd8)(inst, index);
|
||||||
|
}
|
||||||
|
|
||||||
ARM_INST_PTR INTERPRETER_TRANSLATE(sbc)(unsigned int inst, int index)
|
ARM_INST_PTR INTERPRETER_TRANSLATE(sbc)(unsigned int inst, int index)
|
||||||
{
|
{
|
||||||
arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(sbc_inst));
|
arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(sbc_inst));
|
||||||
|
@ -2408,15 +2424,7 @@ ARM_INST_PTR INTERPRETER_TRANSLATE(ssat16)(unsigned int inst, int index)
|
||||||
|
|
||||||
return inst_base;
|
return inst_base;
|
||||||
}
|
}
|
||||||
ARM_INST_PTR INTERPRETER_TRANSLATE(ssub8)(unsigned int inst, int index) { UNIMPLEMENTED_INSTRUCTION("SSUB8"); }
|
|
||||||
ARM_INST_PTR INTERPRETER_TRANSLATE(ssub16)(unsigned int inst, int index)
|
|
||||||
{
|
|
||||||
return INTERPRETER_TRANSLATE(sadd16)(inst, index);
|
|
||||||
}
|
|
||||||
ARM_INST_PTR INTERPRETER_TRANSLATE(ssubaddx)(unsigned int inst, int index)
|
|
||||||
{
|
|
||||||
return INTERPRETER_TRANSLATE(sadd16)(inst, index);
|
|
||||||
}
|
|
||||||
ARM_INST_PTR INTERPRETER_TRANSLATE(stc)(unsigned int inst, int index)
|
ARM_INST_PTR INTERPRETER_TRANSLATE(stc)(unsigned int inst, int index)
|
||||||
{
|
{
|
||||||
arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(stc_inst));
|
arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(stc_inst));
|
||||||
|
@ -5039,6 +5047,7 @@ unsigned InterpreterMainLoop(ARMul_State* state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SADD8_INST:
|
SADD8_INST:
|
||||||
|
SSUB8_INST:
|
||||||
SADD16_INST:
|
SADD16_INST:
|
||||||
SADDSUBX_INST:
|
SADDSUBX_INST:
|
||||||
SSUBADDX_INST:
|
SSUBADDX_INST:
|
||||||
|
@ -5046,7 +5055,9 @@ unsigned InterpreterMainLoop(ARMul_State* state) {
|
||||||
{
|
{
|
||||||
if (inst_base->cond == 0xE || CondPassed(cpu, inst_base->cond)) {
|
if (inst_base->cond == 0xE || CondPassed(cpu, inst_base->cond)) {
|
||||||
generic_arm_inst* const inst_cream = (generic_arm_inst*)inst_base->component;
|
generic_arm_inst* const inst_cream = (generic_arm_inst*)inst_base->component;
|
||||||
|
const u8 op2 = inst_cream->op2;
|
||||||
|
|
||||||
|
if (op2 == 0x00 || op2 == 0x01 || op2 == 0x02 || op2 == 0x03) {
|
||||||
const s16 rn_lo = (RN & 0xFFFF);
|
const s16 rn_lo = (RN & 0xFFFF);
|
||||||
const s16 rn_hi = ((RN >> 16) & 0xFFFF);
|
const s16 rn_hi = ((RN >> 16) & 0xFFFF);
|
||||||
const s16 rm_lo = (RM & 0xFFFF);
|
const s16 rm_lo = (RM & 0xFFFF);
|
||||||
|
@ -5061,17 +5072,17 @@ unsigned InterpreterMainLoop(ARMul_State* state) {
|
||||||
hi_result = (rn_hi + rm_hi);
|
hi_result = (rn_hi + rm_hi);
|
||||||
}
|
}
|
||||||
// SASX
|
// SASX
|
||||||
else if (inst_cream->op2 == 0x01) {
|
else if (op2 == 0x01) {
|
||||||
lo_result = (rn_lo - rm_hi);
|
lo_result = (rn_lo - rm_hi);
|
||||||
hi_result = (rn_hi + rm_lo);
|
hi_result = (rn_hi + rm_lo);
|
||||||
}
|
}
|
||||||
// SSAX
|
// SSAX
|
||||||
else if (inst_cream->op2 == 0x02) {
|
else if (op2 == 0x02) {
|
||||||
lo_result = (rn_lo + rm_hi);
|
lo_result = (rn_lo + rm_hi);
|
||||||
hi_result = (rn_hi - rm_lo);
|
hi_result = (rn_hi - rm_lo);
|
||||||
}
|
}
|
||||||
// SSUB16
|
// SSUB16
|
||||||
else if (inst_cream->op2 == 0x03) {
|
else if (op2 == 0x03) {
|
||||||
lo_result = (rn_lo - rm_lo);
|
lo_result = (rn_lo - rm_lo);
|
||||||
hi_result = (rn_hi - rm_hi);
|
hi_result = (rn_hi - rm_hi);
|
||||||
}
|
}
|
||||||
|
@ -5094,6 +5105,48 @@ unsigned InterpreterMainLoop(ARMul_State* state) {
|
||||||
cpu->Cpsr &= ~(1 << 19);
|
cpu->Cpsr &= ~(1 << 19);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (op2 == 0x04 || op2 == 0x07) {
|
||||||
|
s32 lo_val1, lo_val2;
|
||||||
|
s32 hi_val1, hi_val2;
|
||||||
|
|
||||||
|
// SADD8
|
||||||
|
if (op2 == 0x04) {
|
||||||
|
lo_val1 = (s32)(s8)(RN & 0xFF) + (s32)(s8)(RM & 0xFF);
|
||||||
|
lo_val2 = (s32)(s8)((RN >> 8) & 0xFF) + (s32)(s8)((RM >> 8) & 0xFF);
|
||||||
|
hi_val1 = (s32)(s8)((RN >> 16) & 0xFF) + (s32)(s8)((RM >> 16) & 0xFF);
|
||||||
|
hi_val2 = (s32)(s8)((RN >> 24) & 0xFF) + (s32)(s8)((RM >> 24) & 0xFF);
|
||||||
|
}
|
||||||
|
// SSUB8
|
||||||
|
else {
|
||||||
|
lo_val1 = (s32)(s8)(RN & 0xFF) - (s32)(s8)(RM & 0xFF);
|
||||||
|
lo_val2 = (s32)(s8)((RN >> 8) & 0xFF) - (s32)(s8)((RM >> 8) & 0xFF);
|
||||||
|
hi_val1 = (s32)(s8)((RN >> 16) & 0xFF) - (s32)(s8)((RM >> 16) & 0xFF);
|
||||||
|
hi_val2 = (s32)(s8)((RN >> 24) & 0xFF) - (s32)(s8)((RM >> 24) & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
RD = ((lo_val1 & 0xFF) | ((lo_val2 & 0xFF) << 8) | ((hi_val1 & 0xFF) << 16) | ((hi_val2 & 0xFF) << 24));
|
||||||
|
|
||||||
|
if (lo_val1 >= 0)
|
||||||
|
cpu->Cpsr |= (1 << 16);
|
||||||
|
else
|
||||||
|
cpu->Cpsr &= ~(1 << 16);
|
||||||
|
|
||||||
|
if (lo_val2 >= 0)
|
||||||
|
cpu->Cpsr |= (1 << 17);
|
||||||
|
else
|
||||||
|
cpu->Cpsr &= ~(1 << 17);
|
||||||
|
|
||||||
|
if (hi_val1 >= 0)
|
||||||
|
cpu->Cpsr |= (1 << 18);
|
||||||
|
else
|
||||||
|
cpu->Cpsr &= ~(1 << 18);
|
||||||
|
|
||||||
|
if (hi_val2 >= 0)
|
||||||
|
cpu->Cpsr |= (1 << 19);
|
||||||
|
else
|
||||||
|
cpu->Cpsr &= ~(1 << 19);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cpu->Reg[15] += GET_INST_SIZE(cpu);
|
cpu->Reg[15] += GET_INST_SIZE(cpu);
|
||||||
INC_PC(sizeof(generic_arm_inst));
|
INC_PC(sizeof(generic_arm_inst));
|
||||||
|
@ -5407,7 +5460,7 @@ unsigned InterpreterMainLoop(ARMul_State* state) {
|
||||||
FETCH_INST;
|
FETCH_INST;
|
||||||
GOTO_NEXT_INST;
|
GOTO_NEXT_INST;
|
||||||
}
|
}
|
||||||
SSUB8_INST:
|
|
||||||
STC_INST:
|
STC_INST:
|
||||||
{
|
{
|
||||||
// Instruction not implemented
|
// Instruction not implemented
|
||||||
|
|
Loading…
Reference in a new issue