diff options
| author | Dennis Brentjes <d.brentjes@gmail.com> | 2018-06-16 16:11:01 +0200 |
|---|---|---|
| committer | Dennis Brentjes <d.brentjes@gmail.com> | 2018-06-16 16:11:01 +0200 |
| commit | 95bc5cd73abd425045889638ccd7dc756419ac15 (patch) | |
| tree | b028dce9fb6bb81feae1c6b2ce3f80f614c89932 | |
| parent | ca642d0c8b0a3dd5f768749b58ba66ac35472610 (diff) | |
| download | openwar-95bc5cd73abd425045889638ccd7dc756419ac15.tar.gz openwar-95bc5cd73abd425045889638ccd7dc756419ac15.tar.bz2 openwar-95bc5cd73abd425045889638ccd7dc756419ac15.zip | |
Implements CLD and O_SMEM as src operand.
| -rw-r--r-- | emulate/emulator.cpp | 7 | ||||
| -rw-r--r-- | emulate/emulator.hpp | 28 |
2 files changed, 35 insertions, 0 deletions
diff --git a/emulate/emulator.cpp b/emulate/emulator.cpp index 8c606a5..805b305 100644 --- a/emulate/emulator.cpp +++ b/emulate/emulator.cpp @@ -263,6 +263,11 @@ void Emulator::handle_I_PUSH(_DInst inst) } } +void Emulator::handle_I_CLD(_DInst inst) +{ + cpu.df() = 0; +} + void Emulator::int_0x21() { switch(cpu.ah()) { //Dos Version @@ -339,6 +344,7 @@ Emulator::Emulator(binparse::Offset32 init_eip, binparse::Offset32 init_esp, std REGISTER_HANDLER(I_OR ); REGISTER_HANDLER(I_ADD ); REGISTER_HANDLER(I_PUSH); + REGISTER_HANDLER(I_CLD ); #undef REGISTER_HANDLER @@ -353,6 +359,7 @@ Emulator::Emulator(binparse::Offset32 init_eip, binparse::Offset32 init_esp, std REGISTER_GETTER(R_BX, bx ); REGISTER_GETTER(R_EBX, ebx); + REGISTER_GETTER(R_CL, cl ); REGISTER_GETTER(R_CX, cx ); REGISTER_GETTER(R_ECX, ecx); diff --git a/emulate/emulator.hpp b/emulate/emulator.hpp index ce0e1c6..fc33722 100644 --- a/emulate/emulator.hpp +++ b/emulate/emulator.hpp @@ -206,6 +206,33 @@ public: } break; } + case O_SMEM: { + auto segment = register_getters.at(SEGMENT_GET(inst.segment))(); + auto segment_offset = ldt[boost::apply_visitor(return_visitor(), segment) >> 3].offset; + auto register_contents = register_getters.at(src_op.index)(); + int32_t offset = boost::apply_visitor(return_visitor(), register_contents) + inst.disp; + std::cout << segment_offset << std::endl << offset << std::endl << inst.disp << std::endl; + std::cout << segment_offset + offset + inst.disp << std::endl; + auto memory_offset = segment_offset + offset + inst.disp; + switch(src_op.size) { + case 8: { + src = *reinterpret_cast<uint8_t*>(&memory[memory_offset]); + break; + } + case 16: { + src = *reinterpret_cast<uint16_t*>(&memory[memory_offset]); + break; + } + case 32: { + src = *reinterpret_cast<uint32_t*>(&memory[memory_offset]); + break; + } + default: { + throw UnhandledInstruction(); + } + } + break; + } default: { throw UnhandledInstruction(); } @@ -231,6 +258,7 @@ public: void handle_I_OR (_DInst inst); void handle_I_ADD (_DInst inst); void handle_I_PUSH(_DInst inst); + void handle_I_CLD (_DInst inst); void int_0x21(); void int_0x31(); |
