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

90 lines
1.4 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;
2019-08-03 17:41:44 +02:00
uint nprms;
2019-08-03 19:01:12 +02:00
uint (*func)(acc_t *, acc_t *, acc_t *,
ulong *, ulong *, ulong *);
2019-06-07 22:23:38 +02:00
};
2019-08-03 19:01:12 +02:00
bool eval_cond(uint cond);
2019-07-02 20:13:05 +02:00
2019-08-03 19:01:12 +02:00
void exec_instr(instr_t *in,
2019-06-07 22:23:38 +02:00
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-08-03 19:01:12 +02:00
void dump_instr(instr_t *in,
2019-06-12 15:30:35 +02:00
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