From 6a06934dde2a21353a7f6e6e8229c5c7ac5d6e19 Mon Sep 17 00:00:00 2001 From: tuz358 Date: Mon, 5 Mar 2018 09:57:32 +0900 Subject: [PATCH] Add dec_r32(0x48~0x4f) instruction --- include/instructions.h | 1 + instructions.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/instructions.h b/include/instructions.h index 2373cc4..db875a3 100644 --- a/include/instructions.h +++ b/include/instructions.h @@ -25,6 +25,7 @@ public: void add_rm32_r32(); // 0x01 void xor_rm32_r32(); // 0x31 + void dec_r32(); // 0x48 ~ 0x4f void mov_rm32_r32(); // 0x89 void nop(); // 0x90 void mov_ecx_imm32(); // 0xb9 diff --git a/instructions.cpp b/instructions.cpp index 511be6d..c023449 100644 --- a/instructions.cpp +++ b/instructions.cpp @@ -22,6 +22,12 @@ void Instructions::init_instructions(){ this->instructions[0x01] = &Instructions::add_rm32_r32; this->instructions[0x31] = &Instructions::xor_rm32_r32; + + for(int i = 0;i < 8;i++){ + // 0x48 ~ 0x4f : dec_r32 + this->instructions[0x48+i] = &Instructions::dec_r32; + } + this->instructions[0x89] = &Instructions::mov_rm32_r32; this->instructions[0x90] = &Instructions::nop; this->instructions[0xb9] = &Instructions::mov_ecx_imm32; @@ -146,6 +152,12 @@ void Instructions::xor_rm32_r32(){ } } +void Instructions::dec_r32(){ + printf("dec_r32 called.\n"); + uint8_t opcode = memory.read_uint8(this->eip-1); + this->registers[opcode - 0x48]--; +} + void Instructions::mov_rm32_r32(){ printf("mov_rm32_r32 called.\n"); uint32_t addr, imm32;