diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-07-20 10:39:48 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-07-20 10:39:48 -0700 |
commit | aec53ecd939c763935d3fff1386425a4a79ea02d (patch) | |
tree | 57d58ee617f37926e37a22492316384d1110e3d7 | |
parent | 64b957a6de17f00574eef088425a766c071b965e (diff) | |
download | mu-aec53ecd939c763935d3fff1386425a4a79ea02d.tar.gz |
4372
Don't refer to program internals before showing its data structures.
-rw-r--r-- | subx/011parse.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/subx/011parse.cc b/subx/011parse.cc index 4735dfd2..0b0d4f66 100644 --- a/subx/011parse.cc +++ b/subx/011parse.cc @@ -46,8 +46,6 @@ void run(const string& text_bytes) { if (trace_contains_errors()) return; load(p); if (trace_contains_errors()) return; - if (p.segments.empty()) return; - EIP = p.segments.at(0).start; while (EIP < End_of_program) run_one_instruction(); } @@ -153,6 +151,10 @@ void transform(program& p) { //:: load void load(const program& p) { + if (p.segments.empty()) { + raise << "no code to run\n" << end(); + return; + } for (int i = 0; i < SIZE(p.segments); ++i) { const segment& seg = p.segments.at(i); uint32_t addr = seg.start; @@ -170,6 +172,7 @@ void load(const program& p) { } if (i == 0) End_of_program = addr; } + EIP = p.segments.at(0).start; } uint8_t hex_byte(const string& s) { |