mirror of
https://gitlab.os-k.eu/os-k-team/kvisc.git
synced 2023-08-25 14:05:46 +02:00
76 lines
1.0 KiB
C
76 lines
1.0 KiB
C
// The OS/K Team licences this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
#include "instrs.h"
|
|
#include "arch_i.h"
|
|
|
|
//
|
|
// Stack manipulation instructions
|
|
//
|
|
|
|
IMPL_START_1(push)
|
|
{
|
|
CHK_STACK(<);
|
|
PUSH(v1);
|
|
}
|
|
IMPL_END;
|
|
|
|
IMPL_START_1(pop)
|
|
{
|
|
CHK_STACK(<=);
|
|
POP(v1);
|
|
}
|
|
IMPL_OUT;
|
|
|
|
IMPL_START_1(call)
|
|
{
|
|
CHK_STACK(<);
|
|
PUSH(ctx->r[RIP].val);
|
|
JUMP(v1);
|
|
}
|
|
IMPL_END;
|
|
|
|
IMPL_START_0(ret)
|
|
{
|
|
CHK_STACK(<=);
|
|
POP(ctx->r[RIP].val);
|
|
}
|
|
IMPL_END;
|
|
|
|
IMPL_START_0(enter)
|
|
{
|
|
CHK_STACK(<);
|
|
PUSH(ctx->r[RBP].val);
|
|
ctx->r[RBP].val = ctx->r[RSP].val;
|
|
}
|
|
IMPL_END;
|
|
|
|
IMPL_START_0(leave)
|
|
{
|
|
// Do NOT check stack here!
|
|
POP(ctx->r[RBP].val);
|
|
}
|
|
IMPL_END;
|
|
|
|
IMPL_START_0(pushf)
|
|
{
|
|
CHK_STACK(<);
|
|
|
|
writemem64(ctx, ctx->r[FLG].val, ctx->r[RSP].val);
|
|
ctx->r[RSP].val -= 8;
|
|
}
|
|
IMPL_END;
|
|
|
|
IMPL_START_0(popf)
|
|
{
|
|
CHK_STACK(<=);
|
|
|
|
CHK_SUPERV(); // XXX
|
|
|
|
ctx->r[RSP].val += 8;
|
|
ctx->r[FLG].val = readmem64(ctx, ctx->r[RSP].val);
|
|
}
|
|
IMPL_END;
|
|
|
|
|