about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
Diffstat (limited to 'subx')
-rw-r--r--subx/apps/factorial.subx38
-rw-r--r--subx/examples/ex10.subx4
-rw-r--r--subx/examples/ex5.subx2
-rw-r--r--subx/examples/ex8.subx6
-rw-r--r--subx/examples/ex9.subx4
5 files changed, 27 insertions, 27 deletions
diff --git a/subx/apps/factorial.subx b/subx/apps/factorial.subx
index dc89f7c0..c8de4790 100644
--- a/subx/apps/factorial.subx
+++ b/subx/apps/factorial.subx
@@ -41,9 +41,9 @@
   # else EAX <- factorial(5)
 $run_main:
     # push arg
-  68/push                         .               .             .           .             .           .           .               5/imm32           # push 5
+  68/push  5/imm32
     # EAX <- call
-  e8/call                         .               .             .           .             .           .           factorial/disp32
+  e8/call  factorial/disp32
     # discard arg
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add 4 to ESP
 $main_exit:
@@ -58,15 +58,15 @@ factorial:
   b8/copy                         .               .             .           .             .           .           .               1/imm32           # copy 1 to EAX
   # if (n <= 1) jump exit
   81          7/subop/compare     1/mod/*+disp8   4/rm32/sib    4/base/ESP  4/index/none  .           .           4/disp8         1/imm32           # compare *(ESP+4) with 1
-  7e/jump-if-<=                   .               .             .           .             .           .           $factorial:exit/disp8             # jump if <= to $factorial:exit
+  7e/jump-if-<=  $factorial:exit/disp8
   # EBX: n-1
   8b/copy                         1/mod/*+disp8   4/rm32/sib    4/base/ESP  4/index/none              3/r32/EBX   4/disp8         .                 # copy *(ESP+4) to EBX
   81          5/subop/subtract    3/mod/direct    3/rm32/EBX    .           .             .           .           .               1/imm32           # subtract 1 from EBX
   # prepare call
-  55/push                         .               .             .           .             .           .           .               .                 # push EBP
+  55/push-EBP
   89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
   # EAX: factorial(n-1)
-  53/push                         .               .             .           .             .           .           .               .                 # push EBX
+  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
@@ -84,9 +84,9 @@ $factorial:exit:
 test_factorial:
   # factorial(5)
     # push arg
-  68/push                         .               .             .           .             .           .           .               5/imm32           # push 5
+  68/push  5/imm32
     # call
-  e8/call                         .               .             .           .             .           .           factorial/disp32
+  e8/call  factorial/disp32
     # discard arg
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add 4 to ESP
   # if EAX == 120
@@ -94,9 +94,9 @@ test_factorial:
   75/jump-if-unequal              .               .             .           .             .           .           $test_factorial:else/disp8
     # print('.')
       # push args
-  68/push                         .               .             .           .             .           .           .               Test_passed/imm32
+  68/push  Test_passed/imm32
       # call
-  e8/call                         .               .             .           .             .           .           write_stderr/disp32
+  e8/call  write_stderr/disp32
       # discard arg
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add 4 to ESP
     # return
@@ -105,9 +105,9 @@ test_factorial:
 $test_factorial:else:
     # print('F')
       # push args
-  68/push                         .               .             .           .             .           .           .               Test_failed/imm32
+  68/push  Test_failed/imm32
       # call
-  e8/call                         .               .             .           .             .           .           write_stderr/disp32
+  e8/call  write_stderr/disp32
       # discard arg
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add 4 to ESP
   # end
@@ -152,10 +152,10 @@ $argv_fail:
 
 write_stderr:  # s : (address array byte) -> <void>
   # save registers
-  50/push                         .               .             .           .             .           .           .               .                 # push EAX
-  51/push                         .               .             .           .             .           .           .               .                 # push ECX
-  52/push                         .               .             .           .             .           .           .               .                 # push EDX
-  53/push                         .               .             .           .             .           .           .               .                 # push EBX
+  50/push-EAX
+  51/push-ECX
+  52/push-EDX
+  53/push-EBX
   # write(2/stderr, (data) s+4, (size) *s)
     # fd = 2 (stderr)
   bb/copy                         .               .             .           .             .           .           .               2/imm32           # copy 2 to EBX
@@ -169,10 +169,10 @@ write_stderr:  # s : (address array byte) -> <void>
   b8/copy                         .               .             .           .             .           .           .               4/imm32/write     # copy 1 to EAX
   cd/syscall  0x80/imm8
   # restore registers
-  5b/pop                          .               .             .           .             .           .           .               .                 # pop EBX
-  5a/pop                          .               .             .           .             .           .           .               .                 # pop EDX
-  59/pop                          .               .             .           .             .           .           .               .                 # pop ECX
-  58/pop                          .               .             .           .             .           .           .               .                 # pop EAX
+  5b/pop-EBX
+  5a/pop-EDX
+  59/pop-ECX
+  58/pop-EAX
   # end
   c3/return
 
diff --git a/subx/examples/ex10.subx b/subx/examples/ex10.subx
index 97dd42eb..81f4f2ae 100644
--- a/subx/examples/ex10.subx
+++ b/subx/examples/ex10.subx
@@ -24,8 +24,8 @@
   8b/copy                         1/mod/*+disp8   4/rm32/sib    4/base/ESP  4/index/none  .           3/r32/EBX   0xc/disp8       .                 # copy *(ESP+12) to EBX
   # call argv_equal(s1, s2)
     # push args
-  50/push                         .               .             .           .             .           .           .               .                 # push EAX
-  53/push                         .               .             .           .             .           .           .               .                 # push EBX
+  50/push-EAX
+  53/push-EBX
     # call
   e8/call argv_equal/disp32
   # exit(EAX)
diff --git a/subx/examples/ex5.subx b/subx/examples/ex5.subx
index 4502a4bd..faecdcfb 100644
--- a/subx/examples/ex5.subx
+++ b/subx/examples/ex5.subx
@@ -11,7 +11,7 @@
 
 # main:
   # prolog
-  55/push                         .               .             .           .             .           .           .               .                 # push EBP
+  55/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
diff --git a/subx/examples/ex8.subx b/subx/examples/ex8.subx
index 8233c4f3..8d9efcd7 100644
--- a/subx/examples/ex8.subx
+++ b/subx/examples/ex8.subx
@@ -22,17 +22,17 @@
   8b/copy                         1/mod/*+disp8   4/rm32/sib    4/base/ESP  4/index/none              3/r32/EBX   8/disp8         .                       # copy *(ESP+8) to EBX
   # call ascii_length(EBX)
     # prepare call
-  55/push                         .               .             .           .             .           .           .               .                       # push EBP
+  55/push-EBP
   89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                       # copy ESP to EBP
     # push args
-  53/push                         .               .             .           .             .           .           .               .                       # push EBX
+  53/push-EBX
     # call
   e8/call  ascii_length/disp32
     # discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32                 # add 4 to ESP
     # clean up after call
   89/copy                         3/mod/direct    4/rm32/ESP    .           .             .           5/r32/EBP   .               .                       # copy EBP to ESP
-  5d/pop                          .               .             .           .             .           .           .               .                       # pop to EBP
+  5d/pop-to-EBP
 
   # exit(EAX)
   89/copy                         3/mod/direct    3/rm32/EBX    .           .             .           0/r32/EAX   .               .                       # copy EAX to EBX
diff --git a/subx/examples/ex9.subx b/subx/examples/ex9.subx
index da98b03b..dde9fa37 100644
--- a/subx/examples/ex9.subx
+++ b/subx/examples/ex9.subx
@@ -26,8 +26,8 @@
   8b/copy                         1/mod/*+disp8   4/rm32/sib    4/base/ESP  4/index/none              3/r32/EBX   0xc/disp8       .                 # copy *(ESP+12) to EBX
   # call string_equal(s1, s2)
     # push args
-  50/push                         .               .             .           .             .           .           .               .                 # push EAX
-  53/push                         .               .             .           .             .           .           .               .                 # push EBX
+  50/push-EAX
+  53/push-EBX
     # call
   e8/call  ascii_difference/disp32
     # discard args