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-07-11 18:34:21 +02:00
|
|
|
R(RSP) -= 8;
|
|
|
|
writemem(ctx, v1, R(RSP), 8);
|
2019-05-29 16:57:22 +02:00
|
|
|
}
|
|
|
|
IMPL_END;
|
|
|
|
|
|
|
|
IMPL_START_1(pop)
|
|
|
|
{
|
2019-07-11 18:34:21 +02:00
|
|
|
v1 = readmem(ctx, R(RSP), 8);
|
|
|
|
R(RSP) += 8;
|
2019-05-29 16:57:22 +02:00
|
|
|
}
|
|
|
|
IMPL_OUT;
|
|
|
|
|
|
|
|
IMPL_START_1(call)
|
|
|
|
{
|
2019-07-11 18:34:21 +02:00
|
|
|
R(RSP) -= 8;
|
|
|
|
writemem(ctx, R(RIP), R(RSP), 8);
|
2019-06-16 12:17:31 +02:00
|
|
|
|
2019-07-11 18:34:21 +02:00
|
|
|
R(RIP) = v1;
|
2019-05-29 16:57:22 +02:00
|
|
|
}
|
|
|
|
IMPL_END;
|
|
|
|
|
|
|
|
IMPL_START_0(ret)
|
|
|
|
{
|
2019-07-11 18:34:21 +02:00
|
|
|
R(RIP) = readmem(ctx, R(RSP), 8);
|
|
|
|
R(RSP) += 8;
|
2019-05-29 16:57:22 +02:00
|
|
|
}
|
|
|
|
IMPL_END;
|
|
|
|
|
|
|
|
IMPL_START_0(enter)
|
|
|
|
{
|
2019-07-11 18:34:21 +02:00
|
|
|
writemem(ctx, R(RBP), R(RSP) - 8, 8);
|
|
|
|
R(RBP) = R(RSP) - 8;
|
|
|
|
R(RSP) -= (p1->val + 1) * 8;
|
2019-05-29 16:57:22 +02:00
|
|
|
}
|
|
|
|
IMPL_END;
|
|
|
|
|
|
|
|
IMPL_START_0(leave)
|
|
|
|
{
|
2019-07-11 18:34:21 +02:00
|
|
|
R(RSP) = R(RBP) + 8;
|
|
|
|
R(RBP) = readmem(ctx, R(RBP), 8);
|
2019-05-29 16:57:22 +02:00
|
|
|
}
|
|
|
|
IMPL_END;
|
|
|
|
|