about summary refs log tree commit diff stats
path: root/subx/apps
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-10-01 15:35:56 -0700
committerKartik Agaram <vc@akkartik.com>2018-10-01 15:53:44 -0700
commitd25e51dc0fdd154644ff4ddeb15d2ea436ea943b (patch)
tree30f7e33c52634f4e3db42d76eb50cbb4f6aba1bc /subx/apps
parentf872f7c726c45b96ee5d3a899915fc3bde26f942 (diff)
downloadmu-d25e51dc0fdd154644ff4ddeb15d2ea436ea943b.tar.gz
4644
Diffstat (limited to 'subx/apps')
-rw-r--r--subx/apps/crenshaw2-1bin1322 -> 1360 bytes
-rw-r--r--subx/apps/crenshaw2-1.subx26
-rwxr-xr-xsubx/apps/factorialbin1320 -> 1358 bytes
-rw-r--r--subx/apps/factorial.subx22
4 files changed, 24 insertions, 24 deletions
diff --git a/subx/apps/crenshaw2-1 b/subx/apps/crenshaw2-1
index 266414fa..299e7870 100644
--- a/subx/apps/crenshaw2-1
+++ b/subx/apps/crenshaw2-1
Binary files differdiff --git a/subx/apps/crenshaw2-1.subx b/subx/apps/crenshaw2-1.subx
index c0bdc768..dec4023a 100644
--- a/subx/apps/crenshaw2-1.subx
+++ b/subx/apps/crenshaw2-1.subx
@@ -25,10 +25,10 @@
     # call
   e8/call  abort/disp32
     # discard arg
-  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add 4 to ESP
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
   # exit(0)
-  bb/copy                         .               .             .           .             .           .           .               0/imm32           # copy 0 to EBX
-  b8/copy                         .               .             .           .             .           .           .               1/imm32/exit      # copy 1 to EAX
+  bb/copy                         .               .             .           .             .           .           .               0/imm32           # copy to EBX
+  b8/copy                         .               .             .           .             .           .           .               1/imm32/exit      # copy to EAX
   cd/syscall  0x80/imm8
 
 ## helpers
@@ -42,10 +42,10 @@ abort:  # s : (address array byte) -> <void>
     # call
   e8/call  error/disp32
     # discard arg
-  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add 4 to ESP
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
   # exit(1)
-  bb/copy                         .               .             .           .             .           .           .               1/imm32           # copy 1 to EBX
-  b8/copy                         .               .             .           .             .           .           .               1/imm32/exit      # copy 1 to EAX
+  bb/copy                         .               .             .           .             .           .           .               1/imm32           # copy to EBX
+  b8/copy                         .               .             .           .             .           .           .               1/imm32/exit      # copy to EAX
   cd/syscall  0x80/imm8
 
 # print out "Error: #{s} expected\n" to stderr
@@ -56,28 +56,28 @@ error:  # s : (address array byte) -> <void>
     # call
   e8/call  write_stderr/disp32
     # discard arg
-  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add 4 to ESP
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
   # write_stderr(s)
     # push args
   ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    4/base/ESP  4/index/none  .           .           4/disp8         .                 # push *(ESP+4)
     # call
   e8/call  write_stderr/disp32
     # discard arg
-  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add 4 to ESP
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
   # write_stderr(" expected")
     # push args
   68/push  " expected"/imm32
     # call
   e8/call  write_stderr/disp32
     # discard arg
-  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add 4 to ESP
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
   # write_stderr("\n")
     # push args
   68/push  Newline/imm32
     # call
   e8/call  write_stderr/disp32
     # discard arg
-  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add 4 to ESP
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
   # end
   c3/return
 
@@ -92,15 +92,15 @@ write_stdout:  # s : (address array byte) -> <void>
   53/push-EBX
   # write(1/stdout, (data) s+4, (size) *s)
     # fd = 1 (stdout)
-  bb/copy                         .               .             .           .             .           .           .               1/imm32           # copy 1 to EBX
+  bb/copy                         .               .             .           .             .           .           .               1/imm32           # copy to EBX
     # x = s+4
   8b/copy                         1/mod/*+disp8   4/rm32/SIB    5/base/EBP  4/index/none  .           1/r32/ECX   8/disp8         .                 # copy *(EBP+8) to ECX
-  81          0/subop/add         3/mod/direct    1/rm32/ECX    .           .             .           .           .               4/imm32           # add 4 to ECX
+  81          0/subop/add         3/mod/direct    1/rm32/ECX    .           .             .           .           .               4/imm32           # add to ECX
     # size = *s
   8b/copy                         1/mod/*+disp8   4/rm32/SIB    5/base/EBP  4/index/none  .           2/r32/EDX   8/disp8         .                 # copy *(EBP+8) to EDX
   8b/copy                         0/mod/indirect  2/rm32/EDX    .           .             .           2/r32/EDX   .               .                 # copy *EDX to EDX
     # call write()
-  b8/copy                         .               .             .           .             .           .           .               4/imm32/write     # copy 1 to EAX
+  b8/copy                         .               .             .           .             .           .           .               4/imm32/write     # copy to EAX
   cd/syscall  0x80/imm8
   # restore registers
   5b/pop-to-EBX
diff --git a/subx/apps/factorial b/subx/apps/factorial
index 2686b934..d9596ee6 100755
--- a/subx/apps/factorial
+++ b/subx/apps/factorial
Binary files differdiff --git a/subx/apps/factorial.subx b/subx/apps/factorial.subx
index 9b014313..d223b692 100644
--- a/subx/apps/factorial.subx
+++ b/subx/apps/factorial.subx
@@ -23,7 +23,7 @@
   # prolog
   89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
   # if (argc > 1)
-  81          7/subop/compare     1/mod/*+disp8   4/rm32/SIB    5/base/EBP  4/index/none  .           .           0/disp8         1/imm32           # compare *EBP with 1
+  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
@@ -32,9 +32,9 @@
     # call
   e8/call  kernel_string_equal/disp32
     # discard args
-  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add 8 to ESP
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
     # check result
-  3d/compare                      .               .             .           .             .           .           .               1/imm32           # compare EAX with 1
+  3d/compare-EAX  1/imm32
   75/jump-if-not-equal  $run_main/disp8
   # then
   e8/call  run_tests/disp32
@@ -46,11 +46,11 @@ $run_main:
     # EAX <- call
   e8/call  factorial/disp32
     # discard arg
-  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add 4 to ESP
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
 $main_exit:
   # exit(EAX)
   89/copy                         3/mod/direct    3/rm32/EBX    .           .             .           0/r32/EAX   .               .                 # copy EAX to EBX
-  b8/copy                         .               .             .           .             .           .           .               1/imm32           # copy 1 to EAX
+  b8/copy                         .               .             .           .             .           .           .               1/imm32           # copy to EAX
   cd/syscall  0x80/imm8
 
 # factorial(n)
@@ -60,18 +60,18 @@ factorial:
   89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
   53/push-EBX
   # initialize EAX to 1 (base case)
-  b8/copy                         .               .             .           .             .           .           .               1/imm32           # copy 1 to EAX
+  b8/copy                         .               .             .           .             .           .           .               1/imm32           # copy to EAX
   # if (n <= 1) jump exit
-  81          7/subop/compare     1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           8/disp8         1/imm32           # compare *(EBP+8) with 1
+  81          7/subop/compare     1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           .           8/disp8         1/imm32           # compare *(EBP+8)
   7e/jump-if-<=  $factorial:exit/disp8
   # EBX: n-1
   8b/copy                         1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none              3/r32/EBX   8/disp8         .                 # copy *(EBP+8) to EBX
-  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 from EBX
   # EAX: factorial(n-1)
   53/push-EBX
   e8/call                         .               .             .           .             .           .           factorial/disp32
   # discard arg
-  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add 4 to ESP
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
   # return n * factorial(n-1)
   f7          4/subop/multiply    1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none                          8/disp8         .                 # multiply *(EBP+8) into EAX
   # TODO: check for overflow
@@ -89,7 +89,7 @@ test_factorial:
     # call
   e8/call  factorial/disp32
     # discard arg
-  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add 4 to ESP
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
   # check_ints_equal(EAX, 120, failure message)
     # push args
   68/push  "F - test_factorial"/imm32
@@ -98,7 +98,7 @@ test_factorial:
     # call
   e8/call  check_ints_equal/disp32
     # discard args
-  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0xc/imm32         # add 12 to ESP
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0xc/imm32         # add to ESP
   # end
   c3/return