mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 23:52:26 +00:00
Introduce calculate EA steps.
This commit is contained in:
parent
9359f6477b
commit
e4426dc952
@ -399,7 +399,7 @@ template <
|
||||
|
||||
// JMP: copies EA(0) to the program counter.
|
||||
case Operation::JMP:
|
||||
flow_controller.set_pc(flow_controller.effective_address(0));
|
||||
flow_controller.set_pc(src.l);
|
||||
break;
|
||||
|
||||
/*
|
||||
@ -438,7 +438,7 @@ template <
|
||||
break;
|
||||
|
||||
case Operation::LEA:
|
||||
dest.l = flow_controller.effective_address(0);
|
||||
dest.l = src.l;
|
||||
break;
|
||||
|
||||
// case Operation::PEA:
|
||||
|
@ -11,14 +11,14 @@
|
||||
using namespace InstructionSet::M68k;
|
||||
|
||||
template <Step... T> struct Steps {
|
||||
static constexpr uint16_t value = 0;
|
||||
static constexpr uint32_t value = 0;
|
||||
};
|
||||
|
||||
template <Step F, Step... T> struct Steps<F, T...> {
|
||||
static constexpr uint16_t value = uint16_t(F) | uint16_t(Steps<T...>::value << 3);
|
||||
static constexpr uint32_t value = uint16_t(F) | uint16_t(Steps<T...>::value << 4);
|
||||
};
|
||||
|
||||
template<Model model> uint16_t Sequence<model>::steps_for(Operation operation) {
|
||||
template<Model model> uint32_t Sequence<model>::steps_for(Operation operation) {
|
||||
switch(operation) {
|
||||
// This handles a NOP, and not much else.
|
||||
default: return 0;
|
||||
@ -28,6 +28,7 @@ template<Model model> uint16_t Sequence<model>::steps_for(Operation operation) {
|
||||
//
|
||||
case Operation::LEA:
|
||||
return Steps<
|
||||
Step::CalcEA1,
|
||||
Step::Perform
|
||||
>::value;
|
||||
|
||||
|
@ -35,6 +35,12 @@ enum class Step {
|
||||
StoreOp1,
|
||||
/// Store the value of operand 2.
|
||||
StoreOp2,
|
||||
/// Calculate effective address of operand 1.
|
||||
CalcEA1,
|
||||
/// Calculate effective address of operand 2.
|
||||
CalcEA2,
|
||||
|
||||
Max = CalcEA2
|
||||
};
|
||||
|
||||
/// Indicates the abstract steps necessary to perform an operation,
|
||||
@ -47,8 +53,9 @@ template<Model model> class Sequence {
|
||||
/// if no further steps remain. This step is removed from the
|
||||
/// list of remaining steps.
|
||||
Step pop_front() {
|
||||
const auto step = Step(steps_ & 7);
|
||||
steps_ >>= 3;
|
||||
static_assert(int(Step::Max) < 16);
|
||||
const auto step = Step(steps_ & 15);
|
||||
steps_ >>= 4;
|
||||
return step;
|
||||
}
|
||||
|
||||
@ -59,12 +66,12 @@ template<Model model> class Sequence {
|
||||
}
|
||||
|
||||
private:
|
||||
uint16_t steps_ = 0;
|
||||
uint32_t steps_ = 0;
|
||||
|
||||
uint16_t steps_for(Operation);
|
||||
uint32_t steps_for(Operation);
|
||||
};
|
||||
|
||||
static_assert(sizeof(Sequence<Model::M68000>) == sizeof(uint16_t));
|
||||
static_assert(sizeof(Sequence<Model::M68000>) == sizeof(uint32_t));
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user