about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-10-05 21:50:20 -0700
committerKartik Agaram <vc@akkartik.com>2018-10-05 21:50:20 -0700
commitde21899cb2560ca7788539304051aae380a40959 (patch)
tree59d853ac63bb7f0a888c671ba15c47888f3caf75
parent94ad882e828f83df4a4cc0deab1a10e9d5e54eec (diff)
downloadmu-de21899cb2560ca7788539304051aae380a40959.tar.gz
4669
-rw-r--r--subx/examples/ex1.subx11
-rw-r--r--subx/examples/ex2.subx13
-rw-r--r--subx/examples/ex4.subx50
-rw-r--r--subx/examples/ex7.subx14
-rw-r--r--subx/examples/ex8.subx2
5 files changed, 40 insertions, 50 deletions
diff --git a/subx/examples/ex1.subx b/subx/examples/ex1.subx
index 444f872a..8839fb6b 100644
--- a/subx/examples/ex1.subx
+++ b/subx/examples/ex1.subx
@@ -9,12 +9,9 @@
 #   42
 
 == code
-# instruction                     effective address                                                   operand     displacement    immediate
-# op          subop               mod             rm32          base        index         scale       r32
-# 1-3 bytes   3 bits              2 bits          3 bits        3 bits      3 bits        2 bits      2 bits      0/1/2/4 bytes   0/1/2/4 bytes
-  bb/copy-to-EBX  2a/imm32
-  # exit(EBX)
-  b8/copy-to-EAX  1/imm32
-  cd/syscall  0x80/imm8
+bb/copy-to-EBX  2a/imm32
+# exit(EBX)
+b8/copy-to-EAX  1/imm32
+cd/syscall  0x80/imm8
 
 # vim:nowrap:textwidth=0
diff --git a/subx/examples/ex2.subx b/subx/examples/ex2.subx
index 3035b39f..e44d5ea8 100644
--- a/subx/examples/ex2.subx
+++ b/subx/examples/ex2.subx
@@ -8,13 +8,10 @@
 #   2
 
 == code
-# instruction                     effective address                                                   operand     displacement    immediate
-# op          subop               mod             rm32          base        index         scale       r32
-# 1-3 bytes   3 bits              2 bits          3 bits        3 bits      3 bits        2 bits      2 bits      0/1/2/4 bytes   0/1/2/4 bytes
-  bb/copy-to-EBX  1/imm32
-  43/inc-EBX
-  # exit(EBX)
-  b8/copy-to-EAX  1/imm32
-  cd/syscall  0x80/imm8
+bb/copy-to-EBX  1/imm32
+43/inc-EBX
+# exit(EBX)
+b8/copy-to-EAX  1/imm32
+cd/syscall  0x80/imm8
 
 # vim:nowrap:textwidth=0
diff --git a/subx/examples/ex4.subx b/subx/examples/ex4.subx
index 3c4f8949..9e062cb2 100644
--- a/subx/examples/ex4.subx
+++ b/subx/examples/ex4.subx
@@ -5,35 +5,31 @@
 #   $ subx run examples/ex4
 
 == code
-# instruction                     effective address                                                   operand     displacement    immediate
-# op          subop               mod             rm32          base        index         scale       r32
-# 1-3 bytes   3 bits              2 bits          3 bits        3 bits      3 bits        2 bits      2 bits      0/1/2/4 bytes   0/1/2/4 bytes
+# read(stdin, x, 1)
+  # fd = 0 (stdin)
+bb/copy-to-EBX  0/imm32
+  # initialize x (location to write result to)
+b9/copy-to-ECX  x/imm32
+  # size = 1 character
+ba/copy-to-EDX  1/imm32
+  # read(fd, x, size)
+b8/copy-to-EAX  3/imm32/read
+cd/syscall  0x80/imm8
 
-  # read(stdin, x, 1)
-    # fd = 0 (stdin)
-  bb/copy-to-EBX  0/imm32
-    # initialize x (location to write result to)
-  b9/copy-to-ECX  x/imm32
-    # size = 1 character
-  ba/copy-to-EDX  1/imm32
-    # read(fd, x, size)
-  b8/copy-to-EAX  3/imm32/read
-  cd/syscall  0x80/imm8
+# write(stdout, x, 1)
+  # fd = 1 (stdout)
+bb/copy-to-EBX  1/imm32
+  # initialize x (location to read from)
+b9/copy-to-ECX  x/imm32
+  # size = 1 character
+ba/copy-to-EDX  1/imm32
+  # write(fd, x, size)
+b8/copy-to-EAX  4/imm32/write
+cd/syscall  0x80/imm8
 
-  # write(stdout, x, 1)
-    # fd = 1 (stdout)
-  bb/copy-to-EBX  1/imm32
-    # initialize x (location to read from)
-  b9/copy-to-ECX  x/imm32
-    # size = 1 character
-  ba/copy-to-EDX  1/imm32
-    # write(fd, x, size)
-  b8/copy-to-EAX  4/imm32/write
-  cd/syscall  0x80/imm8
-
-  # exit(EBX)
-  b8/copy-to-EAX  1/imm32/exit
-  cd/syscall  0x80/imm8
+# exit(EBX)
+b8/copy-to-EAX  1/imm32/exit
+cd/syscall  0x80/imm8
 
 == data
 x:
diff --git a/subx/examples/ex7.subx b/subx/examples/ex7.subx
index 841daf61..615f5d21 100644
--- a/subx/examples/ex7.subx
+++ b/subx/examples/ex7.subx
@@ -29,12 +29,12 @@
   cd/syscall  0x80/imm8
     # save stream
   bb/copy-to-EBX  stream/imm32
-  89/copy                         0/mod/indirect  3/rm32/EBX                                          0/r32/EAX                                           # copy EAX to *EBX
+  89/copy                         0/mod/indirect  3/rm32/EBX    .           .             .           0/r32/EAX   .               .                       # copy EAX to *EBX
 
   # write(stream, "a", 1)
     # load stream
   bb/copy-to-EBX  stream/imm32
-  8b/copy                         0/mod/indirect  3/rm32/EBX                                          3/r32/EBX                                           # copy *EBX to EBX
+  8b/copy                         0/mod/indirect  3/rm32/EBX    .           .             .           3/r32/EBX   .               .                       # copy *EBX to EBX
     #
   b9/copy-to-ECX  a/imm32
   ba/copy-to-EDX  1/imm32/size
@@ -44,7 +44,7 @@
   # close(stream)
     # load stream
   bb/copy-to-EBX  stream/imm32
-  8b/copy                         0/mod/indirect  3/rm32/EBX                                          3/r32/EBX                                           # copy *EBX to EBX
+  8b/copy                         0/mod/indirect  3/rm32/EBX    .           .             .           3/r32/EBX   .               .                       # copy *EBX to EBX
     #
   b8/copy-to-EAX  6/imm32/close
   cd/syscall  0x80/imm8
@@ -57,12 +57,12 @@
   cd/syscall  0x80/imm8
     # save stream
   bb/copy-to-EBX  stream/imm32
-  89/copy                         0/mod/indirect  3/rm32/EBX                                          0/r32/EAX                                           # copy EAX to *EBX
+  89/copy                         0/mod/indirect  3/rm32/EBX    .           .             .           0/r32/EAX   .               .                       # copy EAX to *EBX
 
   # read(stream, b, 1)
     # load stream
   bb/copy-to-EBX  stream/imm32
-  8b/copy                         0/mod/indirect  3/rm32/EBX                                          3/r32/EBX                                           # copy *EBX to EBX
+  8b/copy                         0/mod/indirect  3/rm32/EBX    .           .             .           3/r32/EBX   .               .                       # copy *EBX to EBX
     #
   b9/copy-to-ECX  b/imm32
   ba/copy-to-EDX  1/imm32/size
@@ -72,7 +72,7 @@
   # close(stream)
     # load stream
   bb/copy-to-EBX  stream/imm32
-  8b/copy                         0/mod/indirect  3/rm32/EBX                                          3/r32/EBX                                           # copy *EBX to EBX
+  8b/copy                         0/mod/indirect  3/rm32/EBX    .           .             .           3/r32/EBX   .               .                       # copy *EBX to EBX
     #
   b8/copy-to-EAX  6/imm32/close
   cd/syscall  0x80/imm8
@@ -85,7 +85,7 @@
   # exit(b)
     # load b
   bb/copy-to-EBX  b/imm32
-  8b/copy                         0/mod/indirect  3/rm32/EBX                                          3/r32/EBX                                           # copy *EBX to EBX
+  8b/copy                         0/mod/indirect  3/rm32/EBX    .           .             .           3/r32/EBX   .               .                       # copy *EBX to EBX
     #
   b8/copy-to-EAX  1/imm32/exit
   cd/syscall  0x80/imm8
diff --git a/subx/examples/ex8.subx b/subx/examples/ex8.subx
index adc3f413..4dc0054f 100644
--- a/subx/examples/ex8.subx
+++ b/subx/examples/ex8.subx
@@ -35,7 +35,7 @@
 
 ascii-length:  # (s)
   # initialize s (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
+  8b/copy                         1/mod/*+disp8   4/rm32/sib    4/base/ESP  4/index/none  .           2/r32/EDX   4/disp8         .                 # copy *(ESP+4) to EDX
   # var result = 0 (EAX)
   b8/copy-to-EAX  0/imm32
 $ascii-length-loop: