mirror of
https://gitlab.os-k.eu/os-k-team/kvisc.git
synced 2023-08-25 14:05:46 +02:00
49 lines
2.8 KiB
C
49 lines
2.8 KiB
C
// The OS/K Team licences this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
#include "arch.h"
|
|
|
|
#define IMPL_START_0(name) \
|
|
void i_##name(ctx_t *ctx, acc_t *p1, acc_t *p2) \
|
|
{ \
|
|
|
|
#define IMPL_START_1(name) \
|
|
void i_##name(ctx_t *ctx, acc_t *p1, acc_t *p2) \
|
|
{ \
|
|
ulong v1 = (p1->type == A_REG ? ctx->r[p1->val].val : p1->val); \
|
|
if (p1->mem) v1 = readmem64(ctx, v1 + p1->off); \
|
|
|
|
#define IMPL_START_2(name) \
|
|
void i_##name(ctx_t *ctx, acc_t *p1, acc_t *p2) \
|
|
{ \
|
|
ulong v1 = (p1->type == A_REG ? ctx->r[p1->val].val : p1->val); \
|
|
ulong v2 = (p2->type == A_REG ? ctx->r[p2->val].val : p2->val); \
|
|
if (p1->mem) v1 = readmem64(ctx, v1 + p1->off); \
|
|
if (p2->mem) v2 = readmem64(ctx, v2 + p2->off); \
|
|
|
|
#define IMPL_START_3(name) \
|
|
void i_##name(ctx_t *ctx, acc_t *p1, acc_t *p2) \
|
|
{ \
|
|
ulong v2 = (p2->type == A_REG ? ctx->r[p2->val].val : p2->val); \
|
|
if (p2->mem) v2 = readmem64(ctx, v2 + p2->off); \
|
|
|
|
#define IMPL_OUT \
|
|
assert(p1->type == A_REG || p1->mem); \
|
|
if (p1->mem) { \
|
|
ulong addr = p1->type == A_REG ? ctx->r[p1->val].val : p1->val; \
|
|
writemem64(ctx, v1, addr); \
|
|
} \
|
|
else ctx->r[p1->val].val = v1; \
|
|
} \
|
|
|
|
#define IMPL_END \
|
|
}
|
|
|
|
#define CHK_SUPERV() \
|
|
do { \
|
|
if ((ctx->r[FLG].val & (1L << 62)) == 1) { \
|
|
_except(ctx, E_SYS, "Supervisor-only INSTR"); \
|
|
} \
|
|
} while (0)
|
|
|