kvisc/vm/in/stack.c

55 lines
736 B
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>
//
// Stack manipulation instructions
//
IMPL_START_1(push)
{
rsp -= 8;
writemem(ctx, v1, rsp, 8);
}
IMPL_END;
IMPL_START_1(pop)
{
v1 = readmem(ctx, rsp, 8);
rsp += 8;
}
IMPL_OUT;
IMPL_START_1(call)
{
rsp -= 8;
writemem(ctx, rip, rsp, 8);
rip = v1;
}
IMPL_END;
IMPL_START_0(ret)
{
rip = readmem(ctx, rsp, 8);
rsp += 8;
}
IMPL_END;
IMPL_START_0(enter)
{
writemem(ctx, rbp, rsp - 8, 8);
rbp = rsp - 8;
rsp -= (p1->val + 1) * 8;
}
IMPL_END;
IMPL_START_0(leave)
{
rsp = rbp + 8;
rbp = readmem(ctx, rbp, 8);
}
IMPL_END;