kvisc/vm/pc/decode.h

97 lines
1.5 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,
2019-07-22 14:41:50 +02:00
CD_C,
CD_O,
CD_Z,
CD_S,
CD_P,
CD_BE,
CD_L,
CD_LE,
CD_AXZ,
CD_BXZ,
CD_CXZ,
CD_DXZ,
2019-06-07 22:23:38 +02:00
};
enum
{
2019-07-24 16:52:26 +02:00
SUFF_REP = (1 << 7),
SUFF_LOCK = (1 << 6),
SUFF_COND = 0b00011111,
2019-06-07 22:23:38 +02:00
};
enum
{
2019-07-24 17:42:42 +02:00
A_NONE = 0,
A_REG = 3,
2019-06-07 22:23:38 +02:00
2019-07-24 16:52:26 +02:00
A_IMM8 = 1,
A_IMM16 = 2,
A_IMM32 = 4,
A_IMM64 = 8,
2019-06-07 22:23:38 +02:00
2019-07-24 16:52:26 +02:00
AM_RR = 0xF0,
AM_RRI = 0xF1,
AM_RRII = 0xF2,
2019-06-07 22:23:38 +02:00
};
2019-07-24 16:52:26 +02:00
#define ACC_FMT_IS_MEM(x) (((x) & 0xF0) != 0)
#define ACC_IS_MEM(p) ACC_FMT_IS_MEM((p)->type)
2019-06-07 22:23:38 +02:00
struct acc_t
{
uint type;
ulong val;
// A_REG
2019-07-24 16:52:26 +02:00
uchar reg;
2019-06-07 22:23:38 +02:00
// AM_...
ulong addr;
uint mlen;
2019-06-12 15:30:35 +02:00
// For instruction dumping ONLY
2019-07-24 16:52:26 +02:00
uchar reg1, reg2;
char imm1;
long 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
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