Add cmp_rm32_imm(0x81,0x83) instruction

This commit is contained in:
tuz358
2018-03-19 00:45:35 +09:00
parent 41c52b1388
commit 2b42720df0
2 changed files with 14 additions and 9 deletions

View File

@@ -139,5 +139,5 @@ public:
void and_rm32_imm(int imm_flag);
void sub_rm32_imm(int imm_flag);
void xor_rm32_imm(int imm_flag);
void cmp_rm32_imm8();
void cmp_rm32_imm(int imm_flag);
};

View File

@@ -493,7 +493,7 @@ void Instructions::opcode_81(){
xor_rm32_imm(IMM32);
break;
case 7:
// TODO: cmp_rm32_imm8();
cmp_rm32_imm(IMM32);
break;
default:
break;
@@ -514,7 +514,7 @@ void Instructions::opcode_83(){
case 4: and_rm32_imm(IMM8); break;
case 5: sub_rm32_imm(IMM8); break;
case 6: xor_rm32_imm(IMM8); break;
case 7: cmp_rm32_imm8(); break;
case 7: cmp_rm32_imm(IMM8); break;
default: break;
}
}
@@ -893,15 +893,20 @@ void Instructions::xor_rm32_imm(int imm_flag){
this->eip++;
}
void Instructions::cmp_rm32_imm8(){
//printf("cmp_rm32_imm8 called.\n");
void Instructions::cmp_rm32_imm(int imm_flag){
//printf("cmp_rm32_imm called.\n");
this->eip++;
uint8_t imm8 = memory.read_uint8(this->eip);
//printf("imm8: 0x%08x (%d)\n", imm8, imm8);
uint32_t result = this->registers[this->M] - imm8;
set_flag(!result, ZF);
if(imm_flag == IMM8){
uint8_t imm8 = memory.read_uint8(this->eip);
set_flag(!(this->registers[this->M] - imm8), ZF);
} else if(imm_flag == IMM32){
uint32_t imm32 = memory.read_uint32(this->eip);
imm32 = swap_endian32(imm32);
set_flag(!(this->registers[this->M] - imm32), ZF);
} else {
}
this->eip++;
}