\ SYSTEM INDEX 23may84hjh***************************************************************** ** FORTH-83 MODEL SYSTEM INDEX ** ** FORTH INTEREST GROUP ** ORANGE COUNTY CHAPTER ** ** WIL BADEN NOSHIR JESUNG ** 339 PRINCETON DRIVE 7121 NIMROD DRIVE ** COSTA MESA HUNTINGTON BEACH ** CA. 92626 CA. 92647 ** ** (714) 546-9894 (714) 842-3832 ** *****************************************************************\ Initial load screen ( 2 2 REDIRECT MAIN) 11 VIEWS INDEX.BLK ( view-file number ) 3 LOAD ( MY vocabulary) 4 LOAD ( system-index) 10 LOAD ( ZAP ) 11 LOAD ( printer routines) INIT-PR : .SYSTEM-INDEX (S --) 16 LOAD ; ( .SYSTEM-INDEX) \ directory 08jun84hjh.SYSTEM-INDEX 1 #LENGTH 11 #MARGIN 11 (.NAME) 9 (FORM) 12 (SORTED) 5 (SWORDS) 8 +CR 14 .NAME 6 .NAMES 6 10CPI 15 12CPI 15 17CPI 15 ?LINE 7 ?PAGE 13 ?TAB 7 ESC 14 FORM 12 ID< 6 INIT-PR-NEC 15 BOTTOM 12 NAMES 8 NON-INCREMENTAL-PRINTING 15 PR#LENGTH 11 PR#LINE 11 PR#MARGIN 11 PR#OUT 11 PRECEDES 4 PRINT 12 PRINTER 11 QUICK 4 SORT 5 SORTED 5 SWORDS 9 SYSTEM-INDEX 9 TERMINAL 11 VIEW.ID 7 ZAP 10 \ MY vocbulary 28may84hjh ONLY FORTH ALSO VOCABULARY MY MY ALSO DEFINITIONS \ SORTED WORDS 03jun84hjh DEFER PRECEDES ( a1,a2 -- f) : QUICK ( a[m],a[n] -- ) 2DUP OVER - 2/ -2 AND + @ >R 2DUP SWAP BEGIN BEGIN DUP @ R@ PRECEDES WHILE 2+ REPEAT SWAP BEGIN R@ OVER @ PRECEDES WHILE 2- REPEAT SWAP 2DUP U< NOT IF 2DUP 2DUP @ >R @ SWAP ! R> SWAP ! SWAP 2- SWAP 2+ THEN 2DUP U< UNTIL R> DROP ROT 2OVER 2OVER - + > IF 2SWAP THEN 2DUP U< IF RECURSE ELSE 2DROP THEN 2DUP U< IF RECURSE ELSE 2DROP THEN ; --> \ SORTED WORDS 2JULY84JAP : SORT (S a,n -- ) ?DUP 0= ABORT" nothing to sort. " 1- 2* OVER + QUICK ; : (SORTED) (S a,n -- ) R> DUP 2+ >R @ IS PRECEDES SORT ; : SORTED (S a,n -- ) STATE @ IF COMPILE (SORTED) ELSE ' IS PRECEDES SORT THEN ; IMMEDIATE --> \ SORTED WORDS 07jun84hjh: ID< (S nfa1,nfa2 -- f ) 2DUP COUNT 31 AND OVER + SWAP DO 1+ DUP C@ I C@ - IF C@ 127 AND I C@ 127 AND - DUP IF 0< SWAP ROT DROP THEN 0= LEAVE THEN LOOP IF C@ 31 AND SWAP C@ 31 AND > THEN ; DEFER .NAME ( nfa -- ) : .NAMES (S -- adr,n ) 0 DO DUP @ .NAME 2+ KEY? ?LEAVE LOOP DROP ; --> \ SORTED WORDS 07jun84hjh : ?LINE (S n -- ) #OUT @ + RMARGIN @ > IF CR THEN ; : ?TAB (S n -- ) #OUT @ NEGATE SWAP MOD SPACES ; : VIEW.ID (S nfa -- ) 19 ( column width ) DUP ?TAB OVER C@ 31 ( name length mask ) AND 7 ( space for file# & screen# ) + RMARGIN @ ROT MOD + ?LINE DUP .ID NAME> >VIEW @ 4896 ( unpack file# and screen# ) /MOD . . ; --> \ SORTED WORDS 07jun84hjh: NAMES (S -- adr,n ) CR CONTEXT @ BODY> >NAME .ID 2 SPACES PAD C/L + DUP #THREADS 0 DO CONTEXT @ I 2* + BEGIN @ ?DUP WHILE DUP >R L>NAME OVER ! 2+ R> REPEAT LOOP OVER - 2/ ; : (SWORDS) (S -- ) NAMES DUP . ." names defined." CR 2DUP SORTED ID< .NAMES ; --> \ SORTED WORDS 07jun84hjh: (.NAME) (S nfa -- ) 13 ( column width ) DUP ?TAB OVER C@ 31 ( name length mask ) AND 1+ ( space for extra blank ) RMARGIN @ ROT MOD + ?LINE .ID ; : SWORDS (S -- ) ['] (.NAME) IS .NAME (SWORDS) ; : SYSTEM-INDEX (S -- ) ['] VIEW.ID IS .NAME (SWORDS) ; \ ZAP 07jun84hjh: ZAP (S -- ) BL WORD DUP CONTEXT @ HASH BEGIN DUP >R @ DUP WHILE L>NAME OVER C@ OVER C@ 63 ( length mask ) AND = IF 2DUP BEGIN SWAP 1+ SWAP 1+ OVER C@ OVER C@ <> UNTIL C@ 127 ( char mask ) AND SWAP C@ = IF N>LINK TUCK TUCK @ R> ! CURRENT @ HASH DUP @ ROT ! ( lfa,voc ) ! EXIT THEN THEN R> DROP N>LINK REPEAT R> 2DROP .ID ." ? " ; \ printing routines 07jun84hjh VARIABLE PR#OUT VARIABLE PR#LINE VARIABLE PR#MARGIN 8 PR#MARGIN ! VARIABLE PR#LENGTH 132 PR#MARGIN @ - PR#LENGTH ! VARIABLE #LENGTH RMARGIN @ #LENGTH ! VARIABLE #MARGIN LMARGIN @ #MARGIN ! --> \ printing routines 07jun84hjh : PRINTER ( : turn printer on ) PRINTING ON ['] (PRINT) IS EMIT PR#OUT @ #OUT ! PR#LINE @ #LINE ! PR#LENGTH @ RMARGIN ! PR#MARGIN @ LMARGIN ! ; : TERMINAL ( : turn printer off ) ['] (EMIT) IS EMIT PRINTING OFF #MARGIN @ LMARGIN ! #LENGTH @ RMARGIN ! #LINE @ PR#LINE ! #OUT @ PR#OUT ! ; : PRINT ( : print rest of input ) PRINTER INTERPRET TERMINAL ; --> \ printing routines 08jun84hjh 59 VARIABLE BOTTOM BOTTOM ! : (FORM) (S -- ) PR#LINE OFF ; DEFER FORM ' FORM IS FORM : LINES (S n -- ) BOTTOM @ #LINE @ - MIN 0 MAX 0 ?DO CR LOOP ; : ?PAGE (S n -- : newpage if less than n lines left on page ) #LINE @ + BOTTOM @ > IF PAGE THEN ; \ printing routines 08jun84hjh : +CR (S -- ) CRLF 0 ?PAGE LMARGIN @ SPACES #OUT OFF ; ' +CR IS CR : ESC (S -- : emit escape control character ) 27 ( esc ) EMIT ; --> \ printing routines for NEC8023A printer 2JULY84JAP EXIT : NON-INCREMENTAL-PRINTING (S -- ) ( need for proper printing ) PRINTER ESC ASCII ] EMIT TERMINAL ; : 17CPI (S -- ) PRINTER ESC ASCII Q EMIT TERMINAL ; : 12CPI (S -- ) PRINTER ESC ASCII E EMIT TERMINAL ; : 10CPI (S -- ) PRINTER ESC ASCII N EMIT TERMINAL ; : INIT-PR-NEC (S -- ) ( Initialize for NEC8023A printer ) 17CPI NON-INCREMENTAL-PRINTING ; ' INIT-PR-NEC IS INIT-PR \ load screen for printing F83 system-index 2july84japPRINT FORTH ZAP MY SYSTEM-INDEX 3 LINES FORTH DEFINITIONS MY ZAP MY EDITOR SYSTEM-INDEX 3 LINES 7 ?PAGE ASSEMBLER SYSTEM-INDEX 3 LINES HIDDEN SYSTEM-INDEX 3 LINES SHADOW SYSTEM-INDEX 3 LINES 7 ?PAGE DOS SYSTEM-INDEX 3 LINES ROOT SYSTEM-INDEX 3 LINES BUG SYSTEM-INDEX 3 LINES USER SYSTEM-INDEX 3 LINES ONLY DEFINITIONS FORTH ALSO MY ALSO : JUNK ; FORGET JUNK SYSTEM-INDEX 3 LINES MY DEFINITIONS --> \ load screen for printing F83 system-index 2JULY84JAP8 ?PAGE CR CR CR .( file# filename.typ ) CR .( 1 META80.BLK ) CR .( 2 KERNAL.BLK ) CR .( 3 EXTEND80.BLK ) CR .( 4 CPU8080.BLK ) CR .( 5 UTILITY.BLK ) CR .( 11 INDEX.BLK ) 3 LINES SYSTEM-INDEX PAGE \ SYSTEM INDEX 2JULY84JAP \ FIRST ISSUE 19-NOV-83 BY WIL BADEN & NOSHIR JESUNG \ MODIFIED FOR REV 2.0.0 BY JOHN A. PETERS To use this system-index type the following from system prompt A> f83 INDEX.BLK after the F83 is loaded and gives prompt ok type OK This will load the initial load screen, which in turn loads the rest of the screens. Change INIT-PR for your printer and have the printer ready at top of form, do a CTRL-P and type INIT-PR .SYSTEM-INDEX This will print out the whole system-index. \ Initial load screen 08jun84hjh REDIRECT MAIN will be used with the directory system (future) This stores % as the VIEW# for ORANGE1A.FIG file in an array These will load the words in MY vocabulary to enable one to print the system-index for the forth 83 model by vocabulary sorted alphabetically. INIT-PR initializes the printer. Change as required. .SYSTEM-INDEX will load screen 16 and 17 , printing the words along with two numbers. The first number denotes the file on which this word belongs and the second informs you which screen number this word was defined. \ directory 28may84hjh These are the words which are defined in this file along with their screen numbers. In future release of the directory system we will show you how to use this directory screen. \ MY vocbulary 28may84hjh This defines the order of search vocabularies. Define my as a new vocabulary. All words which are defined henceforth will be in MY vocabulary. \ SORTED WORDS 03jun84hjh PRECEDES (S a,a -- f) for vectored execution in QUICK> QUICK (S a[m],a[n] -- ) This is C.A.R.. Hoare's quicksort algorithm using vectored execution for the comparison function. It works by dividing the array into two parts, every element in one part less or equal every element in the other part, then reexecuting itself, i.e. recursively, on each part. Recursion is terminated when there are no more than two elements in an array. a[m] is the address of the first locator; a[n] is the address of the last locator. 03jun84hjh SORT (S a,n -- ) This is used as a tag sort. It is used to order an array of locators, i.e. address,pointers,record numbers, etc., of data to be sorted. SORT requires the address of first cell of the array and the number of locators in the array to be on the stack. PRECEDES must be initialized to a comparison function. (SORTED) (S a,n -- ) compiled by SORTED SORTED (S a,n -- ) Sets PRECEDES to and sorts n cells beginning at address a. \ SORTED WORDS 07jun84hjhID< (S nfa1,nfa2 -- f ) This compares the namefields of two words and leaves a true flag on the stack when nfa1 precedes nfa2. .NAME (S nfa -- ) is deferred. .NAME will print the word whose nfa is on the stack. .NAMES (S a,n -- ) This uses .NAME to print n names whose adresses start at address a. \ SORTED WORDS 08jun84hjh ?LINE (S n -- ) ( original recipe) If the word which is going to be printed needs more space than what the right margin allows, it does a CR, else nothing. ?TAB (S n -- ) Moves the cursor to a multiple of n columns from the start of the line, if not already there. VIEW.ID (S nfa -- ) This prints the ID based on the column width, including the file number and screen number, and does a CR if needed. \ SORTED WORDS 07jun84hjhNAMES (S -- adr,n ) This word copies the nfa's in the CONTEXT vocabulary to an array in PAD, and leaves the address of the first cell of the array and the number of locators on the stack. This address and number is used by SORTED to do the sort. (SWORDS) (S -- ) This prints the first message of how many words are defined in the CONTEXT vocabulary, and then sorts and lists. \ SORTED WORDS 07jun84hjh(.NAME) (S -- adr,n ) This is similar to VIEW.ID but does not print the file number. SWORDS (S -- ) This prints only the word sorted alphabetically. SYSTEM-INDEX (S -- ) This prints the word, file number, and the screen which the word belongs to. \ ZAP 07jun84hjhZAP (S -- ) This word takes out the word which follows from the CONTEXT vocabulary and puts it into the CURRENT vocabulary. \ printing routines 07jun84hjh PR#OUT is similar to #OUT but for the printer. PR#LINE is a variable which has number of printer lines printed. PR#MARGIN is the variable which has the printer left margin. PR#LENGTH variable keeps the logical length of the printed line #LENGTH variable keeps the original RMARGIN before printing. #MARGIN variable keeps the original LMARGIN before printing. \ printing routines 07jun84hjh : PRINTER (S --: turn printer on ) This command turns the printer on, puts all the printer variables in their regular counterpart variables. TERMINAL (S --: turn printer off turn console on ) This commans turns the printer off restores the variables and EMIT is revectored to console. PRINT (S --: print rest of the input ) This vectors the rest of the input for printer output. At the end of the input stream it returns to the terminal. \ printing routines 08jun84hjh BOTTOM is a variable indicating number of lines per page. (FORM) (S -- ) This initializes the printer variables for the top of the form. LINES (S -- ) This does n CR's, but not past the bottom of the page. ?PAGE (S -- ) This does a new page if less than n lines left on the page. \ printing routines 08jun84hjh +CR (S -- ) This is a smart CR which does FORM-FEED if at the bottom of the page otherwise does a CR and sets the variables. +CR is vectored as CR ESC (S -- ) This emits an escape character. \ printing routines for NEC8023A printer 08jun84hjh NON-INCREMENTAL-PRINTING (S -- ) This sets the NEC8023A printer in an nonincremental mode. 17CPI (S -- ) sets the printer for 17 char per inch ( for NEC8023A ) 12CPI (S -- ) sets the printer for 12 char per inch ( for NEC8023A ) 10CPI (S -- ) sets the printer for 10 char per inch ( for NEC8023A ) INIT-PR-NEC (S -- ) Initializes the NEC8023A printer. INIT-PR-NEC is vectored to INIT-PR \ load screen for printing F83 system-index 08jun84hjhBefore printing this will zap MY out of FORTH Print system-index for FORTH and 3 blank lines. Zap MY in FORTH back where we can find it. Point to EDITOR vocabulary, print words. Point to ASSEMBLER vocabulary, print words. Point to HIDDEN vocabulary, print words. Point to SHADOW vocabulary, print words. Point to CP/M vocabulary, print words. Point to FILES voocabulary, print words. Point to BUG vocabulary, print words. Point to USER vocabulary, print words. Define proper order making ONLY the current vocabulary. Make ONLY the context vocabulary. Print system-index for ONLY. \ load screen for printing F83 system-index 08jun84hjh Print message which file number pertains to filename. File number 1 is META80.BLK File number 2 is EXTEND80.BLK File number 3 is CPU8080.BLK File number 4 is UTILITY.BLK File number 5 is ORANGE1A.FIG Print SYSTEM-INDEX of MY vocabulary.