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/ex12.subx.html | 77 +++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 36 deletions(-) (limited to 'html/subx/examples/ex12.subx.html') diff --git a/html/subx/examples/ex12.subx.html b/html/subx/examples/ex12.subx.html index daa343eb..92a98277 100644 --- a/html/subx/examples/ex12.subx.html +++ b/html/subx/examples/ex12.subx.html @@ -11,15 +11,20 @@ @@ -54,7 +59,7 @@ if ('onhashchange' in window) {
- 1 ## example showing mmap syscall
+ 1 # Example showing mmap syscall.
  2 # Create a new segment using mmap, save the address, write to it.
  3 #
  4 # To run (from the subx directory):
@@ -63,41 +68,41 @@ if ('onhashchange' in window) {
  7 # You shouldn't get a segmentation fault.
  8 
  9 == code
-10 # instruction                     effective address                                                   operand     displacement    immediate
-11 # op          subop               mod             rm32          base        index         scale       r32
-12 # 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
+10 #   instruction                     effective address                                                   register    displacement    immediate
+11 # . op          subop               mod             rm32          base        index         scale       r32
+12 # . 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
 13 
-14   # syscall(mmap, 0x1000)
-15   bb/copy-to-EBX  Mmap-new-segment/imm32
-16   b8/copy-to-EAX  0x5a/imm32/mmap
-17   cd/syscall  0x80/imm8
+14     # syscall(mmap, 0x1000)
+15     bb/copy-to-EBX  Mmap-new-segment/imm32
+16     b8/copy-to-EAX  0x5a/imm32/mmap
+17     cd/syscall  0x80/imm8
 18 
-19   # store to *EAX
-20   c7/copy                         0/mod/direct    0/rm32/EAX    .           .             .           .           .               0x34/imm32              # copy to *EAX
+19     # write to *EAX to check that we have access to the newly-allocated segment
+20     c7/copy                         0/mod/direct    0/rm32/EAX    .           .             .           .           .               0x34/imm32              # copy to *EAX
 21 
-22   # syscall(exit, EAX)
-23   89/copy                         3/mod/direct    3/rm32/EBX    .           .             .           0/r32/EAX   .               .                       # copy EAX to EBX
-24   b8/copy-to-EAX  1/imm32/exit
-25   cd/syscall  0x80/imm8
+22     # syscall(exit, EAX)
+23     89/copy                         3/mod/direct    3/rm32/EBX    .           .             .           0/r32/EAX   .               .                       # copy EAX to EBX
+24     b8/copy-to-EAX  1/imm32/exit
+25     cd/syscall  0x80/imm8
 26 
 27 == data
 28 
 29 # various constants used here were found in the Linux sources (search for file mman-common.h)
-30 Mmap-new-segment:  # type mmap_arg_struct
-31   # addr
-32   00 00 00 00  # null
-33   # len
-34   00 01 00 00  # 0x1000
-35   # protection flags
-36   03 00 00 00  # PROT_READ | PROT_WRITE
-37   # sharing flags
-38   22 00 00 00  # MAP_PRIVATE | MAP_ANONYMOUS
-39   # fd
-40   ff ff ff ff  # -1 since MAP_ANONYMOUS is specified
-41   # offset
-42   00 00 00 00  # 0 since MAP_ANONYMOUS is specified
+30 Mmap-new-segment:  # type mmap_arg_struct
+31     # addr
+32     00 00 00 00  # null
+33     # len
+34     00 01 00 00  # 0x1000
+35     # protection flags
+36     03 00 00 00  # PROT_READ | PROT_WRITE
+37     # sharing flags
+38     22 00 00 00  # MAP_PRIVATE | MAP_ANONYMOUS
+39     # fd
+40     ff ff ff ff  # -1 since MAP_ANONYMOUS is specified
+41     # offset
+42     00 00 00 00  # 0 since MAP_ANONYMOUS is specified
 43 
-44 # vim:nowrap:textwidth=0
+44 # . . vim:nowrap:textwidth=0
 
-- cgit 1.4.1-2-gfad0