mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-18 01:30:56 +00:00
Implement PUSHes and POPs.
This commit is contained in:
parent
02cea3047e
commit
617be7cba7
@ -165,8 +165,10 @@ IntT *resolve(
|
|||||||
|
|
||||||
namespace Primitive {
|
namespace Primitive {
|
||||||
|
|
||||||
|
// The below takes a reference in order properly to handle PUSH SP, which should place the value of SP after the
|
||||||
|
// push onto the stack.
|
||||||
template <typename IntT, typename MemoryT, typename RegistersT>
|
template <typename IntT, typename MemoryT, typename RegistersT>
|
||||||
void push(IntT value, MemoryT &memory, RegistersT ®isters) {
|
void push(IntT &value, MemoryT &memory, RegistersT ®isters) {
|
||||||
registers.sp_ -= sizeof(IntT);
|
registers.sp_ -= sizeof(IntT);
|
||||||
memory.template access<IntT>(
|
memory.template access<IntT>(
|
||||||
InstructionSet::x86::Source::SS,
|
InstructionSet::x86::Source::SS,
|
||||||
@ -1341,6 +1343,17 @@ inline void shr(IntT &destination, uint8_t count, Status &status) {
|
|||||||
status.set_from<IntT, Flag::Sign, Flag::Zero, Flag::ParityOdd>(destination);
|
status.set_from<IntT, Flag::Sign, Flag::Zero, Flag::ParityOdd>(destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename MemoryT, typename RegistersT>
|
||||||
|
void popf(MemoryT &memory, RegistersT ®isters, Status &status) {
|
||||||
|
status.set(pop<uint16_t>(memory, registers));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename MemoryT, typename RegistersT>
|
||||||
|
void pushf(MemoryT &memory, RegistersT ®isters, Status &status) {
|
||||||
|
uint16_t value = status.get();
|
||||||
|
push<uint16_t>(value, memory, registers);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <
|
template <
|
||||||
@ -1360,7 +1373,7 @@ template <
|
|||||||
[[maybe_unused]] IOT &io
|
[[maybe_unused]] IOT &io
|
||||||
) {
|
) {
|
||||||
using IntT = typename DataSizeType<data_size>::type;
|
using IntT = typename DataSizeType<data_size>::type;
|
||||||
using AddressT = typename AddressT<is_32bit(model)>::type;
|
// using AddressT = typename AddressT<is_32bit(model)>::type;
|
||||||
|
|
||||||
// Establish source() and destination() shorthand to fetch data if necessary.
|
// Establish source() and destination() shorthand to fetch data if necessary.
|
||||||
IntT immediate;
|
IntT immediate;
|
||||||
@ -1551,6 +1564,11 @@ template <
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case Operation::XLAT: Primitive::xlat<uint16_t>(instruction, memory, registers); return;
|
case Operation::XLAT: Primitive::xlat<uint16_t>(instruction, memory, registers); return;
|
||||||
|
|
||||||
|
case Operation::POP: source() = Primitive::pop<IntT>(memory, registers); break;
|
||||||
|
case Operation::PUSH: Primitive::push<IntT>(source(), memory, registers); break;
|
||||||
|
case Operation::POPF: Primitive::popf(memory, registers, status); break;
|
||||||
|
case Operation::PUSHF: Primitive::pushf(memory, registers, status); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write to memory if required to complete this operation.
|
// Write to memory if required to complete this operation.
|
||||||
|
@ -391,11 +391,11 @@ struct FailedExecution {
|
|||||||
@"8D.json.gz", // LEA
|
@"8D.json.gz", // LEA
|
||||||
|
|
||||||
// TODO: CMPS, LODS, MOVS, SCAS, STOS
|
// TODO: CMPS, LODS, MOVS, SCAS, STOS
|
||||||
*/
|
|
||||||
@"E0.json.gz", // LOOPNE
|
@"E0.json.gz", // LOOPNE
|
||||||
@"E1.json.gz", // LOOPE
|
@"E1.json.gz", // LOOPE
|
||||||
@"E2.json.gz", // LOOP
|
@"E2.json.gz", // LOOP
|
||||||
/*
|
|
||||||
// MOV
|
// MOV
|
||||||
@"88.json.gz", @"89.json.gz", @"8A.json.gz", @"8B.json.gz",
|
@"88.json.gz", @"89.json.gz", @"8A.json.gz", @"8B.json.gz",
|
||||||
@"8C.json.gz", @"8E.json.gz",
|
@"8C.json.gz", @"8E.json.gz",
|
||||||
@ -426,9 +426,25 @@ struct FailedExecution {
|
|||||||
|
|
||||||
// NOP
|
// NOP
|
||||||
@"90.json.gz",
|
@"90.json.gz",
|
||||||
|
*/
|
||||||
|
// POP
|
||||||
|
@"07.json.gz", @"0F.json.gz", @"17.json.gz", @"1F.json.gz",
|
||||||
|
@"58.json.gz", @"59.json.gz", @"5A.json.gz", @"5B.json.gz",
|
||||||
|
@"5C.json.gz", @"5D.json.gz", @"5E.json.gz", @"5F.json.gz",
|
||||||
|
@"8F.json.gz",
|
||||||
|
|
||||||
// TODO: POP, POPF, PUSH, PUSHF
|
// PUSH
|
||||||
|
@"06.json.gz", @"0E.json.gz", @"16.json.gz", @"1E.json.gz",
|
||||||
|
@"50.json.gz", @"51.json.gz", @"52.json.gz", @"53.json.gz",
|
||||||
|
@"54.json.gz", @"55.json.gz", @"56.json.gz", @"57.json.gz",
|
||||||
|
@"FF.6.json.gz",
|
||||||
|
|
||||||
|
// POPF
|
||||||
|
@"9D.json.gz",
|
||||||
|
|
||||||
|
// PUSHF
|
||||||
|
@"9C.json.gz",
|
||||||
|
/*
|
||||||
// RCL
|
// RCL
|
||||||
@"D0.2.json.gz", @"D2.2.json.gz",
|
@"D0.2.json.gz", @"D2.2.json.gz",
|
||||||
@"D1.2.json.gz", @"D3.2.json.gz",
|
@"D1.2.json.gz", @"D3.2.json.gz",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user