From 8a2d1dc5c8b6639985d26d1c915048d87d52426b Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 18 Oct 2020 16:59:54 +0200 Subject: Added xor, mov, jmp --- asm/intel64/add.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'asm/intel64/add.cpp') diff --git a/asm/intel64/add.cpp b/asm/intel64/add.cpp index dc5c704..2de2219 100644 --- a/asm/intel64/add.cpp +++ b/asm/intel64/add.cpp @@ -9,10 +9,16 @@ using namespace std::string_literals; Op_add::Op_add(AsmArgs& args) { - if (args[0].type() == typeid(Register32) && std::any_cast(args[0]).name() == "eax" && args[1].type() == typeid(Immediate32)) { // add eax, imm32 - machine_code = std::vector{ 0x05 } + std::any_cast(args[1]).getCode(); - } else if (args[0].type() == typeid(Register64) && std::any_cast(args[0]).name() == "rax" && args[1].type() == typeid(Immediate32)) { // add rax, imm32 - machine_code = REX("W") + std::vector{ 0x05 } + std::any_cast(args[1]).getCode(); + if (args[0].type() == typeid(AsmArgs::Register32) && + std::any_cast(args[0]).name() == "eax" && + args[1].type() == typeid(AsmArgs::Immediate32)) + { // add eax, imm32 + machine_code = std::vector{ 0x05 } + std::any_cast(args[1]).getCode(); + } else if (args[0].type() == typeid(AsmArgs::Register64) && + std::any_cast(args[0]).name() == "rax" && + args[1].type() == typeid(AsmArgs::Immediate32)) + { // add rax, imm32 + machine_code = REX("W") + std::vector{ 0x05 } + std::any_cast(args[1]).getCode(); } else { throw std::runtime_error("Unimplemented: add "s + args[0].type().name() + " "s + args[1].type().name()); } @@ -20,12 +26,13 @@ Op_add::Op_add(AsmArgs& args) namespace { -bool registered0 { registerOp(mangleName("add"), [](AsmArgs& args) -> std::shared_ptr{ +bool registered { + registerOp(mangleName("add"), [](AsmArgs& args) -> std::shared_ptr{ return std::make_shared(args); - }) }; -// TODO -bool registered1 { registerOp(mangleName("add"), [](AsmArgs& args) -> std::shared_ptr{ + }) && + registerOp(mangleName("add"), [](AsmArgs& args) -> std::shared_ptr{ return std::make_shared(args); - }) }; + }) +}; } -- cgit v1.2.3