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/decode.h

106 lines
1.9 KiB
C
Raw Normal View History

2019-06-07 22:23:38 +02:00
// 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
{
2019-07-01 21:46:36 +02:00
SUFF_LOCK = (1 << 15),
SUFF_NOMORE = (1 << 14),
SUFF_COND = (1 << 13),
SUFF_REP = (1 << 15),
2019-06-07 22:23:38 +02:00
Fx_MASK = 0x1F,
2019-07-01 21:46:36 +02:00
F3_SHIFT = 10,
F2_SHIFT = 5,
2019-06-07 22:23:38 +02:00
};
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;
2019-06-12 15:30:35 +02:00
// For instruction dumping ONLY
2019-06-14 13:34:24 +02:00
ushort reg1, reg2;
short imm1, imm2;
2019-06-07 22:23:38 +02:00
};
enum { NOPRM, P_REG, P_IMM, P_MEM=4 };
struct instr_t
{
char *name;
char *full;
uint prm1;
uint prm2;
2019-07-01 21:46:36 +02:00
uint prm3;
2019-06-07 22:23:38 +02:00
2019-07-09 21:02:26 +02:00
uint (*func)(ctx_t *, acc_t *, acc_t *, acc_t *,
2019-07-01 21:46:36 +02:00
ulong *, ulong *, ulong *);
2019-06-07 22:23:38 +02:00
};
2019-07-02 20:13:05 +02:00
bool eval_cond(ctx_t *ctx, uint cond);
2019-06-07 22:23:38 +02:00
void exec_instr(ctx_t *ctx,
instr_t *in,
acc_t *p1,
2019-07-01 21:46:36 +02:00
acc_t *p2,
acc_t *p3,
2019-06-07 22:23:38 +02:00
bool lock,
2019-07-02 20:13:05 +02:00
bool rep);
2019-06-07 22:23:38 +02:00
void extract_param(ctx_t *ctx,
acc_t *p,
uchar fmt);
2019-06-12 15:30:35 +02:00
void dump_instr(ctx_t *ctx,
instr_t *in,
acc_t *p1,
acc_t *p2,
2019-07-01 21:46:36 +02:00
acc_t *p3,
2019-06-12 15:30:35 +02:00
bool lock,
2019-07-02 20:13:05 +02:00
bool rep);
2019-06-12 15:30:35 +02:00