about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-09-20 13:42:57 -0700
committerKartik Agaram <vc@akkartik.com>2018-09-20 13:42:57 -0700
commit87d5bdb96193be044cc95f562904fc6da60e0bf0 (patch)
treebd8669e7f77ce53e66f72dfdc405b24dd92d1f1b /subx
parent220575dc4a70228438ed6f4a10324f5669277044 (diff)
downloadmu-87d5bdb96193be044cc95f562904fc6da60e0bf0.tar.gz
4550
Diffstat (limited to 'subx')
-rw-r--r--subx/034compute_segment_address.cc3
-rw-r--r--subx/035labels.cc17
2 files changed, 19 insertions, 1 deletions
diff --git a/subx/034compute_segment_address.cc b/subx/034compute_segment_address.cc
index c4645fac..0c569c65 100644
--- a/subx/034compute_segment_address.cc
+++ b/subx/034compute_segment_address.cc
@@ -27,7 +27,7 @@ void compute_segment_starts(program& p) {
     segment& curr = p.segments.at(i);
     if (curr.start == 0) {
       curr.start = CODE_START + i*SEGMENT_SIZE + p_offset;
-      trace(99, "transform") << "segment " << i << " begins at address " << curr.start << end();
+      trace(99, "transform") << "segment " << i << " begins at address 0x" << HEXWORD << curr.start << end();
     }
     p_offset += size_of(curr);
     assert(p_offset < SEGMENT_SIZE);  // for now we get less and less available space in each successive segment
@@ -48,6 +48,7 @@ uint32_t num_bytes(const line& inst) {
     const word& curr = inst.words.at(i);
     if (has_operand_metadata(curr, "disp32") || has_operand_metadata(curr, "imm32"))  // only multi-byte operands
       sum += 4;
+    // End num_bytes(curr) Special-cases
     else
       sum++;
   }
diff --git a/subx/035labels.cc b/subx/035labels.cc
index df54bf2f..6edae0d9 100644
--- a/subx/035labels.cc
+++ b/subx/035labels.cc
@@ -216,3 +216,20 @@ xz:
  -a:  # indent to avoid looking like a trace_should_not_contain command for this scenario
             05                                                                                                                              0x0d0c0b0a/imm32  # add to EAX
 +error: '-a' starts with '-', which can be confused with a negative number; use a different name
+
+//: now that we have labels, we need to adjust segment size computation to
+//: ignore them.
+
+:(scenario segment_size_ignores_labels)
+% Mem_offset = CODE_START;
+== code  # 0x08048074
+05/add 0x0d0c0b0a/imm32  # 5 bytes
+foo:                     # 0 bytes
+== data  # 0x08049079
+bar:
+00
++transform: segment 1 begins at address 0x08049079
+
+:(before "End num_bytes(curr) Special-cases")
+else if (is_label(curr))
+  ;  // don't count it