about summary refs log tree commit diff stats
path: root/subx/011run.cc
diff options
context:
space:
mode:
Diffstat (limited to 'subx/011run.cc')
-rw-r--r--subx/011run.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/subx/011run.cc b/subx/011run.cc
index c4bf9fe8..f210f141 100644
--- a/subx/011run.cc
+++ b/subx/011run.cc
@@ -217,11 +217,13 @@ void load(const program& p) {
     raise << "no code to run\n" << end();
     return;
   }
+  // You should keep your segments disjoint.
+  // Tests sometimes don't, but it should still be an error to use the
+  // overlapping regions.
+  set<uint32_t> overlap;
   for (int i = 0;   i < SIZE(p.segments);  ++i) {
     const segment& seg = p.segments.at(i);
     uint32_t addr = seg.start;
-    // you should probably keep your segments disjoint
-    // but tests sometimes don't
     if (!already_allocated(addr))
       Mem.push_back(vma(seg.start));
     trace(99, "load") << "loading segment " << i << " from " << HEXWORD << addr << end();
@@ -231,7 +233,9 @@ void load(const program& p) {
         const word& w = l.words.at(k);
         uint8_t val = hex_byte(w.data);
         if (trace_contains_errors()) return;
+        assert(overlap.find(addr) == overlap.end());
         write_mem_u8(addr, val);
+        overlap.insert(addr);
         trace(99, "load") << "0x" << HEXWORD << addr << " -> " << HEXBYTE << NUM(read_mem_u8(addr)) << end();
         ++addr;
       }