- Used designated initialisation in AVR8 opcode decoder

- Other bits of tidying
This commit is contained in:
Nav
2025-07-22 22:44:17 +01:00
parent 7aff716d5d
commit c12be3231c
4 changed files with 19 additions and 61 deletions

View File

@@ -1120,7 +1120,7 @@ namespace DebugToolDrivers::Protocols::RiscVDebug
* data0 (from X9) and the program buffer being executed again (filling X9 with another word).
*
* To avoid reading an excess of words (which could result in an out-of-bounds exception), we only enable
* auto execution if we require more data that what has already been read.
* auto execution if we require more data than what has already been read.
*/
const auto autoExecutionEnabled = bytes > (DebugTranslator::WORD_BYTE_SIZE * 2);
this->dtmInterface.writeDebugModuleRegister(

View File

@@ -643,8 +643,8 @@ namespace Widgets
static constexpr auto asciiFontColor = QColor{0xA7, 0x77, 0x26};
static constexpr auto changedMemoryAsciiFontColor = QColor{0xB7, 0x7F, 0x21};
const auto byteItemRect = QRect{0, 0, ByteItem::WIDTH, ByteItem::HEIGHT};
const auto byteItemSize = byteItemRect.size();
static constexpr auto byteItemRect = QRect{0, 0, ByteItem::WIDTH, ByteItem::HEIGHT};
static constexpr auto byteItemSize = byteItemRect.size();
auto standardTemplatePixmap = QPixmap{byteItemSize};
standardTemplatePixmap.fill(standardBackgroundColor);

View File

@@ -33,58 +33,16 @@ namespace Targets::Microchip::Avr8::OpcodeDecoder
std::uint8_t byteSize;
Mnemonic mnemonic;
bool canChangeProgramFlow;
std::optional<std::uint32_t> data;
std::optional<std::uint8_t> sourceRegister;
std::optional<std::uint8_t> destinationRegister;
std::optional<Targets::TargetMemoryAddress> programWordAddress;
std::optional<std::int16_t> programWordAddressOffset;
bool canSkipNextInstruction;
std::optional<std::uint8_t> registerBitPosition;
std::optional<std::uint8_t> statusRegisterBitPosition;
std::optional<Targets::TargetMemoryAddress> ioSpaceAddress;
std::optional<Targets::TargetMemoryAddress> dataSpaceAddress;
std::optional<std::uint8_t> displacement;
Instruction(
const std::string& name,
std::uint32_t opcode,
std::uint8_t byteSize,
Mnemonic mnemonic,
bool canChangeProgramFlow,
std::optional<std::uint32_t> data = std::nullopt,
std::optional<std::uint8_t> sourceRegister = std::nullopt,
std::optional<std::uint8_t> destinationRegister = std::nullopt,
std::optional<Targets::TargetMemoryAddress> programWordAddress = std::nullopt,
std::optional<std::int16_t> programWordAddressOffset = std::nullopt,
bool canSkipNextInstruction = false,
std::optional<std::uint8_t> registerBitPosition = std::nullopt,
std::optional<std::uint8_t> statusRegisterBitPosition = std::nullopt,
std::optional<Targets::TargetMemoryAddress> ioSpaceAddress = std::nullopt,
std::optional<Targets::TargetMemoryAddress> dataSpaceAddress = std::nullopt,
std::optional<std::uint8_t> displacement = std::nullopt
)
: name(name)
, opcode(opcode)
, byteSize(byteSize)
, mnemonic(mnemonic)
, canChangeProgramFlow(canChangeProgramFlow)
, data(data)
, sourceRegister(sourceRegister)
, destinationRegister(destinationRegister)
, programWordAddress(programWordAddress)
, programWordAddressOffset(programWordAddressOffset)
, canSkipNextInstruction(canSkipNextInstruction)
, registerBitPosition(registerBitPosition)
, statusRegisterBitPosition(statusRegisterBitPosition)
, ioSpaceAddress(ioSpaceAddress)
, dataSpaceAddress(dataSpaceAddress)
, displacement(displacement)
{}
std::optional<std::uint32_t> data = std::nullopt;
std::optional<std::uint8_t> sourceRegister = std::nullopt;
std::optional<std::uint8_t> destinationRegister = std::nullopt;
std::optional<Targets::TargetMemoryAddress> programWordAddress = std::nullopt;
std::optional<std::int16_t> programWordAddressOffset = std::nullopt;
bool canSkipNextInstruction = false;
std::optional<std::uint8_t> registerBitPosition = std::nullopt;
std::optional<std::uint8_t> statusRegisterBitPosition = std::nullopt;
std::optional<Targets::TargetMemoryAddress> ioSpaceAddress = std::nullopt;
std::optional<Targets::TargetMemoryAddress> dataSpaceAddress = std::nullopt;
std::optional<std::uint8_t> displacement = std::nullopt;
};
}

View File

@@ -521,11 +521,11 @@ namespace Targets::Microchip::Avr8::OpcodeDecoder
}
auto output = Instruction{
SelfType::name,
opcode,
byteSize,
mnemonic,
canChangeProgramFlow
.name = SelfType::name,
.opcode = opcode,
.byteSize = byteSize,
.mnemonic = mnemonic,
.canChangeProgramFlow = canChangeProgramFlow,
};
if constexpr (decltype(sourceRegisterParameter)::hasValue()) {