about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--subx/011run.cc10
-rw-r--r--subx/ex7.subx50
2 files changed, 30 insertions, 30 deletions
diff --git a/subx/011run.cc b/subx/011run.cc
index 218f4e16..5d2aab8a 100644
--- a/subx/011run.cc
+++ b/subx/011run.cc
@@ -61,7 +61,9 @@ cerr << "  syntax\n";
 #   opcode        ModR/M                    SIB                   displacement    immediate
 #   instruction   mod, reg, Reg/Mem bits    scale, index, base
 #   1-3 bytes     0/1 byte                  0/1 byte              0/1/2/4 bytes   0/1/2/4 bytes
-    05                                                                            0a 0b 0c 0d  # add 0x0d0c0b0a to EAX
+    05            .                         .                     .               0a 0b 0c 0d  # add 0x0d0c0b0a to EAX
+# (The single periods are just to help the eye track long gaps between
+# columns, and are otherwise ignored.)
 
 # This program, when run, causes the following events in the trace:
 +load: 0x00000001 -> 05
@@ -132,6 +134,8 @@ void parse(istream& fin, program& out) {
       string word_data;
       lin >> word_data;
       if (word_data.empty()) continue;
+      if (word_data[0] == '#') break;  // comment
+      if (word_data == ".") continue;  // comment token
       if (word_data == "==") {
         if (!l.empty()) {
           assert(!out.segments.empty());
@@ -149,10 +153,6 @@ void parse(istream& fin, program& out) {
         // todo: line metadata
         break;
       }
-      if (word_data[0] == '#') {
-        // comment
-        break;
-      }
       w.push_back(word());
       w.back().original = word_data;
       istringstream win(word_data);
diff --git a/subx/ex7.subx b/subx/ex7.subx
index 4474e110..e312edbe 100644
--- a/subx/ex7.subx
+++ b/subx/ex7.subx
@@ -15,73 +15,73 @@
 # main:
   # prepare to make a call
 # 54
-  55/push                                                                                                                                           # push EBP
+  55/push                         .               .             .           .             .           .           .               .                 # push EBP
 # 55
-  89/copy                         3/mod/direct    5/rm32/EBP                                          4/r32/ESP                                     # copy ESP to EBP
+  89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
 # 57
   # factorial(5)
-  68/push                                                                                                                         5/imm32           # push 5
+  68/push                         .               .             .           .             .           .           .               5/imm32           # push 5
 # 5c
-  e8/call                                                                                                         factorial/disp32
+  e8/call                         .               .             .           .             .           .           factorial/disp32
 # 61
   # discard arg
-  5a/pop                                                                                                                                            # pop into EDX
+  5a/pop                          .               .             .           .             .           .           .               .                 # pop into EDX
 # 62
   # clean up after call
-  89/copy                         3/mod/direct    4/rm32/ESP                                          5/r32/EBP                                     # copy EBP to ESP
+  89/copy                         3/mod/direct    4/rm32/ESP    .           .             .           5/r32/EBP   .               .                 # copy EBP to ESP
 # 64
-  5d/pop                                                                                                                                            # pop to EBP
+  5d/pop                          .               .             .           .             .           .           .               .                 # pop to EBP
 
   # exit(EAX)
 # 65
-  89/copy                         3/mod/direct    3/rm32/EBX                                          0/r32/EAX                                     # copy EAX to EBX
+  89/copy                         3/mod/direct    3/rm32/EBX    .           .             .           0/r32/EAX   .               .                 # copy EAX to EBX
 # 67
-  b8/copy                                                                                                                         1/imm32           # copy 1 to EAX
+  b8/copy                         .               .             .           .             .           .           .               1/imm32           # copy 1 to EAX
 # 6c
-  cd/syscall                                                                                                                      0x80/imm8         # int 80h
+  cd/syscall                      .               .             .           .             .           .           .               0x80/imm8         # int 80h
 
 # factorial(n)
 # 6e
 factorial:
   # initialize n
-  8b/copy                         1/mod/*+disp8   4/rm32/sib    4/base/ESP  4/index/none              2/r32/EDX   4/disp8                           # copy *(ESP+4) to EDX
+  8b/copy                         1/mod/*+disp8   4/rm32/sib    4/base/ESP  4/index/none              2/r32/EDX   4/disp8         .                 # copy *(ESP+4) to EDX
 # 72
   # initialize EAX to 1 (base case)
-  b8/copy                                                                                                                         1/imm32           # copy 1 to EAX
+  b8/copy                         .               .             .           .             .           .           .               1/imm32           # copy 1 to EAX
 # 77
   # if (n <= 1) jump exit
-  81          7/subop/compare     3/mod/direct    2/rm32/EDX                                                                      1/imm32           # compare EDX with 1
+  81          7/subop/compare     3/mod/direct    2/rm32/EDX    .           .             .           .           .               1/imm32           # compare EDX with 1
 # 7d
-  7e/jump-if                                                                                                      factorial:exit/disp8              # jump if <= to exit
+  7e/jump-if                      .               .             .           .             .           .           factorial:exit/disp8              # jump if <= to exit
 # 7f
   # EBX: n-1
-  89/copy                         3/mod/direct    3/rm32/EBX                                          2/r32/EDX                                     # copy EDX to EBX
+  89/copy                         3/mod/direct    3/rm32/EBX    .           .             .           2/r32/EDX   .               .                 # copy EDX to EBX
 # 81
-  81          5/subop/subtract    3/mod/direct    3/rm32/EBX                                                                      1/imm32           # subtract 1 from EBX
+  81          5/subop/subtract    3/mod/direct    3/rm32/EBX    .           .             .           .           .               1/imm32           # subtract 1 from EBX
 # 87
   # prepare call
-  55/push                                                                                                                                           # push EBP
+  55/push                         .               .             .           .             .           .           .               .                 # push EBP
 # 88
-  89/copy                         3/mod/direct    5/rm32/EBP                                          4/r32/ESP                                     # copy ESP to EBP
+  89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
   # EAX: factorial(n-1)
 # 8a
-  53/push                                                                                                                                           # push EBX
+  53/push                         .               .             .           .             .           .           .               .                 # push EBX
 # 8b
-  e8/call                                                                                                         factorial/disp32
+  e8/call                         .               .             .           .             .           .           factorial/disp32
 # 90
   # discard arg
-  5e/pop                                                                                                                                            # pop into ESI
+  5e/pop                          .               .             .           .             .           .           .               .                 # pop into ESI
 # 91
   # clean up after call
-  89/copy                         3/mod/direct    4/rm32/ESP                                          5/r32/EBP                                     # copy EBP to ESP
+  89/copy                         3/mod/direct    4/rm32/ESP    .           .             .           5/r32/EBP   .               .                 # copy EBP to ESP
 # 93
-  5d/pop                                                                                                                                            # pop to EBP
+  5d/pop                          .               .             .           .             .           .           .               .                 # pop to EBP
 # 94
   # refresh n
-  8b/copy                         1/mod/*+disp8   4/rm32/sib    4/base/ESP  4/index/none              2/r32/EDX   4/disp8                           # copy *(ESP+4) to EDX
+  8b/copy                         1/mod/*+disp8   4/rm32/sib    4/base/ESP  4/index/none              2/r32/EDX   4/disp8         .                 # copy *(ESP+4) to EDX
 # 98
   # return n * factorial(n-1)
-  0f af/multiply                  3/mod/direct    2/rm32/EDX                                          0/r32/EAX                                     # multiply EDX (n) into EAX (factorial(n-1))
+  0f af/multiply                  3/mod/direct    2/rm32/EDX    .           .             .           0/r32/EAX   .               .                 # multiply EDX (n) into EAX (factorial(n-1))
   # TODO: check for overflow
 # 9b
 factorial:exit: