mirror of
https://gitlab.os-k.eu/os-k-team/kvisc.git
synced 2023-08-25 14:05:46 +02:00
137 lines
2.3 KiB
C
137 lines
2.3 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 <in/instrs.h>
|
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
#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 = rax;
|
|
}
|
|
|
|
writemem(ctx, val, R(reg), len);
|
|
|
|
STR_MOVE(reg, len);
|
|
}
|
|
|
|
IMPL_START_0(stosb)
|
|
{
|
|
stos_impl(ctx, p1, p2, 1);
|
|
}
|
|
IMPL_END;
|
|
|
|
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;
|
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
IMPL_START_0(scasb)
|
|
{
|
|
}
|
|
IMPL_END;
|
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
IMPL_START_0(cmpsb)
|
|
{
|
|
}
|
|
IMPL_END;
|
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
IMPL_START_0(movsb)
|
|
{
|
|
}
|
|
IMPL_END;
|
|
|
|
//----------------------------------------------------------------------------//
|
|
|