about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-07-25 11:44:25 -0700
committerKartik Agaram <vc@akkartik.com>2019-07-25 11:44:25 -0700
commit08b2b92fd2e90c59a5c0a8112f824c5d361d7c22 (patch)
tree2b49e691fdf6d4b9b43abbda0cd6125c99df93ee /subx
parentb6d51014e7aaaef5bd4cf3e1a78040f77e676df5 (diff)
downloadmu-08b2b92fd2e90c59a5c0a8112f824c5d361d7c22.tar.gz
5474
Diffstat (limited to 'subx')
-rw-r--r--subx/011run.cc31
-rw-r--r--subx/030---operands.cc31
2 files changed, 31 insertions, 31 deletions
diff --git a/subx/011run.cc b/subx/011run.cc
index d9877c4d..b8ca52db 100644
--- a/subx/011run.cc
+++ b/subx/011run.cc
@@ -444,34 +444,3 @@ string to_string(const word& w) {
     out << " /" << w.metadata.at(i);
   return out.str();
 }
-
-int32_t parse_int(const string& s) {
-  if (s.empty()) return 0;
-  istringstream in(s);
-  in >> std::hex;
-  if (s.at(0) == '-') {
-    int32_t result = 0;
-    in >> result;
-    if (!in || !in.eof()) {
-      raise << "not a number: " << s << '\n' << end();
-      return 0;
-    }
-    return result;
-  }
-  uint32_t uresult = 0;
-  in >> uresult;
-  if (!in || !in.eof()) {
-    raise << "not a number: " << s << '\n' << end();
-    return 0;
-  }
-  return static_cast<int32_t>(uresult);
-}
-:(before "End Unit Tests")
-void test_parse_int() {
-  CHECK_EQ(0, parse_int("0"));
-  CHECK_EQ(0, parse_int("0x0"));
-  CHECK_EQ(0, parse_int("0x0"));
-  CHECK_EQ(16, parse_int("10"));  // hex always
-  CHECK_EQ(-1, parse_int("-1"));
-  CHECK_EQ(-1, parse_int("0xffffffff"));
-}
diff --git a/subx/030---operands.cc b/subx/030---operands.cc
index 5e6d6432..ec621017 100644
--- a/subx/030---operands.cc
+++ b/subx/030---operands.cc
@@ -489,3 +489,34 @@ string to_string(const line& inst) {
   }
   return out.str();
 }
+
+int32_t parse_int(const string& s) {
+  if (s.empty()) return 0;
+  istringstream in(s);
+  in >> std::hex;
+  if (s.at(0) == '-') {
+    int32_t result = 0;
+    in >> result;
+    if (!in || !in.eof()) {
+      raise << "not a number: " << s << '\n' << end();
+      return 0;
+    }
+    return result;
+  }
+  uint32_t uresult = 0;
+  in >> uresult;
+  if (!in || !in.eof()) {
+    raise << "not a number: " << s << '\n' << end();
+    return 0;
+  }
+  return static_cast<int32_t>(uresult);
+}
+:(before "End Unit Tests")
+void test_parse_int() {
+  CHECK_EQ(0, parse_int("0"));
+  CHECK_EQ(0, parse_int("0x0"));
+  CHECK_EQ(0, parse_int("0x0"));
+  CHECK_EQ(16, parse_int("10"));  // hex always
+  CHECK_EQ(-1, parse_int("-1"));
+  CHECK_EQ(-1, parse_int("0xffffffff"));
+}