From 739297d8895b08a9ecd8e81b01b7ba8e8dc4a8ae Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 21 Nov 2020 22:57:25 +0100 Subject: Bugfix push + pop --- asm/intel64/mov.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'asm/intel64/mov.cpp') diff --git a/asm/intel64/mov.cpp b/asm/intel64/mov.cpp index 5d09def..805675a 100644 --- a/asm/intel64/mov.cpp +++ b/asm/intel64/mov.cpp @@ -51,6 +51,23 @@ Op_mov::Op_mov(const Asm::Args& args) } else if (args[0].type() == typeid(Asm::Args::Register64) && args[1].type() == typeid(Asm::Args::Immediate32)) { // mov reg64, imm32 (sign-extended) machine_code = REX("W") + std::vector{ 0xC7 } + ModRM("/0", std::any_cast(args[0]).name()) + std::any_cast(args[1]).getCode(); + } else if (args[0].type() == typeid(Asm::Args::Mem8Ptr64) && args[1].type() == typeid(Asm::Args::Immediate8)) { // mov [reg64], imm8 + Asm::Args::Mem8Ptr64 ptr{std::any_cast(args[0])}; + machine_code = std::vector{ 0xC6 } + ModRM("/0", ptr.reg(), ptr.offs()) + std::any_cast(args[1]).getCode(); + + } else if (args[0].type() == typeid(Asm::Args::Mem32Ptr64) && args[1].type() == typeid(Asm::Args::Immediate32)) { // mov [reg64], imm32 + Asm::Args::Mem32Ptr64 ptr{std::any_cast(args[0])}; + machine_code = std::vector{ 0xC7 } + ModRM("/0", ptr.reg(), ptr.offs()) + std::any_cast(args[1]).getCode(); + + } else if (args[0].type() == typeid(Asm::Args::Mem64Ptr64) && args[1].type() == typeid(Asm::Args::Immediate32)) { // mov [reg64], imm32 (sign-extended to imm64) + Asm::Args::Mem64Ptr64 ptr{std::any_cast(args[0])}; + machine_code = REX("W") + std::vector{ 0xC7 } + ModRM("/0", ptr.reg(), ptr.offs()) + std::any_cast(args[1]).getCode(); + + } else if (args[0].type() == typeid(Asm::Args::Mem64Ptr64) && args[1].type() == typeid(Asm::Args::Immediate64)) { // mov [reg64], imm64 (cut to imm32) + Asm::Args::Mem64Ptr64 ptr{std::any_cast(args[0])}; + Asm::Args::Immediate32 imm32{std::any_cast(args[1])}; + machine_code = REX("W") + std::vector{ 0xC7 } + ModRM("/0", ptr.reg(), ptr.offs()) + imm32.getCode(); + } else { throw std::runtime_error("Unimplemented: mov "s + args[0].type().name() + " "s + args[1].type().name()); } @@ -88,6 +105,18 @@ bool registered { }) && registerOp(mangleName("mov"), [](const Asm::Args& args) -> std::shared_ptr{ return std::make_shared(args); + }) && + registerOp(mangleName("mov"), [](const Asm::Args& args) -> std::shared_ptr{ + return std::make_shared(args); + }) && + registerOp(mangleName("mov"), [](const Asm::Args& args) -> std::shared_ptr{ + return std::make_shared(args); + }) && + registerOp(mangleName("mov"), [](const Asm::Args& args) -> std::shared_ptr{ + return std::make_shared(args); + }) && + registerOp(mangleName("mov"), [](const Asm::Args& args) -> std::shared_ptr{ + return std::make_shared(args); }) }; -- cgit v1.2.3