Made FASTCALL cleanup stack values, fixed Ret instruction taking m[offset] instead of m[m[offset]]
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
d70d63ee24
commit
624fad1319
|
@ -78,12 +78,12 @@ namespace Instruction {
|
|||
|
||||
std::unique_ptr<Instruction> Ret::fromTokens(const Instruction::Instruction::parseOperatorResult &op,
|
||||
const std::vector<Token> &tokens) {
|
||||
return std::make_unique<Ret>(tokens.empty() ? 0 : tokens.at(0).getNumericValue());
|
||||
return std::make_unique<Ret>();
|
||||
}
|
||||
|
||||
Ret::Ret(uint32_t count) {
|
||||
instructions.push_back(std::make_unique<Stack::PopImm>(count + 1));
|
||||
instructions.push_back(std::make_unique<Return>(AddressWithOffset{Stack::stackOffsetRegisterAddress, 0}));
|
||||
Ret::Ret() {
|
||||
instructions.push_back(std::make_unique<Stack::PopImm>(1));
|
||||
instructions.push_back(std::make_unique<Return>(AddressWithOffset{0, Stack::stackOffsetRegister}));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace Instruction {
|
|||
std::vector<std::unique_ptr<Instruction>> instructions;
|
||||
public:
|
||||
|
||||
explicit Ret(uint32_t count = 0);
|
||||
explicit Ret();
|
||||
|
||||
CommandOp getCommand() const override {
|
||||
return CommandOp::END;
|
||||
|
|
|
@ -46,11 +46,19 @@ namespace Instruction{
|
|||
FastCall::FastCall(uint32_t address, const std::vector<Token> &data) {
|
||||
initData(data);
|
||||
instructions.push_back(std::make_unique<Call>(address));
|
||||
takedownData(data);
|
||||
}
|
||||
|
||||
FastCall::FastCall(const AddressWithOffset &address, const std::vector<Token> &data) {
|
||||
initData(data);
|
||||
instructions.push_back(std::make_unique<Call>(address));
|
||||
takedownData(data);
|
||||
}
|
||||
|
||||
void FastCall::takedownData(const std::vector<Token> &data) {
|
||||
if(data.size() > 2){
|
||||
instructions.push_back(std::make_unique<Stack::PopImm>(data.size() - 2));
|
||||
}
|
||||
}
|
||||
|
||||
void FastCall::initData(const std::vector<Token> &data) {
|
||||
|
|
|
@ -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<std::unique_ptr<Instruction>> instructions;
|
||||
void initData(const std::vector<Token>& data);
|
||||
void takedownData(const std::vector<Token>& data);
|
||||
public:
|
||||
|
||||
explicit FastCall(const AddressWithOffset& address, const std::vector<Token>& data);
|
||||
|
|
Loading…
Reference in a new issue