From c667bd23fcd5d8bd989b0a1ead61e6c65f3fefb7 Mon Sep 17 00:00:00 2001 From: julianb0 Date: Sat, 8 Jun 2019 09:36:28 +0200 Subject: [PATCH] vm --- vm/pc/decd.c | 17 +++++++---------- vm/pc/decd.h | 21 --------------------- 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/vm/pc/decd.c b/vm/pc/decd.c index fc19ce4..738f82b 100644 --- a/vm/pc/decd.c +++ b/vm/pc/decd.c @@ -34,7 +34,7 @@ void decode(ctx_t *ctx) acc_t p1 = { 0 }; acc_t p2 = { 0 }; - bool rep = 0 + bool rep = 0; uint cond = 0; bool lock, nomore; @@ -228,7 +228,7 @@ void extract_param(ctx_t *ctx, acc_t *p, uchar fmt) imm2 = ctx->get(ctx); } - p->addr = R(reg1) + R(reg2) * imm1 + imm2; + p->addr = R(reg1) + R(reg2) * imm1 + (long)imm2; break; @@ -248,6 +248,8 @@ static bool eval_cond(ctx_t *ctx, uint cond) switch (cond) { + case CD_NONE: ok = 1; break; + case CD_C: ok = flg&CF; break; case CD_O: ok = flg&OF; break; case CD_Z: ok = flg&ZF; break; @@ -358,10 +360,7 @@ void exec_instr( // Debugging dump_instr(ctx, in, p1, p2, lock, rep, cond, pc); - - if (rep && !cond) - cond = CD_CXZ; - + do_rep: if (!eval_cond(ctx, cond)) @@ -384,11 +383,9 @@ do_rep: } } - if (rep) + if (rep && rcx > 0) { - if (cond == CD_CXZ) - rcx--; - + rcx--; goto do_rep; } } diff --git a/vm/pc/decd.h b/vm/pc/decd.h index 457af5c..5ba1f27 100644 --- a/vm/pc/decd.h +++ b/vm/pc/decd.h @@ -93,24 +93,3 @@ void extract_param(ctx_t *ctx, acc_t *p, uchar fmt); - - - - - - - - - - - - - - - - - - - - -