1
0
mirror of https://gitlab.os-k.eu/os-k-team/kvisc.git synced 2023-08-25 14:05:46 +02:00
kvisc/vm/pc/decd.h
2019-06-07 22:23:38 +02:00

117 lines
1.6 KiB
C

// The OS/K Team licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
enum
{
CD_NONE,
CD_C, CD_O, CD_Z, CD_S, CD_P,
CD_A, CD_AE, CD_B, CD_BE,
CD_G, CD_GE, CD_L, CD_LE,
CD_CXZ, COND_RES,
};
enum
{
PREF_LOCK = (1 << 15),
PREF_NOMORE = (1 << 14),
PREF_REP = (1 << 15),
BITS_COND = (1 << 14) | (1 << 13) | (1 << 12)
| (1 << 11) | (1 << 10),
COND_SHIFT = 8,
Fx_MASK = 0x1F,
F1_SHIFT = 5,
};
enum
{
A_NONE = 0b00000,
A_REG = 0b00001,
A_IMM64 = 0b00010,
AM_START = 0b00100,
AM_IMM64 = 0b00,
AM_RR = 0b01,
AM_RRI = 0b10,
AM_RRII = 0b11,
AM_8ACC = 0b00100,
AM_16ACC = 0b01000,
AM_32ACC = 0b01100,
AM_64ACC = 0b10000,
AM_MLEN_MASK = 0b11100,
AM_MFMT_MASK = 0b00011,
};
#define ACC_FMT_IS_MEM(x) ((x) >= AM_START && (x) <= (AM_64ACC|AM_RRII))
#define ACC_IS_MEM(x) (ACC_FMT_IS_MEM((x)->type))
struct acc_t
{
uint type;
ulong val;
// A_REG
ulong reg;
// AM_...
ulong addr;
uint mlen;
};
enum { NOPRM, P_REG, P_IMM, P_MEM=4 };
struct instr_t
{
char *name;
char *full;
uint prm1;
uint prm2;
bool (*func)(ctx_t *, acc_t *, acc_t *, ulong *);
};
void exec_instr(ctx_t *ctx,
instr_t *in,
acc_t *p1,
acc_t *p2,
bool lock,
bool rep,
uint cond,
ulong pc);
void extract_param(ctx_t *ctx,
acc_t *p,
uchar fmt);