1
0
mirror of https://gitlab.os-k.eu/os-k-team/kvisc.git synced 2023-08-25 14:05:46 +02:00
kvisc/vm/in/string.c

137 lines
2.3 KiB
C
Raw Normal View History

2019-06-13 15:32:24 +02:00
// 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 <in/instrs.h>
//----------------------------------------------------------------------------//
2019-06-13 16:27:33 +02:00
#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;
2019-06-13 17:13:59 +02:00
val = rax;
2019-06-13 16:27:33 +02:00
}
writemem(ctx, val, R(reg), len);
STR_MOVE(reg, len);
}
2019-06-13 15:32:24 +02:00
IMPL_START_0(stosb)
{
2019-06-13 16:27:33 +02:00
stos_impl(ctx, p1, p2, 1);
2019-06-13 15:32:24 +02:00
}
IMPL_END;
2019-06-13 17:13:59 +02:00
IMPL_START_0(stosw)
{
stos_impl(ctx, p1, p2, 2);
}
IMPL_END;
IMPL_START_0(stosl)
{
stos_impl(ctx, p1, p2, 4);
}
IMPL_END;
IMPL_START_0(stosq)
{
stos_impl(ctx, p1, p2, 8);
}
IMPL_END;
2019-06-13 15:47:20 +02:00
//----------------------------------------------------------------------------//
2019-06-13 16:27:33 +02:00
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);
}
2019-06-13 15:32:24 +02:00
IMPL_START_0(lodsb)
{
2019-06-13 16:27:33 +02:00
lods_impl(ctx, p1, p2, 1);
2019-06-13 15:32:24 +02:00
}
IMPL_END;
2019-06-13 17:13:59 +02:00
IMPL_START_0(lodsw)
{
lods_impl(ctx, p1, p2, 2);
}
IMPL_END;
IMPL_START_0(lodsl)
{
lods_impl(ctx, p1, p2, 4);
}
IMPL_END;
IMPL_START_0(lodsq)
{
lods_impl(ctx, p1, p2, 8);
}
IMPL_END;
2019-06-13 15:47:20 +02:00
//----------------------------------------------------------------------------//
IMPL_START_0(scasb)
{
}
IMPL_END;
//----------------------------------------------------------------------------//
IMPL_START_0(cmpsb)
{
}
IMPL_END;
//----------------------------------------------------------------------------//
2019-06-13 15:32:24 +02:00
IMPL_START_0(movsb)
{
}
IMPL_END;
//----------------------------------------------------------------------------//