Benutzer-Werkzeuge

Webseiten-Werkzeuge


projects:help.blk

On line HELP system

Screen 0 not modified     
 0 \ Help System                                  11:43JWB03/25/86 
 1 \ Last change:   Screen  009                   11:45JWB03/25/86 
 2                                                                 
 3                                                                 
 4                                                                 
 5                                                                 
 6                                                                 
 7                                                                 
 8                                                                 
 9                                                                 
10                                                                 
11                                                                 
12                                                                 
13                                                                 
14                                                                 
15                                                                 


Screen 1 not modified     
 0 \ HELP SYSTEM LOAD SCREEN                      11:43JWB03/25/86 
 1                                                                 
 2  CR .( Loading HELP system.)                                    
 3                                                                 
 4   2  9   THRU                                                   
 5                                                                 
 6                                                                 
 7                                                                 
 8                                                                 
 9                                                                 
10                                                                 
11                                                                 
12                                                                 
13                                                                 
14                                                                 
15                                                                 


Screen 2 not modified     
 0 \ HELP-0 HBLOCK PBLOCK DONE? IPROMPT MAXPR     11:07JWB12/01/85 
 1 ONLY EDITOR ALSO FORTH ALSO HIDDEN DEFINITIONS                  
 2   VARIABLE #PROMPT     \ Prompt # and index into help screens.  
 3   VARIABLE HBLOCK      \ Contains block # of first help screen. 
 4   VARIABLE FINI        \ Flag set true when it's time to quit.  
 5   VARIABLE MAXP        \ Contains max number of help screens.   
 6 0 CONSTANT IPROMPT     \ Initial Prompt number.                 
 7                                                                 
 8 \ Leave number of last prompt.                                  
 9 : MAXPROMPT ( --  n )                                           
10         MAXP @ ;                                                
11                                                                 
12 \ Leave true flag if user responds positively.                  
13 : (Y/N?)  ( --  flag )                                          
14   ." Yes/No " KEY DUP 223 ( $DF = 11011111 to allow lower case) 
15   AND ASCII Y = SWAP BL = OR ;                                  


Screen 3 not modified     
 0 \ HELP-1  (Y/N?)  (LIST) .HELP                 10:15JWB12/01/85 
 1 \ List a screen without its header and line numbers.            
 2 : (LIST) ( n  -- )                                              
 3         SCR ! CLEARSCREEN                                       
 4         16 0 DO 8 I 3 + AT                                      
 5                 SCR @ BLOCK I C/L * +                           
 6                 C/L -TRAILING >TYPE CR                          
 7              LOOP ;                                             
 8                                                                 
 9 \ Display the current help screen.                              
10 : .HELP  ( --  -- )                                             
11         #PROMPT @ HBLOCK @ 1+ + (LIST)                          
12         20 21 AT BEEP ." More help? "                           
13         (Y/N?)   NOT  FINI ! ;                                  
14 : WHITE 112  ATRIB ! ;  \ Set background to White.              
15 : BLACK  15  ATRIB ! ;  \ Set backbround to black.              


Screen 4 not modified     
 0 \ HELP-2 PROMPT-ADR .PROMPT-CUR +.PROMPT.C     10:10JWB12/01/85 
 1 \ Compute address and character count for prompt number n.      
 2 : PROMPT-ADR ( n  adr count )                                   
 3         32 * B/BUF /MOD                                         
 4         HBLOCK @ + BLOCK         \  Note   the  BLOCK !!!       
 5         SWAP + 32 -TRAILING ;                                   
 6 \ Position cursor at correct position for current prompt and    
 7 \ leave current prompt number n.                                
 8 : .PROMPT-CUR  ( --  n )                                        
 9         #PROMPT @ DUP 3 /MOD                                    
10         SWAP 25 * SWAP  AT ;                                    
11 \ Increment prompt number by n and position cursor and leave new
12 \ prompt number as n'.                                          
13 : +.PROMPT-CUR  ( n   n' )                                      
14         #PROMPT @ + MAXPROMPT MOD #PROMPT !                     
15         .PROMPT-CUR  ;                                          


Screen 5 not modified     
 0 \ HELP-3 .PROMPT .RPROMPT +.PROMPT .HPROMP     10:21JWB12/01/85 
 1 \ Display prompt number n at current cursor position.           
 2 : .PROMPT ( n  -- )                                             
 3         PROMPT-ADR  VTYPE ;                                     
 4 \ As above but with blue background.                            
 5 : .RPROMPT ( n  -- )                                            
 6         PROMPT-ADR WHITE VTYPE BLACK ;                          
 7 \ Increment prompt number by n amd move to new prompt.          
 8 : +.PROMPT ( n  -- )                                            
 9         .PROMPT-CUR .PROMPT                                     
10        +.PROMPT-CUR .RPROMPT ;                                  
11 \ Move to home position and display prompt number 0 .           
12 : .HPROMPT ( --  -- )                                           
13         #PROMPT OFF 0 +.PROMPT ;                                
14 : .EPROMPT ( --  -- )  \ Move to last prompt.                   
15         MAXPROMPT 1- #PROMPT ! 0 +.PROMPT ;                     


Screen 6 not modified     
 0 \ HELP-4                                       11:00JWB12/01/85 
 1 : .LPROMPT ( --  -- )  \ Move to last prompt on line.           
 2         2 #PROMPT @ 3 MOD - +.PROMPT ;                          
 3 : .FPROMPT ( --  -- )  \ Move to first prompt on line.          
 4         MAXPROMPT #PROMPT @ 3 MOD - +.PROMPT ;                  
 5                                                                 
 6 : MENU  ( --  -- )                                              
 7         #PROMPT @ CLEARSCREEN MAXPROMPT 0                       
 8         DO I #PROMPT ! .PROMPT-CUR .PROMPT LOOP 9 22 AT         
 9         ." Select with arrow keys and then press RETURN "       
10         #PROMPT ! .PROMPT-CUR .RPROMPT ;                        
11                                                                 
12 : SCAN  ( false   flag )                                        
13         200 0 DO DROP (KEY?) DUP ?LEAVE LOOP ;                  
14                                                                 
15                                                                 


Screen 7 not modified     
 0 \ HELP-5                                       11:04JWB12/01/85 
 1 \ Same as PCKEY in line editor.                                 
 2 : HCKEY ( --   n flag )                                         
 3         {KEY}                                                   
 4             ?DUP IF TRUE ELSE {KEY} FALSE THEN ;                
 5                                                                 
 6                                                                 
 7 : FKEY                                                          
 8         (KEY?) IF HCKEY ELSE                                    
 9         BEGIN FALSE .PROMPT-CUR .PROMPT SCAN                    
10               .PROMPT-CUR .RPROMPT DUP NOT                      
11               IF SCAN THEN                                      
12         UNTIL .PROMPT-CUR  .PROMPT  HCKEY  THEN ;               
13                                                                 
14                                                                 
15                                                                 


Screen 8 not modified     
 0 \ HELP-6                                       10:22JWB12/01/85 
 1 : CHOOSE                                                        
 2   BEGIN FKEY  IF DUP 13 <> ELSE TRUE THEN                       
 3   WHILE CASE                                                    
 4    72 OF MAXPROMPT 3 - +.PROMPT ENDOF   \ Up arrow              
 5    73 OF MAXPROMPT 9 - +.PROMPT ENDOF   \ Pg up                 
 6    71 OF             .HPROMPT   ENDOF   \ Home key              
 7    79 OF             .EPROMPT   ENDOF   \ End  key              
 8    75 OF MAXPROMPT 1-  +.PROMPT ENDOF   \ Left arrow            
 9   115 OF     .FPROMPT   ENDOF           \ Control left arrow    
10    77 OF  1 +.PROMPT    ENDOF           \ Right arrow           
11   116 OF     .LPROMPT   ENDOF           \ Control right arrow   
12    80 OF  3 +.PROMPT    ENDOF           \ Down arrow            
13    81 OF  9 +.PROMPT    ENDOF           \ Pg down               
14         ENDCASE REPEAT DROP ;                                   
15                                                                 


Screen 9 not modified     
 0 \ HELP-7                                       11:45JWB03/25/86 
 1 : (HELP)   ( scr  nmax   -- )                                   
 2         MAXP ! HBLOCK !    FINI OFF                             
 3         IPROMPT #PROMPT ! MENU                                  
 4         BEGIN   MENU   CHOOSE #PROMPT @                         
 5                 IF .HELP  THEN                                  
 6                 FINI @ #PROMPT @ 0= OR                          
 7         UNTIL   0 22 AT                                         
 8         #PROMPT @ IS IPROMPT  ;                                 
 9 ONLY FORTH ALSO DOS ALSO HIDDEN ALSO FORTH DEFINITIONS          
10 : HELP  ( --  -- )                                              
11         SCR @  FILE @ FLUSH                                     
12   ( B: )  HELP.BLK  OPEN-FILE                                   
13         [ BLK @ 1+ ] LITERAL   63  (HELP)                       
14         !FILES  OPEN-FILE SCR ! ;                               
15 ONLY FORTH ALSO DEFINITIONS                                     


Screen 10 not modified     
 0 EXIT HELP                       SCREEN VIEWING                  
 1 PRINTER AND WORD VIEWING        NO. DISPLAYING WORDS            
 2 COLD FORGET  EMPTY BYE          HEX AND DECIMAL                 
 3 CONDITIONALS                    MORE CONDITIONALS               
 4 SCREEN EDITING                  STAR-SLASH THE SCALAR           
 5 INFINITE LOOPS                  INDEFINITE LOOPS                
 6 ANOTHER LOOP                    LEAVING LOOPS EARLY             
 7 BASIC STACK OPERATORS           FURTHER STACK OPERATORS         
 8 RETURN STACK                    VIRTUAL MEMORY                  
 9 BLOCK AND UPDATE                MEMORY OPERATORS                
10 MORE MEMORY OPERATORS           WORD DEFINITION STRUCTURE       
11 VOCABULARY:ROOT:ONLY            DIVISION                        
12 STRINGS                         STRING:COUNT:TYPE:EXPECT        
13 MOVING STRINGS                  BUFFER                          
14 HIDE:REVEAL:IMMEDIATE           NUMBER FORMATING                
15 CASE STATEMENT                  VARIABLES AND CONSTANTS         


Screen 11 not modified     
 0 MORE VARIABLES & CONST.         MULTITASKING                    
 1 TASK USER VARIABLES   .         PAUSE  RESTART                  
 2 SLEEP WAKE STOP                 MULTI SINGLE                    
 3 X                               X                               
 4 X                               X                               
 5 XMETA COMPILER                  X                               
 6 X                               X                               
 7 XDEMOS                          X                               
 8 XCRASH RECOVERY                 X                               
 9 X8086 CPU REGISTERS             X                               
10 LEAVING FORTH                   STARTING FORTH P 50- 83         
11 STARTING FORTH P110-112         STARTING FORTH P119-135         
12 STARTING FORTH P137-143         STARTING FORTH P161-174         
13 STARTING FORTH P177-247         X                               
14 X                               X                               
15 X                               X                               


Screen 12 not modified     
 0 Screen Viewing Help                                             
 1                                                                 
 2 L               Lists current screen                            
 3 B L             Lists previous screen                           
 4 N L             Lists next screen                               
 5 A L             Lists the shadow screen                         
 6                                                                 
 7 n LIST          Lists screen n                                  
 8 n BROWSE        Use editor to browse screens                    
 9                                                                 
10 n1 n2 INDEX     Lists the first line of screens n1 thru n2      
11                                                                 
12 VIEW {word}     Browse the source definition for {word}         
13                                                                 
14                                                                 
15                                                                 


Screen 13 not modified     
 0 Printer and word viewing help                                   
 1                                                                 
 2 PRINTING ON             Send output to printer, make sure its on
 3 PRINTING OFF            Send output to screen only              
 4                                                                 
 5 WORDS                   List words in the context vocabulary.   
 6                                                                 
 7 ONLY FORTH WORDS        Lists all words in FORTH                
 8                                                                 
 9 ONLY EDITOR WORDS       Lists all words in EDITOR               
10                                                                 
11                                                                 
12                                                                 
13                                                                 
14                                                                 
15                                                                 


Screen 14 not modified     
 0 NUMBER DISPLAYING WORDS                                         
 1    Single signed 16bit numbers      -32768  - 32767             
 2    .    ( n   -- )    Display signed 16bit # followed by space. 
 3    .R   ( n w  -- )   Display # right justified in w wide field.
 4                                                                 
 5 Single unsigned 16bit numbers.      0  - 65535                  
 6    U.   ( u  -- )     Display unsigned 16bit # followed by space
 7    U.R  ( u w   -- )  Display # right justified in w wide field 
 8                                                                 
 9 Double signed 32bit numbers   -2,147,483,648  - 2,147,483,647   
10    D.   ( d  -- )     Display signed 32bit # followed by a space
11    D.R  ( d w   -- )  Display # right justified in w wide field 
12                                                                 
13 Double unsigned 32bit numbers.      0  - 4,294,967,296          
14    UD.   ( ud  -- )   Display unsigned 32bit # followed by space
15    UD.R  ( ud w  -- ) Display # right justified in w wide field 


Screen 15 not modified     
 0 \COLD FORGET  EMPTY  BYE                                        
 1                                                                 
 2                                                                 
 3                                                                 
 4                                                                 
 5    FORGET <name>   Remove <name> and all following words        
 6                    from the dictionary.                         
 7                                                                 
 8                                                                 
 9    EMPTY           Remove all new words added since this        
10                    session started                              
11                                                                 
12                                                                 
13    BYE             Exit Forth and return to DOS                 
14                                                                 
15                                                                 


Screen 16 not modified     
 0 HEX AND DECIMAL                                                 
 1                                                                 
 2                                                                 
 3         HEX     ( --   -- ) Set the system number BASE to 16    
 4                                                                 
 5         DECIMAL ( --   -- ) Set the system number BASE to 10    
 6                                                                 
 7         You could also add the following words to your system.  
 8                                                                 
 9 : OCTAL ( --  -- )  \ Set system number base to 8.              
10         8 BASE ! ;                                              
11                                                                 
12 : BINARY ( --  -- )  \ Set system number base to 2.             
13         2 BASE ! ;                                              
14                                                                 
15                                                                 


Screen 17 not modified     
 0 CONDITIONALS                                                    
 1         tf = 1111111111111111  binary or base 2                 
 2         ff = 0000000000000000  binary or base 2                 
 3     TRUE   ( --   tf )    Leave true flag on top of the stack   
 4     FALSE  ( --   ff )    Leave false flag on top of the stack  
 5    =    ( n m  flag )     Leave tf if n = m , otherwise ff      
 6    <>   ( n m  flag )     Leave tf if n<> m , otherwise ff      
 7    <    ( n m  flag )     Leave tf if n < m , otherwise ff      
 8    >    ( n m  flag )     Leave tf if n > m , otherwise ff      
 9                                                                 
10    0=   ( n    flag )     Leave tf if n = 0 , otherwise ff      
11    0<>  ( n    flag )     Leave tf if n<> 0 , otherwise ff      
12    0 <  ( n    flag )     Leave tf if n < 0 , otherwise ff      
13    0 >  ( n    flag )     Leave tf if n > 0 , otherwise ff      
14    ?DUP ( n    n (n))     Duplicate n if n is non zero          
15    NOTE IF TRIGGERS ON ZERO                                     


Screen 18 not modified     
 0 MORE CONDITIONALS                                               
 1                 NOTE THESE OPERATORS WORK AT THE BINARY LEVEL   
 2                                                                 
 3    AND  ( f1 f2   flag ) Leave tf only if f1 and f2 are true    
 4                                                                 
 5    OR   ( f1 f2   flag ) Leave tf if either f1 or f2 are true   
 6                                                                 
 7    XOR  ( f1 f2   flag ) Leave tf if f1=tf or f2=tf but not both
 8                                                                 
 9    NOT  ( f1  not-flag ) Reverse the flag f1                    
10 NOTE : Starting FORTH  NOT is the same as F83  0=               
11        Starting FORTH  NOT is different than F83 NOT            
12        F83 NOT operates on each of a numbers 16 bits            
13        F83 NOT leaves a false flag ( zero ) only if it          
14        operates on a true flag -1111111111111111 binary         
15        F83 NOT is not the same as 0=                            


Screen 19 not modified     
 0 SCREEN EDITING                                                  
 1                                                                 
 2        FILE?      Display current screen file                   
 3        DEFAULT    Revert to default screen file                 
 4                   used when FORTH was started                   
 5                                                                 
 6        OPEN <name>.BLK   Open an existing screen file           
 7                                                                 
 8        CREATE-FILE <name>.BLK  ( n )                            
 9                   Create a new screen file <name>.BLK           
10                   with  n  blank screens                        
11         MORE      Add  n  blank screens to the end of           
12                   the current screen file                       
13         CAPACITY  Leave number of screens in the current        
14                   screen file                                   
15                                                                 


Screen 20 not modified     
 0 STAR-SLASH THE SCALAR                                           
 1                                                                 
 2     */   ( a b c   ab/c )  Perform multiplication and then      
 3     division. Star-slash multiplies 16bit a  and  b  to form    
 4     a 32bit intermediate result which is then divided by 16bit  
 5     c  to give a 16bit result. The 32bit intermediate product   
 6     ensures accurate results when multipying by fractions.      
 7                                                                 
 8                                                                 
 9                                                                 
10                                                                 
11                                                                 
12                                                                 
13                                                                 
14                                                                 
15                                                                 


Screen 21 not modified     
 0 INFINITE LOOPS                                                  
 1                                                                 
 2         The infinite loop with no exit. This is recommended     
 3         only for an end user application.                       
 4                                                                 
 5           ... (step 1)   BEGIN   (step 2)  AGAIN  (step 3) ...  
 6                                                                 
 7         step 1 is executed once; step 2 is repeated forever.    
 8         Note: step 3 is never executed.                         
 9                                                                 
10                                                                 
11                                                                 
12                                                                 
13                                                                 
14                                                                 
15                                                                 


Screen 22 not modified     
 0 INDEFINITE LOOPS                                                
 1                                                                 
 2         In the indefinite loop the main action is repeated      
 3         until a condition is true. Step 1 is executed once,     
 4         step 2 is executed and (condition) is tested. If        
 5         condition is false step 2 is executed again, if         
 6         condition is true then step 3 is executed. Note         
 7         that step 3 following the loop will be executed         
 8         when loop is exited .                                   
 9                                                                 
10                                                                 
11               ... (step 1)   BEGIN   (step 2)                   
12                                      (condition)                
13                              UNTIL   (step 3)   ...             
14                                                                 
15                                                                 


Screen 23 not modified     
 0 ANOTHER LOOP                                                    
 1                                                                 
 2         Indefinite loop - another form                          
 3         In this form step 1 is executed once. Step 2 is         
 4         executed if condition is true do step 3 and repeat      
 5         starting with step 2 if condition is false leave loop   
 6         and do step 4.                                          
 7                                                                 
 8         ... (step 1)   BEGIN   (step 2)                         
 9                                (condition)                      
10                        WHILE   (step 3)                         
11                        REPEAT  (step 4)  ...                    
12                                                                 
13                                                                 
14                                                                 
15                                                                 


Screen 24 not modified     
 0 LEAVING LOOPS EARLY                                             
 1 Execute step 1. Repeat loop executing step 2 and step 4 on each 
 2 pass - except that if condition is true before loop is finished 
 3 execute step 3 and leave loop to execute step 5. Note step 4    
 4 will not be executedif we leave the loop early.                 
 5                                                                 
 6    ...     (step 1)   DO     (step 2)                           
 7                              (condition) IF (step 3) LEAVE THEN 
 8                              (step 4)                           
 9                       LOOP   (step 5)   ...                     
10 This is an alternative form if step 3 is not required.          
11    ...     (step 1)   DO     (step 2)                           
12                              (condition)  ?LEAVE                
13                              (step 4)                           
14                       LOOP   (step 5)   ...                     
15 NOTE:EXIT CANNOT BE USED IN DO LOOPS -IT RUINS THE RETURN STACK 


Screen 25 not modified     
 0 BASIC STACK OPERATORS                                           
 1    DROP  ( n   -- )      Drop top number on data stack          
 2    SWAP  ( n m   m n )   Swap top two numbers on data stack     
 3    DUP   ( n  n n )      Duplicate top number on data stack     
 4    OVER  ( n m   n m n ) Make copy of second item to top of     
 5    ROT   ( a b c b c a ) Rotate third item to the top of stack  
 6   -ROT   ( a b c c a b ) Rotate in opposite direction           
 7    PICK  ( ? n  ? nth  ) Copy nth item to top of stack (0 based)
 8    ROLL  ( ? n  ? nth  ) Rotate nth item to top (0 based)       
 9    NIP   ( n m   m )     Discard second item on data stack      
10    TUCK  ( n m   m n m ) Push copy of top under second item     
11    3DUP  ( a b c  a b c a b c )   Make a copy of the top 3 items
12    2DROP ( dn   -- )     Drop double number from the top        
13    2SWAP ( dn dm   dm dn ) Swap the top two double numbers      
14    2DUP  ( dn   dn dn )  Make another copy of top double number 
15    2OVER ( dn dm   dn dm dn ) Copy second double number to top  


Screen 26 not modified     
 0 FURTHER STACK OPERATORS                                         
 1         1+      Increment top stack item by                     
 2                                                                 
 3         2+      Increment top stack iten by 2                   
 4                                                                 
 5         1-      Decrement top stack item by 1                   
 6                                                                 
 7         2-      Decrement top stack item by 2                   
 8                                                                 
 9         2*      Multiply  top stack item by 2                   
10                                                                 
11         2/      Divide    top stack item by 2                   
12                                                                 
13         ABS     Replace top item by its absolute value          
14                                                                 
15         NEGATE  Negate top stack item                           


Screen 27 not modified     
 0 RETURN STACK                                                    
 1  >R  R> and  R@ are for accessing the return stack.These words  
 2 are very dangerous!!. Do NOT test or execut them interactively. 
 3 They can only be used within colon definitions.                 
 4   Note: D) indicates data stack,  R) indicates return stack.    
 5 Transfer top data stack item to return stack.                   
 6         >R   ( n   -- D )   ( --   n R )                        
 7 Transfer top return stack item to data stack.                   
 8         R>   ( --   n D )   ( n   -- R )                        
 9 Copy top return stack item to data stack.                       
10         R@   ( --   n D )   ( n    n R )                        
11                                                                 
12 RULES:                                                          
13  1. Each use of >R must be balanced with a corresponding R>.    
14  2. Do not use >R R> and R@ within DO ... LOOPS. Loop control   
15     info is kept on the return stack and could be destroyed.    


Screen 28 not modified     
 0 VIRTUAL MEMORY                                                  
 1 F83 virtual memory operates as follows:                         
 2 The current file open on the mass storage is divided into       
 3 consecutive blocks. The block is the basic unit of storage.     
 4 Each block holds 1024 bytes. Blocks are numbered consecutively  
 5 starting with block 0 at the beggining of the file. On the mass 
 6 storage device (disk or hard disk) the only limit to the number 
 7 of blocks in a file is the capacity of the mass storage device. 
 8                                                                 
 9 In the ram memory of the computer there is an area reserved for 
10 disk buffers. One disk buffer will hold 1024 bytes. In F83 there
11 are 4 disk buffers. Thus in the computers ram memory there can  
12 only be 4 blocks at any one time. FORTH's virtual memory system 
13 keeps track of which blocks are in ram memory and which blocks  
14 are on the mass storage device. This housekeeping is transparent
15 to the user.                                                    


Screen 29 not modified     
 0 BLOCK AND UPDATE                                                
 1                                                                 
 2                                                                 
 3 BLOCK  ( n   adr )  Given the block number n, BLOCK returns     
 4        the address, adr, of the assigned block buffer. The      
 5        buffer address, adr, is the loaction of the first data   
 6        storage cell of the buffer, which consists if 1024 bytes.
 7                                                                 
 8                                                                 
 9 UPDATE ( --   -- )  Mark most recently referenced block as      
10        modified. Then if it's block buffer is required it will  
11        automatically be transfered back to mass storage.        
12                                                                 
13                                                                 
14                                                                 
15                                                                 


Screen 30 not modified     
 0 MEMORY OPERATORS                                                
 1   DUMP  ( adr n   -- ) Dump n bytes of memory starting at adr.  
 2   ERASE ( adr n   -- ) Erase n bytes of memory starting at      
 3                        adr to zeros.                            
 4   FILL ( adr n m  -- ) Fill n bytes of memory starting at adr   
 5                        with low 8 bits of m  ( 0 - 255 ).       
 6                                                                 
 7   !    ( n adr   -- )  STORE 16 bit value at address adr.       
 8   @    ( adr     n  )  FETCH 16 bit value at adr and leave as n.
 9                                                                 
10 NOTE: 16 BIT NUMBERS ARE STORED WITH THE LOW BYTE AT adr AND THE
11       HIGH BYTE AT adr+1 ( THIS IS THE CONVENTION FOR 6502 AND  
12       8086 CPUs - THE 68000 IS NORMAL ).                        
13   C!   ( n adr   -- )  Store low 8 bits of n at address adr.    
14   C@   ( adr     n  )  Fetch 8 bit value at adr and leave as n. 
15   ?    ( adr     -- )  Display contents of cell at adr.         


Screen 31 not modified     
 0 MORE MEMORY OPERATORS                                           
 1        NOTE : cell = 2 bytes = 16 bits = 1 word                 
 2    +!   ( n adr  -- ) Add n to the value found at address adr.  
 3    ON   ( adr    -- ) Set cell at adr to true or -1             
 4    OFF  ( adr    -- ) Set cell at adr to false or 0             
 5                                                                 
 6 CREATE (name) (-- --) Creates a dictionary entry named <named>  
 7                       when executed,<name> leaves the address   
 8 <name>  ( --    adr ) of the first memory cell which follows    
 9                       the word name. No memory is allocated.    
10 ALLOT   ( n      -- ) Allocate n bytes of memory in the         
11                       dictionary.                               
12    ,    ( n      -- ) Allocate 16 bits ( 2 bytes ) of memory    
13                       initializing it to the value n.           
14   C,    ( n      -- ) Allocate 8 bits ( 1 byte ) of memory      
15                       initializing it to low 8 bits of n.       


Screen 32 not modified     
 0 WORD DEFINITION STRUCTURE                                       
 1                                                                 
 2                                                                 
 3              | 4bits   |  12 bits     |                         
 4    vfa   ->  | File #  |  Block #     |   View Field            
 5    lfa   ->  | Link address           |   Link Field            
 6    nfa   ->               | 1PScount  |   Name Field count=5bits
 7                           | 0 char    |                         
 8                           | 0 char    |   char = 7bits          
 9                           | 0 char    |                         
10                           | 1 char    |                         
11    cfa   ->  | Addr Inner Interpr.    |   Code field            
12    pfa   ->  | Parameter List         |   Parameter Field       
13              |    .  .   .  .         |   Also called the       
14              |    .  .   .  .         |   BODY of the word      
15              |    .  .   .  .         |   definition            


Screen 33 not modified     
 0 VOCABULARY:ROOT:ONLY                                            
 1                                                                 
 2   VOCABULARY  {name}  ( --   -- )                               
 3   A dictionary entery for  {name}  is created which specifies a 
 4   new list of word definitions. Subsequent execution of  {name} 
 5   replaces the first vocabulary in the current search order with
 6   {name} . When name becomes the compilation vocabulary new     
 7   definitions will be appended to  {names}'s word list.         
 8                                                                 
 9   ROOT  ( --   -- )                                             
10   A small vocabulary for controlling search order.              
11                                                                 
12   ONLY  ( --   -- )                                             
13   Erases the search order and forces the ROOT vocabulary to be  
14   first and last.                                               
15                                                                 


Screen 34 not modified     
 0 DIVISION                                                        
 1                                                                 
 2              Floored symetric division                          
 3                                                                 
 4              Note that q and r must satisfy the equation.       
 5                                                                 
 6                        m/n = q + r/n                            
 7                                                                 
 8                or      m = nq + r                               
 9                                                                 
10         /   ( m n   q )  Leave q  ,the floor of real quotient   
11                                                                 
12         MOD ( m n   r )  Leave r  ,remainder (satisfying above) 
13                                                                 
14         /MOD (m n   r q ) Leave remainder r and quotient q      
15                                                                 


Screen 35 not modified     
 0 STRINGS                                                         
 1 A counted string in memory is    |05|48|45|4C|4C|4F|  <-hex-<   
 2 preceded by character count.     |05| H| E| L| L| O|            
 3                                                                 
 4 ," {text}"  ( --   -- )  ONLY USE OUTSIDE A WORD DEFINITION     
 5 Compile a counted {text} string into dictionary. Do not use in  
 6 a word definition!!  SYSTEM WILL CRASH.                         
 7                                                                 
 8 " {text}" ( --   adr count )  ONLY USE WITHIN A WORD DEFINITION 
 9 Compile a counted string into a word definition. When word is   
10 later executed the address and count are returned.              
11                                                                 
12 Examples:                                                       
13 CREATE NAME$ ," GEORGE SMITH"                                   
14 : JOB$  " FORTH Progammer" ;                                    
15                     ^                                           


Screen 36 not modified     
 0 STRING COUNT TYPE EXPECT                                        
 1 COUNT  ( adr   adr+1 n )                                        
 2      If adr points to a counted string, COUNT will fetch the    
 3      character count an increment adr to point to first         
 4      character. Count is often used to fetch succesive          
 5      characters of a string.                                    
 6                                                                 
 7 TYPE   ( adr n  -- )  Type n characters of a string at adr.     
 8                                                                 
 9 FILL   ( adr   n c )  Fill string at adr with n copies of c.    
10                                                                 
11 ERASE  ( adr  n )     Fill string at adr with n null's or 0's   
12                                                                 
13 EXPECT ( adr  n )  Input a string of length n  to beffer at adr.
14 Actual number of characters entered is stored in a variable     
15 called SPAN .NOTE: EXPECT does not return a counted string.     


Screen 37 not modified     
 0 MOVING STRINGS                                                  
 1                                                                 
 2    CMOVE    ( adrf adrt   n -- )      Use when adrf > adrt      
 3 Move n bytes from adrf to adrt. Left-most or low memory bytes   
 4 are moved first. ( ie Move starts at begginning of string. )    
 5 Use  CMOVE  to move strings down to lower memory.               
 6                                                                 
 7    CMOVE>   ( adrf adrt   n -- )      Use when adrf < adrt      
 8 Move n bytes from adrf to adrt. Right-most or high memory bytes 
 9 are moved first. ( ie Move starts at end of string. )           
10 Use  CMOVE> to move strings up to a higher memory.              
11                                                                 
12    MOVE     ( adrf adrt   n -- )                                
13 Move n bytes from adrf to adrt. If adrf < adrt use CMOVE>       
14 otherwise use CMOVE. this will prevent overlap.                 
15 Use MOVE when you can't remember wether to use CMOVE or CMOVE>. 


Screen 38 not modified     
 0 BUFFER                                                          
 1 BUFFER  ( n  adr ) Assign block n the buffer storage area at    
 2       adr . The function is the same as for BLOCK except        
 3       that the contents of the data storage area are undefined  
 4       That is . . . The buffer is assigned only and if the      
 5       block is not already in memory its contents might not be  
 6       transferred from mass storage. Not often used.            
 7                                                                 
 8 EMPTY-BUFFERS ( --   -- ) Erase all data in block buffers,      
 9       initialize buffer pointers and mark buffers as empty.     
10                                                                 
11 SAVE-BUFFERS  ( --   -- ) Transfer all buffers marked as        
12       updated to mass storage and then mark them as unmodified. 
13                                                                 
14 FLUSH         ( --   -- ) Same effect as SAVE-BUFFERS followed  
15       by EMPTY-BUFFERS                                          


Screen 39 not modified     
 0 HIDE:REVEAL:IMMEDIATE                                           
 1                                                                 
 2 HIDE        Unlink most latest word from dictionary.            
 3                                                                 
 4 REVEAL      Link the latest word inti the dictionary.           
 5                                                                 
 6 IMMEDIATE   Set precedence bit so latest word is executed       
 7             during compilation instead of being compiled.       
 8                                                                 
 9 ['] {word}  This is an IMMEDIATE word used within a definition  
10             It is used to compile the cfa of the following word 
11             as a LITERAL or number. It is equivalent to the     
12             sequence                                            
13                                                                 
14 [ ' {word} ] LITERAL                                            
15                                                                 


Screen 40 not modified     
 0 NUMBER FORMATING                                                
 1                                                                 
 2 PAD  ( --   adr )  Return address for string output buffer.     
 3 HLD  ( --   adr )  Pointer to current loacation in output buffer
 4 HOLD ( --   adr )  Add character n to string being formed.      
 5 SIGN ( n    --  )  If n is negative insert a -ve sign in the    
 6                    output string. This is different from BRODIE.
 7                                                                 
 8  <#  ( dn   dn  )  Start number formating  ( pad hld ! )        
 9                    dn, the number to be formated , is not used  
10                    <# but is usually present.                   
11  #   ( dn   dn' )  Convert one digit of dn using current number 
12                    BASE and remaining digits as dn' .           
13  #S  ( dn   dn' )  Convert a number until finished. When        
14                    conversion is finished dn' will be zero.     
15  #>  ( dn   adr len )  Terminate numeric conversion.            


Screen 41 not modified     
 0 CASE STATEMENT                                                  
 1 CASE ... OF ... ENDOF ... ENDCASE                               
 2 CASE     causes an index value to be compared to a series       
 3 OF       values. Any number of OF .. ENDOF pairs may be used.   
 4 OF       is equivalent to OVER = IF DROP                        
 5 ENDOF    is equivalent to else                                  
 6 ENDCASE  is equivalent to DROP and number of THENs              
 7 When the index value equals one of the OF values,the sequence   
 8 between that OF and the corresponding ENDOF is executed.        
 9 Control then branches to the word following ENDCASE.            
10 If no match is found, ENDCASE drops the index from the stack.   
11                                                                 
12 The "otherwise" case may be handled by a sequence placed between
13 the last ENDOF and ENDCASE. The index value must however be     
14 preserved across this otherwise sequence so that ENDCASE may    
15 DROP it.                                                        


Screen 42 not modified     
 0 VARIABLES AND CONSTANTS                                         
 1 Values which change quite frequently and must be accessed by a  
 2 number of words are best represented by the use of  VARIABLES.  
 3 Values represented by variables have the added convenience of   
 4 reference by name.                                              
 5                                                                 
 6      VARIABLE <name> (--  -- )   Create 16bit data storage      
 7                                  called <name>                  
 8      <name>          (--  adr )  Leave storage address of <name>
 9                                                                 
10 Values which never change are best represented by CONSTANTs     
11                                                                 
12      CONSTANT <name> ( n  -- )   Create a constant  <name>      
13                                  whose value is  n.             
14      <name>          ( --  n )   Leave value of <name> on stack 
15                                                                 


Screen 43 not modified     
 0 MORE VARIABLES AND CONSTANTS                                    
 1                                                                 
 2   2VARIABLE <name>      Creates a 2 cell ( 4 byte ) variable    
 3                         called <name>.                          
 4                                                                 
 5   <name>   ( --   adr ) When <name> is executed it will push    
 6                         the address of the first cell onto the  
 7                         stack.                                  
 8                                                                 
 9   2CONSTANT <name>      Creates a double constant called <name> 
10             ( --    d ) When <name> is executed the double      
11                         number is pushed onto the data stack.   
12                                                                 
13   2!      ( d adr  -- ) Store the double number d at adr.       
14                                                                 
15   2@      ( adr     d ) Fetch the double number d from adr.     


Screen 44 not modified     
 0 MULTITASKING                                                    
 1 Multitasking allows one computer to appear to do several things 
 2 at the same time. Most of the time a single user computer sits  
 3 in an idle loop waiting for the operator to press the keyboard. 
 4                                                                 
 5 The idea is to utilize this waiting time to perform other useful
 6 tasks. Typical background tasks would be watching over          
 7 instruments in the lab,printing a long file,updating a clock etc
 8                                                                 
 9 F83 uses a very simple yet effective round-robin scheduling     
10 technique. Task switching is extremely fast because each task   
11 maintains its own parameter and return stacks and its own set   
12 of critical variables (called USER variables ) .                
13                                                                 
14 The task switcher just changes the pointer to the correct list  
15 of USER variables.                                              


Screen 45 not modified     
 0 TASK DEPENDENT USER VARIABLES                                   
 1 The following USER variables are needed in every task.          
 2 TOS       Saved during Task switching.                          
 3 ENTRY     Jumped to during multitasking.                        
 4 LINK      Points to next task in the circular queue.            
 5 SP0       Empty parameter stack for this task.                  
 6 RPO       Empty return stack for this task.                     
 7 DP        Size of dictionary. Next available location.          
 8 #OUT      Number of characters sent since last CR.              
 9 #LINE     Number of CR's sent since last page.                  
10 OFFSET    Added to all block references.                        
11 BASE      The current numeric base for number input output.     
12 HLD       Points to a converted character during numeric output.
13 FILE      Allows printing of one file while editing another.    
14 IN-FILE   Allows printing of one file while editing another.    
15 PRINTING  Indicates wether printing is enabled.                 


Screen 46 not modified     
 0 PAUSE RESTART                                                   
 1                                                                 
 2 PAUSE   When multitasking PAUSE stops the current task and      
 3         passes control to the next task in the round robin.     
 4                                                                 
 5         When singletasking PAUSE is equivalent to a NOOP.       
 6                                                                 
 7 RESTART When multitasking RESTART does the reverse of PAUSE.    
 8         It restores critical information stored in task user    
 9         variables and starts executing the task left asleep     
10         during the last pass.                                   
11                                                                 
12                                                                 
13                                                                 
14                                                                 
15                                                                 


Screen 47 not modified     
 0 SLEEP WAKE STOP                                                 
 1                                                                 
 2                                                                 
 3 SLEEP  ( adr   -- ) Used in the form:   {taskname} SLEEP        
 4        Make the addressed task pause indefinitely.              
 5                                                                 
 6 WAKE   ( adr   -- ) Used in the form:   {taskname} WAKE         
 7        Wake up task so that it will execute the next time round.
 8                                                                 
 9 STOP   ( --    -- ) Make the current task pause indefinitely.   
10                                                                 
11                                                                 
12                                                                 
13                                                                 
14                                                                 
15                                                                 


Screen 48 not modified     
 0 MULTI SINGLE                                                    
 1                                                                 
 2                                                                 
 3 MULTI   Start the multitasker. This is done by installing the   
 4         the sheduler/dispatcher loop and activating PAUSE.      
 5                                                                 
 6 SINGLE  Stop multitasking. This is done by removing the         
 7         sheduler/dispatcher loop and restoring PAUSE to         
 8         its NOOP function.                                      
 9                                                                 
10                                                                 
11                                                                 
12                                                                 
13                                                                 
14                                                                 
15                                                                 



Screen 53 not modified     
 0 \ Hard copy screen documentation.              11:23JWB11/23/85 
 1                                                                 
 2 \ Print three screens starting with n on the printer.           
 3 : HTRIAD  ( n   -- )                                            
 4         PRINTING ON                DUP 3 +  SWAP                
 5       ( 27 EMIT ASCII E EMIT  ) CONTROL N EMIT                  
 6         DO CR I LIST LOOP  ( 27 EMIT ASCII F EMIT )             
 7         CONTROL O EMIT  PRINTING OFF ;                          
 8                                                                 
 9 \ Send a top of page command to printer.                        
10 : FFEED                                                         
11         PRINTING ON 12 EMIT PRINTING OFF ;                      
12                                                                 
13 \ Print screens  first through last  on printer, three per page.
14 : DOC   ( first last   -- )                                     
15         1+ SWAP DO I HTRIAD FFEED 3 +LOOP ;                     




Screen 64 not modified     
 0 \ Notes on Starting Forth. 1                   14:09JWB01/09/86 
 1 \ P 50    Replace 'S with SP@ or define  : 'S   SP@ ;           
 2 \         Replace S0 with SP0 or define  : S0   SP0 ;           
 3 \  Because FORTH83 loops work differently you should use:       
 4         : .S CR  SP@ SP0 @ 2DUP <>                              
 5              IF   2- DO I  @ . -2 +LOOP                         
 6              ELSE 2DROP ." EMPTY" THEN   ;                      
 7 \ Or  just use .S  that is already part of your system.         
 8                                                                 
 9 \ P 66-72  Use:    n  VEDIT     to edit screen n .              
10 \ The original F83.COM fill supports the STARTING FORTH style   
11 \ editor.   Go back to DOS and type  F83  <name>.BLK  to try it.
12 \ P 83  See notes for P 50 above.  Also VIEW  .S  to see how    
13 \        the F83 version is implemented.                        
14                                                                 
15                                                                 


Screen 65 not modified     
 0 \ Notes on Starting Forth. 2                   17:12JWB09/22/85 
 1 \ P 110 In F83 I J and K are used only within loops to fetch    
 2 \       the current values of the loop counters.  Use  R@       
 3 \       instead of I to fetch a copy of the top of the return   
 4 \       stack to the parameter stack without changing the       
 5 \       return stack.                                           
 6 \       Use the sequence:  R> R@ SWAP >R  within a definition   
 7 \       instead of I' to fetch  a copy of the second item on    
 8 \       the return stack.  Or use the definition:               
 9 : 2R@   R> R> R@ -ROT >R >R ;                                   
10 \       Use 2R@  for I' .   I' is a poor name!!                 
11 \       WARNING!  It is dangerous to mess with the return stack.
12 \ P112  Use  R@  instead of I  ,  also a dot  .  was ommited    
13 \       from the definition of QUADRATIC.   See below.          
14 : QUADRATIC     ( a b c x   n )                                 
15         >R SWAP ROT R@ * + R> * + .  ;                          


Screen 66 not modified     
 0 \ Notes on Starting Forth. 3                   17:13JWB09/22/85 
 1 \ P 119 Error in footnote!                                      
 2 : R%  50 */ 1+ 2/ ;                                             
 3 \ P 123 I I' and J  see comments for page 110.                  
 4 \ P 131 For COMPOUND to display as in text  insert a   CR       
 5 \       before  SWAP .  ie  : COMPOUND  CR SWAP 21 0 DO  etc    
 6 \ P 135 There is an error in TEST -  should be 10 10 DO  but    
 7 \       even so . .   the FORTH83  DO .. LOOP is not like       
 8 \       the one in Starting FORTH !!!!   Try the following      
 9 : -TEST  DO I . ?KEY ?LEAVE ( any key exit ) -1 +LOOP ;         
10 : +TEST  DO I . ?KEY ?LEAVE ( any key exit )  1 +LOOP ;         
11 \  9 10 +TEST   loops 65534 times.  9 10 -TEST gives   10 9     
12 \ 10 10 +TEST   loops 65535 times. 10 10 -TEST gives   10       
13 \ 11 10 +TEST  gives  10           11 10 -TEST loops 65535 times
14 \ If you try any of the longer loops above press any key to     
15 \ abort!!                                                       


Screen 67 not modified     
 0 \ Notes on Starting Forth. 4                   17:13JWB09/22/85 
 1 \ P 137 XX will clear the stack as indicated but our definition 
 2 \       : CLEAR  DEPTH 0 ?DO DROP LOOP ;  will do it without    
 3 \       the error message.  An alternate definition of CLEAR is:
 4 : CLEAR  SP0 @ SP! ;                                            
 5 \ P 140 In FORTH83  LEAVE causes an immediate exit from the     
 6 \       DO ... LOOP  !!  Thus any words between LEAVE and LOOP  
 7 \       will not be executed if the condition for leaving is    
 8 \       is satisfied.  Try the following and note that  HELLO   
 9 \       is not printed the last time.                           
10 : HELLOS  10 1 DO CR I . I 5 = IF LEAVE THEN ." HELLO" LOOP ;   
11 \       Note: ?LEAVE can replace the phrase  IF LEAVE THEN      
12 \ P 142-143  Use CLEAR-SCREEN definition below instead of PAGE  
13 : CLEAR-SCREEN  0 0 0 2 [ EDITOR ] VIDEO-IO 2DROP 2DROP ; FORTH 
14                                                                 
15                                                                 


Screen 68 not modified     
 0 \ Notes on Starting Forth. 5                   17:13JWB09/22/85 
 1 \ P 161 In FORTH83  UM*     is the name for U*                  
 2 \       and         UM/MOD  is the name for U/MOD               
 3 \       In FORTH83  all loops are relative, use +LOOP for /LOOP 
 4 \ P 164 Double number punctuation is  .  only!  not  ,          
 5 \ P 166 Use the   .   for the  ,  in the double numbers!!!      
 6 \ P 169 FORTH83   SIGN  uses the first number on the stack!!    
 7 \       Whenever Brodie uses  SIGN  replace it with  ROT SIGN   
 8 \ P 170 Replace   SIGN   with   ROT  SIGN                       
 9 \       VIEW  D.  to see how F83  formats numbers.              
10 \ P 172 Replace   SIGN   with   ROT  SIGN                       
11 \ P 174 Use the definitions below:                              
12 : M+    S>D D+ ;     : M/    M/MOD  NIP ;                       
13 : M*/   2DUP XOR SWAP ABS >R SWAP ABS >R OVER XOR -ROT          
14         DABS SWAP R@ UM* ROT R> UM* ROT 0 D+ R@ UM/MOD          
15         -ROT R> UM/MOD NIP SWAP ROT ?DNEGATE ;                  


Screen 69 not modified     
 0 \ Notes on Starting Forth. 6                   17:28JWB09/22/85 
 1 \ P 177 In FORTH83  use   UM*  for  U* and UM/MOD for U/MOD     
 2 \       In FORTH83  use  +LOOP for /LOOP                        
 3 \ P 178 Use  ROT SIGN where ever Brodie uses SIGN  !!           
 4 \ P 202 Use CLEAR-SCREEN definition given earlier for  PAGE     
 5 \ P 204 Use +LOOP  for /LOOP                                    
 6 \ P 215 Type  VIEW  INTERPRET  for definition of our INTERPRET  
 7 \ P 217 In F83  DEFER   is used for execution vectors.          
 8 \ P 233 In F83  the variable H is called  DP                    
 9 \ P 235-237  : 'S  SP@ ;                                        
10 \ P 240 Use DP  instead of H  ;  No OFFSET in this system.      
11 \ P 242 F83 Uses the ONLY vocabulary structure. See the FORTH-83
12 \       standard or wait till we discuss it in class.           
13 \ P 247 Use DP  instead of H  .                                 
14                                                                 
15                                                                 
projects/help.blk.txt · Zuletzt geändert: 2013-06-06 21:27 (Externe Bearbeitung)