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/ex5.subx.html | 77 +++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 36 deletions(-) (limited to 'html/subx/examples/ex5.subx.html') diff --git a/html/subx/examples/ex5.subx.html b/html/subx/examples/ex5.subx.html index b40d911b..917a55d6 100644 --- a/html/subx/examples/ex5.subx.html +++ b/html/subx/examples/ex5.subx.html @@ -11,12 +11,17 @@ @@ -52,48 +57,48 @@ if ('onhashchange' in window) {
- 1 ## read a character from stdin, save it to a local on the stack, write it to stdout
+ 1 # Read a character from stdin, save it to a local on the stack, write it to stdout.
  2 #
  3 # To run (from the subx directory):
  4 #   $ subx translate examples/ex5.subx -o examples/ex5
  5 #   $ subx run examples/ex5
  6 
  7 == code
- 8 # instruction                     effective address                                                   operand     displacement    immediate
- 9 # op          subop               mod             rm32          base        index         scale       r32
-10 # 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
+ 8 #   instruction                     effective address                                                   register    displacement    immediate
+ 9 # . op          subop               mod             rm32          base        index         scale       r32
+10 # . 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 
 12 # main:
-13   # allocate x on the stack
-14   81          5/subop/subtract    3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # subtract from ESP
+13     # allocate x on the stack
+14     81          5/subop/subtract    3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # subtract from ESP
 15 
-16   # syscall(read, stdin, x, 1)
-17     # fd = 0 (stdin)
-18   bb/copy-to-EBX  0/imm32
-19     # initialize x (location to write result to)
-20   8d/copy-address                 1/mod/*+disp8   4/rm32/sib    4/base/ESP  4/index/none              1/r32/ECX   4/disp8         .                 # copy ESP+4 to ECX
-21     # size = 1 character
-22   ba/copy-to-EDX  1/imm32
-23     # syscall
-24   b8/copy-to-EAX  3/imm32/read
-25   cd/syscall  0x80/imm8
+16     # syscall(read, stdin, x, 1)
+17     # . fd = 0 (stdin)
+18     bb/copy-to-EBX  0/imm32
+19     # . data = x (location to write result to)
+20     8d/copy-address                 1/mod/*+disp8   4/rm32/sib    4/base/ESP  4/index/none              1/r32/ECX   4/disp8         .                 # copy ESP+4 to ECX
+21     # . size = 1 character
+22     ba/copy-to-EDX  1/imm32
+23     # . syscall
+24     b8/copy-to-EAX  3/imm32/read
+25     cd/syscall  0x80/imm8
 26 
-27   # syscall(write, stdout, x, 1)
-28     # fd = 1 (stdout)
-29   bb/copy-to-EBX  1/imm32
-30     # initialize x (location to read from)
-31   8d/copy-address                 1/mod/*+disp8   4/rm32/sib    4/base/ESP  4/index/none              1/r32/ECX   4/disp8         .                 # copy ESP+4 to ECX
-32     # size = 1 character
-33   ba/copy-to-EDX  1/imm32
-34     # syscall
-35   b8/copy-to-EAX  4/imm32/write
-36   cd/syscall  0x80/imm8
+27     # syscall(write, stdout, x, 1)
+28     # . fd = 1 (stdout)
+29     bb/copy-to-EBX  1/imm32
+30     # . data = x (location to read from)
+31     8d/copy-address                 1/mod/*+disp8   4/rm32/sib    4/base/ESP  4/index/none              1/r32/ECX   4/disp8         .                 # copy ESP+4 to ECX
+32     # . size = 1 character
+33     ba/copy-to-EDX  1/imm32
+34     # . syscall
+35     b8/copy-to-EAX  4/imm32/write
+36     cd/syscall  0x80/imm8
 37 
-38   # syscall(exit, EBX)
-39   b8/copy-to-EAX  1/imm32/exit
-40   cd/syscall  0x80/imm8
+38     # syscall(exit, EBX)
+39     b8/copy-to-EAX  1/imm32/exit
+40     cd/syscall  0x80/imm8
 41 
-42 # vim:nowrap:textwidth=0
+42 # . . vim:nowrap:textwidth=0
 
-- cgit 1.4.1-2-gfad0