memory, stack, dumping

This commit is contained in:
julianb0 2019-05-16 16:57:59 +02:00
parent b324b120fc
commit 7031207afb
No known key found for this signature in database
GPG Key ID: DDF8325C95299A62
4 changed files with 42 additions and 2 deletions

View File

@ -45,6 +45,11 @@ xchg r m
xchg m r
xchg m i
push i
push r
pop r
cli
sti

View File

@ -83,6 +83,36 @@ IMPL_START_2(xchg)
}
IMPL_OUT;
IMPL_START_1(push)
{
if (ctx->r[RSP].val % 8 > 0 || ctx->r[RBP].val % 8 > 0) {
_except(ctx, E_STK, "Misaligned stack REGS");
}
if (ctx->r[RSP].val > ctx->r[RBP].val) {
_except(ctx, E_STK, "RSP above RBP");
}
writemem64(ctx, v1, ctx->r[RSP]);
ctx->r[RSP].val -= 8;
}
IMPL_END;
IMPL_START_1(pop)
{
if (ctx->r[RSP].val % 8 > 0 || ctx->r[RBP].val % 8 > 0) {
_except(ctx, E_STK, "Misaligned stack REGS");
}
if (ctx->r[RSP].val >= ctx->r[RBP].val) {
_except(ctx, E_STK, "RBP above RSP");
}
v1 = readmem64(ctx, ctx->r[RSP]);
ctx->r[RSP].val += 8;
}
IMPL_OUT;
IMPL_START_0(cli)
{
CHK_SUPERV();

View File

@ -106,6 +106,7 @@ enum
E_ACC, // Invalid access
E_SYS, // Supervisor only
E_ALI, // Alignment error
E_STK, // Stack error
NEXCPTS
};

View File

@ -7,11 +7,15 @@
ushort fwprog[] = {
I_MOV_R_I, RBP, A_IMM32, FWSTACK>>16, FWSTACK&0xFF,
I_MOV_R_I, RSP, A_IMM32, FWSTACK>>16, FWSTACK&0xFF,
I_PUSH_I, A_IMM16, 0xDDEE,
/*
I_MOV_M_I, A_MEM, RBP, A_IMM16, 0xAC,
I_SUB_R_I, RBP, A_IMM16, 8,
I_ADD_M_R, A_OFF, 8, RBP, RSP,
I_MOV_R_M, RAX, A_MEM, RBP,
I_MOV_R_M, RAX, A_MEM, RBP,
*/
};
ushort bget(ctx_t *ctx)