retroforth/interface/rng.retro

16 lines
370 B
Forth
Raw Normal View History

# Random Number Generator
I/O device type 10 is a random number generator. I do this as
part of the VM I/O extensions to allow implementors to use the
best approach on their host system.
~~~
:n:random (-n)
DEVICE:RNG io:scan-for
dup n:negative? [ drop 'Error:_RNG_device_not_found s:put nl ] if;
io:invoke ;
'interface/rng.retro 'n:random d:set-source
~~~