version 1.50, 1996/01/07 17:22:12
|
version 1.57, 1996/05/07 16:15:22
|
Line 76 HEX
|
Line 76 HEX
|
|
|
\ Bit string manipulation 06oct92py |
\ Bit string manipulation 06oct92py |
|
|
Create bits 80 c, 40 c, 20 c, 10 c, 8 c, 4 c, 2 c, 1 c, |
\ Create bits 80 c, 40 c, 20 c, 10 c, 8 c, 4 c, 2 c, 1 c, |
DOES> ( n -- ) + c@ ; |
\ DOES> ( n -- ) + c@ ; |
|
|
: >bit ( addr n -- c-addr mask ) 8 /mod rot + swap bits ; |
\ : >bit ( addr n -- c-addr mask ) 8 /mod rot + swap bits ; |
: +bit ( addr n -- ) >bit over c@ or swap c! ; |
\ : +bit ( addr n -- ) >bit over c@ or swap c! ; |
|
|
: relinfo ( -- addr ) forthstart dup @ + ; |
\ : relinfo ( -- addr ) forthstart dup @ + !!bug!! ; |
: >rel ( addr -- n ) forthstart - ; |
\ : >rel ( addr -- n ) forthstart - ; |
: relon ( addr -- ) relinfo swap >rel cell / +bit ; |
\ : relon ( addr -- ) relinfo swap >rel cell / +bit ; |
|
|
\ here allot , c, A, 17dec92py |
\ here allot , c, A, 17dec92py |
|
|
Line 128 DOES> ( n -- ) + c@ ;
|
Line 128 DOES> ( n -- ) + c@ ;
|
; immediate |
; immediate |
|
|
|
|
: A! ( addr1 addr2 -- ) \ gforth |
\ : A! ( addr1 addr2 -- ) \ gforth |
dup relon ! ; |
\ dup relon ! ; |
: A, ( addr -- ) \ gforth |
\ : A, ( addr -- ) \ gforth |
here cell allot A! ; |
\ here cell allot A! ; |
|
' ! alias A! ( addr1 addr2 -- ) \ gforth |
|
' , alias A, ( addr -- ) \ gforth |
|
|
|
|
\ on off 23feb93py |
\ on off 23feb93py |
|
|
Line 450 hex
|
Line 453 hex
|
|
|
: throw ( y1 .. ym error/0 -- y1 .. ym / z1 .. zn error ) \ exception |
: throw ( y1 .. ym error/0 -- y1 .. ym / z1 .. zn error ) \ exception |
?DUP IF |
?DUP IF |
[ here 4 cells ! ] |
[ here 9 cells ! ] |
handler @ rp! |
handler @ rp! |
r> handler ! |
r> handler ! |
r> lp! |
r> lp! |
Line 489 Defer notfound ( c-addr count -- )
|
Line 492 Defer notfound ( c-addr count -- )
|
2drop -&13 bounce ; |
2drop -&13 bounce ; |
' no.extensions IS notfound |
' no.extensions IS notfound |
|
|
|
: compile-only ( ... -- ) |
|
-&14 throw ; |
|
Defer interpret-special ( c-addr u xt -- ) \ !! use nfa instead of xt? |
|
' compile-only IS interpret-special |
|
|
: interpret ( ?? -- ?? ) \ gforth |
: interpret ( ?? -- ?? ) \ gforth |
\ interpret/compile the (rest of the) input buffer |
\ interpret/compile the (rest of the) input buffer |
BEGIN |
BEGIN |
Line 508 Defer notfound ( c-addr count -- )
|
Line 516 Defer notfound ( c-addr count -- )
|
IF \ not restricted to compile state? |
IF \ not restricted to compile state? |
nip nip execute EXIT |
nip nip execute EXIT |
THEN |
THEN |
-&14 throw |
interpret-special exit |
THEN |
THEN |
drop |
drop |
2dup 2>r snumber? |
2dup 2>r snumber? |
Line 720 variable backedge-locals
|
Line 728 variable backedge-locals
|
|
|
: ?DUP-IF ( compilation -- orig ; run-time n -- n| ) \ gforth question-dupe-if |
: ?DUP-IF ( compilation -- orig ; run-time n -- n| ) \ gforth question-dupe-if |
\ This is the preferred alternative to the idiom "?DUP IF", since it can be |
\ This is the preferred alternative to the idiom "?DUP IF", since it can be |
\ better handled by tools like stack checkers |
\ better handled by tools like stack checkers. Besides, it's faster. |
POSTPONE ?dup POSTPONE if ; immediate restrict |
POSTPONE ?dup-?branch >mark ; immediate restrict |
|
|
: ?DUP-0=-IF ( compilation -- orig ; run-time n -- n| ) \ gforth question-dupe-zero-equals-if |
: ?DUP-0=-IF ( compilation -- orig ; run-time n -- n| ) \ gforth question-dupe-zero-equals-if |
POSTPONE ?dup POSTPONE 0= POSTPONE if ; immediate restrict |
POSTPONE ?dup-0=-?branch >mark ; immediate restrict |
|
|
: THEN ( compilation orig -- ; run-time -- ) \ core |
: THEN ( compilation orig -- ; run-time -- ) \ core |
dup orig? |
dup orig? |
Line 878 Avariable leave-sp leave-stack 3 cells
|
Line 887 Avariable leave-sp leave-stack 3 cells
|
: ?DO ( compilation -- do-sys ; run-time w1 w2 -- | loop-sys ) \ core-ext question-do |
: ?DO ( compilation -- do-sys ; run-time w1 w2 -- | loop-sys ) \ core-ext question-do |
POSTPONE (?do) ?do-like ; immediate restrict |
POSTPONE (?do) ?do-like ; immediate restrict |
|
|
: +DO ( compilation -- do-sys ; run-time w1 w2 -- | loop-sys ) \ gforth plus-do |
: +DO ( compilation -- do-sys ; run-time n1 n2 -- | loop-sys ) \ gforth plus-do |
POSTPONE (+do) ?do-like ; immediate restrict |
POSTPONE (+do) ?do-like ; immediate restrict |
|
|
: U+DO ( compilation -- do-sys ; run-time w1 w2 -- | loop-sys ) \ gforth u-plus-do |
: U+DO ( compilation -- do-sys ; run-time u1 u2 -- | loop-sys ) \ gforth u-plus-do |
POSTPONE (u+do) ?do-like ; immediate restrict |
POSTPONE (u+do) ?do-like ; immediate restrict |
|
|
: -DO ( compilation -- do-sys ; run-time w1 w2 -- | loop-sys ) \ gforth minus-do |
: -DO ( compilation -- do-sys ; run-time n1 n2 -- | loop-sys ) \ gforth minus-do |
POSTPONE (-do) ?do-like ; immediate restrict |
POSTPONE (-do) ?do-like ; immediate restrict |
|
|
: U-DO ( compilation -- do-sys ; run-time w1 w2 -- | loop-sys ) \ gforth u-minus-do |
: U-DO ( compilation -- do-sys ; run-time u1 u2 -- | loop-sys ) \ gforth u-minus-do |
POSTPONE (u-do) ?do-like ; immediate restrict |
POSTPONE (u-do) ?do-like ; immediate restrict |
|
|
: FOR ( compilation -- do-sys ; run-time w -- loop-sys ) \ gforth |
: FOR ( compilation -- do-sys ; run-time u -- loop-sys ) \ gforth |
POSTPONE (for) |
POSTPONE (for) |
POSTPONE begin drop do-dest |
POSTPONE begin drop do-dest |
( 0 0 0 >leave ) ; immediate restrict |
( 0 0 0 >leave ) ; immediate restrict |
Line 957 create s"-buffer /line chars allot
|
Line 966 create s"-buffer /line chars allot
|
state @ IF postpone (.") ," align |
state @ IF postpone (.") ," align |
ELSE [char] " parse type THEN ; immediate |
ELSE [char] " parse type THEN ; immediate |
: ( ( compilation 'ccc<close-paren>' -- ; run-time -- ) \ core,file paren |
: ( ( compilation 'ccc<close-paren>' -- ; run-time -- ) \ core,file paren |
[char] ) parse 2drop ; immediate |
BEGIN |
|
>in @ [char] ) parse nip >in @ rot - = |
|
WHILE |
|
loadfile @ IF |
|
refill 0= abort" missing ')' in paren comment" |
|
THEN |
|
REPEAT ; immediate |
: \ ( -- ) \ core-ext backslash |
: \ ( -- ) \ core-ext backslash |
blk @ |
blk @ |
IF |
IF |
Line 1127 Create ??? 0 , 3 c, char ? c, char ? c,
|
Line 1142 Create ??? 0 , 3 c, char ? c, char ? c,
|
\ Create ( -- ) |
\ Create ( -- ) |
\ ['] noop A, |
\ ['] noop A, |
\ DOES> ( ??? ) |
\ DOES> ( ??? ) |
\ @ execute ; |
\ perform ; |
|
|
: IS ( addr "name" -- ) \ gforth |
: IS ( addr "name" -- ) \ gforth |
' >body |
' >body |
Line 1208 AVariable lookup G forth-wordlist
|
Line 1223 AVariable lookup G forth-wordlist
|
G forth-wordlist current T ! |
G forth-wordlist current T ! |
|
|
: (search-wordlist) ( addr count wid -- nfa / false ) |
: (search-wordlist) ( addr count wid -- nfa / false ) |
dup wordlist-map @ find-method @ execute ; |
dup wordlist-map @ find-method perform ; |
|
|
: search-wordlist ( addr count wid -- 0 / xt +-1 ) \ search |
: search-wordlist ( addr count wid -- 0 / xt +-1 ) \ search |
(search-wordlist) dup IF found THEN ; |
(search-wordlist) dup IF found THEN ; |
Line 1243 G -1 warnings T !
|
Line 1258 G -1 warnings T !
|
last? if |
last? if |
name>string current @ check-shadow |
name>string current @ check-shadow |
then |
then |
current @ wordlist-map @ reveal-method @ execute ; |
current @ wordlist-map @ reveal-method perform ; |
|
|
: rehash ( wid -- ) |
: rehash ( wid -- ) |
dup wordlist-map @ rehash-method @ execute ; |
dup wordlist-map @ rehash-method perform ; |
|
|
: ' ( "name" -- addr ) \ core tick |
: ' ( "name" -- addr ) \ core tick |
name sfind 0= if -&13 bounce then ; |
name sfind 0= if -&13 bounce then ; |
Line 1269 G -1 warnings T !
|
Line 1284 G -1 warnings T !
|
#lf ( sic! ) emit ; |
#lf ( sic! ) emit ; |
|
|
\ : backspaces 0 ?DO #bs emit LOOP ; |
\ : backspaces 0 ?DO #bs emit LOOP ; |
|
|
|
Variable ^d-mode -1 ^d-mode ! \ ^d is "EOF" if at beginning of the line |
|
|
: >string ( span addr pos1 -- span addr pos1 addr2 len ) |
: >string ( span addr pos1 -- span addr pos1 addr2 len ) |
over 3 pick 2 pick chars /string ; |
over 3 pick 2 pick chars /string ; |
: type-rest ( span addr pos1 -- span addr pos1 back ) |
: type-rest ( span addr pos1 -- span addr pos1 back ) |
Line 1284 G -1 warnings T !
|
Line 1302 G -1 warnings T !
|
: (ret) type-rest drop true space ; |
: (ret) type-rest drop true space ; |
: back dup IF 1- #bs emit ELSE #bell emit THEN 0 ; |
: back dup IF 1- #bs emit ELSE #bell emit THEN 0 ; |
: forw 2 pick over <> IF 2dup + c@ emit 1+ ELSE #bell emit THEN 0 ; |
: forw 2 pick over <> IF 2dup + c@ emit 1+ ELSE #bell emit THEN 0 ; |
: eof 2 pick 0= IF bye ELSE (ret) THEN ; |
: eof ^d-mode @ IF |
|
bye |
|
ELSE 2 pick over <> |
|
IF forw drop (del) ELSE #bell emit THEN 0 |
|
THEN ; |
|
|
Create ctrlkeys |
Create ctrlkeys |
] false false back false eof false forw false |
] false false back false eof false forw false |
Line 1298 defer everychar
|
Line 1320 defer everychar
|
: decode ( max span addr pos1 key -- max span addr pos2 flag ) |
: decode ( max span addr pos1 key -- max span addr pos2 flag ) |
everychar |
everychar |
dup #del = IF drop #bs THEN \ del is rubout |
dup #del = IF drop #bs THEN \ del is rubout |
dup bl < IF cells ctrlkeys + @ execute EXIT THEN |
dup bl < IF cells ctrlkeys + perform EXIT THEN |
>r 2over = IF rdrop bell 0 EXIT THEN |
>r 2over = IF rdrop bell 0 EXIT THEN |
r> (ins) 0 ; |
r> (ins) 0 ; |
|
|
\ decode should better use a table for control key actions |
|
\ to define keyboard bindings later |
|
|
|
: accept ( addr len -- len ) \ core |
: accept ( addr len -- len ) \ core |
dup 0< IF abs over dup 1 chars - c@ tuck type |
dup 0< IF abs over dup 1 chars - c@ tuck type |
\ this allows to edit given strings |
\ this allows to edit given strings |
ELSE 0 THEN rot over |
ELSE 0 THEN rot over |
BEGIN key decode UNTIL |
BEGIN key decode dup ^d-mode ! UNTIL |
2drop nip ; |
2drop nip ; |
|
|
\ Output 13feb93py |
\ Output 13feb93py |
|
|
|
: (type) ( c-addr u -- ) \ gforth |
|
outfile-id write-file drop \ !! use ?DUP-IF THROW ENDIF instead of DROP ? |
|
; |
|
|
Defer type ( c-addr u -- ) \ core |
Defer type ( c-addr u -- ) \ core |
\ defer type for a output buffer or fast |
\ defer type for a output buffer or fast |
\ screen write |
\ screen write |
|
|
\ : (type) ( addr len -- ) |
|
\ bounds ?DO I c@ emit LOOP ; |
|
|
|
' (type) IS Type |
' (type) IS Type |
|
|
|
: (emit) ( c -- ) \ gforth |
|
outfile-id emit-file drop \ !! use ?DUP-IF THROW ENDIF instead of DROP ? |
|
; |
|
|
Defer emit ( c -- ) \ core |
Defer emit ( c -- ) \ core |
' (Emit) IS Emit |
' (Emit) IS Emit |
|
|
Line 1353 Defer key ( -- c ) \ core
|
Line 1377 Defer key ( -- c ) \ core
|
\ 2 c, here char r c, char + c, 0 c, |
\ 2 c, here char r c, char + c, 0 c, |
\ 2 c, here char w c, char + c, 0 c, align |
\ 2 c, here char w c, char + c, 0 c, align |
4 Constant w/o ( -- fam ) \ file w-o |
4 Constant w/o ( -- fam ) \ file w-o |
2 Constant r/w ( -- fam ) \ file r-o |
2 Constant r/w ( -- fam ) \ file r-w |
0 Constant r/o ( -- fam ) \ file r-w |
0 Constant r/o ( -- fam ) \ file r-o |
|
|
\ BIN WRITE-LINE 11jun93jaw |
\ BIN WRITE-LINE 11jun93jaw |
|
|
Line 1746 Variable argc
|
Line 1770 Variable argc
|
Defer 'cold ' noop IS 'cold |
Defer 'cold ' noop IS 'cold |
|
|
: cold ( -- ) \ gforth |
: cold ( -- ) \ gforth |
|
stdout TO outfile-id |
pathstring 2@ process-path pathdirs 2! |
pathstring 2@ process-path pathdirs 2! |
init-included-files |
init-included-files |
'cold |
'cold |