// SPDX-FileCopyrightText: 2026 godcodehunter
// SPDX-License-Identifier: LGPL-3.0-only

#ifndef RZ_MILSTD1750_OPCODES_H
#define RZ_MILSTD1750_OPCODES_H

// Full 16-bit opcode match patterns for MIL-STD-1750A instructions. The low
// byte is zero for one-word opcodes; IM-format (0x4A0x) and the special words
// (BPT/NOP) carry meaningful low bits. Shared between the disassembler table
// and the analysis plugin, which compares against the instruction word with its
// operand bits cleared.

#define MIL_OP_LB   0x0000
#define MIL_OP_DLB  0x0400
#define MIL_OP_STB  0x0800
#define MIL_OP_DSTB 0x0C00
#define MIL_OP_AB   0x1000
#define MIL_OP_SBB  0x1400
#define MIL_OP_MB   0x1800
#define MIL_OP_DB   0x1C00
#define MIL_OP_FAB  0x2000
#define MIL_OP_FSB  0x2400
#define MIL_OP_FMB  0x2800
#define MIL_OP_FDB  0x2C00
#define MIL_OP_ORB  0x3000
#define MIL_OP_ANDB 0x3400
#define MIL_OP_CB   0x3800
#define MIL_OP_FCB  0x3C00
#define MIL_OP_LBX  0x4000
#define MIL_OP_DLBX 0x4010
#define MIL_OP_STBX 0x4020
#define MIL_OP_DSTX 0x4030
#define MIL_OP_ABX  0x4040
#define MIL_OP_SBBX 0x4050
#define MIL_OP_MBX  0x4060
#define MIL_OP_DBX  0x4070
#define MIL_OP_FABX 0x4080
#define MIL_OP_FSBX 0x4090
#define MIL_OP_FMBX 0x40A0
#define MIL_OP_FDBX 0x40B0
#define MIL_OP_CBX  0x40C0
#define MIL_OP_FCBX 0x40D0
#define MIL_OP_ANDX 0x40E0
#define MIL_OP_ORBX 0x40F0
#define MIL_OP_XIO  0x4800
#define MIL_OP_VIO  0x4900
#define MIL_OP_AIM  0x4A01
#define MIL_OP_SIM  0x4A02
#define MIL_OP_MIM  0x4A03
#define MIL_OP_MSIM 0x4A04
#define MIL_OP_DIM  0x4A05
#define MIL_OP_DVIM 0x4A06
#define MIL_OP_ANDM 0x4A07
#define MIL_OP_ORIM 0x4A08
#define MIL_OP_XORM 0x4A09
#define MIL_OP_CIM  0x4A0A
#define MIL_OP_NIM  0x4A0B
#define MIL_OP_BIF  0x4F00
#define MIL_OP_SB   0x5000
#define MIL_OP_SBR  0x5100
#define MIL_OP_SBI  0x5200
#define MIL_OP_RB   0x5300
#define MIL_OP_RBR  0x5400
#define MIL_OP_RBI  0x5500
#define MIL_OP_TB   0x5600
#define MIL_OP_TBR  0x5700
#define MIL_OP_TBI  0x5800
#define MIL_OP_TSB  0x5900
#define MIL_OP_SVBR 0x5A00
#define MIL_OP_RVBR 0x5C00
#define MIL_OP_TVBR 0x5E00
#define MIL_OP_SLL  0x6000
#define MIL_OP_SRL  0x6100
#define MIL_OP_SRA  0x6200
#define MIL_OP_SLC  0x6300
#define MIL_OP_DSLL 0x6500
#define MIL_OP_DSRL 0x6600
#define MIL_OP_DSRA 0x6700
#define MIL_OP_DSLC 0x6800
#define MIL_OP_SLR  0x6A00
#define MIL_OP_SAR  0x6B00
#define MIL_OP_SCR  0x6C00
#define MIL_OP_DSLR 0x6D00
#define MIL_OP_DSAR 0x6E00
#define MIL_OP_DSCR 0x6F00
#define MIL_OP_JC   0x7000
#define MIL_OP_JCI  0x7100
#define MIL_OP_JS   0x7200
#define MIL_OP_SOJ  0x7300
#define MIL_OP_BR   0x7400
#define MIL_OP_BEZ  0x7500
#define MIL_OP_BLT  0x7600
#define MIL_OP_BEX  0x7700
#define MIL_OP_BLE  0x7800
#define MIL_OP_BGT  0x7900
#define MIL_OP_BNZ  0x7A00
#define MIL_OP_BGE  0x7B00
#define MIL_OP_LSTI 0x7C00
#define MIL_OP_LST  0x7D00
#define MIL_OP_SJS  0x7E00
#define MIL_OP_URS  0x7F00
#define MIL_OP_L    0x8000
#define MIL_OP_LR   0x8100
#define MIL_OP_LISP 0x8200
#define MIL_OP_LISN 0x8300
#define MIL_OP_LI   0x8400
#define MIL_OP_LIM  0x8500
#define MIL_OP_DL   0x8600
#define MIL_OP_DLR  0x8700
#define MIL_OP_DLI  0x8800
#define MIL_OP_LM   0x8900
#define MIL_OP_EFL  0x8A00
#define MIL_OP_LUB  0x8B00
#define MIL_OP_LLB  0x8C00
#define MIL_OP_LUBI 0x8D00
#define MIL_OP_LLBI 0x8E00
#define MIL_OP_POPM 0x8F00
#define MIL_OP_ST   0x9000
#define MIL_OP_STC  0x9100
#define MIL_OP_STCI 0x9200
#define MIL_OP_MOV  0x9300
#define MIL_OP_STI  0x9400
#define MIL_OP_SFBS 0x9500
#define MIL_OP_DST  0x9600
#define MIL_OP_SRM  0x9700
#define MIL_OP_DSTI 0x9800
#define MIL_OP_STM  0x9900
#define MIL_OP_EFST 0x9A00
#define MIL_OP_STUB 0x9B00
#define MIL_OP_STLB 0x9C00
#define MIL_OP_SUBI 0x9D00
#define MIL_OP_SLBI 0x9E00
#define MIL_OP_PSHM 0x9F00
#define MIL_OP_A    0xA000
#define MIL_OP_AR   0xA100
#define MIL_OP_AISP 0xA200
#define MIL_OP_INCM 0xA300
#define MIL_OP_ABS  0xA400
#define MIL_OP_DABS 0xA500
#define MIL_OP_DA   0xA600
#define MIL_OP_DAR  0xA700
#define MIL_OP_FA   0xA800
#define MIL_OP_FAR  0xA900
#define MIL_OP_EFA  0xAA00
#define MIL_OP_EFAR 0xAB00
#define MIL_OP_FABS 0xAC00
#define MIL_OP_UAR  0xAD00
#define MIL_OP_UA   0xAE00
#define MIL_OP_S    0xB000
#define MIL_OP_SR   0xB100
#define MIL_OP_SISP 0xB200
#define MIL_OP_DECM 0xB300
#define MIL_OP_NEG  0xB400
#define MIL_OP_DNEG 0xB500
#define MIL_OP_DS   0xB600
#define MIL_OP_DSR  0xB700
#define MIL_OP_FS   0xB800
#define MIL_OP_FSR  0xB900
#define MIL_OP_EFS  0xBA00
#define MIL_OP_EFSR 0xBB00
#define MIL_OP_FNEG 0xBC00
#define MIL_OP_USR  0xBD00
#define MIL_OP_US   0xBE00
#define MIL_OP_MS   0xC000
#define MIL_OP_MSR  0xC100
#define MIL_OP_MISP 0xC200
#define MIL_OP_MISN 0xC300
#define MIL_OP_M    0xC400
#define MIL_OP_MR   0xC500
#define MIL_OP_DM   0xC600
#define MIL_OP_DMR  0xC700
#define MIL_OP_FM   0xC800
#define MIL_OP_FMR  0xC900
#define MIL_OP_EFM  0xCA00
#define MIL_OP_EFMR 0xCB00
#define MIL_OP_DV   0xD000
#define MIL_OP_DVR  0xD100
#define MIL_OP_DISP 0xD200
#define MIL_OP_DISN 0xD300
#define MIL_OP_D    0xD400
#define MIL_OP_DR   0xD500
#define MIL_OP_DD   0xD600
#define MIL_OP_DDR  0xD700
#define MIL_OP_FD   0xD800
#define MIL_OP_FDR  0xD900
#define MIL_OP_EFD  0xDA00
#define MIL_OP_EFDR 0xDB00
#define MIL_OP_STE  0xDC00
#define MIL_OP_DSTE 0xDD00
#define MIL_OP_LE   0xDE00
#define MIL_OP_DLE  0xDF00
#define MIL_OP_OR   0xE000
#define MIL_OP_ORR  0xE100
#define MIL_OP_AND  0xE200
#define MIL_OP_ANDR 0xE300
#define MIL_OP_XOR  0xE400
#define MIL_OP_XORR 0xE500
#define MIL_OP_N    0xE600
#define MIL_OP_NR   0xE700
#define MIL_OP_FIX  0xE800
#define MIL_OP_FLT  0xE900
#define MIL_OP_EFIX 0xEA00
#define MIL_OP_EFLT 0xEB00
#define MIL_OP_XBR  0xEC00
#define MIL_OP_XWR  0xED00
#define MIL_OP_C    0xF000
#define MIL_OP_CR   0xF100
#define MIL_OP_CISP 0xF200
#define MIL_OP_CISN 0xF300
#define MIL_OP_CBL  0xF400
#define MIL_OP_UCIM 0xF500
#define MIL_OP_DC   0xF600
#define MIL_OP_DCR  0xF700
#define MIL_OP_FC   0xF800
#define MIL_OP_FCR  0xF900
#define MIL_OP_EFC  0xFA00
#define MIL_OP_EFCR 0xFB00
#define MIL_OP_UCR  0xFC00
#define MIL_OP_UC   0xFD00
#define MIL_OP_NOP  0xFF00
#define MIL_OP_BPT  0xFFFF

// XIO command words (second operand of XIO/VIO).

#define MIL_XIO_SMK  0x2000
#define MIL_XIO_CLIR 0x2001
#define MIL_XIO_ENBL 0x2002
#define MIL_XIO_DSBL 0x2003
#define MIL_XIO_RPI  0x2004
#define MIL_XIO_SPI  0x2005
#define MIL_XIO_OD   0x2008
#define MIL_XIO_RNS  0x200A
#define MIL_XIO_WSW  0x200E
#define MIL_XIO_CO   0x4000
#define MIL_XIO_CLC  0x4001
#define MIL_XIO_MPEN 0x4003
#define MIL_XIO_ESUR 0x4004
#define MIL_XIO_DSUR 0x4005
#define MIL_XIO_DMAE 0x4006
#define MIL_XIO_DMAD 0x4007
#define MIL_XIO_TAS  0x4008
#define MIL_XIO_TAH  0x4009
#define MIL_XIO_OTA  0x400A
#define MIL_XIO_GO   0x400B
#define MIL_XIO_TBS  0x400C
#define MIL_XIO_TBH  0x400D
#define MIL_XIO_OTB  0x400E
#define MIL_XIO_RMK  0xA000
#define MIL_XIO_RIC1 0xA001
#define MIL_XIO_RIC2 0xA002
#define MIL_XIO_RPIR 0xA004
#define MIL_XIO_RDOR 0xA008
#define MIL_XIO_RDI  0xA009
#define MIL_XIO_TPIO 0xA00B
#define MIL_XIO_RMFS 0xA00D
#define MIL_XIO_RSW  0xA00E
#define MIL_XIO_RCFR 0xA00F
#define MIL_XIO_CI   0xC000
#define MIL_XIO_RCS  0xC001
#define MIL_XIO_ITA  0xC00A
#define MIL_XIO_ITB  0xC00E

#endif
