2019-05-30 18:31:50 +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.
|
|
|
|
|
2019-06-05 12:53:09 +02:00
|
|
|
#include <in/instrs.h>
|
2019-05-30 18:31:50 +02:00
|
|
|
|
2019-07-04 20:33:49 +02:00
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
|
2019-07-17 20:26:03 +02:00
|
|
|
IMPL_START_1(jmp) { R(RIP) = v1; } IMPL_END;
|
|
|
|
IMPL_START_1(loop) {
|
|
|
|
if (R(RCX) > 0) {
|
|
|
|
R(RCX)--;
|
|
|
|
R(RIP) = v1;
|
|
|
|
}
|
2019-07-04 20:33:49 +02:00
|
|
|
}
|
2019-07-17 20:26:03 +02:00
|
|
|
IMPL_END;
|
2019-07-04 20:33:49 +02:00
|
|
|
|
2019-07-17 20:26:03 +02:00
|
|
|
IMPL_START_3(b) {
|
|
|
|
COMPARE(v1, v2);
|
2019-07-04 20:33:49 +02:00
|
|
|
|
2019-07-17 20:26:03 +02:00
|
|
|
if (eval_cond(ctx, ctx->cond))
|
|
|
|
R(RIP) = v3;
|
2019-06-03 15:16:11 +02:00
|
|
|
}
|
2019-07-17 20:26:03 +02:00
|
|
|
IMPL_END;
|
2019-06-03 15:16:11 +02:00
|
|
|
|
2019-06-13 15:00:48 +02:00
|
|
|
//----------------------------------------------------------------------------//
|
2019-06-03 15:16:11 +02:00
|
|
|
|
2019-07-17 22:25:50 +02:00
|
|
|
IMPL_START_X_NOIN(lea) { v1 = p2->addr; } IMPL_OUT;
|
2019-07-17 20:26:03 +02:00
|
|
|
IMPL_START_2_ONLY(mov) { v1 = v2; } IMPL_OUT;
|
2019-05-30 18:31:50 +02:00
|
|
|
|
2019-07-17 20:26:03 +02:00
|
|
|
IMPL_START_2_ONLY(movsxb) { v1 = (ulong)(long)(char)(v2 & 0xFF); }IMPL_OUT;
|
|
|
|
IMPL_START_2_ONLY(movsxw) { v1 = (ulong)(long)(short)(v2 & 0xFFFF); }IMPL_OUT;
|
|
|
|
IMPL_START_2_ONLY(movsxl) { v1 = (ulong)(long)(int)(v2 & 0xFFFFFFFF); }IMPL_OUT;
|
2019-05-30 18:31:50 +02:00
|
|
|
|
2019-07-17 22:25:50 +02:00
|
|
|
IMPL_START_X_NOIN(movzx) { DECVZX(v2, p2); v1 = v2; } IMPL_OUT;
|
2019-06-02 16:33:28 +02:00
|
|
|
|
2019-07-17 20:26:03 +02:00
|
|
|
IMPL_START_2(xchg) { ulong t = v1; v1 = v2; v2 = t; } IMPL_OUT_2;
|
2019-07-04 20:33:49 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
|
2019-07-17 20:26:03 +02:00
|
|
|
//
|
|
|
|
// Stack manipulation instructions
|
|
|
|
//
|
|
|
|
|
|
|
|
IMPL_START_1(push) {
|
|
|
|
R(RSP) -= 8;
|
|
|
|
writemem(ctx, v1, R(RSP), 8);
|
|
|
|
} IMPL_END;
|
|
|
|
|
|
|
|
IMPL_START_1(pop) {
|
|
|
|
v1 = readmem(ctx, R(RSP), 8);
|
|
|
|
R(RSP) += 8;
|
|
|
|
} IMPL_OUT;
|
|
|
|
|
|
|
|
IMPL_START_1(call) {
|
|
|
|
R(RSP) -= 8;
|
|
|
|
writemem(ctx, R(RIP), R(RSP), 8);
|
|
|
|
R(RIP) = v1;
|
|
|
|
} IMPL_END;
|
|
|
|
|
|
|
|
IMPL_START_0(ret) {
|
|
|
|
R(RIP) = readmem(ctx, R(RSP), 8); R(RSP) += 8;
|
|
|
|
} IMPL_END;
|
|
|
|
|
2019-07-17 22:25:50 +02:00
|
|
|
IMPL_START_1(enter) {
|
2019-07-17 20:26:03 +02:00
|
|
|
writemem(ctx, R(RBP), R(RSP) - 8, 8);
|
|
|
|
R(RBP) = R(RSP) - 8;
|
2019-07-17 22:25:50 +02:00
|
|
|
R(RSP) -= (v1 + 1) * 8;
|
2019-07-17 20:26:03 +02:00
|
|
|
} IMPL_END;
|
|
|
|
|
|
|
|
IMPL_START_0(leave) {
|
|
|
|
R(RSP) = R(RBP) + 8;
|
|
|
|
R(RBP) = readmem(ctx, R(RBP), 8);
|
|
|
|
} IMPL_END;
|
2019-06-17 20:59:30 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
|