#include "dec.h" #include "codes.h" #include #include #include using namespace std::string_literals; Op_dec::Op_dec(const Asm::Args& args) { if (args[0].type() == typeid(Asm::Args::Register8)) { // dec reg8 machine_code = std::vector{ 0xFE } + ModRM("/1", std::any_cast(args[0]).name()); } else if (args[0].type() == typeid(Asm::Args::Register32)) { // dec reg32 machine_code = std::vector{ 0xFF } + ModRM("/1", std::any_cast(args[0]).name()); } else if (args[0].type() == typeid(Asm::Args::Register64)) { // dec reg64 machine_code = REX("W") + std::vector{ 0xFF } + ModRM("/1", std::any_cast(args[0]).name()); } else { throw std::runtime_error("Unimplemented: dec "s + args[0].type().name()); } } namespace { bool registered { registerOp(mangleName("dec"), [](const Asm::Args& args) -> std::shared_ptr{ return std::make_shared(args); }) && registerOp(mangleName("dec"), [](const Asm::Args& args) -> std::shared_ptr{ return std::make_shared(args); }) && registerOp(mangleName("dec"), [](const Asm::Args& args) -> std::shared_ptr{ return std::make_shared(args); }) }; }