mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-29 12:50:28 +00:00
Implement LEAVE, almost.
This commit is contained in:
parent
2533fd2da9
commit
aafa7de536
@ -216,8 +216,10 @@ template <
|
||||
Primitive::idiv<true, IntT>(pair_high(), pair_low(), source_r(), context);
|
||||
break;
|
||||
} else {
|
||||
// TODO: perform LEAVE as of the 80186.
|
||||
static_assert(int(Operation::IDIV_REP) == int(Operation::LEAVE));
|
||||
if constexpr (std::is_same_v<IntT, uint16_t> || std::is_same_v<IntT, uint32_t>) {
|
||||
Primitive::leave<IntT>();
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
|
@ -144,6 +144,21 @@ void pusha(
|
||||
}
|
||||
}
|
||||
|
||||
template <typename IntT, typename ContextT>
|
||||
void leave(
|
||||
ContextT &context
|
||||
) {
|
||||
// TODO: should use StackAddressSize to determine assignment of bp to sp.
|
||||
// Probably make that a static constexpr on registers.
|
||||
if constexpr (std::is_same_v<IntT, uint32_t>) {
|
||||
context.registers.esp() = context.registers.ebp();
|
||||
context.registers.ebp() = pop<uint32_t, false>(context);
|
||||
} else {
|
||||
context.registers.sp() = context.registers.bp();
|
||||
context.registers.bp() = pop<uint16_t, false>(context);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif /* Stack_hpp */
|
||||
|
Loading…
Reference in New Issue
Block a user