[SLOF] [PATCH] Fix output word
Thomas Huth
thuth at redhat.com
Wed Sep 27 17:25:04 AEST 2017
On 26.09.2017 13:28, Laurent Vivier wrote:
> We can select the console output, but it does not really work
>
> Implement term-io-emit, as we have term-io-key to really
> send characters to the output selected by stdout.
>
> Signed-off-by: Laurent Vivier <lvivier at redhat.com>
> ---
> slof/fs/term-io.fs | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/slof/fs/term-io.fs b/slof/fs/term-io.fs
> index 52ce12a..a0b0f4b 100644
> --- a/slof/fs/term-io.fs
> +++ b/slof/fs/term-io.fs
> @@ -40,6 +40,20 @@
>
> 1 BUFFER: (term-io-char-buf)
>
> +: term-io-emit ( char -- )
> + s" stdout" get-chosen IF
> + decode-int nip nip dup 0= IF 0 EXIT THEN
> + swap (term-io-char-buf) c!
> + >r (term-io-char-buf) 1 s" write" r@ $call-method
> + drop
> + r> drop
> + ELSE
> + [ ' emit behavior compile, ]
> + THEN
> +;
While this is basically the right direction, I've got three concerns /
remarks:
1) Please don't use TABs in Forth code (see Coding Style in README)
2) Have you checked whether it also works with VGA screens? The code in
slof/fs/display.fs ticks to EMIT again ... it looks like it should
work, but better test it first...
3) Speed ... This rather code is called for every character that we
print out. While it likely does not really matter for input, the
output of text was always a rather critical thing in SLOF. Could
you please do some speed measurements first? Something like:
milliseconds 2000 0 do 41 emit loop milliseconds swap - cr .d cr
... and then compare the values before and after your change.
Thanks,
Thomas
More information about the SLOF
mailing list