1
0
mirror of https://gitlab.os-k.eu/os-k-team/kvisc.git synced 2023-08-25 14:05:46 +02:00
This commit is contained in:
julianb0 2019-06-13 16:27:33 +02:00
parent eedcd970e5
commit 037f0b34c0
No known key found for this signature in database
GPG Key ID: 9C7ACF0C053FB8A1
5 changed files with 75 additions and 12 deletions

View File

@ -408,13 +408,13 @@ stosb r rim
# %str = %str - sizeof(x)
# FI
#
# When no parameters are given, %str = RDI and %dest = RAX
# When one parameter is given, %str = RDI and %dest = $1
# When two parameters are given, %str = $2 and %dest = $1
# When no parameters are given, %dest = RAX and %str = RSI
# When one parameter is given, %dest = $1 and %str = RSI
# When two parameters are given, %dest = $1 and %str = $2
#
lodsb
lodsb r
lodsb rm r
lodsb r r
#
# Scan string for a particular value (SCASx)

View File

@ -8,15 +8,21 @@
//----------------------------------------------------------------------------//
#define GETV(v, p) \
#define DECV(v, p) \
ulong v; \
GETV(v, p)
#define GETV(v, p) \
assert(p); \
if (ACC_FMT_IS_MEM(p->type)) \
v = readmem(ctx, p->addr, p->mlen); \
else v = p->val
#define GETVZX(v, p) \
#define DECVZX(v, p) \
ulong v; \
GETVZX(v, p)
#define GETVZX(v, p) \
assert(p); \
if (ACC_FMT_IS_MEM(p->type)) \
v = readmemzx(ctx, p->addr, p->mlen); \
@ -31,13 +37,13 @@ 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 *r1, ulong *r2) \
{ \
GETV(v1, p1);
DECV(v1, p1);
#define IMPL_START_2(name) \
bool i_##name(ctx_t *ctx, acc_t *p1, acc_t *p2, ulong *r1, ulong *r2) \
{ \
GETV(v1, p1); \
GETV(v2, p2);
DECV(v1, p1); \
DECV(v2, p2);
#define IMPL_OUT_ZSF \
SET_ZSF(v1); \

View File

@ -19,7 +19,7 @@ IMPL_OUT;
IMPL_START_1(movzx)
{
GETVZX(v2, p2);
DECVZX(v2, p2);
v1 = v2;
}
IMPL_OUT;

View File

@ -46,8 +46,7 @@ IMPL_START_0(enter)
rbp = rsp;
if (p1) {
GETV(v1, p1);
rsp -= v1 * 8;
rsp -= p1->val * 8;
}
}
IMPL_END;

View File

@ -5,15 +5,73 @@
//----------------------------------------------------------------------------//
#define STR_MOVE(reg, len) \
if ((flg & DF) == 0) \
R(reg) += len; \
else \
R(reg) -= len;
//----------------------------------------------------------------------------//
void stos_impl(ctx_t *ctx, acc_t *p1, acc_t *p2, uint len)
{
ulong reg, val;
if (p2) {
DECV(v2, p2);
reg = p1->reg;
val = v2;
}
else if (p1) {
DECV(v1, p1);
reg = RDI;
val = v1;
}
else {
reg = RDI;
val = R(rax);
}
writemem(ctx, val, R(reg), len);
STR_MOVE(reg, len);
}
IMPL_START_0(stosb)
{
stos_impl(ctx, p1, p2, 1);
}
IMPL_END;
//----------------------------------------------------------------------------//
void lods_impl(ctx_t *ctx, acc_t *p1, acc_t *p2, uint len)
{
ulong reg1, reg2;
if (p2) {
reg1 = p1->reg;
reg2 = p2->reg;
}
else if (p1) {
reg1 = p1->reg;
reg2 = RSI;
}
else {
reg1 = RAX;
reg2 = RSI;
}
R(reg1) = readmem(ctx, R(reg2), len);
}
IMPL_START_0(lodsb)
{
lods_impl(ctx, p1, p2, 1);
}
IMPL_END;