mirror of
https://github.com/TomHarte/CLK.git
synced 2024-08-31 10:29:32 +00:00
Trust the compiler with this bit field.
This commit is contained in:
parent
d9598b35c2
commit
32e0a66610
@ -333,7 +333,7 @@ template <class T, bool dtack_is_implicit, bool signal_will_perform> void Proces
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(instructions[decoded_instruction_.full].micro_operations != std::numeric_limits<uint32_t>::max()) {
|
if(instructions[decoded_instruction_.full].micro_operations != std::numeric_limits<uint32_t>::max()) {
|
||||||
if((instructions[decoded_instruction_.full].source_dest & 0x80) && !is_supervisor_) {
|
if((instructions[decoded_instruction_.full].requires_supervisor) && !is_supervisor_) {
|
||||||
// A privilege violation has been detected.
|
// A privilege violation has been detected.
|
||||||
active_program_ = nullptr;
|
active_program_ = nullptr;
|
||||||
active_micro_op_ = short_exception_micro_ops_;
|
active_micro_op_ = short_exception_micro_ops_;
|
||||||
@ -387,9 +387,9 @@ template <class T, bool dtack_is_implicit, bool signal_will_perform> void Proces
|
|||||||
|
|
||||||
#define offset_pointer(x) reinterpret_cast<RegisterPair32 *>(&reinterpret_cast<uint8_t *>(static_cast<ProcessorStorage *>(this))[x])
|
#define offset_pointer(x) reinterpret_cast<RegisterPair32 *>(&reinterpret_cast<uint8_t *>(static_cast<ProcessorStorage *>(this))[x])
|
||||||
#define source() offset_pointer(active_program_->source_offset)
|
#define source() offset_pointer(active_program_->source_offset)
|
||||||
#define source_address() address_[(active_program_->source_dest >> 4) & 7]
|
#define source_address() address_[active_program_->source]
|
||||||
#define destination() offset_pointer(active_program_->destination_offset)
|
#define destination() offset_pointer(active_program_->destination_offset)
|
||||||
#define destination_address() address_[active_program_->source_dest & 7]
|
#define destination_address() address_[active_program_->dest]
|
||||||
|
|
||||||
case int_type(MicroOp::Action::PerformOperation):
|
case int_type(MicroOp::Action::PerformOperation):
|
||||||
#define sub_overflow() ((result ^ destination) & (destination ^ source))
|
#define sub_overflow() ((result ^ destination) & (destination ^ source))
|
||||||
|
@ -359,6 +359,15 @@ class ProcessorStorage {
|
|||||||
remaining fields, with no additional padding being inserted by the compiler.
|
remaining fields, with no additional padding being inserted by the compiler.
|
||||||
*/
|
*/
|
||||||
struct Program {
|
struct Program {
|
||||||
|
Program() {
|
||||||
|
// Initialisers for bitfields aren't available until C++20. So, yuck, do it manually.
|
||||||
|
requires_supervisor = 0;
|
||||||
|
source = 0;
|
||||||
|
dest = 0;
|
||||||
|
destination_offset = 0;
|
||||||
|
source_offset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/// The offset into the all_micro_ops_ at which micro-ops for this instruction begin,
|
/// The offset into the all_micro_ops_ at which micro-ops for this instruction begin,
|
||||||
/// or std::numeric_limits<uint32_t>::max() if this is an invalid Program.
|
/// or std::numeric_limits<uint32_t>::max() if this is an invalid Program.
|
||||||
uint32_t micro_operations = std::numeric_limits<uint32_t>::max();
|
uint32_t micro_operations = std::numeric_limits<uint32_t>::max();
|
||||||
@ -366,26 +375,30 @@ class ProcessorStorage {
|
|||||||
Operation operation;
|
Operation operation;
|
||||||
/// The number of bytes after the beginning of an instance of ProcessorStorage that the RegisterPair32 containing
|
/// The number of bytes after the beginning of an instance of ProcessorStorage that the RegisterPair32 containing
|
||||||
/// a source value for this operation lies at.
|
/// a source value for this operation lies at.
|
||||||
uint8_t source_offset = 0;
|
uint8_t source_offset: 7;
|
||||||
/// The number of bytes after the beginning of an instance of ProcessorStorage that the RegisterPair32 containing
|
/// The number of bytes after the beginning of an instance of ProcessorStorage that the RegisterPair32 containing
|
||||||
/// a destination value for this operation lies at.
|
/// a destination value for this operation lies at.
|
||||||
uint8_t destination_offset = 0;
|
uint8_t destination_offset: 7;
|
||||||
/// A bitfield comprised of:
|
/// Set if this program requires supervisor mode.
|
||||||
/// b7 = set if this program requires supervisor mode;
|
bool requires_supervisor: 1;
|
||||||
/// b0–b2 = the source address register (for pre-decrement and post-increment actions); and
|
/// The source address register (for pre-decrement and post-increment actions).
|
||||||
/// b4-b6 = destination address register.
|
uint8_t source: 3;
|
||||||
uint8_t source_dest = 0;
|
/// Destination address register.
|
||||||
|
uint8_t dest: 3;
|
||||||
|
|
||||||
void set_source_address([[maybe_unused]] ProcessorStorage &storage, int index) {
|
void set_source_address([[maybe_unused]] ProcessorStorage &storage, int index) {
|
||||||
source_dest = uint8_t((source_dest & 0x0f) | (index << 4));
|
source = uint8_t(index);
|
||||||
|
assert(int(source) == index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_destination_address([[maybe_unused]] ProcessorStorage &storage, int index) {
|
void set_destination_address([[maybe_unused]] ProcessorStorage &storage, int index) {
|
||||||
source_dest = uint8_t((source_dest & 0xf0) | index);
|
dest = uint8_t(index);
|
||||||
|
assert(int(dest) == index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_requires_supervisor(bool requires_supervisor) {
|
void set_requires_supervisor(bool req) {
|
||||||
source_dest = (source_dest & 0x7f) | (requires_supervisor ? 0x80 : 0x00);
|
requires_supervisor = req;
|
||||||
|
assert(requires_supervisor == req);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_source(ProcessorStorage &storage, RegisterPair32 *target) {
|
void set_source(ProcessorStorage &storage, RegisterPair32 *target) {
|
||||||
|
Loading…
Reference in New Issue
Block a user