about summary refs log tree commit diff stats
path: root/subx/035labels.cc
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-12-25 23:00:55 -0800
committerKartik Agaram <vc@akkartik.com>2018-12-25 23:01:26 -0800
commitfb7cd3f16cf3a96e0df8bc8b873602fd4bc05e3a (patch)
treeee56010299ec14a66d6100865d36216438c17ad7 /subx/035labels.cc
parent17b8233f44d42b06420df2f7a51a87cc22a7adbc (diff)
downloadmu-fb7cd3f16cf3a96e0df8bc8b873602fd4bc05e3a.tar.gz
4874
Diffstat (limited to 'subx/035labels.cc')
-rw-r--r--subx/035labels.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/subx/035labels.cc b/subx/035labels.cc
index acbb2206..5531910a 100644
--- a/subx/035labels.cc
+++ b/subx/035labels.cc
@@ -125,6 +125,10 @@ void compute_byte_indices_for_labels(const segment& code, map<string, int32_t>&
           raise << "'" << to_string(inst) << "': labels can only be the first word in a line.\n" << end();
         if (Map_file.is_open())
           Map_file << "0x" << HEXWORD << (code.start + current_byte) << ' ' << label << '\n';
+        if (contains_key(byte_index, label)) {
+          raise << "duplicate label '" << label << "'\n" << end();
+          return;
+        }
         put(byte_index, label, current_byte);
         trace(99, "transform") << "label '" << label << "' is at address " << (current_byte+code.start) << end();
         // no modifying current_byte; label definitions won't be in the final binary
@@ -237,6 +241,14 @@ loop:
 # second jump is to 0 (fall through)
 +transform: instruction after transform: 'eb 00'
 
+:(scenario duplicate_label)
+% Hide_errors = true;
+== 0x1
+loop:
+loop:
+    05  0x0d0c0b0a/imm32
++error: duplicate label 'loop'
+
 :(scenario label_too_short)
 % Hide_errors = true;
 == 0x1