1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-17 06:08:05 +11:00

Move core's readln to xcomp core (high)

This commit is contained in:
Virgil Dupras 2020-05-13 09:28:32 -04:00
parent 029df00ad4
commit d956386e9b
11 changed files with 60 additions and 61 deletions

View File

@ -1 +1 @@
1 7 LOADR+ ( xcomp core high ) 1 12 LOADR+ ( xcomp core high )

22
blk/426
View File

@ -1,14 +1,12 @@
( LITN has to be defined after the last immediate usage of : RDLNMEM+ 0x57 RAM+ @ + ;
it to avoid bootstrapping issues ) ( current position in INBUF )
: LITN 32 , , ( 32 == NUMBER ) ; : IN> 0 RDLNMEM+ ;
( points to INBUF )
: IN( 2 RDLNMEM+ ;
( points to INBUF's end )
: IN) 0x40 ( buffer size ) 2+ RDLNMEM+ ;
: IMMED? 1- C@ 0x80 AND ; ( flush input buffer )
( set IN> to IN( and set IN> @ to null )
( ';' can't have its name right away because, when created, it : (infl) 0 IN( DUP IN> ! ! ;
is not an IMMEDIATE yet and will not be treated properly by
xcomp. )
: _
['] EXIT ,
R> DROP ( exit : )
; IMMEDIATE

32
blk/427
View File

@ -1,16 +1,16 @@
XCURRENT @ ( to PSP ) ( handle backspace: go back one char in IN>, if possible, then
: : emit SPC + BS )
(entry) : (inbs)
( We cannot use LITN as IMMEDIATE because of bootstrapping ( already at IN( ? )
issues. Same thing for ",". IN> @ IN( = IF EXIT THEN
32 == NUMBER 14 == compiledWord ) IN> @ 1- IN> !
[ 32 H@ ! 2 ALLOT 14 H@ ! 2 ALLOT ] C, SPC BS
BEGIN ;
WORD
(find) : KEY
( is word ) 85 RAM+ @ ( (key) override )
IF DUP IMMED? IF EXECUTE ELSE , THEN DUP IF EXECUTE ELSE DROP (key) THEN ;
( maybe number )
ELSE (parse) LITN THEN
AGAIN ; ( cont.: read one char into input buffer and returns whether we
( from PSP ) ';' SWAP 4 - C! should continue, that is, whether CR was not met. )

View File

View File

View File

@ -2,11 +2,11 @@
: RDLN$ : RDLN$
( 57 == rdln's memory ) ( 57 == rdln's memory )
H@ 0x57 RAM+ ! H@ 0x57 RAM+ !
( 2 for IN>, plus 2 for extra bytes after buffer: 1 for ( plus 2 for extra bytes after buffer: 1 for
the last typed 0x0a and one for the following NULL. ) the last typed 0x0a and one for the following NULL. )
INBUFSZ 4 + ALLOT IN) IN> - 2+ ALLOT
(infl) (infl)
['] RDLN< 0x0c RAM+ ! LIT< RDLN< (find) DROP 0x0c RAM+ !
1 0x06 RAM+ ! ( 06 == C<? ) 1 0x06 RAM+ ! ( 06 == C<? )
; ;

14
blk/431 Normal file
View File

@ -0,0 +1,14 @@
( LITN has to be defined after the last immediate usage of
it to avoid bootstrapping issues )
: LITN 32 , , ( 32 == NUMBER ) ;
: IMMED? 1- C@ 0x80 AND ;
( ';' can't have its name right away because, when created, it
is not an IMMEDIATE yet and will not be treated properly by
xcomp. )
: _
['] EXIT ,
R> DROP ( exit : )
; IMMEDIATE

16
blk/432 Normal file
View File

@ -0,0 +1,16 @@
XCURRENT @ ( to PSP )
: :
(entry)
( We cannot use LITN as IMMEDIATE because of bootstrapping
issues. Same thing for ",".
32 == NUMBER 14 == compiledWord )
[ 32 H@ ! 2 ALLOT 14 H@ ! 2 ALLOT ] C,
BEGIN
WORD
(find)
( is word )
IF DUP IMMED? IF EXECUTE ELSE , THEN
( maybe number )
ELSE (parse) LITN THEN
AGAIN ;
( from PSP ) ';' SWAP 4 - C!

13
blk/447
View File

@ -1,13 +0,0 @@
64 CONSTANT INBUFSZ
: RDLNMEM+ 0x57 RAM+ @ + ;
( current position in INBUF )
: IN> 0 RDLNMEM+ ;
( points to INBUF )
: IN( 2 RDLNMEM+ ;
( points to INBUF's end )
: IN) INBUFSZ 2+ RDLNMEM+ ;
( flush input buffer )
( set IN> to IN( and set IN> @ to null )
: (infl) 0 IN( DUP IN> ! ! ;

16
blk/448
View File

@ -1,16 +0,0 @@
( handle backspace: go back one char in IN>, if possible, then
emit SPC + BS )
: (inbs)
( already at IN( ? )
IN> @ IN( = IF EXIT THEN
IN> @ 1- IN> !
SPC BS
;
: KEY
85 RAM+ @ ( (key) override )
DUP IF EXECUTE ELSE DROP (key) THEN ;
( cont.: read one char into input buffer and returns whether we
should continue, that is, whether CR was not met. )

Binary file not shown.