about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-11-30 09:43:49 -0800
committerKartik Agaram <vc@akkartik.com>2018-11-30 09:43:49 -0800
commitc56d803cd8a0e3f28328f91aa1d457905a68641a (patch)
treedd527a54c1ed8b45d5db44960f579c6faaf9ebd8 /subx
parentf989d6ccf9884e911db25494983da476f3c511b1 (diff)
downloadmu-c56d803cd8a0e3f28328f91aa1d457905a68641a.tar.gz
4796
Diffstat (limited to 'subx')
-rw-r--r--subx/apps/crenshaw2-1.subx292
-rw-r--r--subx/subx.vim34
2 files changed, 177 insertions, 149 deletions
diff --git a/subx/apps/crenshaw2-1.subx b/subx/apps/crenshaw2-1.subx
index 62e2cb89..94eede9e 100644
--- a/subx/apps/crenshaw2-1.subx
+++ b/subx/apps/crenshaw2-1.subx
@@ -1,4 +1,4 @@
-## Port of https://github.com/akkartik/crenshaw/blob/master/tutor2.1.pas
+# Port of https://github.com/akkartik/crenshaw/blob/master/tutor2.1.pas
 # Corresponds to the section "single digits" in https://compilers.iecc.com/crenshaw/tutor2.txt
 #
 # To run (from the subx directory):
@@ -36,14 +36,14 @@
   81          7/subop/compare     1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0/disp8         1/imm32           # compare *EBP
   7e/jump-if-lesser-or-equal  $run-main/disp8
   # and if (argv[1] == "test")
-    # push args
+    # . push args
   68/push  "test"/imm32
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0x8/disp8       .                 # push *(EBP+8)
-    # call
+    # . call
   e8/call  kernel-string-equal/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
-    # check result
+    # . check result
   3d/compare-EAX  1/imm32
   75/jump-if-not-equal  $run-main/disp8
   # then return run-tests()
@@ -53,20 +53,20 @@
   eb/jump  $main:end/disp8
 $run-main:
   # allocate space for an exit-descriptor
-    # var ed/EAX : (address exit-descriptor)
+    # . var ed/EAX : (address exit-descriptor)
   81          5/subop/subtract    3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # subtract from ESP
   8d/copy-address                 0/mod/indirect  4/rm32/sib    4/base/ESP  4/index/none  .           0/r32/EAX   .               .                 # copy ESP to EAX
-    # clear ed->target (so we really exit)
+    # . clear ed->target (so we really exit)
   c7/copy                         0/mod/direct    0/rm32/EAX    .           .             .           .           .               0/imm32           # copy to *EAX
   # compile(Stdin, 1/stdout, 2/stderr, ed)
-    # push args
+    # . push args
   50/push-EAX/ed
   68/push  2/imm32/stderr
   68/push  1/imm32/stdout
   68/push  Stdin/imm32
-    # call
+    # . call
   e8/call  compile/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0x10/imm32        # add to ESP
   # syscall(exit, 0)
   bb/copy-to-EBX  0/imm32
@@ -83,11 +83,11 @@ compile:  # in : fd or (address stream), out : fd or (address stream), err : fd
   50/push-EAX
   51/push-ECX
   # Look = get-char(in)
-    # push args
+    # . push args
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           8/disp8      .                    # push *(EBP+8)
-    # call
+    # . call
   e8/call  get-char/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
   # var num/ECX : (address stream) on the stack
   # Numbers can be 32 bits or 8 hex bytes long. One of them will be in 'Look', so we need space for 7 bytes.
@@ -98,85 +98,85 @@ compile:  # in : fd or (address stream), out : fd or (address stream), err : fd
   # num->length = 7
   c7/copy                         1/mod/*+disp8   1/rm32/ECX    .           .             .           .           8/disp8         7/imm32           # copy to *(ECX+8)
   # clear-stream(num)
-    # push args
+    # . push args
   51/push-ECX
-    # call
+    # . call
   e8/call  clear-stream/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
   # get-num(in, num, err, ed)
-    # push args
+    # . push args
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0x14/disp8      .                 # push *(EBP+20)
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0x10/disp8      .                 # push *(EBP+16)
   51/push-ECX/num
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           8/disp8      .                    # push *(EBP+8)
-    # call
+    # . call
   e8/call  get-num/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0x10/imm32        # add to ESP
   # EAX = write(_test-stream, "Ab")
-    # push args
+    # . push args
   68/push  "Ab"/imm32
   68/push  _test-stream/imm32
-    # call
+    # . call
   e8/call  write/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
   # EAX = write(out, "bb/copy-to-EBX  ")
-    # push args
+    # . push args
   68/push  "bb/copy-to-EBX  "/imm32
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0xc/disp8       .                 # push *(EBP+12)
-    # call
+    # . call
   e8/call  write/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
   # write-stream(out, num)
-    # push args
+    # . push args
   51/push-ECX/num
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0xc/disp8       .                 # push *(EBP+12)
-    # call
+    # . call
   e8/call  write-stream/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
   # write(out, Newline)
-    # push args
+    # . push args
   68/push  Newline/imm32
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0xc/disp8       .                 # push *(EBP+12)
-    # call
+    # . call
   e8/call  write/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
   # EAX = write(out, "b8/copy-to-EAX  1/imm32/exit")
-    # push args
+    # . push args
   68/push  "b8/copy-to-EAX  1/imm32/exit"/imm32
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0xc/disp8       .                 # push *(EBP+12)
-    # call
+    # . call
   e8/call  write/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
   # EAX = write(out, Newline)
-    # push args
+    # . push args
   68/push  Newline/imm32
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0xc/disp8       .                 # push *(EBP+12)
-    # call
+    # . call
   e8/call  write/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
   # EAX = write(out, "cd/syscall  0x80/imm8")
-    # push args
+    # . push args
   68/push  "cd/syscall  0x80/imm8"/imm32
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0xc/disp8       .                 # push *(EBP+12)
-    # call
+    # . call
   e8/call  write/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
   # EAX = write(out, Newline)
-    # push args
+    # . push args
   68/push  Newline/imm32
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0xc/disp8       .                 # push *(EBP+12)
-    # call
+    # . call
   e8/call  write/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
   # restore registers
   59/pop-to-ECX
@@ -214,16 +214,16 @@ get-num:  # in : (address buffered-file), out : (address stream), err : fd or (a
   55/push-EBP
   89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
   # EAX = is-digit?(Look)
-    # push args
+    # . push args
   ff          6/subop/push        0/mod/indirect  5/rm32/.disp32            .             .           .           Look/disp32     .                 # push *Look
-    # call
+    # . call
   e8/call  is-digit?/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
   # if EAX == 0 error
   3d/compare-EAX  0/imm32
   75/jump-if-not-equal  $get-num:main/disp8
-    # expected(ed, err, "integer")
+    # . expected(ed, err, "integer")
       # push args
   68/push  "integer"/imm32
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0x10/disp8      .                 # push *(EBP+16)
@@ -253,13 +253,13 @@ $get-num:main:
   3b/compare                      3/mod/direct    1/rm32/ECX    .           .             .           2/r32/EDX   .               .                 # compare EDX with ECX
   7d/jump-if-lesser  $get-num:stage2/disp8
     # error(ed, err, "get-num: too many digits in number")  # TODO: show full number
-      # push args
+      # . push args
   68/push  "get-num: too many digits in number"/imm32
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0x10/disp8      .                 # push *(EBP+16)
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0x14/disp8      .                 # push *(EBP+20)
-      # call
+      # . call
   e8/call  error/disp32  # never returns
-      # discard args
+      # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0xc/imm32         # add to ESP
 $get-num:stage2:
   # out->data[out->write] = LSB(Look)
@@ -269,11 +269,11 @@ $get-num:stage2:
   # ++out->write
   41/increment-ECX
   # Look = get-char(in)
-    # push args
+    # . push args
   56/push-ESI
-    # call
+    # . call
   e8/call  get-char/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
 $get-num:loop-end:
   # persist necessary variables from registers
@@ -291,92 +291,92 @@ $get-num:loop-end:
   c3/return
 
 test-get-num-reads-single-digit:
-  ## check that get-num returns first character if it's a digit
+  # - check that get-num returns first character if it's a digit
   # This test uses exit-descriptors. Use EBP for setting up local variables.
   55/push-EBP
   89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
-  ## clear all streams
+  # - clear all streams
   # clear-stream(_test-stream)
-    # push args
+    # . push args
   68/push  _test-stream/imm32
-    # call
+    # . call
   e8/call  clear-stream/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
   # clear-stream(_test-buffered-file+4)
-    # push args
+    # . push args
   b8/copy-to-EAX  _test-buffered-file/imm32
   05/add-to-EAX  4/imm32
   50/push-EAX
-    # call
+    # . call
   e8/call  clear-stream/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
   # clear-stream(_test-output-stream)
-    # push args
+    # . push args
   68/push  _test-output-stream/imm32
-    # call
+    # . call
   e8/call  clear-stream/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
   # clear-stream(_test-error-stream)
-    # push args
+    # . push args
   68/push  _test-error-stream/imm32
-    # call
+    # . call
   e8/call  clear-stream/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
-  ## initialize 'in'
+  # - initialize 'in'
   # write(_test-stream, "3")
-    # push args
+    # . push args
   68/push  "3"/imm32
   68/push  _test-stream/imm32
-    # call
+    # . call
   e8/call  write/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
-  ## initialize exit-descriptor 'ed'
+  # - initialize exit-descriptor 'ed'
   # allocate on stack
   # var ed/EAX : (address exit-descriptor)
   81          5/subop/subtract    3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # subtract from ESP
   8d/copy-address                 0/mod/indirect  4/rm32/sib    4/base/ESP  4/index/none  .           0/r32/EAX   .               .                 # copy ESP to EAX
   # size the exit-descriptor for the call to get-num below
   # tailor-exit-descriptor(ed, 16)
-    # push args
+    # . push args
   68/push  0x10/imm32/nbytes-of-args-for-get-num
   50/push-EAX/ed
-    # call
+    # . call
   e8/call  tailor-exit-descriptor/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
-  ## prime the pump
+  # - prime the pump
   # get-char(_test-buffered-file)
-    # push args
+    # . push args
   68/push  _test-buffered-file/imm32
-    # call
+    # . call
   e8/call  get-char/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
   ## get-num(in, out, err, ed)
-    # push args
+    # . push args
   50/push-EAX/ed
   68/push  _test-error-stream/imm32
   68/push  _test-output-stream/imm32
   68/push  _test-buffered-file/imm32
-    # call
+    # . call
   e8/call  get-num/disp32
   ## registers except ESP may be clobbered at this point
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0x10/imm32        # add to ESP
   # check-ints-equal(*_test-output-stream.data, '3')
-    # push args
+    # . push args
   68/push  "F - test-get-num-reads-single-digit"/imm32
   68/push  0x33/imm32
   b8/copy-to-EAX  _test-output-stream/imm32
   ff          6/subop/push        1/mod/*+disp8   0/rm32/EAX    .           .             .           .           0xc/disp8       .                 # push *(EAX+12)
-    # call
+    # . call
   e8/call  check-ints-equal/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0xc/imm32         # add to ESP
   # reclaim locals
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
@@ -384,86 +384,86 @@ test-get-num-reads-single-digit:
   c3/return
 
 test-get-num-aborts-on-non-digit-in-Look:
-  ## check that get-num returns first character if it's a digit
+  # - check that get-num returns first character if it's a digit
   # This test uses exit-descriptors. Use EBP for setting up local variables.
   55/push-EBP
   89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
-  ## clear all streams
+  # - clear all streams
   # clear-stream(_test-stream)
-    # push args
+    # . push args
   68/push  _test-stream/imm32
-    # call
+    # . call
   e8/call  clear-stream/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
   # clear-stream(_test-buffered-file+4)
-    # push args
+    # . push args
   b8/copy-to-EAX  _test-buffered-file/imm32
   05/add-to-EAX  4/imm32
   50/push-EAX
-    # call
+    # . call
   e8/call  clear-stream/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
   # clear-stream(_test-output-stream)
-    # push args
+    # . push args
   68/push  _test-output-stream/imm32
-    # call
+    # . call
   e8/call  clear-stream/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
   # clear-stream(_test-error-stream)
-    # push args
+    # . push args
   68/push  _test-error-stream/imm32
-    # call
+    # . call
   e8/call  clear-stream/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
-  ## initialize 'in'
+  # - initialize 'in'
   # write(_test-stream, "3")
-    # push args
+    # . push args
   68/push  "3"/imm32
   68/push  _test-stream/imm32
-    # call
+    # . call
   e8/call  write/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
-  ## initialize exit-descriptor 'ed'
+  # - initialize exit-descriptor 'ed'
   # allocate on stack
   # var ed/EAX : (address exit-descriptor)
   81          5/subop/subtract    3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # subtract from ESP
   8d/copy-address                 0/mod/indirect  4/rm32/sib    4/base/ESP  4/index/none  .           0/r32/EAX   .               .                 # copy ESP to EAX
   # size the exit-descriptor for the call to get-num below
   # tailor-exit-descriptor(ed, 16)
-    # push args
+    # . push args
   68/push  0x10/imm32/nbytes-of-args-for-get-num
   50/push-EAX/ed
-    # call
+    # . call
   e8/call  tailor-exit-descriptor/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
-  ## don't initialize Look
-  ## get-num(in, out, err, ed)
-    # push args
+  # - don't initialize Look
+  # - get-num(in, out, err, ed)
+    # . push args
   50/push-EAX/ed
   68/push  _test-error-stream/imm32
   68/push  _test-output-stream/imm32
   68/push  _test-buffered-file/imm32
-    # call
+    # . call
   e8/call  get-num/disp32
-  ## registers except ESP may be clobbered at this point
-    # discard args
+  # registers except ESP may be clobbered at this point
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0x10/imm32        # add to ESP
-  ## check that get-num tried to call exit(1)
+  # - check that get-num tried to call exit(1)
   # check-ints-equal(ed->value, 2, msg)  # i.e. stop was called with value 1
-    # push args
+    # . push args
   68/push  "F - test-get-num-aborts-on-non-digit-in-Look"/imm32
   68/push  2/imm32
-    # push ed->value
+    # . push ed->value
   ff          6/subop/push        1/mod/*+disp8   0/rm32/EAX    .           .             .           .           4/disp8         .                 # push *(EAX+4)
-    # call
+    # . call
   e8/call  check-ints-equal/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0xc/imm32         # add to ESP
   # reclaim locals
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
@@ -478,42 +478,42 @@ expected:  # ed : (address exit-descriptor), f : fd or (address stream), s : (ad
   55/push-EBP
   89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
   # write(f, "Error: ")
-    # push args
+    # . push args
   68/push  "Error: "/imm32
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0xc/disp8       .                 # push *(EBP+12)
-    # call
+    # . call
   e8/call  write/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
   # write(f, s)
-    # push args
+    # . push args
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0x10/disp8      .                 # push *(EBP+16)
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0xc/disp8       .                 # push *(EBP+12)
-    # call
+    # . call
   e8/call  write/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
   # write(f, " expected")
-    # push args
+    # . push args
   68/push  " expected"/imm32
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0xc/disp8       .                 # push *(EBP+12)
-    # call
+    # . call
   e8/call  write/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
   # write(f, Newline)
-    # push args
+    # . push args
   68/push  Newline/imm32
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0xc/disp8       .                 # push *(EBP+12)
-    # call
+    # . call
   e8/call  write/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
   # stop(ed, 1)
-    # push args
+    # . push args
   68/push  1/imm32
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           8/disp8         .                 # push *(EBP+8)
-    # call
+    # . call
   e8/call  stop/disp32
   ## should never get past this point
   # epilog
@@ -527,34 +527,34 @@ error:  # ed : (address exit-descriptor), f : fd or (address stream), s : (addre
   55/push-EBP
   89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
   # write(f, "Error: ")
-    # push args
+    # . push args
   68/push  "Error: "/imm32
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0xc/disp8       .                 # push *(EBP+12)
-    # call
+    # . call
   e8/call  write/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
   # write(f, s)
-    # push args
+    # . push args
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0x10/disp8      .                 # push *(EBP+16)
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0xc/disp8       .                 # push *(EBP+12)
-    # call
+    # . call
   e8/call  write/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
   # write(f, Newline)
-    # push args
+    # . push args
   68/push  Newline/imm32
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0xc/disp8       .                 # push *(EBP+12)
-    # call
+    # . call
   e8/call  write/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
   # stop(ed, 1)
-    # push args
+    # . push args
   68/push  1/imm32
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           8/disp8         .                 # push *(EBP+8)
-    # call
+    # . call
   e8/call  stop/disp32
   ## should never get past this point
   # epilog
@@ -570,11 +570,11 @@ get-char:  # f : (address buffered-file) -> <void>
   # save registers
   50/push-EAX
   # read-byte(f)
-    # push args
+    # . push args
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           0x8/disp8       .                 # push *(EBP+8)
-    # call
+    # . call
   e8/call  read-byte/disp32
-    # discard args
+    # . discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
   # save EAX to Look
   89/copy                         0/mod/indirect  5/rm32/.disp32            .             .           0/r32/EAX   Look/disp32     .                 # copy EAX to *Look
diff --git a/subx/subx.vim b/subx/subx.vim
index 0ba55cd9..515c8cd6 100644
--- a/subx/subx.vim
+++ b/subx/subx.vim
@@ -17,15 +17,43 @@ setlocal formatoptions+=c  " but comments should still wrap
 
 setlocal iskeyword+=-
 
-syntax match subxComment /#.*$/  | highlight link subxComment Comment
-syntax match subxSalientComment /##.*$/  | highlight link subxSalientComment SalientComment
+"? syntax match subxH1Comment /^# ===== .*/ | highlight subxH1Comment ctermfg=14
+"? syntax match subxH2Comment /^# ==== .*/ | highlight subxH2Comment ctermfg=39
+"? syntax match subxH3Comment /^# === .*/ | highlight subxH3Comment ctermfg=33
+"? syntax match subxH4Comment /^# == .*/ | highlight subxH4Comment ctermfg=27
+"? syntax match subxH5Comment /^# = .*/ | highlight subxH5Comment ctermfg=21
+"? syntax match subxH6Comment /^# [^=].*/ | highlight subxH6Comment ctermfg=19
+
+"? syntax match subxH1Comment /^# === .*/ | highlight subxH1Comment ctermfg=14
+"? syntax match subxH2Comment /^# --- .*/ | highlight subxH2Comment ctermfg=39
+"? syntax match subxComment /^# [^=-\.].*/ | highlight subxComment ctermfg=33
+"? syntax match subxS1Comment /^# \. .*/ | highlight subxS1Comment ctermfg=27
+"? syntax match subxS2Comment /^# \. \. .*/ | highlight subxS2Comment ctermfg=21
+"? syntax match subxS3Comment /^# \. \. \. .*/ | highlight subxS3Comment ctermfg=19
+
+"? syntax match subxH1Comment /^# =.*/ | highlight subxH1Comment ctermfg=14
+"? syntax match subxH2Comment /^# -.*/ | highlight subxH2Comment ctermfg=39
+"? syntax match subxComment /^#[^ ].*\|# [^ .=-].*\|# \?$/ | highlight subxComment ctermfg=27
+"? syntax match subxS1Comment /^# \..*/ | highlight subxS1Comment ctermfg=21
+"? syntax match subxS2Comment /^# \. \..*/ | highlight subxS2Comment ctermfg=19
+"? syntax match subxS3Comment /^# \. \. \..*/ | highlight subxS3Comment ctermfg=18
+
+syntax match subxH1Comment /# =.*/ | highlight subxH1Comment ctermfg=14
+syntax match subxH2Comment /# -.*/ | highlight subxH2Comment ctermfg=39
+syntax match subxComment /#[^ ].*\|# [^.=-].*\|# \?$/ | highlight subxComment ctermfg=27
+syntax match subxS1Comment /# \..*/ | highlight subxS1Comment ctermfg=19
+
+"? syntax match subxH2Comment /^# --- .*/ | highlight subxH2Comment ctermfg=33
+"? syntax match subxH3Comment /^# --- .*/ | highlight subxH3Comment ctermfg=21
+"? syntax match subxComment /#.*$/  | highlight link subxComment Comment
+"? syntax match subxSalientComment /##.*$/  | highlight link subxSalientComment SalientComment
 set comments-=:#
 set comments+=n:#
 syntax match subxCommentedCode "#? .*"  | highlight link subxCommentedCode CommentedCode
 let b:cmt_head = "#? "
 
 " comment token
-syntax match subxDelimiter / \. /  | highlight link subxDelimiter Delimiter
+syntax match subxDelimiter / \. /  | highlight link subxDelimiter CommentedCode
 
 syntax match subxString %"[^"]*"% | highlight link subxString Constant
 " match globals but not registers like 'EAX'