1
2
3 :(scenario operand_metadata_outside_code_segment)
4 % Hide_errors = true;
5 == 0x1
6 cd 0x80/imm8
7 == 0x1000
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( program& p) {
15 trace(99, "transform") << "-- ensure operands only in code segments" << end();
16 if (p.segments.empty()) return;
17 for (int i = 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 }