about summary refs log tree commit diff stats
path: root/subx/examples
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-10-14 12:53:50 -0700
committerKartik Agaram <vc@akkartik.com>2018-10-14 12:53:50 -0700
commita9a5718d086d9df52b84b96a6ab4ee751dc26a5e (patch)
treeae28bcf9243aa220e529a1ffd8e7f67bd03041c8 /subx/examples
parent0e0a90420e2e0b3a86b2fcaad08938b2feba6274 (diff)
downloadmu-a9a5718d086d9df52b84b96a6ab4ee751dc26a5e.tar.gz
4698
Diffstat (limited to 'subx/examples')
-rw-r--r--subx/examples/ex11.subx6
-rw-r--r--subx/examples/ex12.subx4
-rw-r--r--subx/examples/ex4.subx10
-rw-r--r--subx/examples/ex5.subx10
-rw-r--r--subx/examples/ex6.subx6
-rw-r--r--subx/examples/ex7.subx18
6 files changed, 27 insertions, 27 deletions
diff --git a/subx/examples/ex11.subx b/subx/examples/ex11.subx
index 038bd4c6..cd8cdf4d 100644
--- a/subx/examples/ex11.subx
+++ b/subx/examples/ex11.subx
@@ -22,7 +22,7 @@
 
 # main:
   e8/call  run-tests/disp32  # 'run-tests' is a function created automatically by SubX. It calls all functions that start with 'test-'.
-  # exit(EAX)
+  # syscall(exit, EAX)
   89/copy                         3/mod/direct    3/rm32/EBX    .           .             .           0/r32/EAX   .               .                 # copy EAX to EBX
   b8/copy-to-EAX  1/imm32
   cd/syscall  0x80/imm8
@@ -312,7 +312,7 @@ write-stderr:  # s : (address array byte) -> <void>
   51/push-ECX
   52/push-EDX
   53/push-EBX
-  # write(2/stderr, (data) s+4, (size) *s)
+  # syscall(write, 2/stderr, (data) s+4, (size) *s)
     # fd = 2 (stderr)
   bb/copy-to-EBX  2/imm32
     # x = s+4
@@ -321,7 +321,7 @@ write-stderr:  # s : (address array byte) -> <void>
     # 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()
+    # syscall
   b8/copy-to-EAX  4/imm32/write
   cd/syscall  0x80/imm8
   # restore registers
diff --git a/subx/examples/ex12.subx b/subx/examples/ex12.subx
index ba760707..b35c8c95 100644
--- a/subx/examples/ex12.subx
+++ b/subx/examples/ex12.subx
@@ -11,7 +11,7 @@
 # op          subop               mod             rm32          base        index         scale       r32
 # 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
 
-  # mmap(0x1000)
+  # syscall(mmap, 0x1000)
   bb/copy-to-EBX  mmap-new-segment/imm32
   b8/copy-to-EAX  0x5a/imm32/mmap
   cd/syscall  0x80/imm8
@@ -19,7 +19,7 @@
   # store to *EAX
   c7/copy                         0/mod/direct    0/rm32/EAX    .           .             .           .           .               0x34/imm32              # copy to *EAX
 
-  # exit(EAX)
+  # syscall(exit, EAX)
   89/copy                         3/mod/direct    3/rm32/EBX    .           .             .           0/r32/EAX   .               .                       # copy EAX to EBX
   b8/copy-to-EAX  1/imm32/exit
   cd/syscall  0x80/imm8
diff --git a/subx/examples/ex4.subx b/subx/examples/ex4.subx
index 9e062cb2..6a9236eb 100644
--- a/subx/examples/ex4.subx
+++ b/subx/examples/ex4.subx
@@ -5,29 +5,29 @@
 #   $ subx run examples/ex4
 
 == code
-# read(stdin, x, 1)
+# syscall(read, stdin, x, 1)
   # fd = 0 (stdin)
 bb/copy-to-EBX  0/imm32
   # initialize x (location to write result to)
 b9/copy-to-ECX  x/imm32
   # size = 1 character
 ba/copy-to-EDX  1/imm32
-  # read(fd, x, size)
+  # syscall
 b8/copy-to-EAX  3/imm32/read
 cd/syscall  0x80/imm8
 
-# write(stdout, x, 1)
+# syscall(write, stdout, x, 1)
   # fd = 1 (stdout)
 bb/copy-to-EBX  1/imm32
   # initialize x (location to read from)
 b9/copy-to-ECX  x/imm32
   # size = 1 character
 ba/copy-to-EDX  1/imm32
-  # write(fd, x, size)
+  # syscall
 b8/copy-to-EAX  4/imm32/write
 cd/syscall  0x80/imm8
 
-# exit(EBX)
+# syscall(exit, EBX)
 b8/copy-to-EAX  1/imm32/exit
 cd/syscall  0x80/imm8
 
diff --git a/subx/examples/ex5.subx b/subx/examples/ex5.subx
index 4dad3043..cdc009bf 100644
--- a/subx/examples/ex5.subx
+++ b/subx/examples/ex5.subx
@@ -13,29 +13,29 @@
   # allocate x on the stack
   81          5/subop/subtract    3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # subtract from ESP
 
-  # read(stdin, x, 1)
+  # syscall(read, stdin, x, 1)
     # fd = 0 (stdin)
   bb/copy-to-EBX  0/imm32
     # initialize x (location to write result to)
   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
     # size = 1 character
   ba/copy-to-EDX  1/imm32
-    # read(fd, x, size)
+    # syscall
   b8/copy-to-EAX  3/imm32/read
   cd/syscall  0x80/imm8
 
-  # write(stdout, x, 1)
+  # syscall(write, stdout, x, 1)
     # fd = 1 (stdout)
   bb/copy-to-EBX  1/imm32
     # initialize x (location to read from)
   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
     # size = 1 character
   ba/copy-to-EDX  1/imm32
-    # write(fd, x, size)
+    # syscall
   b8/copy-to-EAX  4/imm32/write
   cd/syscall  0x80/imm8
 
-  # exit(EBX)
+  # syscall(exit, EBX)
   b8/copy-to-EAX  1/imm32/exit
   cd/syscall  0x80/imm8
 
diff --git a/subx/examples/ex6.subx b/subx/examples/ex6.subx
index 1c726c65..2b8aa212 100644
--- a/subx/examples/ex6.subx
+++ b/subx/examples/ex6.subx
@@ -10,18 +10,18 @@
 # op          subop               mod             rm32          base        index         scale       r32
 # 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
 
-  # write(stdout, x, size)
+  # syscall(write, stdout, x, size)
     # fd = 1 (stdout)
   bb/copy-to-EBX  1/imm32
     # initialize x (location to write result to)
   b9/copy-to-ECX  x/imm32
     # initialize size
   8b/copy                         0/mod/indirect  5/rm32/.disp32            .             .           2/r32/EDX   size/disp32     .                 # copy *size to EDX
-    # write(fd, x, size)
+    # syscall
   b8/copy-to-EAX  4/imm32/write
   cd/syscall  0x80/imm8
 
-  # exit(EBX)
+  # syscall(exit, EBX)
   b8/copy-to-EAX  1/imm32/exit
   cd/syscall  0x80/imm8
 
diff --git a/subx/examples/ex7.subx b/subx/examples/ex7.subx
index 615f5d21..2cf65ab3 100644
--- a/subx/examples/ex7.subx
+++ b/subx/examples/ex7.subx
@@ -15,13 +15,13 @@
 # op          subop               mod             rm32          base        index         scale       r32
 # 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
 
-  # creat(filename)
+  # syscall(creat, filename)
   bb/copy-to-EBX  filename/imm32
   b9/copy-to-ECX  0x180/imm32/fixed-perms
   b8/copy-to-EAX  8/imm32/creat
   cd/syscall  0x80/imm8
 
-  # stream = open(filename, O_WRONLY, 0)  # we can't use 'fd' because it looks like a hex byte
+  # stream = syscall(open, filename, O_WRONLY, 0)  # we can't use 'fd' because it looks like a hex byte
   bb/copy-to-EBX  filename/imm32
   b9/copy-to-ECX  1/imm32/wronly
   ba/copy-to-EDX  0x180/imm32/fixed-perms
@@ -31,7 +31,7 @@
   bb/copy-to-EBX  stream/imm32
   89/copy                         0/mod/indirect  3/rm32/EBX    .           .             .           0/r32/EAX   .               .                       # copy EAX to *EBX
 
-  # write(stream, "a", 1)
+  # syscall(write, stream, "a", 1)
     # load stream
   bb/copy-to-EBX  stream/imm32
   8b/copy                         0/mod/indirect  3/rm32/EBX    .           .             .           3/r32/EBX   .               .                       # copy *EBX to EBX
@@ -41,7 +41,7 @@
   b8/copy-to-EAX  4/imm32/write
   cd/syscall  0x80/imm8
 
-  # close(stream)
+  # syscall(close, stream)
     # load stream
   bb/copy-to-EBX  stream/imm32
   8b/copy                         0/mod/indirect  3/rm32/EBX    .           .             .           3/r32/EBX   .               .                       # copy *EBX to EBX
@@ -49,7 +49,7 @@
   b8/copy-to-EAX  6/imm32/close
   cd/syscall  0x80/imm8
 
-  # stream = open(filename, O_RDONLY, 0)
+  # stream = syscall(open, filename, O_RDONLY, 0)
   bb/copy-to-EBX  filename/imm32
   b9/copy-to-ECX  0/imm32/rdonly
   ba/copy-to-EDX  0x180/imm32/fixed-perms
@@ -59,7 +59,7 @@
   bb/copy-to-EBX  stream/imm32
   89/copy                         0/mod/indirect  3/rm32/EBX    .           .             .           0/r32/EAX   .               .                       # copy EAX to *EBX
 
-  # read(stream, b, 1)
+  # syscall(read, stream, b, 1)
     # load stream
   bb/copy-to-EBX  stream/imm32
   8b/copy                         0/mod/indirect  3/rm32/EBX    .           .             .           3/r32/EBX   .               .                       # copy *EBX to EBX
@@ -69,7 +69,7 @@
   b8/copy-to-EAX  3/imm32/read
   cd/syscall  0x80/imm8
 
-  # close(stream)
+  # syscall(close, stream)
     # load stream
   bb/copy-to-EBX  stream/imm32
   8b/copy                         0/mod/indirect  3/rm32/EBX    .           .             .           3/r32/EBX   .               .                       # copy *EBX to EBX
@@ -77,12 +77,12 @@
   b8/copy-to-EAX  6/imm32/close
   cd/syscall  0x80/imm8
 
-  # unlink(filename)
+  # syscall(unlink, filename)
   bb/copy-to-EBX  filename/imm32
   b8/copy-to-EAX  0xa/imm32/unlink
   cd/syscall  0x80/imm8
 
-  # exit(b)
+  # syscall(exit, b)
     # load b
   bb/copy-to-EBX  b/imm32
   8b/copy                         0/mod/indirect  3/rm32/EBX    .           .             .           3/r32/EBX   .               .                       # copy *EBX to EBX