p4_bracket_defined_
p4_bracket_not_
p4_cpu_nr_
p4_dot_h2_
p4_fetch_from_
p4_fetch_from_execution_
p4_goto_cpu_RT_
p4_immediate_bit_
p4_into_
p4_into_execution_
p4_into_local_execution_
p4_load_cpus_
p4_loadf_
p4_make_
p4_make_to_execution_
p4_make_to_local_execution_
p4_prefix_begin_
p4_prefix_end_
p4_prefix_end_doubled_
p4_printf_
p4_semicolon_and_
p4_semicolon_and_execution_
p4_smart_interpret_init
p4_smart_interpret_init_
p4_smart_interpret_off_
p4_smart_interpret_on_
p4_smudge_bit_
p4_sprintf_
p4_store_to_
p4_tick_from_
p4_to_compile
p4_to_compile_
p4_var_
p4_zero_local_RT_
p4_call
p4_compile1
p4_compile2
p4_forget_loadf
p4_forget_word
p4_goto_cpu
p4_header_from
p4_hereword
p4_make_head
p4_outf
p4_outs
p4_parseword
p4_smart_interpret_char
p4_store_c_string
p4_bracket_defined_ :
[DEFINED] word ( -- nfa|0 ) immediate
'
[IF]
[IFDEF] word
[DEFINED] word [IF]
reference: ../src/yours.c:0803
p4_bracket_not_ :
[NOT] ( a -- a' )
0=
[IF]
[IFNOT]
[DEFINED]
[DEFINED] word [NOT] [IF]
[IFNOTDEF] word
reference: ../src/yours.c:0821
p4_cpu_nr_ :
CPU# ( -- )
reference: ../src/yours.c:0379
p4_dot_h2_ :
.H2 ( value -- )
0x0 -> 00 0xf -> 0f 0x12 -> 12 0x123 -> 0123 0x1234 -> 1234 0x12345 -> 012345
reference: ../src/yours.c:0523
p4_fetch_from_ :
@> name ( -- value )
VARIABLE
VALUE
LVALUE
LOCALS|
VAR
DEFER
DOER
DOES>
reference: ../src/yours.c:0199
p4_fetch_from_execution_ :
((@>)) ( -- value )
@>
reference: ../src/yours.c:0186
p4_goto_cpu_RT_ :
GOTO-CPU ( nr -- )
reference: ../src/yours.c:0346
p4_immediate_bit_ :
(IMMEDIATE#) ( -- bit-mask )
" my-word" FIND IF >FFA C@ (IMMEDIATE#) AND IF ." immediate" THEN ELSE DROP THEN
reference: ../src/yours.c:0100
p4_into_ :
INTO word ( -- pfa )
LOCALS|
VAR
TO A
INTO A !
reference: ../src/yours.c:0733
p4_into_execution_ :
((INTO))
INTO
reference: ../src/yours.c:0710
p4_into_local_execution_ :
((INTO-)) ( -- value )
INTO
reference: ../src/yours.c:0718
p4_load_cpus_ :
<<CPU>> ( -- )
reference: ../src/yours.c:0357
p4_loadf_ :
LOADF filename ( -- )
INCLUDE
MARKER
LOADED
FORGET
reference: ../src/yours.c:0552
p4_make_ :
MAKE word ... ;AND ( -- )
MAKE
;AND
MAKE
DOER
DEFER
NOOP
MAKE
LOCALS|
VAR
reference: ../src/yours.c:0617
p4_make_to_execution_ :
((MAKE))
MAKE
reference: ../src/yours.c:0593
p4_make_to_local_execution_ :
((MAKE-))
MAKE
reference: ../src/yours.c:0583
p4_prefix_begin_ :
($ word ( -- cs-token ) compile-only
)
>COMPILE
($ IF ($ 0= A1 @ )) ($ THEN ." hello " )Note that an opening simple
(
reference: ../src/yours.c:0152
p4_prefix_end_ :
) ( cs-token -- )
($
>COMPILE
reference: ../src/yours.c:0163
p4_prefix_end_doubled_ :
)) ( cs-token cs-token -- )
($
>COMPILE
simulate: : )) [COMPILE] ) [COMPILE] ) ; IMMEDIATE
reference: ../src/yours.c:0175
p4_printf_ :
PRINTF ( args ... format$ -- )
SPRINTF
SPRINTF
reference: ../src/yours.c:0507
p4_semicolon_and_ :
;AND ( -- )
MAKE
;AND
EXIT
MAKE
reference: ../src/yours.c:0653
p4_semicolon_and_execution_ :
(;AND)
;AND
reference: ../src/yours.c:0640
p4_smart_interpret_init :
reference: ../src/yours.c:0280
p4_smart_interpret_init_ :
SMART-INTERPRET-INIT
IMMEDIATE
DEFER
SMART-INTERPRET-INIT
"hello"
" hello"
\if-unix
\if-unknown
reference: ../src/yours.c:0298
p4_smart_interpret_off_ :
SMART-INTERPRET-OFF
INTERPRET
SMART-INTERPRET-INIT
reference: ../src/yours.c:0317
p4_smart_interpret_on_ :
SMART-INTERPRET-ON
INTERPRET
SMART-INTERPRET-INIT
reference: ../src/yours.c:0327
p4_smudge_bit_ :
(SMUDGE#) ( -- bit-mask )
" my-word" FIND IF >FFA C@ (SMUDGE#) AND IF ." smudge" THEN ELSE DROP THEN
reference: ../src/yours.c:0110
p4_sprintf_ :
SPRINTF ( args ... format$ dest$ -- len-dest )
variable A 256 ALLOT 15 " example" " the %#s value is %i" A 1+ SPRINTF A C! A COUNT TYPE
reference: ../src/yours.c:0497
p4_store_to_ :
!> name ( value -- )
TO
reference: ../src/yours.c:0696
p4_tick_from_ :
'> name ( -- xt )
'
[']
reference: ../src/yours.c:0679
p4_to_compile
reference: ../src/yours.c:0137
p4_to_compile_ :
>COMPILE ( xt -- )
POSTPONE
IF
THEN
POSTPONE
COMPILE
[COMPILE]
INTERPRET
reference: ../src/yours.c:0135
p4_var_ :
VAR name ( -- )
VALUE
LVALUE
VALUE
LVALUE
reference: ../src/yours.c:0780
p4_zero_local_RT_ :
((0LVALUE))
VAR
reference: ../src/yours.c:0769
p4_call :
>COMPILE
POSTPONE
reference: ../src/yours.c:0124
p4_compile1
reference: ../src/yours.c:0752
p4_compile2
reference: ../src/yours.c:0745
p4_forget_loadf
reference: ../src/yours.c:0539
p4_forget_word
reference: ../src/yours.c:0562
p4_goto_cpu
reference: ../src/yours.c:0348
p4_header_from :
reference: ../src/yours.c:0272
p4_hereword
reference: ../src/yours.c:0221
p4_make_head :
To make a new primitive Forth word, you have to write a C function of type
static void name_(void)
Use the preprocessor macro
FCode (p4_name)
to provide the prototype with the underscore appended to the name. The underscore helps to avoid name clashes with names and keywords of the C language.
If you want to call such a primitive from C-source you must of course append the underscore to the name in the function call yourself. If you want to call it from another input file then you must leave out the `static' keyword in the function definition, which is what the alternative macro
code (name)
does. Both are of course nothing but shortcuts to ease input of all those words.
Having defined a primitive you must add it to the forth dictionary in order to make it visible to Forth. At the end of each input file defining forth primitives you'll find a table declared with the macro
LISTWORDS (wordset_name) = { ... };
This declares a vector of some type and shows how to continue with the initialization of the vector. Each vector element registers a forth word for loading into the dictionary at startup. In p4th the dictionary is not an initialized C structure but it is built from such structures -- like the one described here -- at startup.
To enter words into this table there are several macros, all for brevity named with two uppercase letters. Using such a macro adds one more element to the list of initializers following the LISTWORDS declaration. Besides primitives you can enter variables and constants to the dictionary this way.
CO (NAME, c-name) a primitive, not immediate CI (NAME, c-name) an immediate primitive CS (NAME, c-name) a primitive with separate execution and compilation semantics, see examples in core.c (if, case etc.) and macros in p4_comp.h and -- good luck :-) OV (NAME) a normal variable OC (NAME, value) a normal constant OL (NAME, value) a normal value IV (NAME) an immediate variable IC (NAME, value) an immediate constant IL (NAME, value) an immediate value
reference: ../src/yours.c:0367
p4_outf
reference: ../src/yours.c:0533
p4_outs
reference: ../src/yours.c:0511
p4_parseword
reference: ../src/yours.c:0808
p4_smart_interpret_char :
reference: ../src/yours.c:0248
p4_store_c_string
reference: ../src/yours.c:0559