From ca332915c84edd98d4f9bdf42f5c414ce46c1f01 Mon Sep 17 00:00:00 2001 From: tuz358 Date: Mon, 5 Mar 2018 11:25:03 +0900 Subject: [PATCH] Add set_flag(int flag, uint32_t flag_type) func and a minor upate --- include/instructions.h | 3 +++ instructions.cpp | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/include/instructions.h b/include/instructions.h index 895b62c..ee813b5 100644 --- a/include/instructions.h +++ b/include/instructions.h @@ -5,9 +5,12 @@ #include "memory.h" #include "utils.h" +const uint32_t ZF = 1 << 6; + class Instructions{ private: void init_instructions(); + void set_flag(int flag, uint32_t flag_type); public: Memory memory; uint32_t registers[8]; // eax, ecx, edx, ebx, esp, ebp, esi, edi diff --git a/instructions.cpp b/instructions.cpp index a166212..54b0a7d 100644 --- a/instructions.cpp +++ b/instructions.cpp @@ -251,3 +251,11 @@ void Instructions::opcode_ff(){ break; } } + +void Instructions::set_flag(int flag, uint32_t flag_type){ + if (flag) { + this->eflags &= ~flag_type; + } else { + this->eflags |= flag_type; + } +}