X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=blobdiff_plain;f=src%2Flib_6_variables.4th;fp=src%2Flib_6_variables.4th;h=0000000000000000000000000000000000000000;hb=30a093845e2d1097242e948bb577fb71f73bc860;hp=a7aea7004573489c14dc06cab9869ef2f64cb9f7;hpb=c52194127d604bd365f7222936b46f34f62a4814;p=forth.jl.git diff --git a/src/lib_6_variables.4th b/src/lib_6_variables.4th deleted file mode 100644 index a7aea70..0000000 --- a/src/lib_6_variables.4th +++ /dev/null @@ -1,76 +0,0 @@ -\ Remaining field address conversion words - -: >NAME - BEGIN - 1- DUP @ - NFA_MARK AND - NFA_MARK = UNTIL -; - -: NAME> 1- LINK> ; - -: >LINK >NAME 1- ; - -: >BODY 1+ ; - -: BODY> 1- ; - -\ Constants and Variables - -: CONSTANT - CREATE , -DOES> @ -; - -: ALLOT ( n -- ) - H +! ( adds n to H, after this the old value of H is still on the stack ) -; - -: VARIABLE - CREATE - 1 CELLS ALLOT ( allocate 1 cell of memory, push the pointer to this memory ) -; - -: VALUE ( n -- ) - CREATE , -DOES> @ -; - -: TO IMMEDIATE ( n -- ) - BL WORD ( get the name of the value ) - FIND DROP ( look it up in the dictionary ) - >BODY ( get a pointer to the first data field (the 'LIT') ) - STATE @ IF ( compiling? ) - ['] LIT , ( compile LIT ) - , ( compile the address of the value ) - ['] ! , ( compile ! ) - ELSE ( immediate mode ) - ! ( update it straightaway ) - THEN -; - -( x +TO VAL adds x to VAL ) -: +TO IMMEDIATE - BL WORD ( get the name of the value ) - FIND DROP ( look it up in the dictionary ) - >BODY ( get a pointer to the first data field (the 'LIT') ) - STATE @ IF ( compiling? ) - ['] LIT , ( compile LIT ) - , ( compile the address of the value ) - ['] +! , ( compile +! ) - ELSE ( immediate mode ) - +! ( update it straightaway ) - THEN -; - -( Fill u ints, starting at a, with the value b ) -: FILL ( a u b -- ) - -ROT OVER + SWAP ?DO - DUP I ! - LOOP - DROP -; - -: ERASE ( a u -- ) - 0 FILL -;