about summary refs log tree commit diff stats
path: root/subx/examples
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-10-05 21:30:22 -0700
committerKartik Agaram <vc@akkartik.com>2018-10-05 21:30:22 -0700
commit94ad882e828f83df4a4cc0deab1a10e9d5e54eec (patch)
treef51448732674fa8744e8517c4755255afc764b1f /subx/examples
parent03d50cc83c7c2bebb2b019667b80c1c51f4a8def (diff)
downloadmu-94ad882e828f83df4a4cc0deab1a10e9d5e54eec.tar.gz
4668
Diffstat (limited to 'subx/examples')
-rw-r--r--subx/examples/ex1.subx4
-rw-r--r--subx/examples/ex10.subx10
-rw-r--r--subx/examples/ex11.subx18
-rw-r--r--subx/examples/ex12.subx6
-rw-r--r--subx/examples/ex2.subx4
-rw-r--r--subx/examples/ex3.subx6
-rw-r--r--subx/examples/ex4.subx18
-rw-r--r--subx/examples/ex5.subx14
-rw-r--r--subx/examples/ex6.subx8
-rw-r--r--subx/examples/ex7.subx58
-rw-r--r--subx/examples/ex8.subx4
-rw-r--r--subx/examples/ex9.subx2
12 files changed, 76 insertions, 76 deletions
diff --git a/subx/examples/ex1.subx b/subx/examples/ex1.subx
index 996ef955..444f872a 100644
--- a/subx/examples/ex1.subx
+++ b/subx/examples/ex1.subx
@@ -12,9 +12,9 @@
 # instruction                     effective address                                                   operand     displacement    immediate
 # 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
-  bb/copy                         .               .             .           .             .           .           .               2a/imm32          # copy 42 to EBX
+  bb/copy-to-EBX  2a/imm32
   # exit(EBX)
-  b8/copy                         .               .             .           .             .           .           .               1/imm32           # copy to EAX
+  b8/copy-to-EAX  1/imm32
   cd/syscall  0x80/imm8
 
 # vim:nowrap:textwidth=0
diff --git a/subx/examples/ex10.subx b/subx/examples/ex10.subx
index 43b0e1d1..b179369f 100644
--- a/subx/examples/ex10.subx
+++ b/subx/examples/ex10.subx
@@ -30,7 +30,7 @@
   # exit(EAX)
 $exit:
   89/copy                         3/mod/direct    3/rm32/EBX    .           .             .           0/r32/EAX   .               .                 # copy EAX to EBX
-  b8/copy                         .               .             .           .             .           .           .               1/imm32           # copy to EAX
+  b8/copy-to-EAX  1/imm32
   cd/syscall  0x80/imm8
 
 # compare two null-terminated ascii strings
@@ -42,9 +42,9 @@ argv-equal:  # (s1, s2) : null-terminated ascii strings -> EAX : boolean
   # while (true)
 $argv-equal:loop:
     # c1/EAX, c2/EBX = *s1, *s2
-  b8/copy  0/imm32  # clear EAX
+  b8/copy-to-EAX  0/imm32
   8a/copy                         0/mod/indirect  1/rm32/ECX    .           .             .           0/r32/EAX   .               .                 # copy byte at *ECX to lower byte of EAX
-  bb/copy  0/imm32  # clear EBX
+  bb/copy-to-EBX  0/imm32
   8a/copy                         0/mod/indirect  2/rm32/EDX    .           .             .           3/r32/EBX   .               .                 # copy byte at *EDX to lower byte of EBX
     # if (c1 == 0) break
   3d/compare-EAX  0/imm32
@@ -62,11 +62,11 @@ $argv-equal:break:
   81          7/subop/compare     3/mod/direct    3/rm32/EBX    .           .             .           .           .               0/imm32           # compare EBX
   75/jump-if-not-equal  $argv-equal:false/disp8
 $argv-equal:success:
-  b8/copy                         .               .             .           .             .           .           .               1/imm32           # copy to EAX
+  b8/copy-to-EAX  1/imm32
   c3/return
   # return false
 $argv-equal:false:
-  b8/copy                         .               .             .           .             .           .           .               0/imm32           # copy to EAX
+  b8/copy-to-EAX  0/imm32
   c3/return
 
 # vim:nowrap:textwidth=0
diff --git a/subx/examples/ex11.subx b/subx/examples/ex11.subx
index 2ffdaad3..038bd4c6 100644
--- a/subx/examples/ex11.subx
+++ b/subx/examples/ex11.subx
@@ -24,7 +24,7 @@
   e8/call  run-tests/disp32  # 'run-tests' is a function created automatically by SubX. It calls all functions that start with 'test-'.
   # exit(EAX)
   89/copy                         3/mod/direct    3/rm32/EBX    .           .             .           0/r32/EAX   .               .                 # copy EAX to EBX
-  b8/copy                         .               .             .           .             .           .           .               1/imm32           # copy to EAX
+  b8/copy-to-EAX  1/imm32
   cd/syscall  0x80/imm8
 
 # compare a null-terminated ascii string with a more idiomatic length-prefixed byte array
@@ -62,15 +62,15 @@ kernel-string-equal:  # s : null-terminated ascii string, benchmark : length-pre
   8b/copy                         1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           6/r32/ESI   0xc/disp8       .                 # copy *(EBP+12) to ESI
   81          0/subop/add         3/mod/direct    6/rm32/ESI    .           .             .           .           .               4/imm32           # add to ESI
   # initialize loop counter i into ECX
-  b9/copy                         .               .             .           .             .           .           .               0/imm32/exit      # copy to ECX
+  b9/copy-to-ECX  0/imm32/exit
   # while (i/ECX < n/EDX)
 $kernel-string-equal:loop:
   39/compare                      3/mod/direct    1/rm32/ECX    .           .             .           2/r32/EDX   .               .                 # compare ECX with EDX
   74/jump-if-equal  $kernel-string-equal:break/disp8
     # c1/EAX, c2/EBX = *s, *benchmark
-  b8/copy  0/imm32  # clear EAX
+  b8/copy-to-EAX  0/imm32
   8a/copy                         0/mod/indirect  7/rm32/EDI    .           .             .           0/r32/EAX   .               .                 # copy byte at *EDI to lower byte of EAX
-  bb/copy  0/imm32  # clear EBX
+  bb/copy-to-EBX  0/imm32
   8a/copy                         0/mod/indirect  6/rm32/ESI    .           .             .           3/r32/EBX   .               .                 # copy byte at *ESI to lower byte of EBX
     # if (c1 == 0) return false
   3d/compare-EAX  0/imm32
@@ -86,16 +86,16 @@ $kernel-string-equal:loop:
   eb/jump  $kernel-string-equal:loop/disp8
 $kernel-string-equal:break:
   # if (*s/EDI == 0) return true
-  b8/copy  0/imm32  # clear EAX
+  b8/copy-to-EAX  0/imm32
   8a/copy                         0/mod/indirect  7/rm32/EDI    .           .             .           0/r32/EAX   .               .                 # copy byte at *EDI to lower byte of EAX
   81          7/subop/compare     3/mod/direct    0/rm32/EAX    .           .             .           .           .               0/imm32           # compare EAX
   75/jump-if-not-equal  $kernel-string-equal:false/disp8
-  b8/copy                         .               .             .           .             .           .           .               1/imm32           # copy to EAX
+  b8/copy-to-EAX  1/imm32
 $kernel-string-equal:true:
   eb/jump  $kernel-string-equal:end/disp8
   # return false
 $kernel-string-equal:false:
-  b8/copy                         .               .             .           .             .           .           .               0/imm32           # copy to EAX
+  b8/copy-to-EAX  0/imm32
 
 $kernel-string-equal:end:
   # restore registers
@@ -314,7 +314,7 @@ write-stderr:  # s : (address array byte) -> <void>
   53/push-EBX
   # write(2/stderr, (data) s+4, (size) *s)
     # fd = 2 (stderr)
-  bb/copy                         .               .             .           .             .           .           .               2/imm32           # copy to EBX
+  bb/copy-to-EBX  2/imm32
     # x = s+4
   8b/copy                         1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none  .           1/r32/ECX   8/disp8         .                 # copy *(EBP+8) to ECX
   81          0/subop/add         3/mod/direct    1/rm32/ECX    .           .             .           .           .               4/imm32           # add to ECX
@@ -322,7 +322,7 @@ write-stderr:  # s : (address array byte) -> <void>
   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()
-  b8/copy                         .               .             .           .             .           .           .               4/imm32/write     # copy to EAX
+  b8/copy-to-EAX  4/imm32/write
   cd/syscall  0x80/imm8
   # restore registers
   5b/pop-to-EBX
diff --git a/subx/examples/ex12.subx b/subx/examples/ex12.subx
index 1db660ed..ba760707 100644
--- a/subx/examples/ex12.subx
+++ b/subx/examples/ex12.subx
@@ -12,8 +12,8 @@
 # 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)
-  bb/copy                         .               .             .           .             .           .           .               mmap-new-segment/imm32  # copy to EBX
-  b8/copy                         .               .             .           .             .           .           .               0x5a/imm32/mmap         # copy to EAX
+  bb/copy-to-EBX  mmap-new-segment/imm32
+  b8/copy-to-EAX  0x5a/imm32/mmap
   cd/syscall  0x80/imm8
 
   # store to *EAX
@@ -21,7 +21,7 @@
 
   # exit(EAX)
   89/copy                         3/mod/direct    3/rm32/EBX    .           .             .           0/r32/EAX   .               .                       # copy EAX to EBX
-  b8/copy                         .               .             .           .             .           .           .               1/imm32/exit            # copy to EAX
+  b8/copy-to-EAX  1/imm32/exit
   cd/syscall  0x80/imm8
 
 == data
diff --git a/subx/examples/ex2.subx b/subx/examples/ex2.subx
index 800674f1..3035b39f 100644
--- a/subx/examples/ex2.subx
+++ b/subx/examples/ex2.subx
@@ -11,10 +11,10 @@
 # instruction                     effective address                                                   operand     displacement    immediate
 # 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
-  bb/copy                         .               .             .           .             .           .           .               1/imm32           # copy to EBX
+  bb/copy-to-EBX  1/imm32
   43/inc-EBX
   # exit(EBX)
-  b8/copy                         .               .             .           .             .           .           .               1/imm32           # copy to EAX
+  b8/copy-to-EAX  1/imm32
   cd/syscall  0x80/imm8
 
 # vim:nowrap:textwidth=0
diff --git a/subx/examples/ex3.subx b/subx/examples/ex3.subx
index bbb6f1a7..8496b9c2 100644
--- a/subx/examples/ex3.subx
+++ b/subx/examples/ex3.subx
@@ -12,9 +12,9 @@
 # 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
   # result: EBX = 0
-  bb/copy                         .               .             .           .             .           .           .               0/imm32           # copy to EBX
+  bb/copy-to-EBX  0/imm32
   # counter: ECX = 1
-  b9/copy                         .               .             .           .             .           .           .               1/imm32           # copy to ECX
+  b9/copy-to-ECX  1/imm32
 
 $loop:
   # while (counter <= 10)
@@ -29,7 +29,7 @@ $loop:
 
 $exit:
   # exit(EBX)
-  b8/copy                         .               .             .           .             .           .           .               1/imm32           # copy to EAX
+  b8/copy-to-EAX  1/imm32
   cd/syscall  0x80/imm8
 
 # vim:nowrap:textwidth=0
diff --git a/subx/examples/ex4.subx b/subx/examples/ex4.subx
index 946a4810..3c4f8949 100644
--- a/subx/examples/ex4.subx
+++ b/subx/examples/ex4.subx
@@ -11,28 +11,28 @@
 
   # read(stdin, x, 1)
     # fd = 0 (stdin)
-  bb/copy                         .               .             .           .             .           .           .               0/imm32           # copy to EBX
+  bb/copy-to-EBX  0/imm32
     # initialize x (location to write result to)
-  b9/copy                         .               .             .           .             .           .           .               x/imm32           # copy to ECX
+  b9/copy-to-ECX  x/imm32
     # size = 1 character
-  ba/copy                         .               .             .           .             .           .           .               1/imm32           # copy to EDX
+  ba/copy-to-EDX  1/imm32
     # read(fd, x, size)
-  b8/copy                         .               .             .           .             .           .           .               3/imm32/read      # copy to EAX
+  b8/copy-to-EAX  3/imm32/read
   cd/syscall  0x80/imm8
 
   # write(stdout, x, 1)
     # fd = 1 (stdout)
-  bb/copy                         .               .             .           .             .           .           .               1/imm32           # copy to EBX
+  bb/copy-to-EBX  1/imm32
     # initialize x (location to read from)
-  b9/copy                         .               .             .           .             .           .           .               x/imm32           # copy to ECX
+  b9/copy-to-ECX  x/imm32
     # size = 1 character
-  ba/copy                         .               .             .           .             .           .           .               1/imm32           # copy to EDX
+  ba/copy-to-EDX  1/imm32
     # write(fd, x, size)
-  b8/copy                         .               .             .           .             .           .           .               4/imm32/write     # copy to EAX
+  b8/copy-to-EAX  4/imm32/write
   cd/syscall  0x80/imm8
 
   # exit(EBX)
-  b8/copy                         .               .             .           .             .           .           .               1/imm32/exit      # copy to EAX
+  b8/copy-to-EAX  1/imm32/exit
   cd/syscall  0x80/imm8
 
 == data
diff --git a/subx/examples/ex5.subx b/subx/examples/ex5.subx
index d773b366..4dad3043 100644
--- a/subx/examples/ex5.subx
+++ b/subx/examples/ex5.subx
@@ -15,28 +15,28 @@
 
   # read(stdin, x, 1)
     # fd = 0 (stdin)
-  bb/copy                         .               .             .           .             .           .           .               0/imm32           # copy to EBX
+  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                         .               .             .           .             .           .           .               1/imm32           # copy to EDX
+  ba/copy-to-EDX  1/imm32
     # read(fd, x, size)
-  b8/copy                         .               .             .           .             .           .           .               3/imm32/read      # copy to EAX
+  b8/copy-to-EAX  3/imm32/read
   cd/syscall  0x80/imm8
 
   # write(stdout, x, 1)
     # fd = 1 (stdout)
-  bb/copy                         .               .             .           .             .           .           .               1/imm32           # copy to EBX
+  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                         .               .             .           .             .           .           .               1/imm32           # copy to EDX
+  ba/copy-to-EDX  1/imm32
     # write(fd, x, size)
-  b8/copy                         .               .             .           .             .           .           .               4/imm32/write     # copy to EAX
+  b8/copy-to-EAX  4/imm32/write
   cd/syscall  0x80/imm8
 
   # exit(EBX)
-  b8/copy                         .               .             .           .             .           .           .               1/imm32/exit      # copy to EAX
+  b8/copy-to-EAX  1/imm32/exit
   cd/syscall  0x80/imm8
 
 # vim:nowrap:textwidth=0
diff --git a/subx/examples/ex6.subx b/subx/examples/ex6.subx
index 256aa47c..1c726c65 100644
--- a/subx/examples/ex6.subx
+++ b/subx/examples/ex6.subx
@@ -12,17 +12,17 @@
 
   # write(stdout, x, size)
     # fd = 1 (stdout)
-  bb/copy                         .               .             .           .             .           .           .               1/imm32           # copy to EBX
+  bb/copy-to-EBX  1/imm32
     # initialize x (location to write result to)
-  b9/copy                         .               .             .           .             .           .           .               x/imm32           # copy to ECX
+  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)
-  b8/copy                         .               .             .           .             .           .           .               4/imm32/write     # copy to EAX
+  b8/copy-to-EAX  4/imm32/write
   cd/syscall  0x80/imm8
 
   # exit(EBX)
-  b8/copy                         .               .             .           .             .           .           .               1/imm32/exit      # copy to EAX
+  b8/copy-to-EAX  1/imm32/exit
   cd/syscall  0x80/imm8
 
 == data
diff --git a/subx/examples/ex7.subx b/subx/examples/ex7.subx
index d5956ec9..841daf61 100644
--- a/subx/examples/ex7.subx
+++ b/subx/examples/ex7.subx
@@ -16,78 +16,78 @@
 # 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)
-  bb/copy                         .               .             .           .             .           .           .               filename/imm32          # copy to EBX
-  b9/copy                         .               .             .           .             .           .           .               0x180/imm32/fixed-perms # copy to ECX
-  b8/copy                         .               .             .           .             .           .           .               8/imm32/creat           # copy to EAX
+  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
-  bb/copy                         .               .             .           .             .           .           .               filename/imm32          # copy to EBX
-  b9/copy                         .               .             .           .             .           .           .               1/imm32/wronly          # copy to ECX
-  ba/copy                         .               .             .           .             .           .           .               0x180/imm32/fixed-perms # copy to EDX
-  b8/copy                         .               .             .           .             .           .           .               5/imm32/open            # copy to EAX
+  bb/copy-to-EBX  filename/imm32
+  b9/copy-to-ECX  1/imm32/wronly
+  ba/copy-to-EDX  0x180/imm32/fixed-perms
+  b8/copy-to-EAX  5/imm32/open
   cd/syscall  0x80/imm8
     # save stream
-  bb/copy                         .               .             .           .             .           .           .               stream/imm32            # copy to EBX
+  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)
     # load stream
-  bb/copy                         .               .             .           .             .           .           .               stream/imm32            # copy to EBX
+  bb/copy-to-EBX  stream/imm32
   8b/copy                         0/mod/indirect  3/rm32/EBX                                          3/r32/EBX                                           # copy *EBX to EBX
     #
-  b9/copy                         .               .             .           .             .           .           .               a/imm32                 # copy to ECX
-  ba/copy                         .               .             .           .             .           .           .               1/imm32/size            # copy to EDX
-  b8/copy                         .               .             .           .             .           .           .               4/imm32/write           # copy to EAX
+  b9/copy-to-ECX  a/imm32
+  ba/copy-to-EDX  1/imm32/size
+  b8/copy-to-EAX  4/imm32/write
   cd/syscall  0x80/imm8
 
   # close(stream)
     # load stream
-  bb/copy                         .               .             .           .             .           .           .               stream/imm32            # copy to EBX
+  bb/copy-to-EBX  stream/imm32
   8b/copy                         0/mod/indirect  3/rm32/EBX                                          3/r32/EBX                                           # copy *EBX to EBX
     #
-  b8/copy                         .               .             .           .             .           .           .               6/imm32/close           # copy to EAX
+  b8/copy-to-EAX  6/imm32/close
   cd/syscall  0x80/imm8
 
   # stream = open(filename, O_RDONLY, 0)
-  bb/copy                         .               .             .           .             .           .           .               filename/imm32          # copy to EBX
-  b9/copy                         .               .             .           .             .           .           .               0/imm32/rdonly          # copy to ECX
-  ba/copy                         .               .             .           .             .           .           .               0x180/imm32/fixed-perms # copy to EDX
-  b8/copy                         .               .             .           .             .           .           .               5/imm32/open            # copy to EAX
+  bb/copy-to-EBX  filename/imm32
+  b9/copy-to-ECX  0/imm32/rdonly
+  ba/copy-to-EDX  0x180/imm32/fixed-perms
+  b8/copy-to-EAX  5/imm32/open
   cd/syscall  0x80/imm8
     # save stream
-  bb/copy                         .               .             .           .             .           .           .               stream/imm32            # copy to EBX
+  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)
     # load stream
-  bb/copy                         .               .             .           .             .           .           .               stream/imm32            # copy to EBX
+  bb/copy-to-EBX  stream/imm32
   8b/copy                         0/mod/indirect  3/rm32/EBX                                          3/r32/EBX                                           # copy *EBX to EBX
     #
-  b9/copy                         .               .             .           .             .           .           .               b/imm32                 # copy to ECX
-  ba/copy                         .               .             .           .             .           .           .               1/imm32/size            # copy to EDX
-  b8/copy                         .               .             .           .             .           .           .               3/imm32/read            # copy to EAX
+  b9/copy-to-ECX  b/imm32
+  ba/copy-to-EDX  1/imm32/size
+  b8/copy-to-EAX  3/imm32/read
   cd/syscall  0x80/imm8
 
   # close(stream)
     # load stream
-  bb/copy                         .               .             .           .             .           .           .               stream/imm32            # copy to EBX
+  bb/copy-to-EBX  stream/imm32
   8b/copy                         0/mod/indirect  3/rm32/EBX                                          3/r32/EBX                                           # copy *EBX to EBX
     #
-  b8/copy                         .               .             .           .             .           .           .               6/imm32/close           # copy to EAX
+  b8/copy-to-EAX  6/imm32/close
   cd/syscall  0x80/imm8
 
   # unlink(filename)
-  bb/copy                         .               .             .           .             .           .           .               filename/imm32          # copy to EBX
-  b8/copy                         .               .             .           .             .           .           .               0xa/imm32/unlink        # copy to EAX
+  bb/copy-to-EBX  filename/imm32
+  b8/copy-to-EAX  0xa/imm32/unlink
   cd/syscall  0x80/imm8
 
   # exit(b)
     # load b
-  bb/copy                         .               .             .           .             .           .           .               b/imm32                 # copy to EBX
+  bb/copy-to-EBX  b/imm32
   8b/copy                         0/mod/indirect  3/rm32/EBX                                          3/r32/EBX                                           # copy *EBX to EBX
     #
-  b8/copy                         .               .             .           .             .           .           .               1/imm32/exit            # copy to EAX
+  b8/copy-to-EAX  1/imm32/exit
   cd/syscall  0x80/imm8
 
 == data
diff --git a/subx/examples/ex8.subx b/subx/examples/ex8.subx
index 2726eea9..adc3f413 100644
--- a/subx/examples/ex8.subx
+++ b/subx/examples/ex8.subx
@@ -30,14 +30,14 @@
 
   # exit(EAX)
   89/copy                         3/mod/direct    3/rm32/EBX    .           .             .           0/r32/EAX   .               .                 # copy EAX to EBX
-  b8/copy                         .               .             .           .             .           .           .               1/imm32/exit      # copy to EAX
+  b8/copy-to-EAX  1/imm32/exit
   cd/syscall  0x80/imm8
 
 ascii-length:  # (s)
   # initialize s (EDX)
   8b/copy                         1/mod/*+disp8   4/rm32/sib    4/base/ESP  4/index/none              2/r32/EDX   4/disp8                           # copy *(ESP+4) to EDX
   # var result = 0 (EAX)
-  b8/copy                         .               .             .           .             .           .           .               0/imm32           # copy to EAX
+  b8/copy-to-EAX  0/imm32
 $ascii-length-loop:
   # var c = *s (ECX)
   8a/copy                         0/mod/*         2/rm32/EDX    .           .             .           1/r32/ECX   .               .                 # copy byte at *EDX to lower byte of ECX
diff --git a/subx/examples/ex9.subx b/subx/examples/ex9.subx
index 7e4132b2..fa2877df 100644
--- a/subx/examples/ex9.subx
+++ b/subx/examples/ex9.subx
@@ -33,7 +33,7 @@
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
   # exit(EAX)
   89/copy                         3/mod/direct    3/rm32/EBX    .           .             .           0/r32/EAX   .               .                 # copy EAX to EBX
-  b8/copy                         .               .             .           .             .           .           .               1/imm32/exit      # copy to EAX
+  b8/copy-to-EAX  1/imm32/exit
   cd/syscall  0x80/imm8
 
 ascii-difference:  # (s1, s2) : null-terminated ascii strings