diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-10-01 11:29:00 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-10-01 11:29:00 -0700 |
commit | 745c582e28e22fa5823d031ce2776c7f795913c0 (patch) | |
tree | 64cbd4a4d1e924928c99ecf133fc1d6fcb0e9840 /subx | |
parent | df39c0c8dee65a10dfc339a970a3beb4d0e481f3 (diff) | |
download | mu-745c582e28e22fa5823d031ce2776c7f795913c0.tar.gz |
4636
Diffstat (limited to 'subx')
-rw-r--r-- | subx/011run.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/subx/011run.cc b/subx/011run.cc index 9248ff84..b11dae90 100644 --- a/subx/011run.cc +++ b/subx/011run.cc @@ -153,6 +153,8 @@ void parse(istream& fin, program& out) { if (starts_with(segment_title, "0x")) { segment s; s.start = parse_int(segment_title); + sanity_check_program_segment(out, s.start); + if (trace_contains_errors()) continue; trace(99, "parse") << "new segment from 0x" << HEXWORD << s.start << end(); out.segments.push_back(s); } @@ -195,6 +197,29 @@ void parse_word(const string& data, word& out) { } } +void sanity_check_program_segment(const program& p, uint32_t addr) { + for (int i = 0; i < SIZE(p.segments); ++i) { + if (p.segments.at(i).start == addr) + raise << "can't have multiple segments starting at address 0x" << std::hex << addr << '\n' << end(); + } +} + +// helper for tests +void parse(const string& text_bytes) { + program p; + istringstream in(text_bytes); + parse(in, p); +} + +:(scenarios parse) +:(scenario detect_duplicate_segments) +% Hide_errors = true; +== 0xee +ab +== 0xee +cd ++error: can't have multiple segments starting at address 0xee + //:: transform :(before "End Types") |