Implement NOP with offsets
This commit is contained in:
parent
98e3e77686
commit
6d8b3f0e09
|
@ -47,6 +47,7 @@
|
|||
#include "virtual/Stack.h"
|
||||
#include "virtual/Call.h"
|
||||
#include "virtual/FastCall.h"
|
||||
#include "virtual/Container.h"
|
||||
|
||||
#include "../Declaration.h"
|
||||
|
||||
|
@ -89,15 +90,25 @@ namespace Instruction {
|
|||
addOperator("LOAD", 2, Load::fromTokens);
|
||||
addOperator("LOAD_DIRECT", 2, Load::fromDirectTokens);
|
||||
|
||||
//Using NOT x = 255 - x. Cannot accept offsets
|
||||
// NOT dest, source
|
||||
//Using NOT x = 255 - x.
|
||||
addOperator("NOT", 2, [](const parseOperatorResult &op, const std::vector<Token> &tokens) -> std::unique_ptr<Instruction> {
|
||||
if(op.offset1 != 0){
|
||||
throw std::runtime_error("NOT cannot use addressing offsets");
|
||||
auto c = std::make_unique<Container>("NOT op with offset");
|
||||
c->addInstruction(std::make_unique<Copy>(AddressWithOffset{(uint32_t) MgmtRegisters::std_SCRATCH_0, 0}, AddressWithOffset{tokens.at(1).getNumericValue(), op.offset1}, 1));
|
||||
c->addInstruction(std::make_unique<Calc>(Calc::Operation::SUB, 0,
|
||||
(uint32_t) MgmtRegisters::std_SCRATCH_0,
|
||||
(uint32_t)MgmtRegisters::INTERNAL_REGISTER_ALWAYS_FFFFFFFF,
|
||||
(uint32_t) MgmtRegisters::std_SCRATCH_0));
|
||||
c->addInstruction(std::make_unique<Copy>(AddressWithOffset{tokens.at(1).getNumericValue(), op.offset2}, AddressWithOffset{(uint32_t) MgmtRegisters::std_SCRATCH_0, 0}, 1));
|
||||
return std::move(c);
|
||||
}
|
||||
return std::make_unique<Calc>(Calc::Operation::SUB, 0,
|
||||
auto i = std::make_unique<Calc>(Calc::Operation::SUB, 0,
|
||||
tokens.at(0).getNumericValue(),
|
||||
(uint32_t)MgmtRegisters::INTERNAL_REGISTER_ALWAYS_FFFFFFFF,
|
||||
tokens.at(1).getNumericValue());
|
||||
i->comment = "NOT op";
|
||||
return std::move(i);
|
||||
});
|
||||
|
||||
addOperator("AND", 3, CalcImm::fromAndTokens);
|
||||
|
|
Loading…
Reference in a new issue