From bb2b6ba7fd72bbebc3a4490d090f080e7b8628cc Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 4 Aug 2018 17:00:27 -0700 Subject: 4478 --- html/subx/033non_code_segment.cc.html | 94 +++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 html/subx/033non_code_segment.cc.html (limited to 'html/subx/033non_code_segment.cc.html') diff --git a/html/subx/033non_code_segment.cc.html b/html/subx/033non_code_segment.cc.html new file mode 100644 index 00000000..cd4efdd5 --- /dev/null +++ b/html/subx/033non_code_segment.cc.html @@ -0,0 +1,94 @@ + + + + +Mu - subx/033non_code_segment.cc + + + + + + + + + + +
+ 1 //: Raise an error when operand metadata is used in non-code segments.
+ 2 
+ 3 :(scenario operand_metadata_outside_code_segment)
+ 4 % Hide_errors = true;
+ 5 == 0x1  # code segment
+ 6 cd 0x80/imm8
+ 7 == 0x1000  # data segment
+ 8 cd 12/imm8
+ 9 +error: 12/imm8: metadata imm8 is only allowed in the (first) code segment
+10 
+11 :(before "End Transforms")
+12 Transform.push_back(ensure_operands_only_in_code_segments);
+13 :(code)
+14 void ensure_operands_only_in_code_segments(/*const*/ program& p) {
+15   trace(99, "transform") << "-- ensure operands only in code segments" << end();
+16   if (p.segments.empty()) return;
+17   for (int i = /*skip code segment*/1;  i < SIZE(p.segments);  ++i) {
+18     const segment& seg = p.segments.at(i);
+19     for (int j = 0;  j < SIZE(seg.lines);  ++j) {
+20       const line& l = seg.lines.at(j);
+21       for (int k = 0;  k < SIZE(l.words);  ++k) {
+22         const word& w = l.words.at(k);
+23         for (map<string, uint32_t>::iterator p = Operand_bound.begin();  p != Operand_bound.end();  ++p)
+24           if (has_metadata(w, p->first))
+25             raise << w.original << ": metadata " << p->first << " is only allowed in the (first) code segment\n" << end();
+26       }
+27     }
+28   }
+29 }
+
+ + + -- cgit 1.4.1-2-gfad0