about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-11-23 16:19:06 -0800
committerKartik Agaram <vc@akkartik.com>2018-11-23 16:19:06 -0800
commite345224833ae2f2251b2c80a11cc6fc4f05d4bc4 (patch)
treef5c37d0181b89247d3d8282dbc379160a062990a /subx
parentd373c008b3ef54845175db7b8e8319d750a5b7bf (diff)
downloadmu-e345224833ae2f2251b2c80a11cc6fc4f05d4bc4.tar.gz
4764
Diffstat (limited to 'subx')
-rwxr-xr-xsubx/apps/crenshaw2-1bin5716 -> 6313 bytes
-rw-r--r--subx/apps/crenshaw2-1.subx226
2 files changed, 221 insertions, 5 deletions
diff --git a/subx/apps/crenshaw2-1 b/subx/apps/crenshaw2-1
index 2f8be36a..b3128d1d 100755
--- a/subx/apps/crenshaw2-1
+++ b/subx/apps/crenshaw2-1
Binary files differdiff --git a/subx/apps/crenshaw2-1.subx b/subx/apps/crenshaw2-1.subx
index 817543e4..6857c6a4 100644
--- a/subx/apps/crenshaw2-1.subx
+++ b/subx/apps/crenshaw2-1.subx
@@ -47,7 +47,7 @@
   75/jump-if-not-equal  $run-main/disp8
   # then return run-tests()
   e8/call  run-tests/disp32
-  8b/copy                         0/mod/indirect  5/rm32/.disp32            .             .           1/r32/EBX   Num-test-failures/disp32          # copy *Num-test-failures to EBX
+  8b/copy                         0/mod/indirect  5/rm32/.disp32            .             .           3/r32/EBX   Num-test-failures/disp32          # copy *Num-test-failures to EBX
   eb/jump  $main:end/disp8
 $run-main:
   # allocate space for an exit-descriptor
@@ -212,7 +212,7 @@ test-get-num-reads-single-digit:
   # This test uses exit-descriptors. Use EBP for setting up local variables.
   55/push-EBP
   89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
-  ## 1. initialize 'in'
+  ## clear all streams
   # clear-stream(_test-stream)
     # push args
   68/push  _test-stream/imm32
@@ -229,6 +229,21 @@ test-get-num-reads-single-digit:
   e8/call  clear-stream/disp32
     # discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+  # clear-stream(_test-output-stream)
+    # push args
+  68/push  _test-output-stream/imm32
+    # call
+  e8/call  clear-stream/disp32
+    # discard args
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+  # clear-stream(_test-error-stream)
+    # push args
+  68/push  _test-error-stream/imm32
+    # call
+  e8/call  clear-stream/disp32
+    # discard args
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+  ## initialize 'in'
   # write(_test-stream, "3")
     # push args
   68/push  "3"/imm32
@@ -237,7 +252,7 @@ test-get-num-reads-single-digit:
   e8/call  write/disp32
     # discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
-  ## 2. initialize exit-descriptor 'ed'
+  ## initialize exit-descriptor 'ed'
   # allocate on stack
   # var ed/EAX : (address exit-descriptor)
   81          5/subop/subtract    3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # subtract from ESP
@@ -290,7 +305,7 @@ test-get-num-aborts-on-non-digit-in-Look:
   # This test uses exit-descriptors. Use EBP for setting up local variables.
   55/push-EBP
   89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
-  ## 1. initialize 'in'
+  ## clear all streams
   # clear-stream(_test-stream)
     # push args
   68/push  _test-stream/imm32
@@ -307,6 +322,21 @@ test-get-num-aborts-on-non-digit-in-Look:
   e8/call  clear-stream/disp32
     # discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+  # clear-stream(_test-output-stream)
+    # push args
+  68/push  _test-output-stream/imm32
+    # call
+  e8/call  clear-stream/disp32
+    # discard args
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+  # clear-stream(_test-error-stream)
+    # push args
+  68/push  _test-error-stream/imm32
+    # call
+  e8/call  clear-stream/disp32
+    # discard args
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+  ## initialize 'in'
   # write(_test-stream, "3")
     # push args
   68/push  "3"/imm32
@@ -315,7 +345,7 @@ test-get-num-aborts-on-non-digit-in-Look:
   e8/call  write/disp32
     # discard args
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
-  ## 2. initialize exit-descriptor 'ed'
+  ## initialize exit-descriptor 'ed'
   # allocate on stack
   # var ed/EAX : (address exit-descriptor)
   81          5/subop/subtract    3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # subtract from ESP
@@ -357,6 +387,192 @@ test-get-num-aborts-on-non-digit-in-Look:
   5d/pop-to-EBP
   c3/return
 
+test-get-num-reads-multiple-digits:
+  ## check that get-num returns all initial digits until it encounters a non-digit
+  # This test uses exit-descriptors. Use EBP for setting up local variables.
+  55/push-EBP
+  89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
+  ## clear all streams
+  # clear-stream(_test-stream)
+    # push args
+  68/push  _test-stream/imm32
+    # call
+  e8/call  clear-stream/disp32
+    # discard args
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+  # clear-stream(_test-buffered-file+4)
+    # push args
+  b8/copy-to-EAX  _test-buffered-file/imm32
+  05/add-to-EAX  4/imm32
+  50/push-EAX
+    # call
+  e8/call  clear-stream/disp32
+    # discard args
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+  # clear-stream(_test-output-stream)
+    # push args
+  68/push  _test-output-stream/imm32
+    # call
+  e8/call  clear-stream/disp32
+    # discard args
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+  # clear-stream(_test-error-stream)
+    # push args
+  68/push  _test-error-stream/imm32
+    # call
+  e8/call  clear-stream/disp32
+    # discard args
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+  ## initialize 'in'
+  # write(_test-stream, "3456 x")
+    # push args
+  68/push  "3456"/imm32
+  68/push  _test-stream/imm32
+    # call
+  e8/call  write/disp32
+    # discard args
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+  ## initialize exit-descriptor 'ed'
+  # allocate on stack
+  # var ed/EAX : (address exit-descriptor)
+  81          5/subop/subtract    3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # subtract from ESP
+  8d/copy-address                 0/mod/indirect  4/rm32/sib    4/base/ESP  4/index/none  .           0/r32/EAX   .               .                 # copy ESP to EAX
+  # size the exit-descriptor for the call to get-num below
+  # tailor-exit-descriptor(ed, 16)
+    # push args
+  68/push  0x10/imm32/nbytes-of-args-for-get-num
+  50/push-EAX/ed
+    # call
+  e8/call  tailor-exit-descriptor/disp32
+    # discard args
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+  ## prime the pump
+  # get-char(_test-buffered-file)
+    # push args
+  68/push  _test-buffered-file/imm32
+    # call
+  e8/call get-char/disp32
+    # discard args
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+  ## get-num(in, out, err, ed)
+    # push args
+  50/push-EAX/ed
+  68/push  _test-error-stream/imm32
+  68/push  _test-output-stream/imm32
+  68/push  _test-buffered-file/imm32
+    # call
+  e8/call  get-num/disp32
+  ## registers except ESP may be clobbered at this point
+    # discard args
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0x10/imm32        # add to ESP
+  # check-ints-equal(*_test-output-stream.data, '3456')
+    # push args
+  68/push  "F - test-get-num-reads-multiple-digits"/imm32
+  68/push  0x36353433/imm32
+  b8/copy-to-EAX  _test-output-stream/imm32
+  ff          6/subop/push        1/mod/*+disp8   0/rm32/EAX    .           .             .           .           0xc/disp8       .                 # push *(EAX+12)
+    # call
+  e8/call  check-ints-equal/disp32
+    # discard args
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0xc/imm32         # add to ESP
+  # reclaim locals
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+  5d/pop-to-EBP
+  c3/return
+
+test-get-num-reads-multiple-digits-followed-by-nondigit:
+  ## check that get-num returns all initial digits until it encounters a non-digit
+  # This test uses exit-descriptors. Use EBP for setting up local variables.
+  55/push-EBP
+  89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
+  ## clear all streams
+  # clear-stream(_test-stream)
+    # push args
+  68/push  _test-stream/imm32
+    # call
+  e8/call  clear-stream/disp32
+    # discard args
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+  # clear-stream(_test-buffered-file+4)
+    # push args
+  b8/copy-to-EAX  _test-buffered-file/imm32
+  05/add-to-EAX  4/imm32
+  50/push-EAX
+    # call
+  e8/call  clear-stream/disp32
+    # discard args
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+  # clear-stream(_test-output-stream)
+    # push args
+  68/push  _test-output-stream/imm32
+    # call
+  e8/call  clear-stream/disp32
+    # discard args
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+  # clear-stream(_test-error-stream)
+    # push args
+  68/push  _test-error-stream/imm32
+    # call
+  e8/call  clear-stream/disp32
+    # discard args
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+  ## initialize 'in'
+  # write(_test-stream, "3456 x")
+    # push args
+  68/push  "3456 x"/imm32
+  68/push  _test-stream/imm32
+    # call
+  e8/call  write/disp32
+    # discard args
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+  ## initialize exit-descriptor 'ed'
+  # allocate on stack
+  # var ed/EAX : (address exit-descriptor)
+  81          5/subop/subtract    3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # subtract from ESP
+  8d/copy-address                 0/mod/indirect  4/rm32/sib    4/base/ESP  4/index/none  .           0/r32/EAX   .               .                 # copy ESP to EAX
+  # size the exit-descriptor for the call to get-num below
+  # tailor-exit-descriptor(ed, 16)
+    # push args
+  68/push  0x10/imm32/nbytes-of-args-for-get-num
+  50/push-EAX/ed
+    # call
+  e8/call  tailor-exit-descriptor/disp32
+    # discard args
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+  ## prime the pump
+  # get-char(_test-buffered-file)
+    # push args
+  68/push  _test-buffered-file/imm32
+    # call
+  e8/call get-char/disp32
+    # discard args
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+  ## get-num(in, out, err, ed)
+    # push args
+  50/push-EAX/ed
+  68/push  _test-error-stream/imm32
+  68/push  _test-output-stream/imm32
+  68/push  _test-buffered-file/imm32
+    # call
+  e8/call  get-num/disp32
+  ## registers except ESP may be clobbered at this point
+    # discard args
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0x10/imm32        # add to ESP
+  # check-ints-equal(*_test-output-stream.data, '3456')
+    # push args
+  68/push  "F - test-get-num-reads-multiple-digits-followed-by-nondigit"/imm32
+  68/push  0x36353433/imm32
+  b8/copy-to-EAX  _test-output-stream/imm32
+  ff          6/subop/push        1/mod/*+disp8   0/rm32/EAX    .           .             .           .           0xc/disp8       .                 # push *(EAX+12)
+    # call
+  e8/call  check-ints-equal/disp32
+    # discard args
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0xc/imm32         # add to ESP
+  # reclaim locals
+  81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+  5d/pop-to-EBP
+  c3/return
+
 ## helpers
 
 # write(f, "Error: "+s+" expected\n") then stop(ed, 1)