Instruction length fixes

This commit is contained in:
scawful
2023-12-03 06:16:17 -05:00
parent ca9cc42d6b
commit db91b0401a
4 changed files with 83 additions and 31 deletions

View File

@@ -270,6 +270,7 @@ class MemoryImpl : public Memory, public Loggable {
} else {
// Handle stack underflow
std::cout << "Stack underflow!" << std::endl;
throw std::runtime_error("Stack underflow!");
}
}
@@ -279,7 +280,7 @@ class MemoryImpl : public Memory, public Loggable {
} else {
// Handle stack overflow
std::cout << "Stack overflow!" << std::endl;
return 0;
throw std::runtime_error("Stack overflow!");
}
}

View File

@@ -140,7 +140,7 @@ class MockMemory : public Memory {
memory_[address + 1] = (value >> 8) & 0xFF;
});
ON_CALL(*this, PushByte(::testing::_)).WillByDefault([this](uint8_t value) {
memory_.at(SP_) = value;
memory_.at(SP_--) = value;
});
ON_CALL(*this, PopByte()).WillByDefault([this]() {
uint8_t value = memory_.at(SP_);
@@ -151,6 +151,7 @@ class MockMemory : public Memory {
.WillByDefault([this](uint16_t value) {
memory_.at(SP_) = value & 0xFF;
memory_.at(SP_ + 1) = (value >> 8) & 0xFF;
this->SetSP(SP_ - 2);
});
ON_CALL(*this, PopWord()).WillByDefault([this]() {
uint16_t value = static_cast<uint16_t>(memory_.at(SP_)) |