added to aas3
This commit is contained in:
parent
527d2e7346
commit
9ac28aa798
48 changed files with 7134 additions and 0 deletions
127
ass3/simulator_SIC_XE/include/opcode.h
Normal file
127
ass3/simulator_SIC_XE/include/opcode.h
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
#ifndef OPCODE_H
|
||||
#define OPCODE_H
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#include <unordered_map>
|
||||
#include <string_view>
|
||||
#include <optional>
|
||||
#include <cstdint>
|
||||
|
||||
// ==============================
|
||||
// Opcode definitions (SIC/XE)
|
||||
// ==============================
|
||||
#define ADD 0x18
|
||||
#define ADDF 0x58
|
||||
#define ADDR 0x90
|
||||
#define AND 0x40
|
||||
#define CLEAR 0xB4
|
||||
#define COMP 0x28
|
||||
#define COMPF 0x88
|
||||
#define COMPR 0xA0
|
||||
#define DIV 0x24
|
||||
#define DIVF 0x64
|
||||
#define DIVR 0x9C
|
||||
#define FIX 0xC4
|
||||
#define FLOAT 0xC0
|
||||
#define HIO 0xF4
|
||||
#define J 0x3C
|
||||
#define JEQ 0x30
|
||||
#define JGT 0x34
|
||||
#define JLT 0x38
|
||||
#define JSUB 0x48
|
||||
#define LDA 0x00
|
||||
#define LDB 0x68
|
||||
#define LDCH 0x50
|
||||
#define LDF 0x70
|
||||
#define LDL 0x08
|
||||
#define LDS 0x6C
|
||||
#define LDT 0x74
|
||||
#define LDX 0x04
|
||||
#define LPS 0xD0
|
||||
#define MUL 0x20
|
||||
#define MULF 0x60
|
||||
#define MULR 0x98
|
||||
#define NORM 0xC8
|
||||
#define OR 0x44
|
||||
#define RD 0xD8
|
||||
#define RMO 0xAC
|
||||
#define RSUB 0x4C
|
||||
#define SHIFTL 0xA4
|
||||
#define SHIFTR 0xA8
|
||||
#define SIO 0xF0
|
||||
#define SSK 0xEC
|
||||
#define STA 0x0C
|
||||
#define STB 0x78
|
||||
#define STCH 0x54
|
||||
#define STF 0x80
|
||||
#define STI 0xD4
|
||||
#define STL 0x14
|
||||
#define STS 0x7C
|
||||
#define STSW 0xE8
|
||||
#define STT 0x84
|
||||
#define STX 0x10
|
||||
#define SUB 0x1C
|
||||
#define SUBF 0x5C
|
||||
#define SUBR 0x94
|
||||
#define SVC 0xB0
|
||||
#define TD 0xE0
|
||||
#define TIO 0xF8
|
||||
#define TIX 0x2C
|
||||
#define TIXR 0xB8
|
||||
#define WD 0xDC
|
||||
|
||||
// ==============================
|
||||
// Extended opcodes (SIC/XE/XE)
|
||||
// ==============================
|
||||
#define NOP 0xF1
|
||||
#define HALT 0xF2
|
||||
#define XEXE 0xEE // Enable extended mode
|
||||
#define VADD 0x18
|
||||
#define VADDR 0x90
|
||||
#define VSUB 0x1C
|
||||
#define VSUBR 0x94
|
||||
#define VMUL 0x20
|
||||
#define VMULR 0x98
|
||||
#define VDIV 0x24
|
||||
#define VDIVR 0x9C
|
||||
#define STVA 0x0C
|
||||
#define STVS 0x7C
|
||||
#define STVT 0x84
|
||||
#define LDVA 0x00
|
||||
#define LDVS 0x68
|
||||
#define LDVT 0x04
|
||||
|
||||
static std::unordered_map<std::string_view, uint8_t> mnemonicToOpcode;
|
||||
static bool opcodeTablesInitialized = false;
|
||||
|
||||
|
||||
enum class InstructionType {
|
||||
TYPE1,
|
||||
TYPE2,
|
||||
TYPE3_4,
|
||||
INVALID
|
||||
};
|
||||
|
||||
class Machine; // forward
|
||||
|
||||
// Store raw function pointer (void*) to allow different handler signatures
|
||||
using RawHandler = void*;
|
||||
|
||||
struct InstructionInfo {
|
||||
const char* name;
|
||||
InstructionType type;
|
||||
RawHandler handler;
|
||||
};
|
||||
|
||||
extern InstructionInfo instructions[];
|
||||
extern InstructionInfo instructionsEXEX[];
|
||||
|
||||
extern std::optional<uint8_t> findOpcodeByMnemonic(std::string_view name);
|
||||
extern const InstructionInfo& getInstructionInfo(uint8_t opcode);
|
||||
|
||||
|
||||
// Initialize the instruction table
|
||||
void loadInstructionSet();
|
||||
|
||||
#endif // OPCODE_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue