mirror of
https://gitlab.os-k.eu/os-k-team/kvisc.git
synced 2023-08-25 14:05:46 +02:00
82 lines
1.0 KiB
C
82 lines
1.0 KiB
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)
|
|
{
|
|
CHK_STACK(<);
|
|
PUSH(v1);
|
|
}
|
|
IMPL_END;
|
|
|
|
IMPL_START_1(pop)
|
|
{
|
|
CHK_STACK(<=);
|
|
POP(v1);
|
|
}
|
|
IMPL_OUT;
|
|
|
|
IMPL_START_1(call)
|
|
{
|
|
CHK_STACK(<);
|
|
PUSH(rip);
|
|
JUMP(v1);
|
|
}
|
|
IMPL_END;
|
|
|
|
IMPL_START_0(ret)
|
|
{
|
|
CHK_STACK(<=);
|
|
POP(rip);
|
|
}
|
|
IMPL_END;
|
|
|
|
IMPL_START_0(enter)
|
|
{
|
|
// We don't CHK_STACK(<) here because ENTER
|
|
// (should) always be preceded by a CALL,
|
|
// which already checks the stack
|
|
|
|
PUSH(rbp);
|
|
rbp = rsp;
|
|
|
|
if (p1) {
|
|
GETV(v1, p1);
|
|
rsp -= v1 * 8;
|
|
}
|
|
}
|
|
IMPL_END;
|
|
|
|
IMPL_START_0(leave)
|
|
{
|
|
// Do NOT check stack here
|
|
// (it would always fail)
|
|
rsp = rbp;
|
|
POP(rbp);
|
|
}
|
|
IMPL_END;
|
|
|
|
IMPL_START_0(pushf)
|
|
{
|
|
CHK_STACK(<);
|
|
PUSH(flg);
|
|
}
|
|
IMPL_END;
|
|
|
|
IMPL_START_0(popf)
|
|
{
|
|
CHK_STACK(<=);
|
|
|
|
// XXX
|
|
CHK_SUPERV();
|
|
|
|
POP(flg);
|
|
}
|
|
IMPL_END;
|
|
|