1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-01-27 06:35:04 +00:00

Include size and supervisor flag in Preinstruction.

This commit is contained in:
Thomas Harte 2022-04-26 19:44:02 -04:00
parent baf1bd354d
commit 8902bb1af0
2 changed files with 15 additions and 11 deletions

View File

@ -488,7 +488,8 @@ template <uint8_t op, bool validate> Preinstruction Predecoder<model>::validated
operation,
op1_mode, op1_reg,
op2_mode, op2_reg,
requires_supervisor<model>(operation));
requires_supervisor<model>(operation),
size(operation));
}
const auto invalid = invalid_operands<op>();
@ -499,7 +500,8 @@ template <uint8_t op, bool validate> Preinstruction Predecoder<model>::validated
operation,
op1_mode, op1_reg,
op2_mode, op2_reg,
requires_supervisor<model>(operation));
requires_supervisor<model>(operation),
size(operation));
}
/// Decodes the fields within an instruction and constructs a `Preinstruction`, given that the operation has already been

View File

@ -359,28 +359,30 @@ class Preinstruction {
return operands_[index] >> 5;
}
bool requires_supervisor() {
return flags_ & 0x80;
}
DataSize size() {
return DataSize(flags_ & 0x7f);
}
private:
uint8_t operands_[2] = { uint8_t(AddressingMode::None), uint8_t(AddressingMode::None)};
uint8_t flags_ = 0;
public:
Preinstruction(
Operation operation,
AddressingMode op1_mode, int op1_reg,
AddressingMode op2_mode, int op2_reg,
[[maybe_unused]] bool is_supervisor = false) : operation(operation)
bool is_supervisor,
DataSize size) : operation(operation)
{
operands_[0] = uint8_t(op1_mode) | uint8_t(op1_reg << 5);
operands_[1] = uint8_t(op2_mode) | uint8_t(op2_reg << 5);
flags_ = (is_supervisor ? 0x80 : 0x00) | uint8_t(size);
}
Preinstruction(Operation operation, [[maybe_unused]] bool is_supervisor = false) : operation(operation) {}
Preinstruction(Operation operation, AddressingMode op1_mode, int op1_reg, [[maybe_unused]] bool is_supervisor = false) : operation(operation) {
operands_[0] = uint8_t(op1_mode) | uint8_t(op1_reg << 5);
}
// TODO: record is_supervisor.
Preinstruction() {}
};