1
0
mirror of https://gitlab.os-k.eu/os-k-team/kvisc.git synced 2023-08-25 14:05:46 +02:00
kvisc/vm/in/stack.c

77 lines
834 B
C
Raw Normal View History

2019-05-30 12:44:56 +02:00
// The OS/K Team licenses this file to you under the MIT license.
2019-05-29 16:57:22 +02:00
// 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-29 16:57:22 +02:00
//
// Stack manipulation instructions
//
IMPL_START_1(push)
{
2019-06-15 20:21:38 +02:00
CHK_STACK();
2019-05-29 16:57:22 +02:00
PUSH(v1);
}
IMPL_END;
IMPL_START_1(pop)
{
2019-06-15 20:21:38 +02:00
CHK_STACK();
2019-05-29 16:57:22 +02:00
POP(v1);
}
IMPL_OUT;
IMPL_START_1(call)
{
2019-06-15 20:21:38 +02:00
CHK_STACK();
2019-06-02 16:33:28 +02:00
PUSH(rip);
2019-05-29 16:57:22 +02:00
JUMP(v1);
}
IMPL_END;
IMPL_START_0(ret)
{
2019-06-15 20:21:38 +02:00
CHK_STACK();
2019-06-02 16:33:28 +02:00
POP(rip);
2019-05-29 16:57:22 +02:00
}
IMPL_END;
IMPL_START_0(enter)
{
2019-06-15 20:21:38 +02:00
CHK_STACK();
2019-06-12 18:43:24 +02:00
2019-06-02 16:33:28 +02:00
PUSH(rbp);
rbp = rsp;
2019-06-12 18:43:24 +02:00
if (p1) {
2019-06-13 16:27:33 +02:00
rsp -= p1->val * 8;
2019-06-12 18:43:24 +02:00
}
2019-05-29 16:57:22 +02:00
}
IMPL_END;
IMPL_START_0(leave)
{
2019-06-12 18:43:24 +02:00
rsp = rbp;
2019-06-02 16:33:28 +02:00
POP(rbp);
2019-05-29 16:57:22 +02:00
}
IMPL_END;
IMPL_START_0(pushf)
{
2019-06-15 20:21:38 +02:00
CHK_STACK();
2019-06-02 16:33:28 +02:00
PUSH(flg);
2019-05-29 16:57:22 +02:00
}
IMPL_END;
IMPL_START_0(popf)
{
2019-06-15 20:21:38 +02:00
CHK_STACK();
2019-05-30 12:44:56 +02:00
2019-05-29 19:00:13 +02:00
// XXX
CHK_SUPERV();
2019-05-29 16:57:22 +02:00
2019-06-02 16:33:28 +02:00
POP(flg);
2019-05-29 16:57:22 +02:00
}
IMPL_END;