2021-01-16 02:30:30 +00:00
|
|
|
//
|
|
|
|
// Decoder.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
2021-01-17 03:09:19 +00:00
|
|
|
// Created by Thomas Harte on 15/01/21.
|
2021-01-16 02:30:30 +00:00
|
|
|
// Copyright © 2021 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef InstructionSets_M50740_Decoder_hpp
|
|
|
|
#define InstructionSets_M50740_Decoder_hpp
|
|
|
|
|
|
|
|
#include "Instruction.hpp"
|
|
|
|
|
2021-01-16 03:33:14 +00:00
|
|
|
#include <cstddef>
|
2021-01-16 02:30:30 +00:00
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
namespace InstructionSet {
|
|
|
|
namespace M50740 {
|
|
|
|
|
|
|
|
class Decoder {
|
|
|
|
public:
|
|
|
|
std::pair<int, Instruction> decode(const uint8_t *source, size_t length);
|
|
|
|
|
|
|
|
private:
|
|
|
|
enum class Phase {
|
|
|
|
Instruction,
|
2021-01-16 03:47:52 +00:00
|
|
|
AwaitingOperand,
|
|
|
|
ReadyToPost
|
2021-01-16 02:50:05 +00:00
|
|
|
} phase_ = Phase::Instruction;
|
2021-01-16 03:47:52 +00:00
|
|
|
int operand_size_ = 0, operand_bytes_ = 0;
|
2021-01-16 02:50:05 +00:00
|
|
|
int consumed_ = 0;
|
|
|
|
Instruction instr_;
|
2021-01-16 02:30:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* InstructionSets_M50740_Decoder_hpp */
|