From 87d5bdb96193be044cc95f562904fc6da60e0bf0 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Thu, 20 Sep 2018 13:42:57 -0700 Subject: 4550 --- subx/034compute_segment_address.cc | 3 ++- subx/035labels.cc | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'subx') 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 -- cgit 1.4.1-2-gfad0