/*
    MISC processor instruction set
*/

typedef unsigned short int WORD;    // machine word
typedef short int SWORD;            // signed machine word
typedef unsigned char BYTE;         // machine byte

// conversion macros
#define get_inst(v) (v >> 8)
#define get_src(v) (v & 0x0F)
#define get_dest(v)  ((v >> 4) & 0x0F)
#define make_inst(v, d, s) ((v << 8) | (d << 4) | (s))

// size of machine memory
#define MEMSIZE 65536
#define MAXWORD 65536

// status flags
#define Z 1
#define N 2

#define SR  0x0D            // stack pointer   (index into register array)
#define PC  0x0E            // status register
#define SP  0x0F            // program counter

#define NOP     0x00
#define HALT    0x01

#define LDI     0x10
#define LDR     0x11
#define LDP     0x12
#define LDA     0x13

#define STA     0x20
#define STP     0x21

#define ADD     0x30
#define SUB     0x31
#define MUL     0x32
#define DIV     0x33
#define MOD     0x34

#define SHR     0x35
#define SHL     0x36
#define AND     0x37
#define OR      0x38
#define XOR     0x39

#define ADDI    0x40
#define SUBI    0x41
#define MULI    0x42
#define DIVI    0x43
#define MODI    0x44

#define SHRI    0x45
#define SHLI    0x46
#define ANDI    0x47
#define ORI     0x48
#define XORI    0x49

#define CALLA   0x50
#define CALLP   0x51
#define RET     0x52

#define PUSH    0x60
#define PULL    0x61

#define CMP     0x70
#define CMPI    0x71
#define BE      0x72
#define BL      0x73
#define BLE     0x74
#define BG      0x75
#define BGE     0x76
#define BAA     0x77
#define BAP     0x78

#define IN      0x80
#define OUT     0x81




