From b161f2b85f2bcec66cb0ceaf3ebdb7537eb2efab Mon Sep 17 00:00:00 2001 From: tuz358 Date: Mon, 5 Mar 2018 11:28:20 +0900 Subject: [PATCH] Add cmp_rm32_imm8 instruction --- include/instructions.h | 2 ++ instructions.cpp | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/instructions.h b/include/instructions.h index ee813b5..67b51e7 100644 --- a/include/instructions.h +++ b/include/instructions.h @@ -36,4 +36,6 @@ public: void jmp_imm8(); // 0xeb void hlt(); // 0xf4 void opcode_ff(); // 0xff + + void cmp_rm32_imm8(); }; diff --git a/instructions.cpp b/instructions.cpp index 54b0a7d..f9442ea 100644 --- a/instructions.cpp +++ b/instructions.cpp @@ -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){ if (flag) { this->eflags &= ~flag_type;