summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Brentjes <d.brentjes@gmail.com>2016-10-04 22:34:50 +0200
committerDennis Brentjes <d.brentjes@gmail.com>2016-10-04 22:40:29 +0200
commit44320ada80b08ecf88caf114b2b0be8c8e08e505 (patch)
tree549b4196cd0e492ae2f720252c4adfa2e46f18a6
parent0588b1ad00078daeda76a810b9ba6c68f97206a2 (diff)
downloadopenwar-44320ada80b08ecf88caf114b2b0be8c8e08e505.tar.gz
openwar-44320ada80b08ecf88caf114b2b0be8c8e08e505.tar.bz2
openwar-44320ada80b08ecf88caf114b2b0be8c8e08e505.zip
adds jnz and moves around some output.
-rw-r--r--emulate/emulator.hpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/emulate/emulator.hpp b/emulate/emulator.hpp
index 69c2f46..1d26f99 100644
--- a/emulate/emulator.hpp
+++ b/emulate/emulator.hpp
@@ -293,6 +293,18 @@ public:
interrupt_handlers.at(boost::apply_visitor(return_visitor(), imm))();
}
+ void handle_I_JNZ(_DInst inst) {
+ if(!cpu.zf()) {
+ if(inst.ops[0].type == O_PC || inst.ops[0].type == O_PTR || inst.ops[0].type == O_DISP) {
+ cpu.eip() = INSTRUCTION_GET_TARGET(&inst);
+ } else if (inst.ops[0].type == O_SMEM) {
+ throw UnhandledInstruction();
+ } else {
+ throw UnrecognizedInstruction();
+ }
+ }
+ }
+
void int_0x21() {
if(cpu.ah() == 0x30) {
cpu.al() = 6;
@@ -319,6 +331,7 @@ public:
REGISTER_HANDLER(I_INT);
REGISTER_HANDLER(I_SHR);
REGISTER_HANDLER(I_CMP);
+ REGISTER_HANDLER(I_JNZ);
#undef REGISTER_HANDLER
@@ -392,12 +405,14 @@ void emulate(std::string file_path) {
_DInst decinst;
distorm_decompose(&ci, &decinst, 1, &decodedInstructionsCount);
- emulator.cpu.eip() += decinst.size;
-
_DecodedInst inst;
distorm_format64(&ci, &decinst, &inst);
- std::cout << "CurrentInstruction: " << std::hex << std::setw(8) << std::setfill('0') << inst.offset << ":\t" << inst.mnemonic.p << " " << inst.operands.p << std::endl;
+
std::cout << emulator.cpu << std::endl;
+ std::cout << "CurrentInstruction: " << std::hex << std::setw(8) << std::setfill('0') << inst.offset << ":\t" << inst.mnemonic.p << " " << inst.operands.p << std::endl;
+ std::cout << std::endl << std::endl;
+
+ emulator.cpu.eip() += decinst.size;
emulator.handle_instruction(decinst);
}