Adjust starting point, update testing.

This commit is contained in:
Brad Nelson
2021-09-19 22:26:18 -07:00
parent 9d3c88e028
commit d3f2777a2c
5 changed files with 14 additions and 17 deletions

View File

@ -139,8 +139,11 @@ see_all_test: $(POSIX)/ueforth
also streams \
also ansi \
also termios \
also sockets \
also telnetd \
also httpd \
also web-interface \
also editor \
see-all bye | $< >/dev/null
# ---- GENERATED ----

View File

@ -20,7 +20,7 @@
internals definitions
( Leave some room for growth of starting system. )
$4000 constant growth-gap
$8000 constant growth-gap
here growth-gap + growth-gap 1- + growth-gap 1- invert and constant saving-base
: park-heap ( -- a ) saving-base ;
: park-forth ( -- a ) saving-base cell+ ;

View File

@ -12,6 +12,8 @@
\ See the License for the specific language governing permissions and
\ limitations under the License.
: fsqrt ( r -- r ) 1e 20 0 do fover fover f/ f+ 0.5e f* loop fnip ;
6 value precision
: set-precision ( n -- ) to precision ;
@ -23,25 +25,13 @@ forth definitions internals
: #fs ( r -- ) fdup f0< if fnegate #f+s [char] - hold else #f+s then ;
: f. ( r -- ) <# #fs #> type space ;
: fnip ( ra rb -- rb ) fswap fdrop ;
(
internals definitions
: 1/f' ( r -- r )
2.82352941176e fover 1.88235294118e f* f-
20 0 do fover fover f* 2e fswap f- f* loop fnip ;
$80000000 constant sign-mask
$7f800000 constant exp-mask
$3f000000 constant half-mask
$007fffff constant mantissa-mask
: fsplit ( r -- r f n )
fp@ l@ dup mantissa-mask and half-mask or fp@ l!
dup 0< swap exp-mask and 23 rshift 126 - ;
: fjoin ( r f n -- r )
127 + 23 lshift swap $80000000 and or
1e fp@ @ mantissa-mask and or fp@ ! f* ;
forth definitions internals
)
: 1/f ( r -- r ) fsplit negate 1/f' fjoin ;
: f/ ( r r -- r ) 1/f f* ;
: fsqrt ( r -- r ) 1e 20 0 do fover fover f/ f+ 0.5e f* loop fnip ;
forth
forth definitions

View File

@ -19,6 +19,7 @@
X("SF@", FAT, *++fp = *(float *) tos; DROP) \
X("SF!", FSTORE, *(float *) tos = *fp--; DROP) \
X("FDUP", FDUP, fp[1] = *fp; ++fp) \
X("FNIP", FNIP, fp[-1] = *fp; --fp) \
X("FDROP", FDROP, --fp) \
X("FOVER", FOVER, fp[1] = fp[-1]; ++fp) \
X("FSWAP", FSWAP, float ft = fp[-1]; fp[-1] = *fp; *fp = ft) \
@ -27,6 +28,8 @@
X("F+", FPLUS, fp[-1] += *fp; --fp) \
X("F-", FMINUS, fp[-1] -= *fp; --fp) \
X("F*", FSTAR, fp[-1] *= *fp; --fp) \
X("F/", FSLASH, fp[-1] /= *fp; --fp) \
X("1/F", FINVERSE, *fp = 1.0 / *fp) \
X("S>F", STOF, *++fp = (float) tos; DROP) \
X("F>S", FTOS, DUP; tos = (cell_t) *fp--) \

View File

@ -63,7 +63,8 @@ variable tests-found variable tests-run variable tests-passed
context @ @ begin dup while dup test? if 2dup >r >r swap execute r> r> then >link repeat 2drop ;
: reset-test-counters 0 tests-found ! 0 tests-run ! 0 tests-passed ! ;
: count-test ( xt -- ) drop 1 tests-found +! ;
: check-fresh depth if }confirm ." DEPTH LEAK! " depth . 1 throw then ;
: check-fresh depth if }confirm ." DEPTH LEAK! " depth . 1 throw then
fdepth if }confirm ." FDEPTH LEAK! " fdepth . 1 throw then ;
: wrap-test ( xt -- ) expect-reset >r check-fresh r> execute check-fresh expect-finish ;
: red 1 fg ; : green 2 fg ; : hr 40 for [char] - emit next cr ;
: replace-line 13 emit clear-to-eol ;