// 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 // // Stack manipulation instructions // IMPL_START_1(push) { R(RSP) -= 8; writemem(ctx, v1, R(RSP), 8); } IMPL_END; IMPL_START_1(pop) { v1 = readmem(ctx, R(RSP), 8); R(RSP) += 8; } IMPL_OUT; IMPL_START_1(call) { R(RSP) -= 8; writemem(ctx, R(RIP), R(RSP), 8); R(RIP) = v1; } IMPL_END; IMPL_START_0(ret) { R(RIP) = readmem(ctx, R(RSP), 8); R(RSP) += 8; } IMPL_END; IMPL_START_0(enter) { writemem(ctx, R(RBP), R(RSP) - 8, 8); R(RBP) = R(RSP) - 8; R(RSP) -= (p1->val + 1) * 8; } IMPL_END; IMPL_START_0(leave) { R(RSP) = R(RBP) + 8; R(RBP) = readmem(ctx, R(RBP), 8); } IMPL_END;