From 2bd7b72618921380e600bf888af281f33a0eaed7 Mon Sep 17 00:00:00 2001 From: tuz358 Date: Wed, 14 Mar 2018 08:32:04 +0900 Subject: [PATCH] Add je_imm8(0x74) instruction --- include/instructions.h | 1 + instructions.cpp | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/instructions.h b/include/instructions.h index f02828a..e3366a5 100644 --- a/include/instructions.h +++ b/include/instructions.h @@ -85,6 +85,7 @@ public: void pop_edi(); // 0x5f void push_imm32(); // 0x68 void push_imm8(); // 0x6a + void je_imm8(); // 0x74 void jne_imm8(); // 0x75 void opcode_83(); // 0x83 void mov_rm32_r32(); // 0x89 diff --git a/instructions.cpp b/instructions.cpp index 28a2e32..c4c4908 100644 --- a/instructions.cpp +++ b/instructions.cpp @@ -31,7 +31,7 @@ void Instructions::init_instructions(){ this->instructions[0x15] = &Instructions::adc_eax_imm32; this->instructions[0x19] = &Instructions::sbb_rm32_r32; this->instructions[0x1b] = &Instructions::sbb_r32_rm32; - this->instructions[0x1d] = &Instructions::sbb_eax_imm32; + this->instructions[0x1d] = &Instructions::sbb_eax_imm32; this->instructions[0x21] = &Instructions::and_rm32_r32; this->instructions[0x23] = &Instructions::and_r32_rm32; this->instructions[0x25] = &Instructions::and_eax_imm32; @@ -78,6 +78,7 @@ void Instructions::init_instructions(){ this->instructions[0x5f] = &Instructions::pop_edi; this->instructions[0x68] = &Instructions::push_imm32; this->instructions[0x6a] = &Instructions::push_imm8; + this->instructions[0x74] = &Instructions::je_imm8; this->instructions[0x75] = &Instructions::jne_imm8; this->instructions[0x83] = &Instructions::opcode_83; this->instructions[0x89] = &Instructions::mov_rm32_r32; @@ -1132,6 +1133,18 @@ void Instructions::push_imm8(){ this->eip++; } +void Instructions::je_imm8(){ + //printf("je_imm8 called.\n"); + + int8_t imm8 = memory.read_int8(this->eip); + + int zero_flag = this->get_flag(ZF); + if (zero_flag){ + this->eip += imm8; + } + this->eip++; +} + void Instructions::jne_imm8(){ //printf("jne_imm8 called.\n");