From 3f6b5e337b282bd8675a97e048e267e6f90ccec6 Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Mon, 17 Oct 2022 17:54:53 -0700 Subject: Clean up address handling and change autoinc to preincrement --- isa/checker.cpp | 6 ++++-- isa/decode.cpp | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/isa/checker.cpp b/isa/checker.cpp index 7bca5c9..770d9d6 100644 --- a/isa/checker.cpp +++ b/isa/checker.cpp @@ -17,8 +17,10 @@ void checker::execute() { if (inst.need_indirect_load) { auto addr = mem.fetch(inst.init_address.value()); - if (inst.need_autoinc_store) - mem.store(*inst.init_address, (addr + 1) & 07777); + if (inst.need_autoinc_store) { + addr = (addr + 1) & 07777; + mem.store(*inst.init_address, addr); + } inst.final_address = addr; } else { assert(!inst.need_autoinc_store); diff --git a/isa/decode.cpp b/isa/decode.cpp index cb6a694..03e2225 100644 --- a/isa/decode.cpp +++ b/isa/decode.cpp @@ -252,7 +252,7 @@ instruction_context decode(unsigned int dfifb, unsigned int pc, unsigned int bit // Instructions with memory operands may be direct or indirect if (inst.need_exec_load || inst.need_exec_store || inst.possibly_redirects) { - auto addr = (df << 12) | ((bits & 00200) ? (inst.next_pc & 07600) : 0) | (bits & 00177); + auto addr = (df << 12) | ((bits & 00200) ? (pc & 07600) : 0) | (bits & 00177); if (bits & 00400) { inst.need_indirect_load = true; inst.init_address = addr; @@ -262,7 +262,7 @@ instruction_context decode(unsigned int dfifb, unsigned int pc, unsigned int bit } // Non-jump indirect memory operands may be autoincrementing depending on operand bits - if (!inst.possibly_redirects && inst.need_indirect_load && ((bits & 00170) == 00010)) + if (!inst.possibly_redirects && inst.need_indirect_load && ((inst.init_address.value() & 07770) == 00010)) inst.need_autoinc_store = true; return inst; -- cgit v1.2.3