From 14a380525ed2df295463b1906b718cb26871df3b Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Fri, 30 Nov 2018 16:54:01 -0800 Subject: 4809 - subx: html with 5 colors for comments --- html/subx/examples/ex3.subx.html | 59 ++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 27 deletions(-) (limited to 'html/subx/examples/ex3.subx.html') diff --git a/html/subx/examples/ex3.subx.html b/html/subx/examples/ex3.subx.html index f60a8248..fb098a31 100644 --- a/html/subx/examples/ex3.subx.html +++ b/html/subx/examples/ex3.subx.html @@ -11,12 +11,17 @@ @@ -52,7 +57,7 @@ if ('onhashchange' in window) {
- 1 ## add the first 10 numbers, and return the result in the exit code
+ 1 # Add the first 10 numbers, and return the result in the exit code.
  2 #
  3 # To run (from the subx directory):
  4 #   $ subx translate examples/ex3.subx -o examples/ex3
@@ -62,32 +67,32 @@ if ('onhashchange' in window) {
  8 #   55
  9 
 10 == code
-11 # instruction                     effective address                                                   operand     displacement    immediate
-12 # op          subop               mod             rm32          base        index         scale       r32
-13 # 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
+11 #   instruction                     effective address                                                   register    displacement    immediate
+12 # . op          subop               mod             rm32          base        index         scale       r32
+13 # . 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
 14 
-15   # result: EBX = 0
-16   bb/copy-to-EBX  0/imm32
-17   # counter: ECX = 1
-18   b9/copy-to-ECX  1/imm32
+15     # result: EBX = 0
+16     bb/copy-to-EBX  0/imm32
+17     # counter: ECX = 1
+18     b9/copy-to-ECX  1/imm32
 19 
 20 $loop:
-21   # while (counter <= 10)
-22   81          7/subop/compare     3/mod/direct    1/rm32/ECX    .           .             .           .           .               0xa/imm32         # compare ECX
-23   7f/jump-if-greater  $exit/disp8
-24   # result += counter
-25   01/add                          3/mod/direct    3/rm32/EBX    .           .             .           1/r32/ECX   .               .                 # add ECX to EBX
-26   # ++counter
-27   41/inc-ECX
-28   # loop
-29   eb/jump  $loop/disp8
+21     # while (counter <= 10)
+22     81          7/subop/compare     3/mod/direct    1/rm32/ECX    .           .             .           .           .               0xa/imm32         # compare ECX
+23     7f/jump-if-greater  $exit/disp8
+24     # result += counter
+25     01/add                          3/mod/direct    3/rm32/EBX    .           .             .           1/r32/ECX   .               .                 # add ECX to EBX
+26     # ++counter
+27     41/inc-ECX
+28     # loop
+29     eb/jump  $loop/disp8
 30 
 31 $exit:
-32   # exit(EBX)
-33   b8/copy-to-EAX  1/imm32
-34   cd/syscall  0x80/imm8
+32     # syscall(exit, EBX)
+33     b8/copy-to-EAX  1/imm32
+34     cd/syscall  0x80/imm8
 35 
-36 # vim:nowrap:textwidth=0
+36 # . . vim:nowrap:textwidth=0
 
-- cgit 1.4.1-2-gfad0