about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-07-25 17:13:01 -0700
committerKartik Agaram <vc@akkartik.com>2019-07-25 17:13:28 -0700
commit6dff1f28b4a513ab51e21cc9ee2680797dc62e49 (patch)
treeede7715cc0b73fc588a9ed8f685230953d141cba /subx
parentecbdc925d43f489e5c5b101900db88f9d260efe7 (diff)
downloadmu-6dff1f28b4a513ab51e21cc9ee2680797dc62e49.tar.gz
5477
Diffstat (limited to 'subx')
-rw-r--r--subx/011run.cc4
-rw-r--r--subx/028translate.cc6
2 files changed, 7 insertions, 3 deletions
diff --git a/subx/011run.cc b/subx/011run.cc
index cc3b82f6..1730c790 100644
--- a/subx/011run.cc
+++ b/subx/011run.cc
@@ -91,10 +91,12 @@ void run(const string& text_bytes) {
   if (trace_contains_errors()) return;
   load(p);
   if (trace_contains_errors()) return;
+  // convenience to keep tests concise: 'Entry' label need not be provided
+  // not allowed in real programs
   if (p.entry)
     EIP = p.entry;
   else
-    EIP = find(p, "code")->start;  // just in unit tests
+    EIP = find(p, "code")->start;
   while (EIP < End_of_program)
     run_one_instruction();
 }
diff --git a/subx/028translate.cc b/subx/028translate.cc
index 937647f2..46f4f219 100644
--- a/subx/028translate.cc
+++ b/subx/028translate.cc
@@ -80,6 +80,10 @@ void save_elf(const program& p, const string& filename) {
 }
 
 void save_elf(const program& p, ostream& out) {
+  if (p.entry == 0) {
+    raise << "no 'Entry' label found\n" << end();
+    return;
+  }
   write_elf_header(out, p);
   for (size_t i = 0;  i < p.segments.size();  ++i)
     write_segment(p.segments.at(i), out);
@@ -104,8 +108,6 @@ void write_elf_header(ostream& out, const program& p) {
   // e_version
   O(0x01); O(0x00); O(0x00); O(0x00);
   // e_entry
-  if (p.entry == 0)
-    raise << "no 'Entry' label found\n" << end();
   uint32_t e_entry = p.entry;
   // Override e_entry
   emit(e_entry);