\ The Rest is Silence 26Sep83map************************************************************* ************************************************************* *** *** *** Please direct all questions, comments, and *** *** miscellaneous personal abuse to: *** *** *** *** Henry Laxen or Michael Perry *** *** 1259 Cornell Avenue 1125 Bancroft Way *** *** Berkeley, California Berkeley, California *** *** 94706 94702 *** *** *** *** (415) 525-8582 (415) 644-3421 *** *** *** ************************************************************* ************************************************************* ( Load Screen to Bring up Standard System 26Sep83map) CR .( Loading system extensions.) CR 2 VIEW# C! ( This will be view file# 2 ) 3 CONSTANT BASICS 6 CONSTANT FILE-INTERFACE BASICS LOAD FILE-INTERFACE LOAD FROM CPU8080.BLK 1 LOAD ( Machine Dependent Code ) FROM UTILITY.BLK 1 LOAD ( The Standard System ) FROM UTILITY.BLK 2 LOAD ( The System Options ) 13 LOAD ( View Files setup ) --> \ Load up the system 16Oct83map: HELLO (S -- ) CR ." 8080 Forth 83 Model " .VERSION CR ." Modified 16Oct83" EMPTY-BUFFERS ONLY FORTH ALSO DEFINITIONS DEFAULT ; ' HELLO IS BOOT : MARK (S -- ) CREATE DOES> (FORGET) FORTH DEFINITIONS ; MARK EMPTY HERE FENCE ! CR .( System has been loaded, Size = ) HERE U. CR .( Now save the system with BYE and SAVE ) ( Commenting and Loading Words 16Oct83map) 64 CONSTANT C/L 16 CONSTANT L/SCR : \ ( -- ) >IN @ NEGATE C/L MOD >IN +! ; IMMEDIATE : (S ( -- ) [COMPILE] ( ; IMMEDIATE : ? (S adr -- ) @ . ; : ?ENOUGH (S n -- ) DEPTH 1- > ABORT" Not enough Parameters" ; : THRU (S n1 n2 -- ) 2 ?ENOUGH 1+ SWAP ?DO I LOAD LOOP ; : +THRU (S n1 n2 -- ) BLK @ + SWAP BLK @ + SWAP THRU ; : --> (S -- ) >IN OFF 1 BLK +! ; IMMEDIATE 1 2 +THRU ( Rest of Basic Utilities ) \ The ALSO and ONLY Concept 11SEP83HHLCONTEXT DUP @ SWAP 2+ ! ( Make FORTH also ) VOCABULARY ONLY ONLY DEFINITIONS : ALSO (S -- ) CONTEXT DUP 2+ #VOCS 2- 2* CMOVE> ; HERE 2+ ] DOES> DUP CONTEXT #VOCS 1- 2* 2DUP ERASE + ! CONTEXT ! UNNEST [ ' ONLY ! ( Patch into ONLY ) : X END? ON ; HEX A080 DECIMAL ' X >NAME ! IMMEDIATE : SEAL (S -- ) ' >BODY CONTEXT #VOCS 2* ERASE CONTEXT ! ; : PREVIOUS (S -- ) CONTEXT DUP 2+ SWAP #VOCS 2- 2* CMOVE CONTEXT #VOCS 2- 2* + OFF ; \ The ALSO and ONLY Concept 28AUG83HHL: FORTH FORTH ; : DEFINITIONS DEFINITIONS ; : ORDER (S -- ) CR ." Context: " CONTEXT #VOCS 0 DO DUP @ ?DUP IF BODY> >NAME .ID THEN 2+ LOOP DROP CR ." Current: " CURRENT @ BODY> >NAME .ID ; : VOCS (S -- ) VOC-LINK @ BEGIN DUP #THREADS 2* - BODY> >NAME .ID @ DUP 0= UNTIL DROP ; ONLY FORTH ALSO DEFINITIONS \ Load Screen for CP/M Interface 27Sep83map 1 6 +THRU FORTH DEFINITIONS CR .( FILE Interface Loaded ) EXIT The CP/M interface consists of a set of words that access the BDOS functions of CP/M, such as making, opening, and deleting files. There is also a word that parses a string and creates a file control block. Finally the word SAVE can be used to save the contents of memory as a CP/M file. \ CP/M BDOS Interface 07JUL83HHLVOCABULARY CP/M CP/M DEFINITIONS CREATE FCB2 B/FCB ALLOT : RESET (S --- ) 0 13 BDOS DROP ; : CLOSE (S --- B) FILE @ 16 BDOS ; : SEARCH0 (S --- B) FILE @ 17 BDOS ; : SEARCH (S --- B) FILE @ 18 BDOS ; : OPEN (S --- B) FILE @ 15 BDOS ; : MAKE (S --- B) FILE @ 22 BDOS ; : DELETE (S --- B) FILE @ 19 BDOS ; : READ (S --- B) FILE @ 20 BDOS ; : WRITE (S --- B) FILE @ 21 BDOS ; \ Create File Control Blocks 08Oct83map: (!FCB) (S Addr len FCB-addr --- ) DUP FILE ! DUP B/FCB ERASE DUP 1+ 11 BLANK >R OVER 1+ C@ ASCII : = IF OVER C@ [ ASCII A 1- ] LITERAL - R@ C! 2 /STRING THEN R> 1+ -ROT 0 DO DUP C@ ASCII . = IF SWAP 8 I - + ELSE 2DUP C@ SWAP C! SWAP 1+ THEN SWAP 1+ LOOP 2DROP ; : !FCB (S FCB-addr ) BL WORD COUNT CAPS @ IF 2DUP UPPER THEN ROT (!FCB) ; : MAKE-FILE (S -- ) MAKE CPM-ERR? ABORT" Can't MAKE File " ; \ Save a Core Image as a File on Disk 16Oct83mapDEFER HEADER ' NOOP IS HEADER : SAVE (S Addr len --- ) FILE @ -ROT FCB2 !FCB DELETE DROP MAKE-FILE HEADER 0 ?DO DUP SET-DMA WRITE CPM-ERR? ABORT" Write error" 128 + 128 +LOOP DROP CLOSE CPM-ERR? ABORT" Close error" FILE ! ; FORTH DEFINITIONS : CREATE-FILE (S #blocks -- ) 1 ?ENOUGH [ CP/M ] FCB2 !FCB MAKE-FILE DUP MORE 0 ?DO I BUFFER B/BUF BLANK UPDATE LOOP SAVE-BUFFERS CLOSE ; CP/M DEFINITIONS \ Display Directory 05Oct83map: .NAME (S n -- ) #OUT @ C/L > IF CR THEN 32 * PAD + 1+ 8 2DUP TYPE SPACE + 3 TYPE 3 SPACES ; FORTH DEFINITIONS : DIR (S -- ) [ CP/M ] FILE @ " ????????.???" FCB2 (!FCB) CR PAD SET-DMA SEARCH0 BEGIN .NAME SEARCH DUP CPM-ERR? UNTIL DROP FILE ! ; : .FILE (S adr -- ) 1+ 8 2DUP -TRAILING TYPE + ." ." 3 TYPE SPACE ; : FILE? (S -- ) FILE @ .FILE ; CP/M DEFINITIONS \ Define and Open files 30Sep83map: FILE: (S -- fcb ) >IN @ CREATE >IN ! FILE @ HERE DUP B/FCB ALLOT !FCB SWAP FILE ! DOES> FILE ! OPEN-FILE ; : ?DEFINE (S -- fcb ) >IN @ DEFINED IF NIP >BODY ELSE DROP >IN ! FILE: THEN ; FORTH DEFINITIONS : OPEN (S -- ) [ CP/M ] ?DEFINE FILE ! OPEN-FILE ; : DEFINE (S -- ) FILE @ OPEN FILE ! ; \ MultiFile Operations 02AUG83HHLVOCABULARY FILES ONLY FORTH ALSO CP/M ALSO FILES ALSO DEFINITIONS VARIABLE >FROM : EXCHANGE (S -- ) FILE @ >FROM @ FILE ! >FROM ! ; FORTH DEFINITIONS : FROM (S -- ) FILE @ OPEN EXCHANGE FILE ! FILES ; FILES DEFINITIONS : LOAD (S n -- ) FILE @ >R >FROM @ FILE ! LOAD R> FILE ! ; ONLY FORTH ALSO DEFINITIONS \ Set up VIEW-FILES table 26Sep83mapDEFINE META80.BLK 1 ' META80.BLK >BODY 40 + C! DEFINE EXTEND80.BLK 2 ' EXTEND80.BLK >BODY 40 + C! ' META80.BLK VIEW-FILES 0 + ! ' EXTEND80.BLK VIEW-FILES 2 + ! ' CPU8080.BLK VIEW-FILES 4 + ! ' UTILITY.BLK VIEW-FILES 6 + ! ( Load Screen to Bring up Standard System 26Sep83map) This is set so that later definitions can be VIEWed BASICS The most primitive words, needed by everything else. FILE-INTERFACE A set of words that allow convenient use of file CPU8080.BLK Contains all of the 8080 machine dependent stuff, such as the Assembler, the Debug Utility which patches next, and the MultiTasker, which need some code words in order to function efficiently. UTILITY.BLK Contains all of the standard utilities that are usually resident in a Forth system, such as the editor, the decompiler, a print utility, etc. \ Load up the system 23MAY83HHL HELLO (S -- ) Gives the user the sign on message, making him foolishly believe that he is running an 83 Standard System. It also does all of the one time start up code required, such as relocating the heads and opening the screen file, if any. MARK (S -- ) A Defining word that allows you to restore the dictionary to a known state. EMPTY The current state of the dictionary. ( Commenting and Loading Words 25Jul83map) C/L The number of characters per line. L/SCR The number of lines per screen. \ A comment word. Ignores the rest of the line (S Used for Stack Comments. Behaves just like ( ? Displays the contents of an address. ?ENOUGH (S n -- ) Issue an error message if too few parameters on the stack. THRU (S n1 n2 -- ) Load a bunch of screens. +THRU (S n1 n2 -- ) Load a bunch of screens relative to the current screen. --> (S -- ) Load the next screen. \ The ALSO and ONLY Concept 11SEP83HHL ONLY A small vocabulary that initializes the search order. ALSO (S -- ) Adds another vocabulary to the search order. The Run Time code for ONLY. Erases the search order and forces the ONLY vocabulary to be first and last. X Another NULL name so ONLY can be entered without crashing. SEAL Takes the next word in the input stream and seals the vocabulary. No other vocabularies will be searched. PREVIOUS The inverse of ALSO, removes the most recently referenced vocabulary from the search order. \ The ALSO and ONLY Concept 23MAY83HHLWe initialize the ONLY vocabulary with a few definitions that allow us to do vocabulary related things. ORDER (S -- ) Displays the search order currently in effect. Also displays the CURRENT vocabulary, which is were definitions are placed. VOCS (S -- ) Lists all of the vocabularies that have been defined so far, in the order of their definition. \ CP/M BDOS Interface 07JUL83HHLCP/M All of the CP/M words are in their own vocabulary. FCB2 Space for a second FCB when needed. RESET Reset the CP/M disk system CLOSE Close the current file. SEARCH0 Search for the first occurance SEARCH Search for the next occurance. OPEN Open a file if it exists. MAKE Create a new file. DELETE Delete an old file. READ Read the next sequential record. WRITE Write the next sequential record. \ Create File Control Blocks 08Oct83map(!FCB) (S Addr len FCB-addr --- ) Set up the filce control block per the specified string. This is the primitive file parse word, which breaks the drive/file name string into a drive specifier, file name, and extension, and leaves the parsed result in the given file control block address. !FCB (S FCB-addr ) Parse the next word in the input stream as a file. If CAPS is false, allow lower case names. MAKE-FILE create directory entry for new file, and report errors. \ Save a Core Image as a File on Disk 08Oct83mapHEADER This is different for CP/M-80, CP/M-86, and CP/M-68K. SAVE (S addr len -- ) Save the string specified as a CP/M file whose name is specified following the SAVE word. The current screen file is not disturbed. CREATE-FILE creates a new file containing the given number of blocks. \ Display Directory 05Oct83map.NAME prints one filename. DIR prints a directory of the current dirve. .FILE prints the name of a file, given the address of its FCB. FILE? prints the name of the current file. \ Open files and list directories 30Sep83mapFILE: (S -- fcb ) Define the next word as a file by allocating an FCB in the dictionary and parsing the next word as a file name. Leave the address of the file control block. ?DEFINE (S -- fcb ) Define the next word as a file if it does not already exist. Leave the address of the file control block. DEFINE (S -- ) Define the following word as a file name without opening it. OPEN (S -- ) Open the following file and make it the current file. OPEN does the right thing even if the file was previously defined. \ MultiFile Operations 02AUG83HHLFILES Inter file operations go here. >FROM A pointer to the FCB of the FROM file EXCHANGE (S -- ) Exchange the FROM file with the current FILE. FROM (S -- ) Make the next word in the input stream the FROM file. It will be opened and set to the >FROM file. LOAD (S n -- ) Load from the FROM file and then restore the current file. \ Set up VIEW-FILES table 26Sep83mapMETA80.BLK This file was used to generate the precompile code. We arbitrarily set its view file# to 1 EXTEND80.BLK This file was opened on the execute line. We arbitrarily set its view file# to 2 Now we must initialize the VIEW-FILES array. This way the correct file will automatically be opened when a definition is requested. Unfortunately the user must keep track of which file corresponds to which number, and set up this table.