From 4e3b0ae3c1c6a0444eda30c43da34338e6063d0d Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 4 Mar 2025 14:10:28 -0500 Subject: [PATCH] Resolve type warnings in ENTER, spurious new lines in PC. --- InstructionSets/x86/Implementation/Stack.hpp | 11 ++++++----- Machines/PCCompatible/PCCompatible.cpp | 18 ++++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/InstructionSets/x86/Implementation/Stack.hpp b/InstructionSets/x86/Implementation/Stack.hpp index 00d4a7c22..bdce4b843 100644 --- a/InstructionSets/x86/Implementation/Stack.hpp +++ b/InstructionSets/x86/Implementation/Stack.hpp @@ -152,18 +152,18 @@ void enter( const auto alloc_size = instruction.dynamic_storage_size(); const auto nesting_level = instruction.nesting_level() & 0x1f; - // Preauthorse contents that'll be fetched via BP. + // Preauthorise contents that'll be fetched via BP. const auto copied_pointers = nesting_level - 2; if(copied_pointers > 0) { context.memory.preauthorise_read( Source::SS, - context.registers.bp() - copied_pointers * sizeof(uint16_t), - copied_pointers * sizeof(uint16_t) + uint16_t(context.registers.bp() - size_t(copied_pointers) * sizeof(uint16_t)), + uint32_t(size_t(copied_pointers) * sizeof(uint16_t)) // TODO: I don't think this can actually be 32 bit. ); } - // Preauthorse stack activity. - context.memory.preauthorise_stack_write((1 + copied_pointers) * sizeof(uint16_t)); + // Preauthorise writes. + context.memory.preauthorise_stack_write(uint32_t(size_t(nesting_level) * sizeof(uint16_t))); // Push BP and grab the end of frame. push(context.registers.bp(), context); @@ -179,6 +179,7 @@ void enter( // Set final BP. context.registers.bp() = frame; + context.registers.sp() -= alloc_size; } template diff --git a/Machines/PCCompatible/PCCompatible.cpp b/Machines/PCCompatible/PCCompatible.cpp index 0fdc51d21..13788b6c3 100644 --- a/Machines/PCCompatible/PCCompatible.cpp +++ b/Machines/PCCompatible/PCCompatible.cpp @@ -122,7 +122,7 @@ class FloppyController { using Command = Intel::i8272::Command; switch(decoder_.command()) { default: - log.error().append("TODO: implement FDC command %d\n", uint8_t(decoder_.command())); + log.error().append("TODO: implement FDC command %d", uint8_t(decoder_.command())); break; case Command::WriteDeletedData: @@ -619,9 +619,9 @@ class IO { switch(port) { default: if constexpr (std::is_same_v) { - log.error().append("Unhandled out: %02x to %04x\n", value, port); + log.error().append("Unhandled out: %02x to %04x", value, port); } else { - log.error().append("Unhandled out: %04x to %04x\n", value, port); + log.error().append("Unhandled out: %04x to %04x", value, port); } break; @@ -630,7 +630,7 @@ class IO { // On the XT the NMI can be masked by setting bit 7 on I/O port 0xA0. case 0x00a0: - log.error().append("TODO: NMIs %s\n", (value & 0x80) ? "masked" : "unmasked"); + log.error().append("TODO: NMIs %s", (value & 0x80) ? "masked" : "unmasked"); break; case 0x0000: dma_.controller.write<0x0>(uint8_t(value)); break; @@ -703,7 +703,7 @@ class IO { fdc_.set_digital_output(uint8_t(value)); break; case 0x03f4: - log.error().append("TODO: FDC write of %02x at %04x\n", value, port); + log.error().append("TODO: FDC write of %02x at %04x", value, port); break; case 0x03f5: fdc_.write(uint8_t(value)); @@ -730,7 +730,7 @@ class IO { template IntT in([[maybe_unused]] uint16_t port) { switch(port) { default: - log.error().append("Unhandled in: %04x\n", port); + log.error().append("Unhandled in: %04x", port); break; case 0x0000: return dma_.controller.read<0x0>(); @@ -844,7 +844,7 @@ class FlowController { halted_ = true; } void wait() { - log.error().append("WAIT ????\n"); + log.error().append("WAIT ????"); } void repeat_last() { @@ -1229,9 +1229,11 @@ class ConcreteMachine: using namespace PCCompatible; namespace { +static constexpr bool ForceAT = false; + template std::unique_ptr machine(const Target &target, const ROMMachine::ROMFetcher &rom_fetcher) { - switch(target.model) { + switch(ForceAT ? PCModelApproximation::AT : target.model) { case PCModelApproximation::XT: return std::make_unique> (target, rom_fetcher);