kvisc/vm/pc/exec.c

43 lines
1.1 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.
#include <pc/arch.h>
#define OUTPUT(p, r) { \
if (p->type == A_REG) \
R(p->reg) = r; \
else if (ACC_IS_MEM(p)) \
writemem(r, p->addr, p->mlen); \
else _except(E_ACC, "Trying to output to an IMM"); \
}
//
// Executes an instruction
//
void exec_instr(instr_t *in,
acc_t *p1,
acc_t *p2,
acc_t *p3)
{
uint out;
ulong r1 = 0, r2 = 0;
// Global instruction counter
ctx->ninstrs++;
if (ctx->dumpsw)
dump_instr(in, p1, p2, p3);
out = in->func(p1, p2, p3, &r1, &r2);
if (out)
{
OUTPUT(p1, r1);
if (__builtin_expect(out == 2, 0))
OUTPUT(p2, r2);
R(RZX) = 0;
}
}