Note: Words marked with H are implementation words, present only as an aid to the implementation of other words. When their definition is given, it is for reference only; these words are not guaranteed to stay the same nor even to continue to exist in future releases. **** alloc-mem.f: variable apropos-string H A variable holding the address of the substring being searched for. Internal use only. : apropos-hook ( lfa -- ) H If the word whose link field address is lfa contains the apropos-string as a substring of its name, prints the name. Otherwise does nothing. Internal only. **** bitfields.f: variable bitoffset H : bitalign ( offset size -- offset' size ) H : left-right-bit# ( #bits -- #bits bit# ) H Internal Use. create masks H : bitmask ( n -- mask ) H : nbit@ ( byte_addr. bit# #bits -- n ) H code 1bit@ ( byte_addr. bit# -- f ) H code 1bit! ( f byte_addr. bit# -- ) H code 1bitset ( byte_addr. bit# -- ) H code 1bitclr ( byte_addr. bit# -- ) H code nbitx! ( n byte_addr. bit# bitmask -- ) H : nbit! ( n byte_addr. bit# #bits -- ) H **** iftrue.f: create context-save-area H : save-context ( -- ) H : restore-context ( -- ) H : (seal ( voc-cfa -- ) H Given the compilation address of a vocabulary, makes that vocabulary the only vocabulary in the search path. variable ignore-level H Current nesting level of conditionals. : start-ignoring ( -- ) H : stop-ignoring ( old-do-undefined -- ) H **** callfinder.f: : probably-cfa? ( cfa -- flag) H Given an address (cfa), makes an educated guess whether or not that address is the compilation address of some word, leaving true if it probably is. : reasonable-ip? ( ip -- flag) H Given an address (ip), makes an educated guess whether or not that address is within a sequence of Forth tokens (in other words, whether that address is a reasonable value for the interpreter pointer). True if yes. : find-cfa ( ip -- f cfa ) H Given an ip address (an address somewhere within the sequence of tokens defining a high-level Forth word), searches backward to find the compilation address of that word. Returns that compilation address, and a flag which is true if that word is a "create does>" word. : .current-word ( ip -- ) H Given an ip address, prints the name of the word which uses that address to store its token sequence. : .last-executed ( ip -- ) H Given an ip address, prints the name of the word whose execution resulted in that ip being pushed on the return stack. : .caller ( ip -- ) H Given an ip address, prints the name of the word that was being executed when that ip was pushed on the return stack. : (rstrace ( -- ) H Prints a formatted trace of the contents of the return stack. **** decompiler.f: 2 constant /branch H Constant leaving the number of bytes compiled for a branch offset. : word-type ( cfa -- word-type ) H : ta1+ ( token-address -- token-address' ) H Given the address of a Forth "token", finds the address of the next one. A "token" is what is compiled into the dictionary for each Forth word that is part of another Forth word. In many Forth systems, this is just the code-field address of the compiled Forth word. In this implementation, it happens to be a 32-bit absolute address, but this is an implementation detail and is not guaranteed to stay that way. : >data ( cfa -- data-address ) H Given a compilation address, finds the address of the data area for that word. Takes into account the type of word; for instance, the data for variables is not at the same place as the data for user variables. >data understands this and finds the correct data address in both cases. alias >is >data ( for backward compatibility) H : cr." ( -- ) H : .." ( -- ) H : c.id ( cfa -- ) H Given a compilation address, prints the name of the word. : out ( # apf -- ) H : map ( # apf -- a ) H : maptoken ( # apf -- a ) H : case: (s #cases -- ) ( Input stream: case-word-name ) H ( Later: n -- ? ) Defining word for case statements indexed by an integer. : tassociative: ( Input stream: associative-word-name ) H Defining word for associative case statements. defer (see H Forward reference. vocabulary hidden H Vocabulary which contains words which are not intended to be executed directly by the user, but are used for convenience in implementing other words. : breaks H variable end-breaks H : add-break ( break-address break-type -- ) H variable break-type variable break-addr variable where-break H : next-break ( -- break-address break-type ) H : >target ( ip-of-branch-instruction -- target ) H : forward-branch? ( ip-of-branch-token -- f ) H : bare-if? ( ip-of-branch-target -- f ) H : while? ( ip-of-?branch -- f ) H : indent ( -- ) H : +indent ( -- ) H : -indent ( -- ) H : (s cfa -- ) H : .user-variable (s cfa -- ) H : .defer (s cfa -- ) H : .user-defer (s cfa -- ) H : does? ( cfa -- f ) H : code? ( cfa -- f ) H : find-cfa ( ip -- cfa) H : .other (s cfa -- ) H : cf, ( --name ) H variable isvar H 6 tassociative: definition-class H 7 case: .definition-class H **** dump83.f: : .2 (s n -- ) H : d.2 (s addr len -- ) H : emit. (s char -- ) H : dln (s addr --- ) H : ?.n (s n1 n2 -- n1 ) H : ?.a (s n1 n2 -- n1 ) H : .head (s addr len -- addr' len' ) H **** emacs-line-edit.f: variable buflen H variable bufstart H variable bufcurrent H variable lastchar H variable bufcursor H variable last-bufcurrent H : forward-in-buf H : erase-blanks-backward ( -- ) H : erase-non-blanks-backward ( -- ) H : erase-blanks-forward ( -- ) H : erase-non-blanks-forward ( -- ) H : beginning-of-word ( -- ) H : end-of-word ( -- ) H create name-buf H : add-char-to-string ( str char -- ) H : add-char-to-name ( str char -- ) H : do-command ( -- ) H : clear-name-buf ( -- ) H **** cmd-cpl.f: : /n* ( -- ) 2* 2* ; H variable start-of-word H variable #candidates H : word-to-string ( -- str ) H : collect-string ( -- str ) H : add-space ( -- ) H : candidates ( -- addr ) H : end-of-name? ( nfa+n -- nfa+n f ) H : substring? ( addr nfa -- f ) H : new-candidate ( lfa -- lfa ) H : find-candidates-in-thread ( addr thread -- addr ) H : find-candidates-in-voc ( addr voc -- addr ) H : find-candidates ( str -- ) H : cclash? ( char# char str -- char# char f ) H : candidates-agree? ( char# -- char true | false ) H : expand-initial-substring ( -- ) H : one-candidate? ( -- f ) H : do-erase ( -- ) H defer word-is-complete H ' add-space is word-is-complete H : do-expand ( -- ) H : show-candidates ( -- ) H **** exceptions.f: variable exceptions H create pop-exception ( -- ) H **** getenv.f: create getenv-buf 256 allot H The buffer where the string is actually left. This is an implementation detail; don't depend on it. **** clink.f variable cload-base H /l field a_magic H /l field a_text H /l field a_data H /l field a_bss H /l field a_syms H /l field a_entry H /l field a_trsize H /l field a_drsize H /l field strx H /c field sym_type H /c field other H /w field desc H /l field value H constant /exec H create exec /exec allot H : /text ( -- size-of-text-segment ) : /data ( -- size-of-data-segment ) : /bss ( -- size-of-bss-segment ) : /syms ( -- size-of-symbol-table ) : /reloc ( -- size-of-relocation ) : text0 ( -- file-address-of-text ) : data0 ( -- file-address-of-data ) : reloc0 ( -- file-address-of-relocation ) : syms0 ( -- file-address-of-symbols ) : string0 ( -- file-address-of-strings ) variable sym# variable tf : initsym 0 sym# ! ; struct ( symbol table entry ) constant /sym : #syms ( -- number-of-symbols ) /syms /sym / ; create sym /sym allot : getsym ( sym# -- ) : moresyms? sym# @ #syms < ; : nextsym ( -- ) : getsymname ( -- name ) : .symname ( -- ) : .sym ( -- ) : opena.out ( name -- ) : text-sym: ( -- ) : data-bss-sym: ( -- ) : process-symbol ( -- ) : textload ( -- ) : cload ( name -- ) : .a.out ( name -- ) : :ccall ( addr name -- ) : f.out ( -- str ) H : n->str ( n -- hex-str) H : rename ( old-str new-str -- ) H Renames the file "old-str" to "new-str" (like the Unix "mv" command). **** spawn.f 40 /l * constant max-exec-argv H Maximum size for the argument vector to the Unix program. create exec-argv max-exec-argv allot H Space for the argument vector to the Unix program. create exec-envp H Environment vector for the program. variable argvp H variable old-here H **** path-open.f : open-with-prefix ( name prefix -- fp | 0 ) H Concatenates the name string to the prefix string and attempts to open the file with the resulting name. : more-path-prefixes? ( path-list-pointer -- path-list-pointer f ) H Returns true if the path-list-pointer is not the last one. : next-path-prefix ( list-of-paths -- next-item-in-list-of-paths ) H **** path-scan.f : next-name ( addr len -- addr' len' addr count ) H **** path-load.f: create fpaths H : path-init ( -- ) H Reads the EPATH environment variable and extracts the list of search paths from it. **** keyboard.f: The structure used by the set keyboard translation ioctl. H 4 field tablemask H 1 field station H 1 field kentry H 10 field kstring H constant kiosize H create kio kiosize allot H variable cfd H : openconsole H Opens the console so the keyboard can be mapped. : cput ( string where -- ) H Puts the string at where and checks to make sure it's short enough to be accepted by the kernel keymap. : dosetkey ( -- ) H Executes the SETKEY ioctl using parameters set up in the global kio structure. : settables ( -- ) H Does dosetkey for all the translation tables (normal, CAPS, SHIFT, CTRL, UP). : map-char ( char -- char' ) H Given the second character of a C escape sequence like \n, returns the actual character. Thus "ascii t map-char" would return the tab character. : put-char ( addr char -- addr+1 ) H Puts the character char at the address addr and increments the address. : process-char ( to-addr from-addr -- to-addr' incr ) H Puts the character at from-addr at to-addr and returns incremented to-addr and the number of characters taken from the to buffer. If the character at to-addr begins an escape sequence, the escape sequence is decoded. : process-escape-sequences ( string -- string' ) H Given a packed string, returns a new string with C escape sequence converted to the actual characters. **** menus2.f: 10 stack: menu-stack H This stack contains the currently-active hierarchy of menus. The menu that is currently being displayed is on top of the stack. create temp-array H variable #items H variable menu-dirty? H Does the menu need to be redisplayed? : .item ( item-address -- next-item-address ) H Prints a menu item. : .menu ( menu-pfa -- ) H Displays a menu given its pfa. : make-table ( -- ) H : get-selection ( menu-pfa -- ) H Prompts for, reads, and verifies a selection from the current menu. Returns that selection's index into the menu table. : execute-selection ( pfa index -- ) H Executes the index'th selection from the current menu. : to-execution-area ( -- ) H Moves the cursor from the place on the screen which is used for selecting a menu item to the place used for executing the selected item. **** order.f : v>body ( voc-link-addr --- pfa ) H : find-voc ( voc-ptr-addr -- cfa ) H **** patch.f: : word-bounds ( cfa -- pfa end ) H Returns the start and end of the parameter field of the word whose cfa is the input argument. The word is assumed to be a colon definition. If the word has multiple exit's compiled into it, word-bounds will find the first one. Sigh. **** pokearound.f: variable finished? H create new-tib H Buffer used instead of tib variable old-tib variable old->in variable old-state H Variables which remember the old state of the input stream. **** saveforth.f: variable fd H **** showdefer.f : defer@ ( cfa-of-deferred-word -- cfa-of-its-target ) H Finds the cfa of the word the the deferred word executes. **** strings.f: : ("lit ( -- str ) H A run-time word which returns the address of a literal string that is compiled in-line. Also skips past the string. **** time.f: struct ( tm struct returned by 4.2 localtime call) H /l field tm_sec H /l field tm_min H /l field tm_hour H /l field tm_mday H /l field tm_mon H /l field tm_year H /l field tm_wday H /l field tm_yday H /l field tm_isdst H : (today ( -- timeval-struct-addr ) H Gets the timeval structure from Unix. : ," ( --string ) H create months H An array containing 12 pointers. Each pointer is the address of a string representing the name of a month. : 2.r ( n -- ) H Print n in a field 2 characters wide, 0 padding if necessary. **** words.f: : largest (s addr n -- addr' val ) H An implementation word used to scan the dictionary in most-recently-defined order, considering the fact that the dictionary is hashed and thus contains several chains of words. **** terminals.f: /token 3 * constant /termitem H code jumpto ( new-ip -- ) H A "goto" for high-level forth. constant /termctl H Constant leaving the size of a terminal control array. : dumb-del H Delete function for a dumb terminal.