lpf83 definitions



p4_ascii_ : ASCII word ( -- val )

state smart version of CHAR or [CHAR] resp.
 simulate:
   : ASCII  [COMPILE] [CHAR] 
            STATE @ IF [COMPILE] LITERAL THEN ;

reference: ../src/lpf83.c:0280

p4_bounds_ : BOUNDS ( a b -- b+a a )

 simulate:
   : BOUNDS  OVER + SWAP ; 

reference: ../src/lpf83.c:0040

p4_c_reset_ : CRESET ( n addr -- )

reset bits in byte at given address
 simulate:
   : CRESET  TUCK @ SWAP NOT AND SWAP ! ;

reference: ../src/lpf83.c:0132

p4_c_set_ : CSET ( n addr -- )

set bits in byte at given address
 simulate:
   : CSET  TUCK @ SWAP OR SWAP ! ;

reference: ../src/lpf83.c:0121

p4_c_toggle_ : CTOGGLE ( n addr -- )

toggle bits in byte at given address
 simulate:
   : CTOGGLE  TUCK @ SWAP XOR SWAP ! ;

reference: ../src/lpf83.c:0143

p4_control_ : CONTROL word ( -- val )

see ASCII, but returns char - '@'
 simulate:
   : CONTROL  [COMPILE] [CHAR]  [CHAR] @ -  
              STATE @ IF [COMPILE] LITERAL THEN ;

reference: ../src/lpf83.c:0306

p4_dash_rot_ : -ROT ( a b c -- c a b )

inverse of ROT

reference: ../src/lpf83.c:0107

p4_defer_ : DEFER word ( -- )

create a new word with ((DEFER))-semantics
 simulate:
   : DEFER  CREATE 0, DOES> ( the ((DEFER)) runtime ) 
      @ ?DUP IF EXECUTE THEN ;
declare as "DEFER deferword"
and set as "['] executionword TO deferword"

reference: ../src/lpf83.c:0386

p4_defer_RT_ : ((DEFER)) ( -- )

runtime of DEFER words

reference: ../src/lpf83.c:0370

p4_four_dup_ : 4DUP ( a b c d -- a b c d a b c d )

 simulate:
  : 4DUP  4 PICK 4 PICK 4 PICK 4 PICK ;

reference: ../src/lpf83.c:0183

p4_lower

reference: ../src/lpf83.c:0220

p4_lower_ : LOWER ( addr cnt -- )

convert string to lower case This is not in L&P's F83 but provided for symmetry
 simulate:
   : LOWER  0 DO  DUP I +  DUP C@ >R _tolower SWAP C!  LOOP  DROP ;

reference: ../src/lpf83.c:0218

p4_noop_ : NOOP ( -- )

do nothing, used as a place-holder where an execution word is needed

reference: ../src/lpf83.c:0074

p4_number_question_ : NUMBER? ( addr -- d flag )

convert counted string to number - used in inner interpreter ( INTERPRET ), flags if conversion was successful
 example:
   BL WORD  HERE NUMBER? 0= IF ." not a number " THEN . 

reference: ../src/lpf83.c:0336

p4_off_ : OFF ( addr -- )

 simulate:
   : OFF  FALSE SWAP ! ;

reference: ../src/lpf83.c:0153

p4_on_ : ON ( addr -- )

simulate:
   : ON  TRUE SWAP ! ;

reference: ../src/lpf83.c:0162

p4_perform_ : PERFORM ( addr -- ? )

  simulate:
    : PERFORM  @ EXECUTE 

reference: ../src/lpf83.c:0052

p4_place_ : PLACE ( addr1 len addr2 -- )

store string addr1/len at addr2
 simulate:
   : PLACE  2DUP C! 1+ SWAP CMOVE ;

reference: ../src/lpf83.c:0265

p4_question_leave_ : ?LEAVE ( cond -- )

leave a (innermost) loop if condition is true

reference: ../src/lpf83.c:0060

p4_r_p_fetch_ : RP@ ( -- addr )

returns the return stack pointer
 example:
   : R@ RP@ @ ;

reference: ../src/lpf83.c:0083

p4_r_p_store_ : RP! ( addr -- )

sets the return stack pointer, reverse of RP@

reference: ../src/lpf83.c:0091

p4_s_p_store_ : SP! ( ... addr -- )

sets the stack pointer, reverse of SP@

reference: ../src/lpf83.c:0099

p4_scan_ : SCAN ( addr cnt c -- addr' cnt' )

scan for first occurence of c in string
 simulate:
   : SCAN >R BEGIN DUP OVER C@ R@ = 0= OR WHILE 
                    1- SWAP 1- SWAP REPEAT R> DROP ;

reference: ../src/lpf83.c:0248

p4_skip_ : SKIP ( addr cnt c -- addr' cnt' )

skip leading characters c
 simulate:
   : SKIP  >R BEGIN DUP OVER C@ R@ = OR WHILE 
                    1- SWAP 1- SWAP REPEAT R> DROP ;

reference: ../src/lpf83.c:0230

p4_three_dup_ : 3DUP ( a b c -- a b c a b c )

 simulate:
   : 3DUP  3 PICK 3 PICK 3 PICK ;

reference: ../src/lpf83.c:0171

p4_to_execute_ : >EXECUTE ( xt -- ? )

same as EXECUTE , but checks for null as xt argument
 simulate:
   : >EXECUTE  ?DUP IF EXECUTE THEN ;

reference: ../src/lpf83.c:0397

p4_upc_ : UPC ( c1 -- c2 )

convert a single character to upper case
   : UPC  >R _toupper ;

reference: ../src/lpf83.c:0196

p4_upper

reference: ../src/toolkit.c:0334

p4_upper_ : UPPER ( addr cnt -- )

convert string to upper case
 simulate:
   : UPPER  0 DO  DUP I +  DUP C@ UPC SWAP C!  LOOP  DROP ;

reference: ../src/lpf83.c:0206

p4_vocs_ : VOCS ( -- )

list all vocabularies in the system
 simulate:
   : VOCS VOC-LINK @ BEGIN DUP WHILE
                           DUP BODY> >NAME .NAME
                           ->VOC-LINK @
                     REPEAT DROP ; 

reference: ../src/lpf83.c:0356

p4_header

reference: ../src/lpf83.c:0388