Benutzer-Werkzeuge

Webseiten-Werkzeuge


papierkorb:sample11.blk

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

papierkorb:sample11.blk [2025-08-16 17:50] – ↷ Seite von projects:sample11.blk nach papierkorb:sample11.blk verschoben mkapapierkorb:sample11.blk [Unbekanntes Datum] (aktuell) – gelöscht - Externe Bearbeitung (Unbekanntes Datum) 127.0.0.1
Zeile 1: Zeile 1:
-=== Examples for Lecture Number 11 ===  
-<code> 
-Screen 0 not modified      
- 0 \ Examples for Lecture Number 11               20:27JWB12/07/85  
- 1 \ Last change:   Screen  007                   11:12jwb11/22/87  
-                                                                  
-                                                                  
-                                                                  
-                 USER  VARIABLES                                  
-                                                                  
-                 MULTI TASKING                                    
-                                                                  
-                                                                  
-10                                                                  
-11                                                                  
-12                                                                  
-13                                                                  
-14                                                                  
-15                                                                  
  
- 
-Screen 2 not modified      
- 0 \ BLOCK                                        16:03JWB11/29/85  
-                                                                  
-                                                                  
-   BLOCK   ( n   adr )   Given the block number n, BLOCK returns  
-         the in address, adr, of the assigned block buffer. The   
-         buffer address, adr, is the location of the first data   
-         storage cell of the buffer, which consists of 1024 bytes 
-                                                                  
-                                                                  
-   UPDATE  ( --  -- )  Mark most recently referenced block as     
-10       modified.  Then if its block buffer is required it will    
-11       automatically be transfered back to mass storage.          
-12                                                                  
-13                                                                  
-14                                                                  
-15                                                                  
- 
- 
-Screen 3 not modified      
-  BUFFER                                       16:50JWB11/29/85   
-  BUFFER  ( n  adr )  Assign block n the buffer storage area at   
-        adr .  The function is the same as for BLOCK  except      
-        that the contents of the data storage area are undefined  
-        That is . . .  The buffer is assigned only and the        
-        if the block is not already in memory its contents might  
-        not be transfered from mass storage.  Not often used.     
-                                                                  
-  EMPTY-BUFFERS  ( --  -- ) Erase all data in block buffers,      
-        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 4 not modified      
- 0 \ Virtual vector arrays-1                      11:26jwb11/22/87  
- 1 BLK @ 2+  (  6 ) CONSTANT FIRST-BLOCK                            
- 2 BLK @ 4 + (  8 ) CONSTANT LAST-BLOCK                             
-     CREATE   POINTER    0 ,  \ Keeps track of amount allocated.  
-     VARIABLE STORE?          \ Fetch store flag                  
- 5 : =>  STORE? ON ;            \ Assignment operator.              
- 6 \ Allot some virtual memory cells.                               
- 7 : B-ALLOT  ( n  -- )                                             
-         DUP POINTER @ +                                          
-         LAST-BLOCK FIRST-BLOCK -  1+ 1024 * >                    
-10         ABORT" Allocated virtual memory exausted"                
-11         POINTER +!  ;                                            
-12 \ Compile time routine.                                          
-13 : COMPILE-VVECTOR ( n    -- )                                    
-14         POINTER @ OVER 2* B-ALLOT                                
-15         ,  ,  ;   \ pfa: pointer : array-size :                  
- 
- 
-Screen 5 not modified      
- 0 \ Virtual vector arrays-2                      11:26jwb11/22/87  
- 1 \ Runtime for virtual vector.  ?? may be data item to be stored  
- 2 : RUN-VVECTOR  ( ?? pfa    ??? ) \ ??? may be data fetched.      
-         2DUP 2+ @ < NOT        \ ?? pfa  flag                    
-         IF STORE? OFF -1 ABORT" Subscript out of range." THEN    
-         @ SWAP 2*              \ ?? pointer index                
-         + B/BUF /MOD           \ ?? offset  block-offset         
-         FIRST-BLOCK + BLOCK +  \ ?? data-storage-address         
-         STORE? @  STORE? OFF                                     
-         IF  ! UPDATE  ELSE @ THEN ;                              
-10                                                                  
-11 : VVECTOR                                                        
-12         CREATE  COMPILE-VVECTOR                                  
-13         DOES>   RUN-VVECTOR ;                                    
-14                                                                  
-15   500  VVECTOR  XX   500  VVECTOR  YY   500 VVECTOR ZZ           
- 
- 
- 
-Screen 9 not modified      
- 0 \ Multitasking.                                21:01JWB12/07/85  
- 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.  
-                                                                  
- 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 a lab, printing a long file, updating a clock etc 
-                                                                  
- 9 F83 uses a very simple yet  effective round-robin scheduling     
-10 technique.  Task switching is extremly 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 10 not modified      
- 0 \ Task dependent user variables.               20:44JWB12/07/85  
- 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 RP0      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 whether printing is enabled.                 
- 
- 
-Screen 11 not modified      
- 0 \  PAUSE  RESTART                              21:13JWB12/07/85  
-                                                                  
- 2 PAUSE   When multitasking PAUSE stops the current task and       
-         passes control to the next task in the round-robin loop. 
-                                                                  
-         When singletasking PAUSE is equivalent to a NOOP.        
-                                                                  
- 7 RESTART When multitasking RESTART does the reverse of PAUSE.     
-         It restores critical information stored in tasks user    
-         variables and starts executing the task left asleep      
-10         during the last pass.                                    
-11                                                                  
-12                                                                  
-13                                                                  
-14                                                                  
-15                                                                  
- 
- 
-Screen 12 not modified      
- 0 \ SLEEP  WAKE   STOP  MULTI  SINGLE            21:20JWB12/07/85  
- 1 SLEEP   ( adr  -- )  Used in the form:  {taskname}  SLEEP        
-         Make the addressed task pause indefinitely.              
-                                                                  
- 4 WAKE    ( adr  -- )  Used in the form:  {taskname}  WAKE         
-         Wake up task so that it will execute next time round.    
-                                                                  
- 7 STOP    ( --  -- )   Make the current task pause indefinitely.   
-                                                                  
- 9 MULTI   ( --  -- )   Start the multitasker.  This is done by     
-10         installing the scheduler/dispatcher loop and activating  
-11         PAUSE.                                                   
-12                                                                  
-13 SINGLE  ( --  -- )   Stop multitasking.  This is done by         
-14         removing the scheduler/dispatcher loop and restoring     
-15         PAUSE to its NOOP function.                              
- 
- 
-Screen 13 not modified      
- 0 \ Task Definition.                             22:54JWB12/07/85  
-                                                                  
- 2 TASK: {taskname}  ( size  -- )   Creates a named task.  A task   
-         must frist be defined as a word in the dictionary.       
-         Space must also be allocated for:                        
-         1) Its USER variable area.                               
-         2) Two stacks ( parameter stack and return stack).       
-         3) Extra dictionary space for its I/O buffers at PAD     
-            The parameter size abover is the amount of dictionary 
-            space for this task.                                  
-10                                                                  
-11         In addition to alloting space the new task must be       
-12         installed in the round-robin loop.                       
-13 Example:                                                         
-14 400  TASK:  MYTASK    \ Creates a task called MYTASK with 400    
-15                       \ bytes of dictionary space.               
- 
- 
-Screen 14 not modified      
- 0 \  SET-TASK                                    20:28JWB12/07/85  
-                                                                  
- 2 SET-TASK  ( ip.adr task.adr  -- )   Assign an existing task to   
-         execute the code pointed to by ip.adr.  This word is     
-         used in ACTIVATE  which is the end-user word.            
-                                                                  
- 6 ACTIVATE ( task.adr   -- )   Assign the invoked task to execute  
-         the following code and wake up the task makine it ready  
-         to execute.                                              
-                                                                  
-10 BACKGROUND: {taskname} ( --  -- )  Create a new task with 400    
-11         bytes of dictionary space and initialize it to execute   
-12         the code which follows up to the semi-colon .            
-13                                                                  
-14                                                                  
-15                                                                  
- 
- 
-Screen 15 not modified      
- 0 \  Multitasking Examples.                      20:28JWB12/07/85  
- 1 ONLY EDITOR ALSO FORTH DEFINITIONS ALSO                          
- 2 2VARIABLE  TCOUNT                                                
- 3 : TT   TCOUNT 2@ D. ;                                            
-                                                                  
- 5 : COUNTER                                                        
-      10000.  TCOUNT 2!                                           
-      BEGIN  PAUSE                                                
-             TCOUNT 2@ 1. D-  TCOUNT 2!                           
-             TCOUNT 2@  D0=                                       
-10      UNTIL                                                       
-11      CR " COUNTER IS DONE"  VTYPE    STOP ;                      
-12                                                                  
-13                                                                  
-14 BACKGROUND:  TASK1  COUNTER  ;                                   
-15                                                                  
- 
- 
-Screen 16 not modified      
- 0 \ TASK-COUNT                                                     
-                                                                  
- 2 : TASK-COUNT                                                     
-          0.  TCOUNT 2!                                           
-      BEGIN  PAUSE                                                
-             TCOUNT 2@ 1. D+  TCOUNT 2!                           
-      AGAIN  ;                                                    
-                                                                  
-     TASK1  SLEEP                                                 
-     ' TASK-COUNT >BODY TASK1  SET-TASK                           
-10     TASK1  WAKE                                                  
-11                                                                  
-12 \   TASK1  SLEEP                                                 
-13 \  ' COUNTER >BODY  TASK1  SET-TASK                              
-14 \   TASK1   WAKE                                                 
-15                                                                  
- 
- 
-Screen 17 not modified      
- 0 \  S.ON  S.OFF  TONE                           13:22JWB12/08/95  
- 1 HEX                                                              
- 2 :   S.ON  ( --  -- )      \  Turn speaker on.                    
-         61 PC@ 3  OR   61 PC! ;                                  
- 4 :   S.OFF ( --  -- )       \ Turn speaker off.                   
-         61 PC@ FFFC AND  61 PC! ; DECIMAL                        
-                                                                  
- 7 : TONE  ( freq  -- )       \ Make tone of specified frequency.   
-     21 MAX                 \ Lowest frequency.                   
-     1.190000  ROT          \ Get divisor for timer.              
-10     MU/MOD                 \ 16bit.rem   32bit.quot              
-11     DROP NIP  [ HEX ]      \ Keep 16-bit quotient only.          
-12     0B6   043 PC!          \ Write to timer mode register.       
-13     100  /MOD SWAP         \ Split into hi and low byte.         
-14     42 PC! 42 PC!          \ Store low and high byte in timer.   
-15     S.ON  ;  DECIMAL                                             
- 
- 
-Screen 18 not modified      
- 0 \ PIPPING                                      13:23JWB12/08/95  
-                                                                  
- 2 : PIPPING                                                        
-         21 TONE                                                  
-         BEGIN   S.ON S.OFF                                       
-                 PAUSE                                            
-         AGAIN ;                                                  
-                                                                  
- 8 BACKGROUND:  TASK2   PIPPING ;                                   
-                                                                  
-10                                                                  
-11                                                                  
-12                                                                  
-13                                                                  
-14                                                                  
-15                                                                  
- 
- 
-Screen 19 not modified      
- 0 \  VIEW-REG                                    10:43   12/08/85  
- 1 ONLY EDITOR ALSO FORTH DEFINITIONS ALSO                          
-  VARIABLE  VADR \ Holds adr of 16 bit cell                       
-  VARIABLE  VOLD \ Holds old value.                               
- 4 : #' 0 ?DO PAUSE # LOOP ;                                      
- 5 TCOUNT 2+  VADR !                                                
- 6 : VIEWREG  ( --  -- )    15 ATRIB !                              
-         BEGIN  PAUSE  VADR @ @ VOLD @ -                          
-         IF 2 BASE ! VADR @ @ DUP VOLD !                          
-            0 <# ASCII ] HOLD BL HOLD 8 #'S BL HOLD               
-10                 8 #'S BL HOLD ASCII [ HOLD #>                    
-11            CUR@ >R  40 2 AT                                      
-12            VTYPE R>  CUR! DECIMAL THEN                           
-13         AGAIN ;                                                  
-14 BACKGROUND:  TASK3  VIEWREG  ;                                   
-15                                                                  
- 
- 
-Screen 20 not modified      
- 0 \ CLOCK task                                                     
-                                                                  
- 2 :  CLOCK                                                         
-         BEGIN    PAUSE                                           
-         (.TIME)  PAUSE                                           
-         CUR@ >R                                                  
-         20 2 AT VTYPE                                            
-         R> CUR!                                                  
-         AGAIN   ;                                                
-                                                                  
-10 BACKGROUND:  TASK4  CLOCK ;                                      
-11                                                                  
-12                                                                  
-13                                                                  
-14                                                                  
-15                                                                  
- 
- 
-Screen 21 not modified      
- 0 \  MARQUEE                                                       
-                                                                  
- 2 CREATE  SPEED  50 ,    \  1 IS FAST   1000 IS GLACIAL            
- 3 : PAWS  SPEED @ -1 ?DO PAUSE LOOP ;                              
-                                                                  
- 5 CREATE TEXTB   24 ,     \ Beginning block for display            
- 6 CREATE #TEXTB   2 ,     \ How many blocks for display            
- 7 CREATE #T       0 ,     \ Offset in bytes, from TEXTB            
-                         \ in virtual memory.                     
-                                                                  
-10 : VTEXT ( --  adr )  \ Leave virtual address relative to TEXTB   
-11         #T @ 1024 /MOD TEXTB @ + BLOCK + ;                       
-12                                                                  
-13 CREATE MQ? -1 ,         \ Flag read by MARQUEE                   
-14 : HO    MQ? OFF ;       \ Halt the MARQUEE                       
-15 : HUM   MQ? ON  ;       \ Resume the MARQUEE                     
- 
- 
-Screen 22 not modified      
- 0 \ HUH BUMP MARQ                                16:02JWB12/08/85  
- 1 CREATE RD? 0 ,          \ Flag read by MARQUEE                   
- 2 : HUH  -1 RD? +! ;      \ Back up the MARQUEE and redisplay      
-                                                                  
-  4 CONSTANT #BUMP       \ Positions to bump to the left.         
- 5 \ only use powers of 2.                                          
-                                                                  
- 7 : BUMP  ( --  --  )                                              
-         PAD #BUMP + PAD 80 #BUMP - CMOVE ;                       
-                                                                  
-10 \ Display PAD and then bump characters to the left.              
-11 : MARQ  ( --  -- )                                               
-12         PAWS CUR@ 0 0 AT PAD 80 VTYPE CUR!                       
-13         MQ? @ IF BUMP THEN ;                                     
-14 : TAIL  ( --  adr count )                                        
-15         80 #BUMP - PAD + #BUMP ;                                 
- 
- 
-Screen 23 not modified      
- 0 \  MARQUEE                                     16:12JWB12/08/85  
-                                                                  
- 2 : MARQUEE  ( --  -- )                                            
-         BEGIN                                                    
-         CUR@ 0 0 79 0 ATRIB @ INIT-WINDOW CUR!                   
-         PAD 80 BLANK  #T OFF                                     
-         #TEXTB @ 1024 * 0                                        
-         DO VTEXT TAIL CMOVE MARQ MQ? @                           
-            IF #BUMP #T +! THEN   RD? @                           
-            IF 1 RD? +! PAD 80 BLANK -160 DUP #T +!               
-10            ELSE 0 THEN                                           
-11            MQ? @ IF #BUMP ELSE 0 THEN +                          
-12         +LOOP  TAIL BLANK 80 #BUMP / 0                           
-13         DO MARQ LOOP                                             
-14         AGAIN   ;                                                
-15 BACKGROUND: TASK5 MARQUEE ;                                      
- 
- 
-Screen 24 not modified      
-  WELCOME  TO THE WONDERFUL WORLD OF 8086 MULTI-TASKING FORTH.    
- 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.  
-                                                                  
- 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 a lab, printing a long file, updating a clock etc 
-                                                                  
- 9 F83 uses a very simple yet  effective round-robin scheduling     
-10 technique.  Task switching is extremly 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 25 not modified      
-  WELCOME  TO THE WONDERFUL WORLD OF 8086 MULTI-TASKING FORTH.    
-  Now you can read your FORTH screens while you continue to hack  
-  away at you FORTH system.  Things to remember.  SINGLE  . . .   
-  puts the system in the singletasking mode.    MULTI . . .  puts 
-  the system in the multitasking mode.   {taskname}  WAKE . . .   
-  wakes up a task.   {taskname}  SLEEP  . . . puts task to sleep. 
-   DO NOT  use STOP  from the terminal.  It will put the forgroun 
- 7 d task to sleep.   To create a new task use the format: . .      
-   BACKGROUND:  {taskname}  {runtime routine code} ;              
-   Tasknames  can be assigned new jobs using  SET-TASK and        
-10   ACTIVATE.   But be very careful.   It is easy to crash if you  
-11   do something wrong!!   First you should practice with  MULTI   
-12   SINGLE  WAKE  &  SLEEP  using the 5 tasks that I have provided 
-13   then if your brave.  write your own task.   WARNING  WARNING   
-14   Background tasks that output to the screen can mess up the     
-15   cursor.  Study my examples to see how to save the cursor.      
- 
- 
-Screen 26 not modified      
- 0 \ How to use ACTIVATE reassign a taskname                        
-                                                                  
-                                                                  
- 3 : COUNTDOWN  ( --  -- )                                          
-      TASK1  ACTIVATE                                             
-      1000.   TCOUNT 2!                                           
-      BEGIN  PAUSE                                                
-             TCOUNT 2@ 1. D-  TCOUNT 2!                           
-             TCOUNT 2@ (UD.)                                      
-             CUR@ >R 0 2 AT VTYPE R> CUR!                         
-10             TCOUNT 2@  D0=                                       
-11      UNTIL                                                       
-12      CR  " COUNTER IS DONE"  VTYPE                               
-13      STOP ;                                                      
-14                                                                  
-15                                                                  
- 
-</code> 
papierkorb/sample11.blk.1755359401.txt.gz · Zuletzt geändert: 2025-08-16 17:50 von mka