Implement proper Init OutputContext
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
3868034b6b
commit
875f6588d9
|
@ -29,6 +29,7 @@
|
|||
#include "../Registers.h"
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include "../OutputContext.h"
|
||||
|
||||
void Instruction::Init::fromBytes(uint32_t offset, const std::vector<uint8_t> &bytes) {
|
||||
_address = offset;
|
||||
|
@ -69,18 +70,35 @@ std::string Instruction::Init::toString() const {
|
|||
if (count > 1 && increment) {
|
||||
op << " UNTIL " << getAddressRegisterName(address + count - 1, addressOffset);
|
||||
}
|
||||
op << " COUNT " << std::hex << std::setw(6) << std::setfill('0') << count;
|
||||
op << " INCREMENT " << std::dec << (uint32_t) increment;
|
||||
op << " COUNT " << std::hex << std::setw(6) << std::setfill('0') << count;
|
||||
op << " DATA 0x" << std::hex << std::setw(8) << std::setfill('0') << data;
|
||||
op << " INC 0x" << std::hex << std::setw(8) << std::setfill('0') << data_add;
|
||||
op << " ADD 0x" << std::hex << std::setw(8) << std::setfill('0') << data_add;
|
||||
|
||||
return op.str();
|
||||
}
|
||||
|
||||
std::vector<Instruction::OutputFormat> Instruction::Init::toOutputFormat(const OutputContext &context) const {
|
||||
return std::vector<OutputFormat>{
|
||||
//TODO
|
||||
std::vector<OutputFormat> f{
|
||||
OutputFormat{getAddress() + 0 * 4,
|
||||
dynamic_cast<std::stringstream &>(std::stringstream("") << "INIT" << " "
|
||||
<< context.getAddressRegisterName(
|
||||
address, addressOffset)
|
||||
<< ", INC " << std::dec
|
||||
<< (uint32_t) increment).str()}
|
||||
};
|
||||
|
||||
f.emplace_back(OutputFormat{getAddress() + 1 * 4,
|
||||
dynamic_cast<std::stringstream &>(std::stringstream("") << " COUNT " << std::dec
|
||||
<< count).str()});
|
||||
|
||||
f.emplace_back(OutputFormat{getAddress() + 2 * 4,
|
||||
dynamic_cast<std::stringstream &>(std::stringstream("") << " DATA 0x" << std::hex << std::setw(8) << std::setfill('0') << data).str()});
|
||||
|
||||
f.emplace_back(OutputFormat{getAddress() + 3 * 4,
|
||||
dynamic_cast<std::stringstream &>(std::stringstream("") << " ADD 0x" << std::hex << std::setw(8) << std::setfill('0') << data_add).str()});
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
std::vector<uint32_t> Instruction::Init::getPossibleBranches() const {
|
||||
|
@ -90,7 +108,7 @@ std::vector<uint32_t> Instruction::Init::getPossibleBranches() const {
|
|||
std::vector<std::pair<uint32_t, std::unordered_map<uint32_t, uint32_t>>>
|
||||
Instruction::Init::execute(AnalysisState &state) const {
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
state.setRegister(address + (increment ? i : 0), data + data_add * i);
|
||||
state.setRegister(address + increment, data + data_add * i);
|
||||
}
|
||||
|
||||
state.current = _endAddress;
|
||||
|
|
|
@ -54,11 +54,11 @@ namespace Instruction {
|
|||
execute(AnalysisState &state) const override;
|
||||
|
||||
|
||||
uint8_t addressOffset;
|
||||
uint8_t increment;
|
||||
uint32_t address;
|
||||
uint32_t count;
|
||||
uint32_t data;
|
||||
uint32_t data_add;
|
||||
uint8_t addressOffset{};
|
||||
uint8_t increment{};
|
||||
uint32_t address{};
|
||||
uint32_t count{};
|
||||
uint32_t data{};
|
||||
uint32_t data_add{};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue