about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
Diffstat (limited to 'subx')
-rw-r--r--subx/ex1.1.subx3
-rw-r--r--subx/ex1.2.subx9
-rw-r--r--subx/ex2.subx8
-rw-r--r--subx/ex3.subx14
-rw-r--r--subx/ex4.subx24
-rw-r--r--subx/ex5.subx30
-rw-r--r--subx/ex6.subx16
7 files changed, 55 insertions, 49 deletions
diff --git a/subx/ex1.1.subx b/subx/ex1.1.subx
index 7dbcf8af..1cbe5dc1 100644
--- a/subx/ex1.1.subx
+++ b/subx/ex1.1.subx
@@ -4,6 +4,9 @@
 # To run:
 #   $ subx translate ex1.1.subx ex1
 #   $ subx run ex1
+# Expected result:
+#   $ echo $?
+#   42
 
 == 0x08048054  # code segment, after leaving room for ELF header
 # opcode        ModR/M                    SIB                   displacement    immediate
diff --git a/subx/ex1.2.subx b/subx/ex1.2.subx
index a3eee2d9..844678b7 100644
--- a/subx/ex1.2.subx
+++ b/subx/ex1.2.subx
@@ -4,14 +4,17 @@
 # To run:
 #   $ subx translate ex1.2.subx ex1
 #   $ subx run ex1
+# Expected result:
+#   $ echo $?
+#   42
 
 == 0x08048054  # code segment, after leaving room for ELF header
 # 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                                                                                                                      2a/imm32          # copy 42 to EBX
+  bb/copy                                                                                                                 2a/imm32          # copy 42 to EBX
   # exit(EBX)
-  b8                                                                                                                      1/imm32           # copy 1 to EAX
-  cd                                                                                                                      0x80/imm8         # int 80h
+  b8/copy                                                                                                                 1/imm32           # copy 1 to EAX
+  cd/syscall                                                                                                              0x80/imm8         # int 80h
 
 # vim:ft=subx
diff --git a/subx/ex2.subx b/subx/ex2.subx
index 82d84104..20cee840 100644
--- a/subx/ex2.subx
+++ b/subx/ex2.subx
@@ -11,10 +11,10 @@
 # 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                                                                                                                      1/imm32           # copy 1 to EBX
-  81          0/add/subop         3/mod/direct    3/ebx/rm32                                                              1/imm32           # add 1 to EBX
+  bb/copy                                                                                                                 1/imm32           # copy 1 to EBX
+  81          0/subop/add         3/mod/direct    3/rm32/ebx                                                              1/imm32           # add 1 to EBX
   # exit(EBX)
-  b8                                                                                                                      1/imm32           # copy 1 to EAX
-  cd                                                                                                                      0x80/imm8         # int 80h
+  b8/copy                                                                                                                 1/imm32           # copy 1 to EAX
+  cd/syscall                                                                                                              0x80/imm8         # int 80h
 
 # vim:ft=subx
diff --git a/subx/ex3.subx b/subx/ex3.subx
index 5b3fdb16..b2d6d7c4 100644
--- a/subx/ex3.subx
+++ b/subx/ex3.subx
@@ -12,24 +12,24 @@
 # 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
   # result: EBX = 0
-  bb                                                                                                                      0/imm32           # copy 0 to EBX
+  bb/copy                                                                                                                 0/imm32           # copy 0 to EBX
   # counter: ECX = 1
-  b9                                                                                                                      1/imm32           # copy 1 to ECX
+  b9/copy                                                                                                                 1/imm32           # copy 1 to ECX
 
 loop:
   # while (ECX <= 10)
   81            7/subop/compare   3/mod/direct    1/rm32/ecx                                                              0xa/imm32         # compare ECX, 10/imm
-  7f                                                                                                      exit/disp8                        # jump-if-greater
+  7f/jump-if                                                                                              exit/disp8                        # jump-if-greater exit
   # EBX += ECX
-  01                              3/mod/direct    3/rm32/ebx                                  1/r32/ecx                                     # add ECX to EBX
+  01/add                          3/mod/direct    3/rm32/ebx                                  1/r32/ecx                                     # add ECX to EBX
   # ECX++
   81            0/subop/add       3/mod/direct    1/rm32/ecx                                                              1/imm32           # add 1 to ECX
   # loop
-  eb                                                                                                      loop/disp8                        # jump
+  eb/jump                                                                                                 loop/disp8                        # jump loop
 
 exit:
   # exit(EBX)
-  b8                                                                                                                      1/imm32           # copy 1 to EAX
-  cd                                                                                                                      0x80/imm8         # int 80h
+  b8/copy                                                                                                                 1/imm32           # copy 1 to EAX
+  cd/syscall                                                                                                              0x80/imm8         # int 80h
 
 # vim:ft=subx:nowrap
diff --git a/subx/ex4.subx b/subx/ex4.subx
index b8d5ca10..db4abae3 100644
--- a/subx/ex4.subx
+++ b/subx/ex4.subx
@@ -11,31 +11,31 @@
 
   ## read(stdin, x, 1)
   # fd = 0 (stdin)
-  bb                                                                                                                      0/imm32           # copy 0 to EBX
+  bb/copy                                                                                                                 0/imm32           # copy 0 to EBX
   # set location to write to
-  b9                                                                                                                      0x080490a7/imm32  # copy to ECX
+  b9/copy                                                                                                                 0x080490a7/imm32  # copy to ECX
   # size = 1 character
-  ba                                                                                                                      1/imm32           # copy 1 to EDX
+  ba/copy                                                                                                                 1/imm32           # copy 1 to EDX
   # syscall = read
-  b8                                                                                                                      3/imm32           # copy 3 to EAX
+  b8/copy                                                                                                                 3/imm32           # copy 3 to EAX
   # call
-  cd                                                                                                                      0x80/imm8         # int 80h
+  cd/syscall                                                                                                              0x80/imm8         # int 80h
 
   ## write(stdout, x, 1)
   # fd = 1 (stdout)
-  bb                                                                                                                      1/imm32           # copy 1 to EBX
+  bb/copy                                                                                                                 1/imm32           # copy 1 to EBX
   # set location to write to
-  b9                                                                                                                      0x080490a7/imm32  # copy to ECX
+  b9/copy                                                                                                                 0x080490a7/imm32  # copy to ECX
   # size = 1 character
-  ba                                                                                                                      1/imm32           # copy 1 to EDX
+  ba/copy                                                                                                                 1/imm32           # copy 1 to EDX
   # syscall = write
-  b8                                                                                                                      4/imm32           # copy 4 to EAX
+  b8/copy                                                                                                                 4/imm32           # copy 4 to EAX
   # call
-  cd                                                                                                                      0x80/imm8         # int 80h
+  cd/syscall                                                                                                              0x80/imm8         # int 80h
 
   ## exit(EBX)
-  b8                                                                                                                      1/imm32           # copy 1 to EAX
-  cd                                                                                                                      0x80/imm8         # int 80h
+  b8/copy                                                                                                                 1/imm32           # copy 1 to EAX
+  cd/syscall                                                                                                              0x80/imm8         # int 80h
 
 == 0x080490a7
 00 00 00 00  # space for read() to write to
diff --git a/subx/ex5.subx b/subx/ex5.subx
index 65ca4807..540d0315 100644
--- a/subx/ex5.subx
+++ b/subx/ex5.subx
@@ -11,37 +11,37 @@
 
 ## function main
   # prolog
-  55                                                                                                                                        # push EBP
-  89                              3/mod/direct    5/rm32/EBP                                  4/r32/ESP                                     # copy ESP to EBP
+  55/push                                                                                                                                   # push EBP
+  89/copy                         3/mod/direct    5/rm32/EBP                                  4/r32/ESP                                     # copy ESP to EBP
   # allocate x on the stack
-  81            5/subop/subtract  3/mod/direct    4/rm32/ESP                                                              4/imm32           # subtract 4 bytes from ESP
+  81          5/subop/subtract    3/mod/direct    4/rm32/ESP                                                              4/imm32           # subtract 4 bytes from ESP
 
   ## read(stdin, x, 1)
   # fd = 0 (stdin)
-  bb                                                                                                                      0/imm32           # copy 0 to EBX
+  bb/copy                                                                                                                 0/imm32           # copy 0 to EBX
   # set location to read character to
-  89                              3/mod/direct    1/rm32/ECX                                  5/r32/EBP                                     # copy EBP to ECX
+  89/copy                         3/mod/direct    1/rm32/ECX                                  5/r32/EBP                                     # copy EBP to ECX
   # size = 1 character
-  ba                                                                                                                      1/imm32           # copy 1 to EDX
+  ba/copy                                                                                                                 1/imm32           # copy 1 to EDX
   # syscall = read
-  b8                                                                                                                      3/imm32           # copy 3 to EAX
+  b8/copy                                                                                                                 3/imm32           # copy 3 to EAX
   # call
-  cd                                                                                                                      0x80/imm8         # int 80h
+  cd/syscall                                                                                                              0x80/imm8         # int 80h
 
   ## write(stdout, x, 1)
   # fd = 1 (stdout)
-  bb                                                                                                                      1/imm32           # copy 1 to EBX
+  bb/copy                                                                                                                 1/imm32           # copy 1 to EBX
   # set location of character to write out
-  89                              3/mod/direct    1/rm32/ECX                                  5/r32/EBP                                     # copy EBP to ECX
+  89/copy                         3/mod/direct    1/rm32/ECX                                  5/r32/EBP                                     # copy EBP to ECX
   # size = 1 character
-  ba                                                                                                                      1/imm32           # copy 1 to EDX
+  ba/copy                                                                                                                 1/imm32           # copy 1 to EDX
   # syscall = write
-  b8                                                                                                                      4/imm32           # copy 4 to EAX
+  b8/copy                                                                                                                 4/imm32           # copy 4 to EAX
   # call
-  cd                                                                                                                      0x80/imm8         # int 80h
+  cd/syscall                                                                                                              0x80/imm8         # int 80h
 
   ## exit(EBX)
-  b8                                                                                                                      1/imm32           # copy 1 to EAX
-  cd                                                                                                                      0x80/imm8         # int 80h
+  b8/copy                                                                                                                 1/imm32           # copy 1 to EAX
+  cd/syscall                                                                                                              0x80/imm8         # int 80h
 
 # vim:ft=subx:nowrap
diff --git a/subx/ex6.subx b/subx/ex6.subx
index 68dcb8be..685076e7 100644
--- a/subx/ex6.subx
+++ b/subx/ex6.subx
@@ -12,20 +12,20 @@
 
   ## write(stdout, x, 1)
   # fd = 1 (stdout)
-  bb                                                                                                                      1/imm32           # copy 1 to EBX
+  bb/copy                                                                                                                 1/imm32           # copy 1 to EBX
   # set location to write out
-  b9                                                                                                                      0x08049097/imm32  # copy to ECX
+  b9/copy                                                                                                                 0x08049097/imm32  # copy to ECX
   # set size
-  ba                                                                                                                      0x08049093/imm32  # copy to EDX
-  8b                              0/mod/indirect  2/rm32/edx                                  2/r32/edx                                     # copy *EDX to EDX
+  ba/copy                                                                                                                 0x08049093/imm32  # copy to EDX
+  8b/copy                         0/mod/indirect  2/rm32/edx                                  2/r32/edx                                     # copy *EDX to EDX
   # syscall = write
-  b8                                                                                                                      4/imm32           # copy 4 to EAX
+  b8/copy                                                                                                                 4/imm32           # copy 4 to EAX
   # call
-  cd                                                                                                                      0x80/imm8         # int 80h
+  cd/syscall                                                                                                              0x80/imm8         # int 80h
 
   ## exit(EBX)
-  b8                                                                                                                      1/imm32           # copy 1 to EAX
-  cd                                                                                                                      0x80/imm8         # int 80h
+  b8/copy                                                                                                                 1/imm32           # copy 1 to EAX
+  cd/syscall                                                                                                              0x80/imm8         # int 80h
 
 == 0x08049093
 # size of string