about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-07-20 22:16:04 -0700
committerKartik Agaram <vc@akkartik.com>2018-07-20 22:16:04 -0700
commit62197fd5a73f1b6798332161b652ce27f56ae820 (patch)
tree891d428c5fbaa197fc3b7cce63f11b8a5456538b /subx
parent7ecc45c1352c8bf253c6e35e6a9e785219945855 (diff)
downloadmu-62197fd5a73f1b6798332161b652ce27f56ae820.tar.gz
4383
Make room for including multibyte opcodes in the opcode list.
Diffstat (limited to 'subx')
-rw-r--r--subx/010vm.cc31
-rw-r--r--subx/011parse.cc26
2 files changed, 34 insertions, 23 deletions
diff --git a/subx/010vm.cc b/subx/010vm.cc
index 9d6d047d..799bcbcc 100644
--- a/subx/010vm.cc
+++ b/subx/010vm.cc
@@ -181,6 +181,37 @@ inline uint8_t next() {
   return read_mem_u8(EIP++);
 }
 
+//: start tracking supported opcodes
+:(before "End Globals")
+map</*op*/uint8_t, string> name;
+map</*op*/uint8_t, string> name_0f;
+map</*op*/uint8_t, string> name_f3;
+map</*op*/uint8_t, string> name_f3_0f;
+:(before "End One-time Setup")
+init_op_names();
+:(code)
+void init_op_names() {
+  put(name, 0xf4, "halt");
+  // End Initialize Op Names(name)
+}
+
+:(before "End Help Special-cases(key)")
+if (key == "opcodes") {
+  cerr << "Opcodes currently supported by SubX:\n";
+  for (map<uint8_t, string>::iterator p = name.begin();  p != name.end();  ++p)
+    cerr << "  " << HEXBYTE << NUM(p->first) << ": " << p->second << '\n';
+  for (map<uint8_t, string>::iterator p = name_0f.begin();  p != name_0f.end();  ++p)
+    cerr << "  0f " << HEXBYTE << NUM(p->first) << ": " << p->second << '\n';
+  for (map<uint8_t, string>::iterator p = name_f3.begin();  p != name_f3.end();  ++p)
+    cerr << "  f3 " << HEXBYTE << NUM(p->first) << ": " << p->second << '\n';
+  for (map<uint8_t, string>::iterator p = name_f3_0f.begin();  p != name_f3_0f.end();  ++p)
+    cerr << "  f3 0f " << HEXBYTE << NUM(p->first) << ": " << p->second << '\n';
+  cerr << "Coming soon: `subx help operands` for details on words like 'r32' and 'disp8'.\n";
+  return 0;
+}
+:(before "End Help Contents")
+cerr << "  opcodes\n";
+
 :(before "End Includes")
 #include <iomanip>
 #define HEXBYTE  std::hex << std::setw(2) << std::setfill('0')
diff --git a/subx/011parse.cc b/subx/011parse.cc
index d0a6cca4..b37eb1cf 100644
--- a/subx/011parse.cc
+++ b/subx/011parse.cc
@@ -208,6 +208,9 @@ uint8_t hex_byte(const string& s) {
 
 //:: run
 
+:(before "End Initialize Op Names(name)")
+put(name, 0x05, "add imm32 to R0 (EAX)");
+
 //: our first opcode
 :(before "End Single-Byte Opcodes")
 case 0x05: {  // add imm32 to EAX
@@ -226,26 +229,3 @@ int32_t imm32() {
   result |= (next()<<24);
   return result;
 }
-
-//: start tracking supported opcodes
-:(before "End Globals")
-map</*op*/uint8_t, string> name;
-:(before "End One-time Setup")
-init_op_names();
-:(code)
-void init_op_names() {
-  put(name, 0xf4, "halt");
-  put(name, 0x05, "add imm32 to R0 (EAX)");
-  // End Initialize Op Names(name)
-}
-
-:(before "End Help Special-cases(key)")
-if (key == "opcodes") {
-  cerr << "Opcodes currently supported by SubX:\n";
-  for (map<uint8_t, string>::iterator p = name.begin();  p != name.end();  ++p)
-    cerr << "  " << HEXBYTE << NUM(p->first) << ": " << p->second << '\n';
-  cerr << "Coming soon: `subx help operands` for details on words like 'r32' and 'disp8'.\n";
-  return 0;
-}
-:(before "End Help Contents")
-cerr << "  opcodes\n";