2022-05-09 13:24:35 +00:00
|
|
|
//
|
|
|
|
// InstructionOperandFlags.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 09/05/2022.
|
|
|
|
// Copyright © 2022 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef InstructionSets_68k_InstructionOperandFlags_hpp
|
|
|
|
#define InstructionSets_68k_InstructionOperandFlags_hpp
|
|
|
|
|
2023-05-10 21:02:18 +00:00
|
|
|
namespace InstructionSet::M68k {
|
2022-05-09 13:24:35 +00:00
|
|
|
|
2022-05-19 19:49:42 +00:00
|
|
|
template <Model model, Operation t_operation> constexpr uint8_t operand_flags(Operation r_operation) {
|
2022-05-09 13:24:35 +00:00
|
|
|
switch((t_operation != Operation::Undefined) ? t_operation : r_operation) {
|
|
|
|
default:
|
|
|
|
assert(false);
|
|
|
|
|
|
|
|
//
|
|
|
|
// No operands are fetched or stored.
|
2022-10-31 19:15:05 +00:00
|
|
|
//
|
|
|
|
// (which means that source and destination, if they exist,
|
|
|
|
// should be supplied as their effective addresses)
|
2022-05-09 13:24:35 +00:00
|
|
|
//
|
|
|
|
case Operation::PEA:
|
|
|
|
case Operation::JMP: case Operation::JSR:
|
|
|
|
case Operation::MOVEPw: case Operation::MOVEPl:
|
|
|
|
case Operation::TAS:
|
|
|
|
case Operation::RTR: case Operation::RTS: case Operation::RTE:
|
2022-11-14 20:58:58 +00:00
|
|
|
case Operation::RTM:
|
2022-10-27 13:39:00 +00:00
|
|
|
case Operation::RTD:
|
2022-10-31 19:15:05 +00:00
|
|
|
case Operation::TRAP: case Operation::RESET: case Operation::NOP:
|
|
|
|
case Operation::STOP: case Operation::TRAPV: case Operation::BKPT:
|
2022-11-14 20:58:58 +00:00
|
|
|
case Operation::TRAPcc:
|
|
|
|
case Operation::CASb: case Operation::CASw: case Operation::CASl:
|
|
|
|
case Operation::CAS2w: case Operation::CAS2l:
|
2022-10-27 13:39:00 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Operand fetch/store status isn't certain just from the operation; this means
|
|
|
|
// that further content from an extension word will be required.
|
|
|
|
//
|
|
|
|
case Operation::MOVESb: case Operation::MOVESw: case Operation::MOVESl:
|
2022-05-09 13:24:35 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Single-operand read.
|
|
|
|
//
|
|
|
|
case Operation::MOVEtoSR: case Operation::MOVEtoCCR: case Operation::MOVEtoUSP:
|
|
|
|
case Operation::ORItoSR: case Operation::ORItoCCR:
|
|
|
|
case Operation::ANDItoSR: case Operation::ANDItoCCR:
|
|
|
|
case Operation::EORItoSR: case Operation::EORItoCCR:
|
|
|
|
case Operation::Bccb: case Operation::Bccw: case Operation::Bccl:
|
|
|
|
case Operation::BSRb: case Operation::BSRw: case Operation::BSRl:
|
|
|
|
case Operation::TSTb: case Operation::TSTw: case Operation::TSTl:
|
2022-05-21 00:34:51 +00:00
|
|
|
case Operation::MOVEMtoMw: case Operation::MOVEMtoMl:
|
|
|
|
case Operation::MOVEMtoRw: case Operation::MOVEMtoRl:
|
2022-10-27 13:39:00 +00:00
|
|
|
case Operation::MOVEtoC:
|
2022-11-14 20:58:58 +00:00
|
|
|
case Operation::CALLM:
|
|
|
|
case Operation::CHKorCMP2b: case Operation::CHKorCMP2w: case Operation::CHKorCMP2l:
|
2022-05-09 13:24:35 +00:00
|
|
|
return FetchOp1;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Single-operand write.
|
|
|
|
//
|
2022-05-27 14:32:28 +00:00
|
|
|
case Operation::MOVEfromUSP:
|
2022-10-27 13:39:00 +00:00
|
|
|
case Operation::MOVEfromCCR:
|
|
|
|
case Operation::MOVEfromC:
|
2022-05-09 13:24:35 +00:00
|
|
|
return StoreOp1;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Single-operand read-modify-write.
|
|
|
|
//
|
|
|
|
case Operation::NBCD:
|
|
|
|
case Operation::NOTb: case Operation::NOTw: case Operation::NOTl:
|
|
|
|
case Operation::NEGb: case Operation::NEGw: case Operation::NEGl:
|
|
|
|
case Operation::NEGXb: case Operation::NEGXw: case Operation::NEGXl:
|
2022-11-14 20:58:58 +00:00
|
|
|
case Operation::EXTbtow: case Operation::EXTwtol: case Operation::EXTbtol:
|
2022-05-09 13:24:35 +00:00
|
|
|
case Operation::SWAP:
|
|
|
|
case Operation::UNLINK:
|
|
|
|
case Operation::ASLm: case Operation::ASRm:
|
|
|
|
case Operation::LSLm: case Operation::LSRm:
|
|
|
|
case Operation::ROLm: case Operation::RORm:
|
|
|
|
case Operation::ROXLm: case Operation::ROXRm:
|
2022-05-20 15:43:26 +00:00
|
|
|
case Operation::Scc:
|
2022-05-09 13:24:35 +00:00
|
|
|
return FetchOp1 | StoreOp1;
|
|
|
|
|
|
|
|
//
|
2022-05-27 14:32:28 +00:00
|
|
|
// CLR and MOVE SR, which are model-dependent.
|
2022-05-09 13:24:35 +00:00
|
|
|
//
|
2022-05-27 14:32:28 +00:00
|
|
|
case Operation::MOVEfromSR:
|
2022-05-09 13:24:35 +00:00
|
|
|
case Operation::CLRb: case Operation::CLRw: case Operation::CLRl:
|
|
|
|
if constexpr (model == Model::M68000) {
|
|
|
|
return FetchOp1 | StoreOp1;
|
|
|
|
} else {
|
|
|
|
return StoreOp1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Two-operand; read both.
|
|
|
|
//
|
|
|
|
case Operation::CMPb: case Operation::CMPw: case Operation::CMPl:
|
|
|
|
case Operation::CMPAw: case Operation::CMPAl:
|
2022-11-14 20:58:58 +00:00
|
|
|
case Operation::CHKw: case Operation::CHKl:
|
2022-05-09 13:24:35 +00:00
|
|
|
case Operation::BTST:
|
2022-11-14 20:58:58 +00:00
|
|
|
case Operation::LINKw: case Operation::LINKl:
|
|
|
|
case Operation::BFTST: case Operation::BFFFO:
|
|
|
|
case Operation::BFEXTU: case Operation::BFEXTS:
|
|
|
|
case Operation::DIVSorDIVUl:
|
|
|
|
case Operation::MULSorMULUl:
|
2022-05-09 13:24:35 +00:00
|
|
|
return FetchOp1 | FetchOp2;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Two-operand; read source, write dest.
|
|
|
|
//
|
|
|
|
case Operation::MOVEb: case Operation::MOVEw: case Operation::MOVEl:
|
|
|
|
case Operation::MOVEAw: case Operation::MOVEAl:
|
2022-11-14 20:58:58 +00:00
|
|
|
case Operation::PACK: case Operation::UNPK:
|
2022-05-09 13:24:35 +00:00
|
|
|
return FetchOp1 | StoreOp2;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Two-operand; read both, write dest.
|
|
|
|
//
|
|
|
|
case Operation::ABCD: case Operation::SBCD:
|
|
|
|
case Operation::ADDb: case Operation::ADDw: case Operation::ADDl:
|
|
|
|
case Operation::ADDAw: case Operation::ADDAl:
|
|
|
|
case Operation::ADDXb: case Operation::ADDXw: case Operation::ADDXl:
|
|
|
|
case Operation::SUBb: case Operation::SUBw: case Operation::SUBl:
|
|
|
|
case Operation::SUBAw: case Operation::SUBAl:
|
|
|
|
case Operation::SUBXb: case Operation::SUBXw: case Operation::SUBXl:
|
|
|
|
case Operation::ORb: case Operation::ORw: case Operation::ORl:
|
|
|
|
case Operation::ANDb: case Operation::ANDw: case Operation::ANDl:
|
|
|
|
case Operation::EORb: case Operation::EORw: case Operation::EORl:
|
2022-10-22 19:20:30 +00:00
|
|
|
case Operation::DIVUw: case Operation::DIVSw:
|
|
|
|
case Operation::MULUw: case Operation::MULSw:
|
2022-05-09 13:24:35 +00:00
|
|
|
case Operation::ASLb: case Operation::ASLw: case Operation::ASLl:
|
|
|
|
case Operation::ASRb: case Operation::ASRw: case Operation::ASRl:
|
|
|
|
case Operation::LSLb: case Operation::LSLw: case Operation::LSLl:
|
|
|
|
case Operation::LSRb: case Operation::LSRw: case Operation::LSRl:
|
|
|
|
case Operation::ROLb: case Operation::ROLw: case Operation::ROLl:
|
|
|
|
case Operation::RORb: case Operation::RORw: case Operation::RORl:
|
|
|
|
case Operation::ROXLb: case Operation::ROXLw: case Operation::ROXLl:
|
|
|
|
case Operation::ROXRb: case Operation::ROXRw: case Operation::ROXRl:
|
|
|
|
case Operation::BCHG:
|
|
|
|
case Operation::BCLR: case Operation::BSET:
|
2022-11-14 20:58:58 +00:00
|
|
|
case Operation::BFCHG: case Operation::BFCLR: case Operation::BFSET:
|
|
|
|
case Operation::BFINS:
|
2022-05-09 13:24:35 +00:00
|
|
|
return FetchOp1 | FetchOp2 | StoreOp2;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Two-operand; read both, write source.
|
|
|
|
//
|
|
|
|
case Operation::DBcc:
|
|
|
|
return FetchOp1 | FetchOp2 | StoreOp1;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Two-operand; read both, write both.
|
|
|
|
//
|
|
|
|
case Operation::EXG:
|
|
|
|
return FetchOp1 | FetchOp2 | StoreOp1 | StoreOp2;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Two-operand; just write destination.
|
|
|
|
//
|
|
|
|
case Operation::LEA:
|
|
|
|
return StoreOp2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* InstructionSets_68k_InstructionOperandFlags_hpp */
|