diff --git a/src/instructions/virtual/Call.cpp b/src/instructions/virtual/Call.cpp index 70c4253..43e7b46 100644 --- a/src/instructions/virtual/Call.cpp +++ b/src/instructions/virtual/Call.cpp @@ -78,12 +78,12 @@ namespace Instruction { std::unique_ptr Ret::fromTokens(const Instruction::Instruction::parseOperatorResult &op, const std::vector &tokens) { - return std::make_unique(tokens.empty() ? 0 : tokens.at(0).getNumericValue()); + return std::make_unique(); } - Ret::Ret(uint32_t count) { - instructions.push_back(std::make_unique(count + 1)); - instructions.push_back(std::make_unique(AddressWithOffset{Stack::stackOffsetRegisterAddress, 0})); + Ret::Ret() { + instructions.push_back(std::make_unique(1)); + instructions.push_back(std::make_unique(AddressWithOffset{0, Stack::stackOffsetRegister})); } } diff --git a/src/instructions/virtual/Call.h b/src/instructions/virtual/Call.h index 9cdc670..3167bc5 100644 --- a/src/instructions/virtual/Call.h +++ b/src/instructions/virtual/Call.h @@ -60,7 +60,7 @@ namespace Instruction { std::vector> instructions; public: - explicit Ret(uint32_t count = 0); + explicit Ret(); CommandOp getCommand() const override { return CommandOp::END; diff --git a/src/instructions/virtual/FastCall.cpp b/src/instructions/virtual/FastCall.cpp index 03a84b2..410b5d1 100644 --- a/src/instructions/virtual/FastCall.cpp +++ b/src/instructions/virtual/FastCall.cpp @@ -46,11 +46,19 @@ namespace Instruction{ FastCall::FastCall(uint32_t address, const std::vector &data) { initData(data); instructions.push_back(std::make_unique(address)); + takedownData(data); } FastCall::FastCall(const AddressWithOffset &address, const std::vector &data) { initData(data); instructions.push_back(std::make_unique(address)); + takedownData(data); + } + + void FastCall::takedownData(const std::vector &data) { + if(data.size() > 2){ + instructions.push_back(std::make_unique(data.size() - 2)); + } } void FastCall::initData(const std::vector &data) { diff --git a/src/instructions/virtual/FastCall.h b/src/instructions/virtual/FastCall.h index ede0481..77708b4 100644 --- a/src/instructions/virtual/FastCall.h +++ b/src/instructions/virtual/FastCall.h @@ -30,11 +30,12 @@ #include "../Instruction.h" namespace Instruction { - //Akin to __fastcall + //Akin to __fastcall, but the caller cleans up the stack class FastCall : public Instruction { private: std::vector> instructions; void initData(const std::vector& data); + void takedownData(const std::vector& data); public: explicit FastCall(const AddressWithOffset& address, const std::vector& data);