papierkorb:sample10.blk
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| papierkorb:sample10.blk [2025-08-16 17:50] – ↷ Seite von projects:sample10.blk nach papierkorb:sample10.blk verschoben mka | papierkorb:sample10.blk [Unbekanntes Datum] (aktuell) – gelöscht - Externe Bearbeitung (Unbekanntes Datum) 127.0.0.1 | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| - | === Examples for lecture number ten === | ||
| - | < | ||
| - | Screen 0 not modified | ||
| - | 0 \ Examples for lecture number ten. | ||
| - | 1 \ Last change: | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 10 | ||
| - | 11 | ||
| - | 12 | ||
| - | 13 | ||
| - | 14 | ||
| - | 15 | ||
| - | |||
| - | Screen 1 not modified | ||
| - | 0 \ Load screen | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 8 ONLY FORTH DEFINITIONS ALSO | ||
| - | 9 : ESC[ 27 EMIT ASCII [ EMIT ; | ||
| - | 10 : CLS ESC[ ." 2J" ; | ||
| - | 11 : BRIGHT ESC[ ." 1m" ; | ||
| - | 12 : NORMAL ESC[ ." 0m" ; | ||
| - | 13 : BLUE ESC[ ." 44m" ; | ||
| - | 14 ONLY EDITOR ALSO FORTH DEFINITIONS | ||
| - | 15 | ||
| - | |||
| - | |||
| - | Screen 2 not modified | ||
| - | 0 \ Execution vectors or defered words. | ||
| - | 1 \ EXECUTE | ||
| - | 2 : F.HELLO | ||
| - | | ||
| - | 4 : GREETING | ||
| - | | ||
| - | 6 \ PERFORM | ||
| - | 7 : GREETING1 | ||
| - | | ||
| - | 9 \ IS {word} | ||
| - | 10 \ Sample usage: | ||
| - | 11 : GREETING2 | ||
| - | 12 | ||
| - | 13 \ DEFER {word} | ||
| - | 14 \ | ||
| - | 15 DEFER GREETING3 | ||
| - | |||
| - | |||
| - | Screen 3 not modified | ||
| - | 0 \ Extending the FORTH compiler with ... 17: | ||
| - | 1 \ Template for creating new compilers: | ||
| - | 2 \ : {compiler name} | ||
| - | 3 \ | ||
| - | 4 \ | ||
| - | 5 \ At runtime the pfa of the created word is put on the stack. | ||
| - | | ||
| - | | ||
| - | 8 : => ( -- -- ) STORE? ON ; \ Set STORE? to true. | ||
| - | | ||
| - | 10 : SMART-VARIABLE | ||
| - | 11 | ||
| - | 12 | ||
| - | 13 | ||
| - | 14 | ||
| - | 15 | ||
| - | |||
| - | |||
| - | Screen 4 not modified | ||
| - | 0 \ VECTOR | ||
| - | 1 \ Create a one dimensional vector n storage cells | ||
| - | 2 \ Usage: | ||
| - | 3 \ Later: | ||
| - | 4 : COMPILE-VECTOR | ||
| - | | ||
| - | | ||
| - | 7 : RUN-VECTOR | ||
| - | | ||
| - | | ||
| - | 10 | ||
| - | 11 | ||
| - | 12 : VECTOR | ||
| - | 13 DUP 1 < OVER 256 > OR ABORT" Dimension out of range." | ||
| - | 14 | ||
| - | 15 | ||
| - | |||
| - | |||
| - | Screen 5 not modified | ||
| - | 0 \ Magic Variables. | ||
| - | | ||
| - | 2 : FETCH 0 MESSAGE ! ; | ||
| - | 3 : => 1 MESSAGE ! ; | ||
| - | 4 : DISPLAY | ||
| - | 5 : SOUND 3 MESSAGE ! ; | ||
| - | 6 : PLOT 4 MESSAGE ! ; | ||
| - | 7 : CLEAR 5 MESSAGE ! ; | ||
| - | 8 : INC 6 MESSAGE ! ; | ||
| - | 9 : DEC 7 MESSAGE ! ; | ||
| - | 10 | ||
| - | 11 : WAIT 5000 0 DO I DROP LOOP ; | ||
| - | 12 | ||
| - | 13 : COMPILE-MAGIC-VARIABLE | ||
| - | 14 0 , ; | ||
| - | 15 | ||
| - | |||
| - | |||
| - | Screen 6 not modified | ||
| - | 0 \ Magic Variables | ||
| - | 1 ONLY EDITOR ALSO FORTH ALSO | ||
| - | 2 : RUN-MAGIC-VARIABLE | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 10 6 OF 1 SWAP +! ENDOF | ||
| - | 11 7 OF -1 SWAP +! ENDOF | ||
| - | 12 4 OF CR @ 0 ?DO ASCII * EMIT LOOP ENDOF ENDCASE ; | ||
| - | 13 : MAGIC-VARIABLE | ||
| - | 14 | ||
| - | 15 | ||
| - | |||
| - | |||
| - | Screen 7 not modified | ||
| - | 0 \ Visible Arrays. | ||
| - | 1 ONLY EDITOR ALSO FORTH ALSO | ||
| - | | ||
| - | | ||
| - | | ||
| - | 5 : WAIT SPEED @ 0 ?DO I DROP LOOP ; | ||
| - | | ||
| - | 7 : -> | ||
| - | | ||
| - | 9 : DISPLAY | ||
| - | 10 1- 8 /MOD SWAP 8 * SWAP AT 6 .R WAIT ; | ||
| - | 11 | ||
| - | 12 : RDISPLAY | ||
| - | 13 | ||
| - | 14 2DUP 31 ATRIB ! DISPLAY 15 ATRIB ! DISPLAY | ||
| - | 15 | ||
| - | |||
| - | |||
| - | Screen 8 not modified | ||
| - | 0 \ The visible array. | ||
| - | 1 : COMPILE-VISIBLE-ARRAY | ||
| - | | ||
| - | | ||
| - | 4 : RUN-VISIBLE-ARRAY | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 10 : VISIBLE-ARRAY | ||
| - | 11 | ||
| - | 12 | ||
| - | 13 | ||
| - | 14 | ||
| - | 15 | ||
| - | |||
| - | |||
| - | Screen 9 not modified | ||
| - | 0 \ Variables and Random number generator | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 5 160 VISIBLE-ARRAY KEYS | ||
| - | 6 \ Make top of stack an odd number. | ||
| - | 7 : ODD ( n odd ) DUP 1 AND + 1- ; | ||
| - | 8 : (RND) SEED @ 259 * 3 + 32757 AND DUP SEED ! ; | ||
| - | 9 : RND ( n r ) (RND) 32767 */ ; | ||
| - | 10 \ Set up n random keys. | ||
| - | 11 : SET-UP ( n -- ) | ||
| - | 12 8 MAX 160 MIN N-MAX ! CLEARSCREEN | ||
| - | 13 N-MAX @ 1+ 1 DO 1000 RND I -> KEYS LOOP CR ; | ||
| - | 14 : SET-EX | ||
| - | 15 10 N-MAX ! 11 1 DO -> I KEYS LOOP CR CR ; | ||
| - | |||
| - | |||
| - | Screen 10 not modified | ||
| - | 0 \ Shell Sort. | ||
| - | 1 : SHELL-SORT ( -- -- ) \ Ref 8086 BOOK by Rector & Alexy Sec 2-4 | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 10 WHILE DUP KEYS OVER INCREMENT @ + \ key(index+increment) | ||
| - | 11 -> KEYS INCREMENT @ - \ = key(index) | ||
| - | 12 REPEAT KEYTEMP @ SWAP \ key(index+increment) | ||
| - | 13 INCREMENT @ + -> KEYS \ = keytemp | ||
| - | 14 | ||
| - | 15 | ||
| - | |||
| - | |||
| - | Screen 11 not modified | ||
| - | 0 \ Virtual memory. | ||
| - | 1 F83 virtual memory operates as follows: | ||
| - | 2 The current file open on the mass storage unit is divided into | ||
| - | 3 consecutive blocks. | ||
| - | 4 Each block holds 1024 bytes. | ||
| - | 5 starting with block 0 at the beginning of the file. On the | ||
| - | 6 mass storage device (disk or hard disk) the only limit to the | ||
| - | 7 number of blocks in a file is the capacity of the mass storage | ||
| - | 8 device. | ||
| - | 9 In the ram memory of the computer there is an area reserved for | ||
| - | 10 disk buffers. | ||
| - | 11 there are 4 disk buffers. | ||
| - | 12 there can only be 4 blocks at any one time. FORTH' | ||
| - | 13 memory system keeps track of which blocks are in ram memory and | ||
| - | 14 which block are on the mass storage device. This house keeping | ||
| - | 15 is transparent to the user. | ||
| - | |||
| - | |||
| - | Screen 12 not modified | ||
| - | 0 \ BLOCK 16: | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 10 iv) If the block previously occupying the assigned | ||
| - | 11 | ||
| - | 12 be transfered back to mass storage before block n | ||
| - | 13 is moved from mass storage into its assigned buffer. | ||
| - | 14 v) The contents of a block buffer may not be changed | ||
| - | 15 | ||
| - | |||
| - | |||
| - | Screen 13 not modified | ||
| - | | ||
| - | 1 \ Try the following: | ||
| - | 2 \ 13 BLOCK 100 DUMP | ||
| - | 3 \ 13 BLOCK 64 | ||
| - | 4 \ CREATE NAME ," BLOCK EXAMPLES" | ||
| - | 5 \ NAME COUNT 13 BLOCK 2+ SWAP CMOVE | ||
| - | 6 \ 13 LIST 14 LIST 15 LIST 16 LIST 17 LIST | ||
| - | 7 \ 13 LIST | ||
| - | | ||
| - | 9 \ UPDATE | ||
| - | 10 \ | ||
| - | 11 \ | ||
| - | 12 | ||
| - | 13 \ Repeat above except type UPDATE after the CMOVE | ||
| - | 14 | ||
| - | 15 \ Remind me to tell you about the editor bug. | ||
| - | |||
| - | |||
| - | Screen 14 not modified | ||
| - | 0 \ BUFFER | ||
| - | 1 \ BUFFER | ||
| - | 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 the | ||
| - | 5 \ if the block is not already in memory its contents might | ||
| - | 6 \ not be transfered from mass storage. | ||
| - | | ||
| - | 8 \ EMPTY-BUFFERS | ||
| - | 9 \ | ||
| - | 10 | ||
| - | 11 \ SAVE-BUFFERS | ||
| - | 12 \ | ||
| - | 13 | ||
| - | 14 \ FLUSH ( -- -- ) Same effect as SAVE-BUFFERS followed | ||
| - | 15 \ by EMPTY-BUFFERS . | ||
| - | |||
| - | |||
| - | Screen 15 not modified | ||
| - | 0 \ .BUF | ||
| - | 1 \ Each entry in the buffer-pointer array uses 8 bytes. | ||
| - | 2 \ screen and use the word below to study them. | ||
| - | 3 : .BUF ( -- -- ) | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 10 I BUFFER# @ 4 .R | ||
| - | 11 I BUFFER# 2+ @ 8 U.R \ File control block adr | ||
| - | 12 I BUFFER# 4 + @ 8 U.R \ Block buffer address | ||
| - | 13 I BUFFER# 6 + @ 8 U.R \ Update flag | ||
| - | 14 I BUFFER# 4 + @ 20 4 SPACES TYPE | ||
| - | 15 LOOP BASE ! CR CR ; | ||
| - | |||
| - | |||
| - | Screen 16 not modified | ||
| - | 0 \ Buffer pointer array fields. | ||
| - | 1 Buffer # | ||
| - | 2 Buffer 0 is the transient buffer | ||
| - | 3 Buffer 1 is the most recently accessed buffer. | ||
| - | | ||
| - | 5 Buffer 4 is the least recently accessed buffer. | ||
| - | | ||
| - | 7 Pointer is address in buffer pointer array. | ||
| - | 8 Block # is the screen number or block number. | ||
| - | 9 fcb is the address of the file control block. | ||
| - | 10 Data is the address of the 1024 byte data storage area. | ||
| - | 11 Update | ||
| - | 12 | ||
| - | 13 | ||
| - | 14 Note: If block numbers are the same and fcb's are different | ||
| - | 15 | ||
| - | |||
| - | |||
| - | Screen 17 not modified | ||
| - | 0 \ Virtual array. | ||
| - | | ||
| - | 2 : -> STORE? ON ; | ||
| - | 3 \ n is the block number where the virtual array data is stored. | ||
| - | 4 : VIRTUAL-VECTOR | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 10 | ||
| - | 11 | ||
| - | 12 | ||
| - | 13 20 VIRTUAL-VECTOR VV 21 VIRTUAL-VECTOR WW | ||
| - | 14 22 VIRTUAL-VECTOR XX 23 VIRTUAL-VECTOR YY | ||
| - | 15 24 VIRTUAL-VECTOR ZZ | ||
| - | |||
| - | |||
| - | Screen 18 not modified | ||
| - | 0 \ TEST1 | ||
| - | | ||
| - | | ||
| - | 3 : TEST1 | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 10 | ||
| - | 11 | ||
| - | 12 \ > | ||
| - | 13 | ||
| - | 14 | ||
| - | 15 | ||
| - | |||
| - | </ | ||
papierkorb/sample10.blk.1755359401.txt.gz · Zuletzt geändert: 2025-08-16 17:50 von mka