- Refactored entire codebase (excluding the Insight component) to accommodate multiple target architectures (no longer specific to AVR) - Deleted 'generate SVD' GDB monitor command - I will eventually move this functionality to the Bloom website - Added unit size property to address spaces - Many other changes which I couldn't be bothered to describe here
34 lines
1.3 KiB
C++
34 lines
1.3 KiB
C++
#include "Avr8InstructionService.hpp"
|
|
|
|
namespace Services
|
|
{
|
|
using Targets::Microchip::Avr8::OpcodeDecoder::Decoder;
|
|
|
|
std::optional<Targets::TargetMemoryAddress> Avr8InstructionService::resolveProgramDestinationAddress(
|
|
const Targets::Microchip::Avr8::OpcodeDecoder::Instruction& instruction,
|
|
Targets::TargetMemoryAddress instructionAddress,
|
|
const Decoder::InstructionMapping& instructions
|
|
) {
|
|
assert(instruction.canChangeProgramFlow);
|
|
|
|
if (instruction.programWordAddress.has_value()) {
|
|
return *(instruction.programWordAddress) * 2;
|
|
}
|
|
|
|
if (instruction.programWordAddressOffset.has_value()) {
|
|
return static_cast<std::int64_t>(instructionAddress) + (*(instruction.programWordAddressOffset) * 2) + 2;
|
|
}
|
|
|
|
if (instruction.canSkipNextInstruction) {
|
|
const auto subsequentInstructionAddress = instructionAddress + instruction.byteSize;
|
|
const auto subsequentInstructionIt = instructions.find(subsequentInstructionAddress);
|
|
|
|
if (subsequentInstructionIt != instructions.end() && subsequentInstructionIt->second.has_value()) {
|
|
return subsequentInstructionAddress + subsequentInstructionIt->second->byteSize;
|
|
}
|
|
}
|
|
|
|
return std::nullopt;
|
|
}
|
|
}
|