use AddressWithOffset on WRITE
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
1fbb828944
commit
c3bcf99d6a
|
@ -258,9 +258,9 @@ void ImageFormat::decodeAnalyzeInstructionsAt(uint32_t offset) {
|
|||
const auto &writeInstruction = reinterpret_cast<const std::unique_ptr<Instruction::Write> &>(previousInstruction);
|
||||
if (
|
||||
(
|
||||
writeInstruction->address == (uint32_t) KnownRegisters::MGMT_SCRATCH_1
|
||||
|| (writeInstruction->address >= (uint32_t) KnownRegisters::BSM_SCRATCH_START &&
|
||||
writeInstruction->address < (uint32_t) KnownRegisters::BSM_SCRATCH_END)
|
||||
writeInstruction->address.address == (uint32_t) KnownRegisters::MGMT_SCRATCH_1
|
||||
|| (writeInstruction->address.address >= (uint32_t) KnownRegisters::BSM_SCRATCH_START &&
|
||||
writeInstruction->address.address < (uint32_t) KnownRegisters::BSM_SCRATCH_END)
|
||||
)
|
||||
&& writeInstruction->data.size() == 1
|
||||
) { //This is commonly used before jumps to mark return values or switch statements
|
||||
|
|
|
@ -37,11 +37,11 @@ void Instruction::Write::fromBytes(uint32_t offset, const std::vector<uint8_t> &
|
|||
uint32_t command = bytes[offset++];
|
||||
|
||||
uint8_t count = (1 + (command >> 2) & 0b1111);
|
||||
addressOffset = command & 0b11;
|
||||
address.offset = command & 0b11;
|
||||
|
||||
address = bytes[offset++] << 16;
|
||||
address |= bytes[offset++] << 8;
|
||||
address |= bytes[offset++];
|
||||
address.address = bytes[offset++] << 16;
|
||||
address.address |= bytes[offset++] << 8;
|
||||
address.address |= bytes[offset++];
|
||||
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
uint32_t entry = bytes[offset++] << 24;
|
||||
|
@ -57,7 +57,7 @@ void Instruction::Write::fromBytes(uint32_t offset, const std::vector<uint8_t> &
|
|||
|
||||
std::string Instruction::Write::toString() const {
|
||||
std::stringstream op;
|
||||
op << "WRITE " << getAddressRegisterName(address, addressOffset) << " = 0x";
|
||||
op << "WRITE " << getAddressRegisterName(address) << " = 0x";
|
||||
|
||||
for (auto d : data) {
|
||||
op << std::hex << std::setw(8) << std::setfill('0') << d;
|
||||
|
@ -71,8 +71,7 @@ std::vector<Instruction::OutputFormat> Instruction::Write::toOutputFormat(const
|
|||
std::vector<OutputFormat> f{
|
||||
OutputFormat{getAddress() + offset++ * 4,
|
||||
dynamic_cast<std::stringstream &>(std::stringstream("") << "WRITE" << " "
|
||||
<< context.getAddressRegisterName(
|
||||
address, addressOffset) << ", "
|
||||
<< context.getAddressRegisterName(address) << ", "
|
||||
<< std::dec
|
||||
<< (uint32_t) data.size()).str()}
|
||||
};
|
||||
|
@ -81,8 +80,7 @@ std::vector<Instruction::OutputFormat> Instruction::Write::toOutputFormat(const
|
|||
f.emplace_back(OutputFormat{getAddress() + offset * 4,
|
||||
dynamic_cast<std::stringstream &>(std::stringstream("") << " "
|
||||
<< context.getAddressRegisterName(
|
||||
address + offset -
|
||||
1, addressOffset)
|
||||
address.address + offset - 1, address.offset)
|
||||
<< " = 0x" << std::hex
|
||||
<< std::setw(8)
|
||||
<< std::setfill('0')
|
||||
|
@ -100,10 +98,10 @@ std::vector<uint32_t> Instruction::Write::getPossibleBranches() const {
|
|||
|
||||
std::vector<std::pair<uint32_t, std::unordered_map<uint32_t, uint32_t>>>
|
||||
Instruction::Write::execute(AnalysisState &state) const {
|
||||
auto memoryOffset = state.getAddressOffset(addressOffset);
|
||||
auto memoryOffset = state.getAddressOffset(address.offset);
|
||||
|
||||
for (uint32_t i = 0; i < data.size(); ++i) {
|
||||
state.setRegister(memoryOffset + address + i, data[i]);
|
||||
state.setRegister(memoryOffset + address.address + i, data[i]);
|
||||
}
|
||||
|
||||
state.current = _endAddress;
|
||||
|
@ -118,11 +116,11 @@ Instruction::Write::execute(AnalysisState &state) const {
|
|||
std::vector<uint8_t> Instruction::Write::toBytes() const {
|
||||
std::vector<uint8_t> bytes;
|
||||
|
||||
bytes.emplace_back((uint8_t) getCommand() | ((data.size() - 1) << 2) | addressOffset);
|
||||
bytes.emplace_back((uint8_t) getCommand() | ((data.size() - 1) << 2) | address.offset);
|
||||
|
||||
bytes.emplace_back((address >> 16) & 0xFF);
|
||||
bytes.emplace_back((address >> 8) & 0xFF);
|
||||
bytes.emplace_back(address & 0xFF);
|
||||
bytes.emplace_back((address.address >> 16) & 0xFF);
|
||||
bytes.emplace_back((address.address >> 8) & 0xFF);
|
||||
bytes.emplace_back(address.address & 0xFF);
|
||||
|
||||
for (auto d : data) {
|
||||
bytes.emplace_back((d >> 24) & 0xFF);
|
||||
|
|
|
@ -55,9 +55,7 @@ namespace Instruction {
|
|||
std::vector<std::pair<uint32_t, std::unordered_map<uint32_t, uint32_t>>>
|
||||
execute(AnalysisState &state) const override;
|
||||
|
||||
|
||||
uint8_t addressOffset;
|
||||
uint32_t address;
|
||||
AddressWithOffset address;
|
||||
std::vector<uint32_t> data;
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue