Add cmp_rm32_imm8 instruction

This commit is contained in:
tuz358
2018-03-05 11:28:20 +09:00
parent ca332915c8
commit b161f2b85f
2 changed files with 15 additions and 0 deletions

View File

@@ -36,4 +36,6 @@ public:
void jmp_imm8(); // 0xeb void jmp_imm8(); // 0xeb
void hlt(); // 0xf4 void hlt(); // 0xf4
void opcode_ff(); // 0xff void opcode_ff(); // 0xff
void cmp_rm32_imm8();
}; };

View File

@@ -252,6 +252,19 @@ void Instructions::opcode_ff(){
} }
} }
void Instructions::cmp_rm32_imm8(){
printf("cmp_rm32_imm8 called.\n");
this->modrm = memory.read_uint8(this->eip);
this->calc_modrm();
this->eip++;
uint8_t imm8 = memory.read_uint8(this->eip);
uint32_t result = this->registers[this->M] - imm8;
set_flag(!result, ZF);
}
void Instructions::set_flag(int flag, uint32_t flag_type){ void Instructions::set_flag(int flag, uint32_t flag_type){
if (flag) { if (flag) {
this->eflags &= ~flag_type; this->eflags &= ~flag_type;