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