This commit is contained in:
julianb0 2019-06-12 15:47:11 +02:00
parent d5970ad5e5
commit 35af39acf6
No known key found for this signature in database
GPG Key ID: DDF8325C95299A62
5 changed files with 34 additions and 14 deletions

View File

@ -103,7 +103,7 @@ for _, line in enumerate(fp):
.format(tok[0], name, p1, p2, tok[0]))
hd.write("#else\n")
hd.write("#define I_{} {}\n".format(name.upper(), count))
hd.write("extern bool i_{}(ctx_t *, acc_t *, acc_t *, ulong *);\n"
hd.write("extern bool i_{}(ctx_t *, acc_t *, acc_t *, ulong *, ulong *);\n"
.format(tok[0]))
hd.write("#endif\n\n")

View File

@ -15,16 +15,16 @@
#define IMPL_START_0(name) \
bool i_##name(ctx_t *ctx, acc_t *p1, acc_t *p2, ulong *ret) \
bool i_##name(ctx_t *ctx, acc_t *p1, acc_t *p2, ulong *r1, ulong *r2) \
{
#define IMPL_START_1(name) \
bool i_##name(ctx_t *ctx, acc_t *p1, acc_t *p2, ulong *ret) \
bool i_##name(ctx_t *ctx, acc_t *p1, acc_t *p2, ulong *r1, ulong *r2) \
{ \
GETV(v1, p1);
#define IMPL_START_2(name) \
bool i_##name(ctx_t *ctx, acc_t *p1, acc_t *p2, ulong *ret) \
bool i_##name(ctx_t *ctx, acc_t *p1, acc_t *p2, ulong *r1, ulong *r2) \
{ \
GETV(v1, p1); \
GETV(v2, p2);
@ -34,14 +34,14 @@ bool i_##name(ctx_t *ctx, acc_t *p1, acc_t *p2, ulong *ret) \
IMPL_OUT
#define IMPL_OUT \
*ret = v1; \
*r1 = v1; \
return 1; \
}
// XXX
#define IMPL_OUT_2 \
*ret = v1; \
return 1; \
*r1 = v1; \
*r2 = v2; \
return 2; \
}
#define IMPL_END \

View File

@ -295,8 +295,8 @@ void exec_instr(
bool lock, bool rep,
uint cond, ulong pc)
{
bool out = 0;
ulong ret = 0;
bool out;
ulong r1 = 0, r2 = 0;
// Debugging
dump_instr(ctx, in, p1, p2, lock, rep, cond, pc);
@ -306,12 +306,12 @@ do_rep:
if (!eval_cond(ctx, cond))
return;
out = in->func(ctx, p1, p2, &ret);
out = in->func(ctx, p1, p2, &r1, &r2);
if (out)
{
if (p1->type == A_REG)
R(p1->reg) = ret;
R(p1->reg) = r1;
else if (p1->type == A_IMM64)
_except(ctx, E_ACC, "Trying to output to an IMM64");
@ -319,7 +319,22 @@ do_rep:
else
{
assert(ACC_IS_MEM(p1));
writemem(ctx, ret, p1->addr, p1->mlen);
writemem(ctx, r1, p1->addr, p1->mlen);
}
}
if (out == 2)
{
if (p2->type == A_REG)
R(p2->reg) = r2;
else if (p2->type == A_IMM64)
_except(ctx, E_ACC, "Trying to output to an IMM64");
else
{
assert(ACC_IS_MEM(p2));
writemem(ctx, r2, p2->addr, p2->mlen);
}
}

View File

@ -79,7 +79,7 @@ struct instr_t
uint prm1;
uint prm2;
bool (*func)(ctx_t *, acc_t *, acc_t *, ulong *);
bool (*func)(ctx_t *, acc_t *, acc_t *, ulong *, ulong *);
};
void exec_instr(ctx_t *ctx,

View File

@ -80,8 +80,13 @@ void dump_instr(
if (cond)
{
log("c");
if (cond & (1 << 4))
{
cond &= ~(1 << 4);
log("n");
}
assert(cond <= sizeof(cond_suffixes)/sizeof(char *));