Home

ciforth manual - Sikkepitje.nl

image

Contents

1. 8 5 DENOTATIONS The wordset DENOTATIONS contains prefixes mostly one letter words that introduce a denotation i e a generalisation of NUMBER Any word starting with the prefix is considered found in the dictionary and the prefix word executed These words parse input and leave a constant number char or string on the stack or compile such constant depending on STATE For a kernel system it is guaranteed that they reside in the minimum search order wordset called ONLY To make a distinction with the same words in other wordlists the names of denotations are prepended with Prefix in the documentation Actual names in the dictionary do not contain the prefix Apart from Prefix_0 the vocabulary contains entries for all hex digits 1 9 and A F Like NUMBER always did all denotations behave identical in interpret and compile mode and they are not supposed to be postponed Chapter 8 Glossary 71 8 5 1 Prefix_ Name Prefix_ Stackeffect sc Attributes CI Description Parse a delimited string and leave it on the stack A can be embedded in a string by doubling it This is a denotation during compilation this behaviour is compiled 8 5 2 Prefix_ amp Name Prefix_ amp Stackeffect c Attributes CI Description Leave c the non blank char that follows Skip another blank character This is a denotation during compilation this behaviour is compiled See also 8 5 3 Pref
2. See also UM MOD SM REM Mx 8 18 6 SM REM Name SM REM Stackeffect d nl n2 n3 Attributes ISO Description A mixed magnitude math operator which leaves the signed remainder n2 and signed quotient n3 from a double number dividend d and divisor n1 This is a symmetric division i e the remainder takes its sign from the dividend See also M MOD Mx 8 18 7 UM Name UM Stackeffect ul u2 ud Attributes ISO Description A mixed magnitude math operation which leaves the double number ud the unsigned product of two unsigned numbers u1 and u See also UM MOD Mx x 112 ciforth manual 8 18 8 UM MOD Name UM MOD Stackeffect ud ul u2 u3 Attributes ISO Description Leave the unsigned remainder u2 and unsigned quotient u3 from the unsigned double dividend ud and unsigned divisor ul See also UM SM REM 8 19 OPERATINGSYSTEM The wordset OPERATINGSYSTEM contains words that call the underlying operating system or functions available in the BIOS rom 8 19 1 ARGS Name ARGS Stackeffect addr Attributes Description Return the addr of ARGS a user variable that contains a system dependant pointer to any arguments that are passed from the operating system to ciforth during startup In this ciforth it points to an area with the argument count followed
3. 126 ciforth manual 8 23 5 LIST Name LIST Stackeffect n Attributes ISO FIG LO Description Display the ASCII text of screen n The number of the screen is always printed in decimal SCR contains the screen number during and after this process See also BLOCK 8 23 6 LOAD Name LOAD Stackeffect n Attributes ISO FIG LO Description Interrupt the current input source in order to interpret screen n The stack changes in according with the words executed At the end of the screen barring errors or forced changes it continues with the interrupted input source See also BLOCK BUFF THRU QUIT EXIT gt LIST 8 23 7 LOCK Name LOCK Stackeffect n Attributes CI Description Lock the block n Multiple locks are possible and require multiple unlocks Probably because it is to become the current input source The result is that its buffer will not be reclaimed until an UNLOCK occurs See also BLOCK UNLOCK BUFF 8 23 8 R Name Rit Stackeffect addr Attributes U Description A user variable which may contain the location of an editing cursor or other file related function Unused in the kernel of ciforth 8 23 9 SCR Name SCR Stackeffect addr Attributes U Description A user variable containing the screen number most recently reference by LIST See also BLOCK Chapter 8 Glossary
4. Attributes Description MESSAGE is generally used to print error and warning messages Print on the standard error channel the text of line n relative to screen ERRSCR n may be positive or negative and beyond just screen ERRSCR The messages with negative offset contain the strings belonging to the return values for Linux system calls 0 MESSAGE will print version information about the library file the messages sit in If WARNING is zero disc unavailable the message will simply be ignored See also ERROR 8 9 8 THROW Name THROW Stackeffect tc te Attributes ISO Description If tc is zero it is merely discarded If we are executing under control of a CATCH see CATCH for the effect of a non zero tc If we are executing not under control of a CATCH a non zero tc gives a message to the effect that this exception has occurred and starts Forth anew See also CATCH QUIT HANDLER ERROR ERROR 86 ciforth manual 8 9 9 WARNING Name WARNING Stackeffect addr Attributes FIG U Description A user variable containing a value controlling messages If it is 1 a library file is open and messages are fetched from it If it is 0 messages will be presented by number only Don t set WARNING to 1 if there is no block system available because the error system will call itself recursively This may lead to a crash See also MESSAGE
5. ERROR ERRSCR 8 9 10 WHERE Name WHERE Stackeffect addr Attributes U Description A user variable pair which contains the start of the source and the character position of the last error that was thrown by ERROR so not of exceptions thrown The contents of WHERE is interpreted by ERROR if the corresponding exception was never caught See also THROW CATCH 8 9 11 ABORT Name ABORT Stackeffect f Attributes Description The run time action of ABORT 8 9 12 HANDLER Name HANDLER Stackeffect addr Attributes Description A user variable address containing a pointer to the last exception intercepting frame activated by CATCH It points into the return stack If there is a THROW the return stack is restored from HANDLER effecting a multiple level return It is called a frame because more things are restored such as the position of the data stack top and the previous value of HANDLER See also CATCH THROW 8 10 FILES The wordset FILES contains words to input and output to files or load words from files They are underlying the BLOCKS facilities Chapter 8 Glossary 87 8 10 1 CLOSE FILE Name CLOSE FILE Stackeffect fileid ior Attributes ISO Description Close the file with file handle in fileid Return a result code into ior The latter is the Linux error code negated to be inspected using MESSAGE See also OPE
6. OR 8 15 8 INVERT Name INVERT Stackeffect nl n2 Attributes ISO L1 Description Invert all bits of n1 leaving n For pure flags 0 or 1 this is the logical not operator See also AND OR 102 ciforth manual 8 15 9 OR Name OR Stackeffect nl n2 n3 Attributes ISO FIG LO Description Leave the bit wise logical or of two 32 bit values See also AND XOR 8 15 10 U lt Name U lt Stackeffect ul u2 ff Attributes ISO LO Description Leave a true flag if ui is less than u otherwise leave a false flag Interpreted as unsigned numbers See also lt 8 15 11 XOR Name XOR Stackeffect nl n2 n3 Attributes L1 Description Leave the bitwise logical exclusive or of two 32 bit values See also AND OR 8 16 MEMORY The wordset MEMORY contains words to fetch and store numbers from double s cell s or bytes in memory There are also words to copy blocks of memory or fill them and words that fetch a cell operate on it and store it back 8 16 1 Name Stackeffect n addr Attributes ISO FIG LO Description Store all 32 bits of n at addr See also C 21 LI PI PCL Chapter 8 Glossary 103 8 16 2 Name Stackeffect n addr Attributes ISO FIG LO Description Add n to the value addr See also TOGGLE 8 16 3 2 Name
7. PRESENT FIND 8 6 9 FORGET Name FORGET No stackeffect Attributes ISO FIG E LO Description Executed in the form FORGET cccc Deletes definition named cccc from the dictionary with all entries physically following it Recover the space that was in use See also FENCE FORGET VOC 8 6 10 FOUND Name FOUND Stackeffect sc dea Attributes Description Look up the string sc in the dictionary observing the current search order If found leave the dictionary entry address dea of the first entry found else leave a nil pointer If the first part of the string matches a denotation word that word is found whether the denotation is correct or not See also PRESENT CONTEXT FIND FIND VOCABULARY 8 6 11 HERE Name HERE Stackeffect addr Attributes ISO FIG LO Description Leave the address addr of the next available dictionary location See also DP 8 6 12 ID Name ID Stackeffect dea Attributes Description Print a definition s name from its dictionary entry address For dummy entries print nothing See also gt FFA gt NFA 76 ciforth manual 8 6 13 IMMEDIATE Name IMMEDIATE No stackeffect Attributes Description Mark the most recently made definition so that when encountered at compile time it will be executed rather than being compiled i e the immediate bit in its header is set T
8. Name OPEN FILE Stackeffect sc fam fileid ior Attributes ISO Description Open the file with name sc and file access method fam Return a file handle into fileid and a result code into ior The latter is the errno error code negated to be inspected using MESSAGE fam is one of OZREAD ONLY 1 WRITE_ONLY 2 READ_WRITE See also OPEN FILE READ FILE WRITE FILE CREATE FILE DELETE FILE 8 10 7 PUT FILE Name PUT FILE Stackeffect scl sc2 Attributes Description Save the string constant sc to a file with the name sci Any errors are thrown See also GET FILE OPEN FILE THROW 8 10 8 READ FILE Name READ FILE Stackeffect addr nl fd n2 ior Attributes ISO Description Read n characters to addr from current position of the file that is open at fd n2 is the number of characters successfully read this may be zero ior is 0 for success or otherwise errno error code negated to be inspected using MESSAGE See also OPEN FILE WRITE FILE REPOSITION FILE RAW 8 10 9 REPOSITION FILE Name REPOSITION FILE Stackeffect ud fd ior Attributes ISO Description Position the file that is open at fd at position ud ior is 0 for success or otherwise errno negated Information about error codes can be found by MESSAGE See also OPEN FIL
9. TYPE CR 8 21 13 SPACES Name SPACES Stackeffect n Attributes ISO FIG LO Description If n is greater or equal to zero display as much spaces See also SPACE OUT 120 ciforth manual 8 21 14 SPACE Name SPACE No stackeffect Attributes ISO FIG LO Description Transmit an ASCII blank to the output device See also EMIT OUT 8 21 15 TYPE Name TYPE Stackeffect addr count Attributes ISO FIG LO Description Transmit count characters from addr to the output device All terminal I O goes through this word It is high level so terminal I O can be redirected by revectoring it and the usual redirection or tee ing by Linux In this ciforth strings may contain embedded LF s with the effect of a new line at that point in the output however in that case OUT is not observed See also EMIT OUT ETYPE 8 21 16 U Name U Stackeffect u Attributes ISO Description Print the unsigned number u observing the current BASE followed by a blank See also OUT R D R D D R 8 22 PARSING The outer interpreter is responsible for parsing i e it gets a word from the current input source and interprets or compiles it advancing the IN pointer The wordset PARSING contains the words used by this interpreter and other words that consume characters from the input source In this way the outer i
10. dea return its code field address addr By jumping indirectly via this address the definition dea is executed This is the address that is compiled within high level definitions so it serves as an execution token In ciforth it has offset 0 so it is actually the same as the DEA See also CFA gt gt DFA gt FFA gt LFA gt NFA gt SFA gt PHA 78 ciforth manual 8 6 21 gt DFA Name gt DFA Stackeffect dea addr Attributes Description Given a dictionary entry addres return its data field address addr This points to the code for a code word to the high level code for a colon definition and to the DOES gt pointer for a word build using CREATE Normally this is the area behind the header found via gt PHA See also gt BODY gt CFA gt FFA gt LFA gt NFA gt SFA gt PHA 8 6 22 gt FFA Name gt FFA Stackeffect dea addr Attributes Description Given a dictionary entry addres return its flag field address addr See also gt CFA gt DFA gt LFA gt NFA 8 6 23 gt LFA Name gt LFA Stackeffect dea addr Attributes Description Given a dictionary entry addres return its link field address addr It contains the DEA of the previous word See also gt CFA gt DFA gt FFA gt NFA gt PHA gt SFA 8 6 24 g
11. respectively If the character is not present scl is a null string its address is zero and sc2 is the original string Both sci and sc2 may be empty strings i e their count is zero if c is the last or first character in sc See also 1 CORA 8 26 9 TRAILING Name TRAILING Stackeffect scl sc2 Attributes ISO Description Trim the string constant sc1 so as not to contain trailing blank space and leave it as sc See also BLANK 8 26 10 BL Name BL Stackeffect c Attributes ISO FIG Description A constant that leaves the ASCII value for blank 8 26 11 COUNT Name COUNT Stackeffect addrl addr2 n Attributes ISO FIG LO Description Leave the byte address addr2 and byte count n of a message text beginning at address addr1 It is presumed that the first byte at addr1 contains the text byte count and Chapter 8 Glossary 135 the actual text starts with the second byte Alternatively stated fetch a string constant addr n from the brain damaged string variable at addr1 See also TYPE 8 26 12 S Name S Stackeffect addrl n Attributes ISO LO Description Used in the form S cccc Leaves an in line string cccc delimited by the trailing as a constant string addr1 n In ciforth the number of characters has no limit and using S has always an effect on HERE
12. 00045 15 code field A o mea kinaa 20 code field address 19 20 77 109 COLS WOId es ied Hee ee he wee eerie IPFI alg Colon definition ir er 12 19 20 compilation Mode eusebio 4 compilation word liSt o oo oooooo o oo o 137 computation StaCk oosmssinoneraceras ci 12 A O 15 current input source 55 91 120 121 122 123 126 127 128 D dde ici epa 13 data feld eri 2e se ERRE REP ie 18 19 data field address 0 18 19 20 78 data stack sisse phe RII pias 12 98 130 131 DEA ce eee 12 18 73 74 77 80 81 109 defining Word ose as REESE 3 13 44 67 denotation 13 19 45 70 72 73 75 76 77 122 132 139 denota 1255 esee viedo wal ecard EF dos 4s Gale EID 76 GiCtiONary seiiet torete adi eueie es ead ese 12 dictionary entry 0 0 12 18 137 139 dictionary entry address 12 18 19 20 49 73 79 dictionary pointer 64 12 73 74 double ciao coso ERI 13 49 81 89 102 110 E execution token 12 19 12 3 74 109 extra field addresS ooooooocooomomooo 79 F family Of instructions 2204 5 centrar 2T field address ize ice p RR RR E Runs 18 Hag dea Gite Inada Gd pec roe 49 100 flag field address ccr mete I9 TS floored divisi n 22 dcs oid Soh ees wn cA 114 Forth 18g neu ertet dite tacts 49 100 H laugh level erui Rr Rr I2 1 20 ALO I immediate bib 2222 str eb eR
13. 4 1 1 Hello world 02 0 cece cece eee eens 9 4 1 2 The lbraryc trial es Le ead eae dau dee 10 4 1 3 Development 0 0 00 cece eect eee es 10 4 14 Finding things Ob Rr ae tes db 42 Configuring 243 2 eee ea era eed Med a dee bep 12 4 3 Concepts us neta heb eenvR T RD detects etededuedoetec watts 12 AA Portability aves 26d sae et IURE bia eda ed dae edd 14 4 5 Saving a new system 0 cece cee eee hh 15 4 6 Memory organization sacio eitera rrene eee eee ene 16 4 6 1 Boot up Parameters seseees eese 16 4 6 2 Installation Dependent Code 004 16 4 6 3 Machine Code Definitions 0005 17 4 6 4 High level Standard Definitions it 4 6 5 User definitions 0 c eee 17 4 6 6 System Tools ees paipa daia add s Celene aes 17 4 6 7 RAM Workspace 0 000 eee eee eee eee eee 18 4 Opecin layouts cco serae ec ea eng enna ele beans ele ts 18 4 7 1 The layout of a dictionary entry esses 18 4 7 2 Details of memory layout s esses esse 20 4 7 3 Terminal I O and vector cebollas vias Ren 21 4 8 Libraries and options 00 0 0 cece cece nn 21 ASA Opt t 0i2 csa00heoe4 rape EPAA eee oec drei e 21 4 8 2 Private libraries 0 00 cece cece eens 23 4 8 3 Turnkey applications 00 0 esses 23 b Assembler seco r4 0 es TAA GR Er RE SS 25 DL Intr duction neki
14. Description Convert the ASCII text at the current input source with regard to BASE The new value is accumulated into double number d1 being left A decimal point anywhere signifies that the input is to be considered as a double ISO requires it to be at the end of the number ciforth allows any number of decimal points with the same meaning ciforth also allows any number of comma s that are just ignored to improve readability If the first unconvertible digit is not a blank this is an error See also NUMBER BLANK 8 11 12 DIGIT Name DIGIT Stackeffect c n1 n2 true ok c nl x false bad Attributes 92 ciforth manual Description Converts the ASCII character c using base n1 to its binary equivalent n2 accompanied by a true flag If the conversion is invalid leaves only a don t care value and a false flag 8 11 13 DPL Name DPL Stackeffect addr Attributes FIG U LO Description A user variable containing the address of the decimal point on double integer input or a nil pointer It may also be used to hold the output column location of a decimal point in user generated formating See also lt FLD HLD 8 11 14 FLD Name FLD Stackeffect addr Attributes FIG U Description A user variable for control of number output field width Unused in the kernel of ciforth 8 11 15 HLD Name HLD Stackeffect addr Attributes FIG
15. addr left there by BACK Usage is BACK POSTPONE BRANCH BACK See also LOOP UNTIL 8 3 80 BRANCH Name BRANCH No stackeffect Attributes FIG C2 L0 Chapter 8 Glossary 67 Description The run time proceedure to unconditionally branch An in line offset is added to the interpretive pointer IP to branch ahead or back BRANCH is compiled by ELSE AGAIN REPEAT See also OBRANCH 8 3 31 FORWARD Name FORWARD Stackeffect addr Attributes Description Complete a forward branch by backpatching an offset from HERE into addr left there by FORWARD Usage is POSTPONE BRANCH FORWARD FORWARD See also LOOP UNTIL 8 4 DEFINING The wordset DEFINING contains words that add new entries to the dictionary A number of such defining word s are predefined but there is also the possibility to make new defining words using CREATE and DOES gt 8 4 1 Name No stackeffect Attributes ISO FIG E LO Description Used in the form called a colon definition CCCC On Creates a dictionary entry defining cccc as equivalent to the following sequence of Forth word definitions until the next or CODE The word is added as the latest into the CURRENT word list The compiling process is done by the text interpreter as long as STATE is non zero Words with the immediate bit set I are executed rather than being compiled 8 4 2 Name
16. not 0 In ciforth the character string is positioned at the dictionary buffer HERE WORD leaves the character count in the first byte the characters and ends with two or more blanks See also WORD PARSE BLK IN 124 ciforth manual 8 22 14 CHAR Name CHAR Stackeffect c Attributes ISO I Description A compiling word Parse a word Add the run time behaviour leave c the first non blank char of that word in the input source In ciforth this word works also in interpret mode See also Prefix_ amp CHAR 8 22 15 Name No stackeffect Attributes ISO FIG LL1 Description Used in a colon definition in form XXX words more Suspend compilation The words after are executed not compiled This allows calculation or compilation exceptions before resuming compilation with See also LITERAL 8 22 16 Name No stackeffect Attributes ISO I LO Description Used in the form cccc Ignore a comment that will be delimited by the end of the current line May occur during execution or in a colon definition Blank space after the word is required See also C 8 22 17 Name No stackeffect Attributes ISO FIG L1 Description Resume compilation to the completion of a colon definition See also P Chapter 8 Glossary 125 8 23 SCREEN Most of the blocks mass storage is used for screen s that have
17. 129 pisi CMT 44 129 Q Rear ne ee ne Rea AE e gee ee 13 103 A LETT 5 124 A es tewbryePe4vestrterei eed T Joc PLE 29 38 Briana edd Dues gu PER Red ae RP pus 31 BP IS oU sumo ibiza eaa iv been ed ted 39 BS A E E E G A 31 CHAR sivetdaic mies vale Obes nes bow eee ee aed 124 ciforth manual A hes detach ee i rn LL RR Oe 5 124 LA A ideas 110 SMATU oparia e a ade De aR sd aa 81 TOO AEE E Shad eed ha E EEEE E 39 pep crc ode te akc hfe Met PET 9 117 122 132 CASE SENSITIVE cca s ccadebue Gee rara REA 45 MECO oa Ay Bt en eael Heise mte loans toS tan anes 9 13 115 135 rrIPCUP ada ios 103 2 0 corral a E oa 59 SLD P od da eibi 58 62 64 65 X RIGIN 2 26eilz ned sade ae rec ERE 15 16 93 gt 2 101 SB DY rural idea e EE 19 73 74 SCEA cL cC 19 77 SDEA i lzies e eid bh poe ber C PET E 19 78 A E 19 78 SIN PC ECT EA 1 14 95 96 SLB Lr 19 78 SNE A coreane oaae E TP Ch UE MEE ees 19 78 SNUMBER C oaa ya RUP ito 90 POR laa a AAA duca d dob a ps co 78 SRI cats adsis diametri 60 61 130 SSP Aico ieee abeend PRU RIS U IM TOP 19 79 PVE Ao Dea o ema Late E ena E d ERE E Pg ERR 79 SWI D ass bs Ades Saas a ee 79 PRE 0202 aden ER de esate Ree EA eee AGE TOON BOSS 79 Forth Word Index A cues EEEE ER 124 lt TET 101 E PERIERE 89 90 91 100 0 TCR 122 135 o 100 Oe cL I M II 100 OBRANCH Lo sande bee Hagae ater
18. All opcodes on the first position are the same as Intel opcodes barring the bar Note that sometimes parts that are integrated in the opcodes in Intel mnemonics are a separate fixup in the Postit Fixup assembler Examples are the condition codes in jumps You can use it in two ways e You want the opcode for some known Intel opcode Look it up in the first column One of the opcodes on that line is what you want To pick the right one consider the extension that are explained in table 2 Exception PUSHT is not on the line with PUSH Some times you have to trim built in size designators e g you look up LODSW but you are stuck at LODS so that s it With SHOW LODS you can see what the operands look like e You want to know what a POSIT FIXUP code does Look it up in the table on the first word on the line you should recognize an Intel opcode For example you have CALLFAROI That is at the line with CALL So the combination of operands for CALLFAROI are to be found in the description for CALL in the Intel manuals 32 ciforth manual Note Some things are ugly LDS should be LIDS I would replace MOV FA by STA and MOVITA by LDA But that would make the cross referencing more problematic Note The meaning of the operands for JMP and JMPFAR are totally different So my suffices are different Table 1 Opcode cross reference AAA AAD AAM AAS ADC ADCI ADCI A ADCSI
19. Description Parse a character and issue error message if it is not a blank delimiter Chapter 8 Glossary 8 24 5 TEXEC Name EXEC No stackeffect Attributes Description Issue an error message if not executing See also ERROR 8 24 6 7LOADING Name LOADING No stackeffect Attributes Description Issue an error message if not loading See also 7ERROR 8 24 7 PAIRS Name PAIRS Stackeffect nl n2 Attributes Description Issue an error message if n1 does not equal n compiled conditionals do not match See also ERROR 8 24 8 STACK Name STACK No stackeffect Attributes Description Issue an error message if the stack is out of bounds See also ERROR 8 24 9 CSP Name CSP Stackeffect addr Attributes U 129 The message indicates that Description A user variable temporarily storing the stack pointer position for compilation error checking 130 ciforth manual 8 25 STACKS The wordset STACKS contains words related to the data stack and return stack Words can be moved between both stacks Stacks can be reinitialised and the value used to initialise the stack pointer s can be altered 8 25 1 S Name S Stackeffect from to Attributes Description Print the stack in the current base See also LIST 8 25 2 gt R Name gt R Stackeffect n Attributes ISO FIG C LO Description Remove a nu
20. ISO Description Wait for n milliseconds See also KEY 8 19 7 SHELL Name SHELL Stackeffect addr Attributes Description Leave the address addr of a counted string the name of a file that contains the command interpreter or shell This name may be changed an is used by the SYSTEM command The name may contain a path and be at most 252 characters long The default name is bin sh are reserved for a start up stack See also SYSTEM 114 ciforth manual 8 19 8 SYSTEM Name SYSTEM Stackeffect sc Attributes ISO Description Have the operating system execute the command contained in the string sc See also BLOCK ERROR ERRUR 8 19 9 ZEN Name ZEN Stackeffect sc addr Attributes Description Leaves an address that contains a zero ended c type equivalent of sc The same buffer is reused such that this word is not reentrant Use the word immediately e g its intended used is passing parameters to the operating system In fact this is RW BUFFER See also OPEN FILE LINOS LINOS5 8 20 OPERATOR The wordset OPERATOR contains the familiar operators for addition multiplication etc The result of the operation is always an integer number so division can t be precise On ciforth all division operations are compatible with symmetric division The ISO standard require a Forth to choose between floored or symmetric
21. ISO FIG LO Description Drop the number from the stack See also DUP 8 14 7 DUP Name DUP Stackeffect n nn Attributes ISO FIG LO Description Duplicate the value on the stack See also OVER 8 14 8 OVER Name OVER Stackeffect nl n2 nl n2 n1 Attributes ISO FIG LO Description Copy the second stack value placing it as the new top See also DUP 8 14 9 ROT Name ROT Stackeffect nl n2 n3 n2 n3 nl Attributes ISO FIG LO Description Rotate the top three values on the stack bringing the third to the top See also SWAP 100 ciforth manual 8 14 10 SWAP Name SWAP Stackeffect nl n2 n2 nl Attributes ISO FIG LO Description Exchange the top two values on the stack See also ROT 8 15 LOGIC The wordset LOGIC contains logic operators and comparison operators A comparison op erator such as delivers a Forth flag 1 for true 0 for false representing a condition such as equality of two numbers The number 1 has all bits set to one The logical operators AND etc work on all 32 bits one by one In this way they are useful for mask operations as well as for combining conditions represented as flag s But beware that IF only cares whether the top of the stack is non zero such that can mean non equal to IF Such conditions often named just flag s cannot be directly combined using logical operators but 0 0 can help 8 15 1 0 l
22. If it executes successfully i e no THROW is executed by xt leave a zero into tc in addition to any stack effect xt itself might have Otherwise in tc the non zero throw code is left and the stack depth is restored The values of the parameters for xt could have been modified In general there is nothing useful that can be done with those stack items Since the stack depth is known the application may DROP those items See also THROW QUIT HANDLER Chapter 8 Glossary 85 8 9 5 ERROR Name ERROR Stackeffect n Attributes Description Notify the user that an uncaught exception or error with number n has occurred The word that caused it is found using WHERE and displayed Also n is passed to MESSAGE in order to give a description of the error This word is executed by THROW before restarting the interpreter and can be revectored to give more elaborate diagnostics See also 7ERROR WARNING 8 9 6 ERRSCR Name ERRSCR Stackeffect addr Attributes Description A variable containing the address of the number of the screen from which messages are offset Messages correspond with lines and the offset may be positive or negative 0 MESSAGE prints the first line of this screen Traditionally this was screen 4 but the negative Unix error numbers makes this unfeasible See also C L MESSAGE 8 9 7 MESSAGE Name MESSAGE Stackeffect n
23. LL Level One definition of FORTH 78 NFIG Word belongs to FIG standard but the implementation is not quite conforming NISO Word belongs to ISO standard but the implementation is not quite conforming 50 ciforth manual y A user variable Where there is mention of a standard or a model it means that the word actually complies to the standard or the model not that some word of that name is present Words marked with ISO FIG LO will behave identically over all but the whole spectra of Forth s Unless otherwise noted all references to numbers are for 32 bit signed integers For 64 bit signed numbers the most significant part with the sign is on top All arithmetic is implicitly 32 bit signed integer math with error and under flow indication unspecified A nil pointer is an address containing zero This indicates an invalid address The Forth words are divided into wordset s that contain words that logically belong together Each wordset has a separate section with a description The following rules take precedence over any wordset a word may logically belong to e A defining word one that adds to the dictionary is present in the wordset DEFINING e Adenotation word one that has the prefix bit set is present in the wordset DENOTATIONS e An environmental query word one that is understood by ENVIRONMENT is present in the wordset ENVIRONMENTS 8 1 BLOCKS The blo
24. NOOP the handling of options during cold boot is suppressed useful for turnkey applications By redefining as DROP 0 execution and signon are suppressed See also COLD 8 12 6 QUIT Name QUIT No stackeffect Attributes ISO FIG Description Restart the interpreter Clear the return stack stop compilation and return control to the operators terminal or to the redirected input stream This means ACCEPT user input to somewhere in the terminal input buffer and then INTERPRET with that as a SOURCE No message is given See also TIB ABORT 8 12 7 WARM Name WARM No stackeffect Attributes FIG LO Description Perform a so called warm start In addition and before the actions of ABORT discard blocks they may not be written back to mass storage Display the sign on message See also ABORT 8 13 INPUT The wordset INPUT contains words to get input from the terminal and such See Section 8 10 FILES page 86 for disk I O See Section 8 1 BLOCKS page 50 for access of blocks Chapter 8 Glossary 95 8 13 1 ACCEPT Name ACCEPT Stackeffect sc Attributes Description Accept characters from the terminal until a RET is received and return the result as a constant string sc It doesn t contain any line ending but the buffer still does and after 1 the string ends in a LF The editing functions are the same as with ACCEPT This is lighter on the system and s
25. No stackeffect Attributes ISO FIG I C LO Description Terminate a colon definition and stop further compilation Compiles the run time EXIT See also bs 68 ciforth manual 8 4 3 CONSTANT Name CONSTANT Stackeffect n Attributes ISO FIG LO Description A defining word used in the form n CONSTANT cccc to create word cccc with its data field containing n When cccc is later executed it will push the value of n to the stack See also VARIABLE 8 4 4 CREATE Name CREATE No stackeffect Attributes Description A defining word used in the form CREATE cccc Later execution of cccc returns its data field i e the value of HERE immediately after executing CREATE It can be the base of a new defining word if used in the form CREATOR CREATE aaaa DOES gt bbbb CREATOR cccc The second line has the effect of creating a word cccc Its datastructure is build by the code aaaa and when executing cccc its data field is pushed on the stack then the code bbbb is executed Space in this data field has yet to be allocated and the execution action can be changed ciforth is byte aligned so no extra measures are needed See also DOES gt CODE ALLOT C 8 4 5 DOES gt Name DOES gt No stackeffect Attributes ISO FIG LO Description A word which is normally use to specify the run time action
26. The wordset JUGGLING contains words that change order of data on the data stack The necessity for this arise because the data you want to feed to a Forth word is not directly accessible i e on top of the stack It is also possible that you need the same data twice because you have to feed it to two different words s Design your word such that you need them as little as possible because they are confusing 8 14 1 2DROP Name 2DROP Stackeffect nl n2 Attributes ISO Description Drop the topmost two numbers or one double number from the stack See also DROP 2DUP 8 14 2 2DUP Name 2DUP Stackeffect d dd Attributes ISO Description Duplicate the double number on the stack See also OVER 8 14 3 20VER Name 20VER Stackeffect d1 d2 d1 d2 d1 Attributes ISO Description Copy the second stack double placing it as the new top See also 2DUP 8 14 4 2SWAP Name 2SWAP Stackeffect d1 d2 d2 dl Attributes ISO Description Exchange the top doubles on the stack See also ROT Chapter 8 Glossary 99 8 14 5 DUP Name DUP Stackeffect nl nl if zero n1 n1 n1 non zero Attributes ISO FIG LO Description Reproduce n1 only if it is non zero This is usually used to copy a value just before IF to eliminate the need for an ELSE part to drop it See also DUP _ 8 14 6 DROP Name DROP Stackeffect n Attributes
27. USER CONSTANT 8 48 VOCABULARY Name VOCABULARY No stackeffect Attributes FIG E L Description A defining word used in the form VOCABULARY cccc to create a vocabulary definition cccc It will create a word list in the ISO sense Subsequent use of cccc will push this word list the word list associated with cccc to the top of the search order in CONTEXT So it will searched first by INTERPRET A vocabulary s data content field contains at first the dovoc pointer like for any DOES gt word then follows its body The body contains the vocabulary link field address VLFA The VLFA points to the VLFA of the next vocabulary or a nil pointer for the end Then follows a dummy dea that serves as word list identifier or WID in the sense of the ISO standard It has empty fields except for the link field The link field address contains the DEA of the latest word of the vocabulary or a nil pointer if empty Executing the vocabulary means pushing its WID on top of the CONTEXT order In ciforth when there can be at most 16 word list s in the search order the oldest one gets lost The vocabularies generated are IMMEDIATE words See also VOC LINK DEFINITIONS 8 4 9 CODE Name CODE No stackeffect 70 ciforth manual Attributes C Description The run time proceedure compiled by CODE that rewrites the code field of the most recently defined word to point to the following ma
28. WHILE Stackeffect f run time addrl nl addr2 n1 addr1 n2 compile time Attributes ISO FIG I C2 Description Occurs in a colon definition in the form BEGIN WHILE tp REPEAT At run time WHILE selects conditional execution based on boolean flag f If f is true non zero WHILE continues execution of the true part thru to REPEAT which then branches back to BEGIN If f is false zero execution skips to just after REPEAT exiting the structure At compile time WHILE compiles OBRANCH and tucks the target address addr2 under the addr1 left there by BEGIN The stack values will be resolved by REPEAT n1 and n provide checks for compiler security See also FORWARD BEGIN 8 3 21 LOOP Name LOOP Stackeffect n Attributes C2 Chapter 8 Glossary 65 Description The run time proceedure compiled by LOOP which increments the loop index by n and tests for loop completion See also LOOP 8 3 22 Name No stackeffect Attributes Description This is a synonym for EXIT It is the run time word compiled at the end of a colon definition which returns execution to the calling proceedure Stop interpretation of the current definition The return stack must not be engaged See also EXIT 8 3 23 DO Name D0 No stackeffect Attributes C Description The run time proceedure compiled by D0 which prepares the retur
29. XORI XORIIA SIB Table 2 Suffixes not separated by a I Immediate operand SI Sign extended immediate operand FAR Far sometimes combined with OI O Operand OI Operand indirect 5 11 Reference opcodes Pentium only Table three contains all the opcodes present in asipentium frt in alphabetic order with sorted before any letter All opcodes on the first position are the same as Intel opcodes barring the bar Note that again sometimes parts that are integrated in the opcodes in Intel mnemonics are a separate fixup in the Postit Fixup assembler You can use it in the same way as the Intel 386 table But there are much less instances where the opcodes do not agree exactly with Intels Memory operands are specified in the same way for floating point instructions But in those instructions register operands are always floating point registers There is always at most one register specified in a floating point instruction This explicit register may be modifiable target or not For two register operation STO is always implicit In that case normally it is the first operand as per STO ST1 If modiable this means the result is stored in ST1 the explicit register Reversed operation means STO is the second operand as per ST1 STO If modiable this means again that the result is stored in ST1 the explicit register And don t forget SHOW lt opcode gt is your friend Table 3 Opcode cross r
30. added It is the compilation word list in the sense of the ISO standard The WID has the structure of a dictionary entry This allows to link in a new word between the link field of the WID and the next definition See also VOCABULARY CONTEXT 138 ciforth manual 8 28 5 DEFINITIONS Name DEFINITIONS No stackeffect Attributes ISO Description Used in the form cccc DEFINITIONS Make the top most search order word list context the compilation word list current In the example executing vocabulary name cccc add it to the top of the search order and executing DEFINITIONS will result in new definitions added to cecce See also CONTEXT VOCABULARY 8 28 6 ENVIRONMENT Name ENVIRONMENT No stackeffect Attributes CI Description The name of the ENVIRONMENT vocabulary The associated word list contains envi ronment queries The names of words present in ENVIRONMENT are recognized by ENVIRONMENT This word list is not intended to be used as a CONTEXT word list and only as a CURRENT whenever you want to add an environment query See also VOCABULARY 8 28 7 FORTH Name FORTH No stackeffect Attributes NISO FIG LL1 Description The name of the primary vocabulary Execution pushes the FORTH WID to the top of the search order For ISO compliance it would replace the top Until additional user word list s are created new user definitions become a part of FORTH FORTH
31. even during interpretation In ciforth a can be embedded in a string by doubling it In non portable code denotations are recommended om See also 8 27 SUPERFLUOUS The wordset SUPERFLUOUS contains words that are superfluous because they are equivalent to small sequences of code Traditionally one hoped to speed Forth up by coding these words directly 8 27 1 0 Name 0 Stackeffect 0 Attributes Description Leave the number 0 See also CONSTANT 8 27 2 1 Name 1 Stackeffect nl n2 Attributes L1 Description This is shorthand for 1 See also CELL 1 8 27 3 1 Name 1 Stackeffect nl n2 Attributes ISO Description This is shorthand for 1 See also 1 136 ciforth manual 8 27 4 2 Name 2 Stackeffect nl n2 Attributes ISO Description Perform an arithmetical left The bit pattern of n1 is shifted to the left with a result identical to 1 LSHIFT This word should not be used See also 2 8 27 5 2 Name 2 Stackeffect nl n2 Attributes ISO Description Perform an arithmetical right The bit pattern of n1 is shifted to the right except that the left most bit sign bit remains the same This is the same as S gt D 2 FM MOD SWAP DROP It is not the same as 2 nor is it the same as 1 RSHIFT This confusing word should never be used See also 2
32. imc MT 54 EM NUD Lise uh sus desc ve E DLE E Loma 110 cr RS 80 A 80 FORGET MC 75 o lt 25icchieciitsdigestueetdebecsedie 80 FORT PCT RTT axa 138 FORWARD 1i esinee nheney MID p ERIS deris 67 A CERE DONEC EET 75 G CET o EE S d Seas 87 H HANDLER 2 2sdeesduec ias ea Seve bar og dus 86 o ETT 75 REL 91 HIDBEN A 80 TO MPO 92 ciforth manual I PM Tu 61 ID ira a e nbtbes keRBPbiee PIT la 75 IP negreto eare a E T apace ates 61 IMMEDIATE td Ib ica 76 A eRrikf 4 RS 03 PbRP4 RTOO ENS 95 Dg A O A E E 122 INCLUDED cuina drid natant aes 87 INDEX eii ao cada 125 INTERPRET Li4j92 kept REPRISE uer ER PR 122 INVERT 1e pmi dus RM EXP nS 101 J Jueces eM M E Sesser 62 K o dH 96 KEYTu 2 tee id dadend pid agi pb x eiit 96 L Dl d uester URP ORIMPEDILUE REPAS DUE 107 TiO pP 107 LATEST pestillo 138 LEAVE anios gh ais el agi ETE QU Eas 62 LIMIT ues eee id PIE XY rS 54 LINOS 2i xe faded rei ideas nbi dut 113 LINO cae res taaa ii didas 113 TEST scouted eiim arate dacs EE 126 IR Lut cee area eats 57 LITERAL oia iodo 56 OD a Re 126 LOCK aa id 126 A O 62 LSHLIET oae eerdre aaa ii ERES 116 M A OU ees 111 M MOD cn depre PER UTER toh death a dak 111 M X ui 2894 00 Chetan T EEE e tin eves 116 MESSAGE cocer ida eei eE lada 85 MIN e esae e cae bets Gases up i ase s 116 MOD ia YER RE ERE e E Ed 116 MOVES tete edens dcc ae tpe E UE 107 Glossary Index MS 113 N NAME cie n
33. needs an extra terminal input buffer Chapter 4 Manual 21 4 7 3 Terminal I O and vectoring It is useful to be able to change the behaviour of I O words such that they put their output to a different channel For instance they must output to the printer instead of to the console In general this is called vectoring Remember that in normal Forth system all printing of numbers is to the terminal not to a file or even a buffer On a linux system something like it can be accomplished by the redirection facilities available For this reason character output CR EMIT and TYPE all go through a common word that can be changed For lina it is TYPE Because this is defined in high level code it can temporarily be replaced by other code This revectoring is possible for all high level words in ciforth such that we need no special measures to make vectoring possible As an example we replace TYPE by MYTYPE MYTYPE gt DFA TYPE gt DFA And back to default 2 TYPE gt PHA TYPE gt DFA Be careful not to define MYTYPE in terms of TYPE as a recursive tangle will result This method works in all versions of ciforth and is called revectoring A similar technique is not so useful on the input side because keys entered during EXPECT are subject to correction until lt RET gt has been pressed On lina EXPECT is left to the operating system such that inputting to lina has the same look and feel as other input Text can be past
34. the disc buffer containing block n which is the physical disk block OFFSET n The address left is the field within the buffer to be used for data storage If the block is not already in memory it is transferred from disc to a new buffer allocated by BUFFER Blocks are generally used to contain source code to be interpreted by LOAD They can be equally useful to contain other data e g for implementing a database See also BUFFER RAW OFFSET UPDATE FLUSH LOAD 8 1 9 DISK ERROR Name DISK ERROR Stackeffect addr Attributes Description using or closing the block file One means an error and and zero means okay Beware that if error messages are loaded from disk this may clear DISK ERROR This flag is not used See also BLOCK 8 1 10 EMPTY BUFFERS Name EMPTY BUFFERS No stackeffect Attributes ISO FIG LO Description Mark all block buffers as empty Updated blocks are not written to the disc This is an initialization proceedure before first use of the disc The usage as an undo is infeasible in ciforth See also FLUSH BLOCK SCREEN UPDATE Chapter 8 Glossary 53 8 1 11 R W Name R W Stackeffect addr blk n Attributes Description The ciforth primitive for read write of blocks addr specifies the source or desti nation block buffer blk is the sequential number of the referenced physical block and n is a
35. 2 Stackeffect addr x1 x2 Attributes ISO Description Store a pair of 32 bits values x1 x2 to consecutive cells at addr x2 is stored at the lowest address See also 20 cr 8 16 4 20 Name 20 Stackeffect addr x1 x2 Attributes ISO Description Leave a pair of 32 bits values x1 x2 from consequitive cells at addr x2 is fetched from the lowest address See also 2 C 8 16 5 Name Stackeffect addr n Attributes ISO FIG LO Description Leave the 32 bit contents n of addr See also CQ 2 PQ PC LO 8 16 6 ALIGNED Name ALIGNED Stackeffect addrl addr2 Attributes ISO Description Make sure that addr1 is aligned by advancing it if necessary to addr2 See also ALIGN 104 ciforth manual 8 16 7 ALIGN Name ALIGN Stackeffect Attributes ISO Description Make sure that HERE is aligned by advancing it if necessary This means that data of any size can be fetched from that address efficiently See also ALIGNED 8 16 8 BLANK Name BLANK Stackeffect addr count Attributes ISO Description This is shorthand for BL FILL 8 16 9 BM Name BM Stackeffect addr Attributes Description A constant leaving the address of the lowest memory in use by Forth See also DP EM 8 16 10 C Name C
36. 6 35 HIDDEN nito distin tidad ird tod 80 8 6 36 A nie nnanch nen dst Dae a RO cannes 81 8637 MATCH monien neneke tots dire eU 81 BT DOUBLE ojear atada cada 81 A MR 81 872 DABI A EiT E Enp Ea iia ida 82 NC M s lr MANNA RE D 82 BTA Dee ere 82 8 8 ENVIRONMENTS rosas adi oido eire eR wirt 82 8 8 1 CORE MEER 82 OO OPU a e E E MH 82 8 8 3 ENVIRONMENT cias 83 8 8 4 NAME corra do CRT AA Rd En Hel aun 83 8 8 5 SUPPLIER uos dite rtr ehe hi tob aai Pre Hi 83 8 8 6 VERSION 44 acnivaadinne DOCE ORI Ga PREISE ias 83 ES ERRORS cen cetindd coenae E E e A e EN 83 BO TERROR cr pan ea raa eere dro eb eaa 84 8 9 2 Eee 84 8 9 3 ABORT reo Rana 84 B PATO nta padded Net diodo tvi s 84 8 9 5 RO Pn 85 80 ERRIOR estrias 85 BOT MESSAGE ardid 85 8 9 8 THROW MMC EMEN 85 EDS WARNING o seri otovccuur rect Rave eei ds 86 8 9 10 WHERE 2 0 0 cece cece cece ee ees 86 8 9 11 ABONO caera 86 8 9 12 HANDLER er toe e 86 8 10 TBEEES cis ecesasue cn zac rp ti eet ed reda tr s wachewhe 86 S100 CLOSE FIL oc a cescu inap i e e ea 87 8 10 2 ORM ATE BUD ecards iso any ptis 87 103 DELEPESEIEE oras ia atveseases sas coa vaa 87 8104 CET FILE iaa ei da 87 8 10 5 INCLUDED 63522209995 40 C639 0499 ruraran 87 8 10 6 OPEN FILE cecoraoo corrio dg 88 8 1057 PUT EILE A 88 8 10 8 READ FILE a eke Socr eir etaim tae predi 88 8 10 9 REPOSITION FILE ssseee ee 88 8 10 10 WRITE FILE oros estos cda 88 8 10 11 RW BUFFER A A 89 8 11 FORMATTING acest cen cen ee doc
37. A NUMBER OR OTHER DENOTATION The string printed was not found in the dictionary as such but its first part matches a denotation The denotation word however rejected it as not properly formed An example of this is a number containing some non digit character or the character denotation amp followed by more than one character It may also be a miss spelled word that looks like a number e g 25WAP Be aware that denotations may mask regular words This will only happen with user defined denotations Built in denotations are in the ONLY vocabulary that can only be accessed last because it ends the search order Note that hex digits must be typed in uppercase even if CASE SENSITIVE is in effect Error 10 may be caused by using lower case where upper case is expected suach as for ISO standard words See the section Common problems in this chapter if you want to make ciforth case insensitive e ciforth ERROR 11 WORD IS NOT FOUND The string printed was not found in the dictionary This error is detected by tick This may be caused by using lower case where upper case is required for ISO standard words See the section Common problems in this chapter if you want to make ciforth case insensitive e ciforth ERROR 12 NOT RECOGNIZED The string printed was not found in the dictionary nor does it match a number or some other denotation This may be caused by using lower case where upper case is required for ISO standar
38. But DROP is clearer because it can only be interpreted as such it is not a valid word Of course a sensible programmer will not define a word that looks like a denotation 7 CR This must be my lucky day TYPE DON T DO THIS 4 4 Portability If you build your words from the words defined in the ISO standard and are otherwise careful your programs may run on other systems that are ISO standard There are no gratuitous deviations from the standard However a few things are not quite conforming lk The error system uses CATCH and THROW in a conforming way However the codes are not assigned according to the table in the standard Instead positive numbers are ciforth errors and documented in this manual ciforth s errors identify a problem more precisely than the standard allows An error condition that is not detected has no number assigned to it Negative numbers are identical to the numbers used by the host operating system No attempt is made to do better than reproduce the messages belonging to the number as given by strerror It is not possible to catch the following words ABORT ABORT QUIT There is no REFILL This is a matter of philosophy in the background You may not notice it Consequences are that BLK is not inspected for every word interpreted but that blocks in use are locked Files are not read line by line but read in full and evaluated It doesn t use gt IN exactly in the way p
39. Description Occurs in a colon definition in one of the forms me UNTIL BEGIN AGAIN BEGIN WHILE REPEAT At run time BEGIN marks the start of a sequence that may be repetitively executed It serves as a return point from the corresponding UNTIL AGAIN or REPEAT When executing UNTIL a return to BEGIN will occur if the top of the stack is false for AGAIN and REPEAT a return to BEGIN always occurs At compile time BEGIN leaves its return address and n for compiler error checking See also BACK 60 ciforth manual 8 3 5 CO Name CO No stackeffect Attributes Description Return suspend interpretation of the current definition such that when the caller exits this definition is resumed The return stack must not be engaged such as between gt R and R gt or DO and LOOP See also EXIT 8 3 6 DO Name DO Stackeffect nl n2 execute addr n compile Attributes ISO FIG I C2 L0 Description Occurs in a colon definition in form DO LOOP At run time DO begins a sequence with repetitive execution controlled by a loop limit n1 and an index with initial value n2 DO removes these from the stack Upon reaching LOOP the index is incremented by one Until the new index equals or exceeds the limit execution loops back to just after DO otherwise the loop parameters are discarded and execution continues ahead Both n1 and n are determined
40. Descriptor Table Register LIDT Load Interrupt Descriptor Table Register LTR Load Task Register LMSW Load Machine Status Word RDTSC Read from Time Stamp Counter RDMSR Read from Model Specific Register SHLD Double Precision Shift Left SHRD Double Precision Shift Right SLDT Store Local Descriptor Table Register SMSW Store Machine Status Word VERR Verify a Segment for Reading or Writing WRMSR Write to Model Specific Register 40 ciforth manual Suffices of the opcode i e part of the opcode word ALL All CD Control Debug register FS Replaces FS in irregular opcodes GS Replaces GS in irregular opcodes AD Implicit A and Double result IC Implicit C count Items in Fixups Y Yes Use the condition straight NI No Use the condition inverted O Overflow C Carry Z Zero CZI C I Z unsigned lt S Sign 0 P Parity even LI S O signed lt LE L Z signed lt TI To primed or special register F From primed or special register V Variable number in shifts 1l Just by 1 ZO Zero Offset BO I Byte Offset XO Xell Offset Items in Commaers Note that in commaers there is never an X You always have to choose between W for 16 bits and L for 32 bits OW Obligatory word RL Cell relative to IP RW Cell relative to IP RB Byte relative to IP SG Segment word P Port number byte IS Single obligatory byte
41. If you want to find things out you must start up lina again by lina e The sequence REQUIRE TUCK LOCATE TUCK shows you the source for TUCK if it is in the library somewhere REQUIRE TUCK CRACK TUCK show you the source for TUCK if it is in the library or in the kernel but without comment or usage information 12 ciforth manual 4 2 Configuring For configuring your lina without enlarging the dictionary you may use the following se quence S myforth lab BLOCK FILE Or any config 1 LOAD REQUIRE SAVE SYSTEM DOIT CONTAINS FORTH FORGET VOC CONTAINS gt NFA DP newforth SAVE SYSTEM BYE DOIT Here DOIT trims the dictionary just before the saving your system into a new file You can use a similar sequence for expanding the system without building in the SAVE SYSTEM command as well FAR DP allows have a disposable part of the dictionary This may be occasionally useful but make sure to FORGET always the disposed off words 4 3 Concepts A forth user is well aware of how the memory of his computer is organised He allocates it for certain purposes and frees it again at will The last in first out buffer that remembers data for us is called the data stack or sometimes computation stack There are other stacks around but if there is no confusion it is often called just the stack Every stack is in fact a buffer and needs also a stack pointer to keep track of how far it ha
42. Internal used for nested compilation and compiling strings See also BRANCH 8 3 17 THEN Name THEN Stackeffect addr n compile Attributes ISO FIG I CO LO Description Occurs in a colon definition in form E THEN E ELSE THEN At run time THEN serves only as the destination of a forward branch from IF or ELSE It marks the conclusion of the conditional structure At compile time THEN computes the forward branch offset from addr to HERE and stores it at addr n is used for error tests See also FORWARD IF ELSE 64 ciforth manual 8 3 18 UNLOOP Name UNLOOP Stackeffect n Attributes ISO L C LO Description Discard the loop parameters Must be used when the regular end of the loop is by passed That means it is not ended via LOOP LOOP or LEAVE See also DO LOOP LOOP BACK FORWARD EXIT 8 3 19 UNTIL Name UNTIL Stackeffect f run time addr n compile Attributes ISO FIG I C2 L0 Description Occurs within a colon definition in the form BEGIN UNTIL At run time UNTIL controls the conditional branch back to the corresponding BEGIN If f is false execution returns to just after BEGIN otherwise execution continues ahead At compile time UNTIL compiles OBRANCH and an offset from HERE to addr n is used for error tests See also BEGIN 8 3 20 WHILE Name
43. MOV prior to assembling or by END CODE Doesn t this system lay a burden on the programmer Yes He has to know exactly what he is doing But assembly programming is dancing on a rope The Intel syntax tries to hide from you were the rope is A bad idea There is no such thing as assembly programming for dummies An advantage is that you are more aware of what instructions are there Because you see the duplicates Now if you are serious you have to study the asgen frt and as80 frt sources You better get your feet wet with as80 frt before you attack the Pentium The way SIB is handled is so clever that sometimes I don t understand it myself It deviates somewhat from the phases explained here Another invention in this assembler is the family of instructions Assembler instructions are grouped into families with identical fixups and a increment for the opcodes These are defined as a group by a single execution of a defining word For each group there is one opportunity to get the opcode wrong formerly that was for each opcode 5 4 The 8080 assembler The 8080 assembler doesn t take less place than Cassady s In the end the postit fixup makes the Pentium assembler more compact but not the 8080 But The regularities are much more apparent It is much more difficult to make a mistake with the code for the ADD and ADI instructions And there is information there to the point that it all
44. NEU 19 Ml td ai 56 index ness ii aid 21 inner interpreter o oooomomocooc 13 17 19 L library iia as 10 21 Library Addressable by Block 13 library le nu e iia 43 51 link field address 0oo oooooo 19 69 78 load vier nleg li eee ite bide ee eee 18 17 125 logical not 1heLteesrub ew EU RR PRECII 101 M mnemonic message 2 eee eee eee eee 43 N name field addresS o ooo o 19 20 78 NES ida 13 nil Politeia rue 50 58 69 76 NUM DET di Reese eae eee 13 number base age its ba da 89 O old fashioned Stridg 0oooooocococoooo 74 132 outer interpreter 0 6 ce ns 120 override the error detection 000 30 156 P past headers 2 5 bccciereteieieeneidt base ds eens 19 past header addresS ooooooooooooo o 18 78 preferentes cata ri aaa 22 o O D da bee Sect 76 primed registers coke todita ose 39 R Teburn Stak nse rb iia oe 13 130 131 revectofihg cri 21 74 119 120 S scaled index byte csse rai 38 a i ua socer npe ce ERR e dha eo 13 125 126 search Orders ere iere Red T0 71 137 138 search order 4 cesse eee r inu meee 122 STE Leni sese a s E Sle oud aie eats 39 signal an ertoE 225 creuse erre Rhe xu dig as 50 84 SWAP iria a ges dorus 76 mude ies HUP HELPS 19 source field addressS oooooooocccoocromoo 79 Made oceania do eos On 12 ciforth manual SUPINE constants seg tees ba
45. Stackeffect b addr Attributes ISO Description Store 8 bits of b at addr In ciforth running on the Intel architectures there are no restrictions regarding byte addressing See also CQ 8 16 11 CQ Name C Stackeffect addr b Attributes ISO Description Leave the 8 bit contents of memory address In ciforth running on the Intel architectures there are no restrictions regarding byte addressing See also C 2 Chapter 8 Glossary 105 8 16 12 CELL Name CELL Stackeffect nl n2 Attributes ISO Description Advance the memory pointer n1 by one in this case 32 bits cell to n2 This is invaluable for writing portable code Much of the library code of ciforth runs on both 16 and 32 bits systems thanks to this 8 16 13 CELLS Name CELLS Stackeffect nl n2 Attributes ISO Description Return the equivalent of n1 cells in bytes n2 This is invaluable for writing portable code Much of the library code of ciforth runs on both 16 and 32 bits systems thanks to this See also CELL 8 16 14 CHAR Name CHAR Stackeffect nl n2 Attributes ISO Description Advance the memory pointer n1 by one character to n2 In ciforth this means one byte Bytes are the address units ISO is talking about Unfortunately the ISO standard has no way to address bytes See also CELL 8 16 15 CHARS Name CHAR
46. XO BP 8 AX FFFFF800 X though being cor rect and in a logical order looks still bad because it is bad in the sense that the Pentium design got overboard in complication This example is from the built in assembler the one in asi386 frt redefines BP c s to get rid of the SIB instruction First remark lets assume this is 32 bit code because otherwise there would not be a SIB sure There are 3 sizes involved e The size of the data transported this is always the X as in X Then the first X changes its meaning to 16 bit because of the OS prefix e The X in X0 and in X must agree and are 32 bits because you are in a 32 bits segment and this cannot be overridden e The offset in AX is counted in 64 bits a strange array for fetching the DI but anyway And by the way the data is placed in the extra segment Add a bit of awareness of the cost of the instructions in execution time and take care of the difference between the Pentium processors MMX en III and what not and you will see that assembly program is not for the faint of heart The ASSUME of the MASM assembler buys you nothing but inconvenience 5 10 Reference opcodes Intel 386 Table one contains all the opcodes used in asi386 frt in alphabetic order with sorted before any letter T he opcodes that lift the assembler to the level of the Pentium is separately in table 3 in order not to make the tables overly long
47. and being super user See also PC P P q 8 16 29 TOGGLE Name TOGGLE Stackeffect addr b Attributes NFIG Description Complement the contents of addr by the bit pattern b See also XOR 8 16 30 WITHIN Name WITHIN Stackeffect nl n2 n3 ff Attributes ISO Description Return a flag indicating that n1 is in the range n2 inclusive to n3 non inclusive This works for signed as well as unsigned numbers This is shorthand for OVER gt R R U lt See also lt U lt 8 17 MISC The wordset MISC contains words that defy categorisation Chapter 8 Glossary 109 8 17 1 SIGNON Name SIGNON Stackeffect Attributes Description Print a message identifying the version of this Forth The name of the processor known from the environment query CPU is printed using the bizarre convention of a base 36 number This is a tribute to those FIG pioneers See also ABORT COLD 8 17 2 EXECUTE Name EXECUTE Stackeffect xt Attributes ISO FIG LO Description Execute the definition whose execution token is given by xt The code field address serves as an execution token It even has offset 0 but one should not assume that a DEA is an execution token in portable code See also gt CFA 8 17 3 NOOP Name NOOP No stackeffect Attributes Description Do nothing Primarily use
48. at run time and may be the result of other operations Within a loop I will copy the current value of the index to the stack When compiling within the colon definition DO compiles DO and leaves the following address addr and n for later error checking See also I LOOP LOOP LEAVE 8 3 7 ELSE Name ELSE Stackeffect addrl nl addr2 n2 compiling Attributes ISO FIG I C2 L0 Description Occurs within a colon definition in the form IF ELSE THEN At run time ELSE executes after the true part following IF ELSE forces execution to skip over the following false part and resumes execution after the THEN It has no stack effect At compile time ELSE emplaces BRANCH reserving a branch offset leaves the address addr2 and n2 for error testing ELSE also resolves the pending forward branch from IF by calculating the offset from addr1 to HERE and storing at addr1 See also FORWARD Chapter 8 Glossary 61 8 3 8 EXIT Name EXIT No stackeffect Attributes ISO Description Stop interpretation of the current definition The return stack must not be engaged such as between gt R and R gt or DO and LOOP In ciforth it can also be used to terminate interpretation from a string block or file or a line from the current input stream See also 8 3 9 IF Name IF Stackeffect f run time addr n compile Attributes ISO FIG
49. atest aie 62 REFILLS TAB oe e ata iaa de 97 REMAINDER oo coso is ca 97 REPEAT i 4e ap ai li UE per ease 63 REPOSITION EILE 2 74b ri beet eae ad 88 RESTORE una id eee ei O et ema Litus 55 REST RE INPUT comune ad to 55 ROT sce a Bong denuded ge hil ae anos M RR 99 RSHLET iesu aiii EARE Suan hays She iia 117 AA a r E Gana ae ances be Pee o EE 132 jj m paria laa 132 RUBOUT tia a eee 96 RW BUFEER mie tes iras e 89 S D neeccubterEdQekenexe e eess du ideae bed 135 PD p 82 Oir dada e ue Euer E ei Sear 132 DAVE a A A carey coal aie adis 55 SAVE INPUT ati ii 55 DOR iced et Bh gob RMA Rt sed as 126 SDECTERAL crecer eher RE aa Rursus 58 SEEK A M 56 SET SRG ei bete xa pese ala 122 OEI TERM a nne a a 9T ME 113 DIG A aa Eaa eE LE TAA br dus Soe 91 SKIP ec else treerne beg airo ee oe ed ede 63 SM REM esa eiu Cb CU RE RU eee LIT SOURCE zi eicere tieicSgepUrqcetePekties Pese 123 SPACE 4 costume m eode da aa 120 SPACES m 119 ORG 2 c doaue satis ie tee eed eed and Leena e etd 123 SLALEST iex eR cane mie pubae ang doe PR REPRE as 56 146 STATE a PEP o gt i Pr 123 SUPPLIER 04 idiota rai 83 A dd inde Satya ae 2S tele s heo 100 SYSTEM ii deals aah acter Inte ened Steves cat 114 T TAS Koi nde anto i is 109 TERMT O oi 2k ie ERES 97 THEN 2m inepe onte eE ia qe 63 THROW e TTE 85 THRU i A intitle th it iei emus 127 TIB iw a8 abe aa edie alae 96 TOGGL
50. by as many characters Unfortunately name field address is sometimes used where a dictionary entry address would be more correct especially in older documentation This came about because the name was lowest in memory That they happen to be the same is no reason to confuse two completely different concepts In this Forth the code field address and the dictionary address are the same but not accidentally so The source field This is one cell This can be used to hold a reference to the source a block number or a pointer to a string It has not been filled in in the kernel system Past the header This is actually not a field but the free roaming dictionary However most of the time the part of the dictionary space owned by a dictionary entry starts here A pointer to such a field is called a past header address address Mostly a data field address contains a pointer to just this address Note that the entries are not only in alphabetic order they are in order of essentiality They are accessed by gt CFA gt DFA gt FFA gt LFA gt NFA gt SFA Note data field has a specific meaning in the ISO standard It is accessed through gt BODY from the execution token while a data field address is accessed through gt DFA from the dictionary entry address It is in fact one cell behind where the data field address pointer points to The most important flag bits currently defined are The INVISIBLE bit 1 when smudge d and will prevent a
51. byte addressing there are no restrictions 8 16 25 P Name P Stackeffect n port Attributes Description Store the 32 bit data n to the port address port In practice on a IBM PC architecture a port address is 10 bits You can use ports only after asking permission using e g ioperm and being super user See also PO PC PCQ 8 16 26 PQ Name P Stackeffect port n Attributes Description Fetch the 32 bit contents n from the port address port A port address is always 16 bits In practice on a IBM PC architecture a port address is 10 bits You can use ports only after asking permission using e g ioperm and being super user See also P PC PC 108 ciforth manual 8 16 27 PC Name PC Stackeffect b port Attributes Description Store a byte b to the port address port A port address is always 16 bits In practice on a IBM PC architecture a port address is 10 bits You can use ports only after asking permission using e g ioperm and being super user See also PC PL PO 1 8 16 28 PCO Name PC Stackeffect port b Attributes Description Fetch a byte b from the port address port A port address is always 16 bits In practice on a IBM PC architecture a port address is 10 bits You can use ports only after asking permission using e g ioperm
52. control variable for n 0 write and n 1 read R W determines the location on mass storage performs the read or write and throws an exception on errors See also BLOCK DISK ERROR 8 1 12 UPDATE Name UPDATE No stackeffect Attributes ISO FIG LO Description Marks the most recently referenced block pointed to by PREV as altered The block will subsequently be transferred automatically to disc should its buffer be required for storage of a different block In fact the block is transferred to disk immediately See also BLOCK SCREEN 8 1 13 BUFFER Name BUFFER Stackeffect n addr Attributes Description Return the addres addr of a buffer assigned to block n The buffer layout is as follows a cell with the block number a cell with the status and the content The status is negative for locked zero for free and one for present and unlocked The block is not read from the disc The buffer is either one that was already assigned or else a free buffer If there is none free the stalest buffer is freed The contents of that buffer is written to the disc if it was marked as updated In ciforth this is never needed because updated blocks are written immediately In ciforth blocks can be locked and locked buffers are never freed by BUFFER An update flag would somehow be multiplexed with the lock count but it is not needed in ciforth If all buffers were locked BUFFER freezes the syst
53. cuisses dbase 60 GOLD errero k aaeain bbb ee 93 CONSTAN Teseo peccatis ia 68 CONTE Tacita aar E REOS 137 e P T 106 GORE ooo sia be iet vetet et desees s 82 COUNT re sts da a aE ER 134 GPU ARO ogra pest Behe eae Oe p 82 CRs e 118 CREAT Bieta cosa to Ue ubt Pubs 68 CREATE ETLE RE ve eR de 87 GOP ere uae qu nete hire b petiere pue and sendndvenes 129 CURRENT costra iba 137 D Dos e a is a 119 DiR hoi e ues ntt I SAU dee SUE 118 nmm 81 DABS 5 ic seine sede di IIR ERE 82 DECIMAL pc Space rd 90 DEFINTT TONS bora had pee fice Bh lela 138 DELETE EILE 2 mne id ea 87 DEPTH caia ds Gee ea od eds 130 DICTA ia 91 DISK ERROR 050000 mme pes ati ad 52 DELTERAL oro o tube 56 DNEGA TE oia ia a 82 joe 60 DOES gt pura o e ve REI EE E EPIS 68 DP p OP 74 DPL OI i eiii dae bieehe ieee a peewee 92 DROP Ss 5o mio a on 99 DOP xut aar ADU sdb A te 130 DSPQ 2d eepo ap tute bu dd 131 DUP PPP EE D EROR ORE E EE DAR a E 99 144 E Dc PRO R 60 p Mec m 106 Murrieta 119 EMPTY BUFFERS sisse sese 52 ENVIRONMENT cicle TU Pu PE PUES Putin 138 ENVIRONMENT ci 22 0224s3iss daugseseeatisedias 83 A teu EEE LA DEN VRLR ae ees 106 ERRUR OU 85 A xpi saarssdleeense 85 A eRe 119 EVALUATE onobaSeetriissiiedeebeegecesleienys 122 A A 109 ro donee na 61 EXIT CODE A 112 F FE iaa dde 106 tdci cid dia 80 A 106 A EA austen 74 A se denedeotat nes 54 UD A EE DENET EE 92
54. die tk te d gH Rr ORAE oleae 25 5 2 Reliability acus datada IUGERA Red 26 5 3 Principle of operation 0 0 cece eee en 26 5 4 The 8080 assembler 00 c cece cence enne 27 5 5 Opcode sheetsS cece iria cece teen hn 28 5 6 Details about the 80386 instructions 0 0005 28 5 7 16 and 32 bits code and segments 0 0 00 e eee eee 29 5 8 The built in assembler 0 000 eee eee eens 30 5 9 A rant about redundancy 0 0 0 cece eee ees 30 5 10 Reference opcodes Intel 386 0 00 00 c eee eee eee ee Sl 00 ciforth manual 5 11 Reference opcodes Pentium ONly o o oooooooooooo o 35 5 12 The dreaded SIB byte 0 cece aa a ee eens 38 5 13 An incomplete and irregular guide to the instruction mnemonics H eee OLE ree ee ee 39 5 14 Assembler Errors a heei mana co 40 BEPEORS 4 iZ Xn ROSS AA 43 60 1 Error philosophy uranio eee ade eee ee ed eee 43 6 2 Common problems 0 00 c cece ete nn 43 6 2 1 Error 11 or 12 caused by lower Case oo o o 43 6 2 2 Error 8 or only error numbers 000 43 6 2 3 Error 8 while editing a screen 00 00 44 6 9 Error explanations mtrs e rida rd a ed 44 Documentation summary oooooooooooo o AT Glossafy A EE 49 Sl BLOCKS sani tia los 50 8 11 FBUE ees cag caida seed paa bh pie ia da 50 812 YT
55. division for its standard operations Divisions involving negative numbers have an interpretation problem In any case we want the combination of and MOD remainder to be such that you can get the original n back from the two values left by n m MOD and n m by performing m This is true for all Forth s On ciforth the is a symmetric division i e n m give the same result as nm but negated The foregoing rule now has the consequence that m MOD has 2 m 1 possible outcomes instead of m This is very worrysome for mathematicians who stick to the rule that m MOD has m outcomes 0 m 1 or ml 1 O for negative numbers floored division 8 20 1 Name Stackeffect nl n2 n3 Attributes ISO FIG LO Description Leave the signed product n3 of two signed numbers n1 and n See also MOD Chapter 8 Glossary 8 20 2 Name Stackeffect nl n2 sum Attributes ISO FIG LO Description Leave the sum of n1 and n See also MOD 8 20 3 Name Stackeffect n1 n2 diff Attributes ISO FIG LO Description Leave the difference of n1 and n See also NEGATE MOD 8 20 4 MOD Name MOD Stackeffect n1 n2 rem quot Attributes ISO FIG LO 115 Description Leave the remainder and
56. file such as hello frt It just contains the definition we typed earlier HELLO Hello world TYPE CR Now build the program by lina c hello frt That is c for compile The result is a file hello For the compiler to run you must have the library correctly installed If that failed or anything else fails you will get a message with at least ciforth ERROR and hopefully some more or less helpful text as well The is an error number See Chapter 6 Errors page 43 Section Explanations Note for the old hands Indeed the quoted strings are not ISO They surely are a Forth like extension Read up on denotations and the definition of In lina you never have to worry about those quoted strings they are allocated in the dictionary and are permanent 10 ciforth manual 4 1 2 The library If you want to run a program written on some other Forth it may use facilities that are not available in lina s kernel but they may be available in the library A library is a store with facilities available on demand Forth as such doesn t have a library mechanism but lina does lina uses the blocks as a library by addition of the word REQUIRED and a convention Starting with lina r or most any option you have this facility available If you are already in lina you can type 1 LOAD The extension of lab in forth lab means Library Addressable by Block Now we will add DO DEBUG
57. hb exe een ese ata 58 DURS ec O a E wa 99 TERROR eta aa 84 PERRUR idc ene ce cpadnitecdeepadesesacaegens 84 EXEG onc O aa Sa heat 129 TLOADING i b ccdeoteided weit ia eeeeee le Mao 129 PATRO acis oe ea e o bea crest 129 PSTACK ooo 129 O A 103 A 124 MTM 77 ECHAR Tn casado aca 124 COMPILE 0 23328008 irte 57 A A ER SE 124 NODUM ARI A RR A ee 110 MATCH utensilio 81 PEE i15 A hens Sees 103 ABU SU RLLRDRRPIM Rb Mee e ree bp Le D eed ited 53 LOOP osi alie tute Am DL a ELI 58 ciforth manual gt Pr CET 101 SBDUDY Jee eee au BLOG e qe pre eee EN E RET TO PUPA ovd au SEEGERS Swe RAS UR ASA d eds T SDERA uva oa ere Sed ha Ge ee eee SR P EOK 78 tt A 78 PUN sorte sana ras lea msec ee acess Ae 95 A edd eese dad aad ded eee Res tao de ees 78 ONE Lead adea cra a eee de 78 NUMBER lt a be dq se EE OES 90 SPHA dds 1s GS EE REL a RARE 78 iii Beda dea oad hone eS hoe boas ae 130 POP A auch cease 625 ROSE OEE SAREE ARERR 79 A 79 PWLD card a e 79 A ne pe ARR Fa aus e Aas Ss 79 ira e id Gas aa edad fuv erg vu 124 lt T 101 Et AA A cae 90 A 100 0 Dista is O E 135 A ON 100 0 EEA EEE E bets a aot a dub aud bu que 100 OBRANCGH dus dA a eoe be ea p aes 66 1 a PEANN asia aE ad dado A 135 O dedi A bee E 135 2 vi ur 103 QE Losada WR Ke Bie REE A irs BE Eee 136 A 136 2o ecc 103 2DROP acia ri di AAA CER xd 98 SDUP seda eu ruedas Re paa dq xd eee ke ds 98 Glossary Index 20VER MX 98 2BWAP
58. in Linux uses the there available editors Even without tools code can be tested by piping it into Forth then commanding Forth to look to the console as follows echo 8 LOAD cat pascal frt lina Primitive and preliminary as this may seem it has been used for quite substantial developments 18 ciforth manual like the 80386 assembler More advanced is using Your Favorite Editor followed by including files vim mysrc frt SYSTEM mysrc frt INCLUDED See Chapter 4 Manual page 9 Section Getting Started 386 and a 8086 Forth assemblers are available in forth lab They are loaded in accordance with the system that is run It is essential that you regard lina as just a way to get started with Forth Forth is an extensible language and you can set it to your hand But that also means that you must not hesitate to throw away parts of the system you don t like and rebuilt them even in conflict with standards Additions and changes must be planned and tested at the usual Forth high level Later you can rewrite them as code words Again words belonging to tools are perfectly normal dictionary entries 4 6 7 RAM Workspace The RAM workspace contains the compilation space for the dictionary disc buffers the computation and return stacks the user area and the terminal input buffer From the fig Forth user manual For a single user system at least 2k bytes must be available above the compiled system th
59. instruction set e g Intel has the same opcode for MOV X T AX RI BX and MOV X F BX RI AXI To get a reminder of what instructions there are type SHOW OPCODES If you are a bit familiar with the opcodes you are almost there For if you want to know what the precise instruction format of e g IMUL AD just type SHOW IMUL AD You can also type SHOW ALL but that takes a lot of time and is more intended for test purposes 5 6 Details about the 80386 instructions Read the introductory comment of asgen frt for how the assembler keeps track of the state using the BI BY BA tallies 1 A word ending in an opcode reserves place in the dictionary It stand for one assembler instruction The start of the instruction is kept and there is a bitfield the tally for all bits that belong to the instruction if only mentally These bits are put as comment in front of the instruction and they are considered filled in The opcode also determines the instruction length 2 A fixup mostly ends in It OR s in some bits in an already assembled instruction Again there is a mask in front of fixups and in using the fixup these bits are considered to be filled in A fixup cannot touch data before the start of the latest instruction Some addressing modes fixups do not have in them This is in order to adhere more closely to conventions regarding those addressing modes This much can be said You can be sure that a wo
60. number by BLOCK before calling R W See also BLOCK MESSAGE 8 1 19 PREV Name PREV Stackeffect addr Attributes Description A variable containing the address of the disc buffer not its content field most recently referenced The UPDATE command marks this buffer to be written to disc See also BUFFER Chapter 8 Glossary 55 8 1 20 RESTORE INPUT Name RESTORE INPUT Stackeffect nl n2 n3 3 f Attributes ISO Description Restore the input source stream from what was saved by SAVE INPUT ciforth is always able to restore the input across different input sources as long as the input to be restored was not exhausted This has the effect of chaining and doesn t affect the return from nested calls be it interpreting loading or evaluating ciforth always returns a true into f The input source abandoned will never be closed properly so use should be restricted to the same input source See also RESTORE SAVE INPUT 8 1 21 RESTORE Name RESTORE Stackeffect Attributes Description This must follow a SAVE in the same definition Restore the content of SRC from the return stack thus restoring the current input source to what it was when the SAVE was executed See also RESTORE INPUT SAVE INPUT 8 1 22 SAVE INPUT Name SAVE INPUT Stackeffect nl n2 n3 3 Attributes ISO Description Get a complete specification of the input source stream For ci
61. oe premie oaa ote rob eua ue uet bep 98 A ABORT eresi tocea mor bes weg epi x RS ELE 93 ABORT pices ic 3553 4 coheed pied dia cube top sura Eaa bn gor Sec uns 84 UR 115 ACCEBT rele ERI aiden a EXE 95 AGAIN perir eok eieaa a ERE GE EE 59 BL TGNa s nieto deb hadas a et uon Ee 104 AETGNED paus maregi da ai ies 103 ALLEOT 60 deber deme ta REC 74 ASUS api pe eae ce ats ane o Id 157 AND A aa 101 ERGS ica a e a a rs 112 ASSEMBLER oasis 137 B B BUP Costner ol BACK caida 66 BASE ii te ob deka dee ERE 90 BEGIN 21 snes as 59 Em 134 BLANK ensis a dl idee eae oes 104 BEK dues 128 jo WE Pm 52 BLOCK EXEIT e devueted oie chad eI 51 BLOCK EILE 2lemReR e bere Er Ree pk 51 BLOCK HANDEE coca Oa oud PIA peru as ayia in 51 BEOGK SEND Peis stia datus iii gosta 52 BM ens 104 BODY gt dup PD PET 74 BRANCH lt a ias id 66 BYE dec bathe ee denies ade 112 C Gb sag is teats Vee bee Bocas E Eee exe EE Ev 104 A aeu iue secius ond eps due cues 74 QD sated niece Shah atta Rot Een t ted 125 po oe eed bane 104 A rrr RR beri mere RUE 84 CELE m 105 CELLO Li Regegee daa io eS deoes 105 143 CHAR ocio id cus un iste it a 121 CHAR Esta DM Webb o qi 105 CHARO Ln eiua ed eed a e Pour date and 105 CLOSE EILE cuanta ei RE asked 8T CMDVE iesu rU els Rhen Rr eR dide 105 Cons usa buio tiec cele oui te
62. signed quotient of n1 and na The remainder has the sign of the dividend i e symmetric division See also MOD SM REM 8 20 5 Name Stackeffect nl n2 quot Attributes ISO FIG LO Description Leave the signed quotient of n1 and n using symmetric division See also MOD MOD 8 20 6 ABS Name ABS Stackeffect n u Attributes ISO FIG LO Description Leave the absolute value of n as uw See also DABS 116 ciforth manual 8 20 7 LSHIFT Name LSHIFT Stackeffect ul n u2 Attributes ISO Description Perform a logical shift of the bits of ul to the left by n places Put zero into the places uncovered by the shift See also RSHIFT 2x 8 20 8 MAX Name MAX Stackeffect nl n2 max Attributes ISO FIG LO Description Leave the greater of two numbers See also MIN 8 20 9 MIN Name MIN Stackeffect nl n2 min Attributes ISO FIG LO Description Leave the smaller of two numbers See also MAX 8 20 10 MOD Name MOD Stackeffect nl n2 mod Attributes ISO FIG LO Description Leave the remainder of n1 divided by n2 with the same sign as n1 i e symmetric division See also MOD MOD 8 20 11 NEGATE Name NEGATE Stackeffect nl n2 Attributes ISO FIG LO D
63. string constant See also ENVIRONMENT 8 9 ERRORS The wordset ERRORS contains words to handle errors and exceptions 84 ciforth manual 8 9 1 7ERROR Name ERROR Stackeffect f n Attributes Description If the boolean flag is true signal an error with number n This means that an exception is thrown and it is remembered that this is the original place where the exception originated If the exception is never caught an error message is displayed using ERROR All errors signalled by the kernel go through this word allowing to catch e g errors in accessing the block file See also ERROR ERRUR 8 9 2 ERRUR Name ERRUR Stackeffect n Attributes Description Handle the possible error n in Unix fashion If it is zero or positive this means okay If it is negative its value identifies an error condition This error is handled in the same way as by ERROR See also ERROR ERROR 8 9 3 ABORT Name ABORT Stackeffect f Attributes ISO I Description Usage is SOME ABORT lt message gt If ABORT finds a non zero on the stack the lt message gt is displayed and an ABORT is executed Otherwise proceed with the words after lt message gt This word can only be used in compile mode See also ERROR 8 9 4 CATCH Name CATCH Stackeffect xt te Attributes ISO Description Execute xt
64. symbols include addr memory address p 8 bit byte the remaining bits are zero a 7 bit ascii character the remaining bits are zero q 64 bit signed double integer most significant portion with sign on top of stack dea An dictionary entry address the basic address of a Forth word from which all its fields can be found pd logical flag zero is interpreted as false non zero as true faraddr a lt selector address gt pair ff Forth flag a well formed logical flag 0 false 1 true false a false Forth flag 0 n 32 bit signed integer number it is also used for a 32 bit entity where it is irrelevant what number it represents sc a string constant i e two cells an address and a length length characters are present at the address they must not be changed true a true Forth flag 1 uy 32 bit unsigned integer ud 64 bit unsigned double integer most significant portion on top of stack The capital letters on the right show definition characteristics B The word is available only after loading from background storage C May only be used within a colon definition A digit indicates number of memory addresses used if other than one E Intended for execution only FIG Belongs to the FIG model T Has immediate bit set Will execute even when compiling TSO Belongs to ISO standard LO Level Zero definition of FORTH 78
65. that behaviour to be the same on other ciforth systems Often this is called an implementation defined behaviour in the standard Indeed we are obliged to specify this behaviour in our glossary or we don t comply to the standard The behaviour of the other system may very well be a crash In that case the standard probably declares this an ambiguous condition For example On this ciforth OUT is set to zero whenever CR is executed The bottom line is that you never want to write code where lina may crash And that if you want your code to run on some other system you do not want to rely on ciforth specific behaviour If you couldn t get around that you must keep the specific code separate That part has to be checked carefully against the documentation of any other system where you want your code to run on By using CELL it is easy to keep your code 16 32 bit clean This means that it runs on 16 and 32 bits systems 4 5 Saving a new system We have said it before Programming Forth is extending the Forth language A facility to save your system after it has been extended is of the essential It can be argued that if you don t have that you ain t have no Forth It is used for two purposes that are in fact the same Make a customised Forth like you want to have it Make a customised environment like a customer wants to have it Such a customised environment for example a game is often called a turnkey system in Forth pa
66. the same name exists already in the current search order e ciforth ERROR 5 EMPTY NAME FOR NEW DEFINITION An attempt is made to define a new word with an empty string for a name This is detected by CREATE All defining word can return this message It is typically caused by using such a word at the end of a line e ciforth ERROR 6 DISK RANGE Reading to the terminal input buffer failed The message is probably inappropiate e ciforth ERROR 7 FULL STACK The stack has run into the dictionary This can be caused by pushing too many items but usually it must be interpreted as dictionary full If you have enough room you have passed a wrong value to ALLOT This is detected at several places in particular in INTERPRET after each word interpreted Chapter 6 Errors 45 e ciforth ERROR 8 DISC ERROR An access to the Library Accessible by Block screen aka block file has failed This is detected by DISK ERROR called from places where a disk access has occurred It may be that the library file has not been properly installed Check the content of BLOCK FILE You may not have the right to access it Try to view the file Normally the library file is opened read only If you want to edit it make sure to do DEVELOP in order to reopen it in read write mode If you forget you get this message too e ciforth ERROR 9 UNRESOLVED FORWARD REFERENCE Not used e ciforth ERROR 10 NOT A WORD NOR
67. to suit your particular needs You will have available 1 REQUIRED and REQUIRE REQUIRE xxx is equivalent to xxx REQUIRED but it is more convenient 2 DH H B DUMP FARDUMP For showing numbers in hex and parts of memory 3 CRACK To analyse words showing the source code of compiled words 4 LOCATE To show the block of the library file where a word is located 9 OS IMPORT To be able to type shell commands from within Forth as if you were in a terminal window Because this ciforth is hosted meaning that it is started from an operating system you can develop in a convenient way Start lina in a window and use a separate window to start your editor Try out things in lina If they work paste the code into your editor If a word works but its source has scrolled off the screen you can recover the source using CRACK If you have constructed a part or all of your program you can save it from your editor to a file Then by the command INCLUDE lt file name gt load the program in lina and do some further testing You are not obliged to work with separate windows Suppose your favorite editor is called vi After vi OS IMPORT vi you can start editing a file in the same way as from the shell Of course you now have to switch between editing a file and lina But at least you need not set up your Forth again until your testing causes your Forth to crash 4 1 4 Finding things out
68. used completely identical to the original with respect to all options including 1 Analysing arguments passed to lina in your programs can remain the same 4 8 3 Turnkey applications Turnkey application are made using the word TURNKEY They take a word that is to be done and a string with the file name Mostly it is much easier to just use the c option See Chapter 4 Manual page 9 Getting Started Subsection Hello World A turnkey application should decide what to do with the library file that is default opened in COLD Make sure to CATCH errors from BLOCK EXIT and ignore them 24 ciforth manual Chapter 5 Assembler 25 5 Assembler The assembler is described in this manual because it is not feasable to use it from the description in the source 5 1 Introduction Via http home hccnet nl a w m van der horst forthassembler html you can find a couple of assemblers to complement the generic ciforth system The assemblers are not part of the lina package and must be fetched separately They are based on the postit fixup principle an original and novel design to accommodate reverse engineering The assembler that is present in the blocks is code compatible but is less sophisticated especially regards error detection This assembler is automatically loaded in its 16 or a 32 bit form such that it is appropriate for adding small code definitions to the system at hand The background information given her
69. within a high level defining word DOES gt modifies the behaviour of the latest word as to execute the sequence of compiled word addresses following DOES gt Used in combination with CREATE When the DOES gt part executes it begins with the address of the data field of the word on the stack This allows interpretation using this area or its contents Typical uses include the Forth assembler multidimensional arrays and compiler generation Chapter 8 Glossary 69 8 4 6 USER Name USER Stackeffect n Attributes ISO LO Description A defining word used in the form n USER cccc which creates a user variable cccc The data field of cccc contains n as a fixed offset relative to the user pointer register UP for this user variable When cccc is later executed it places the sum of its offset and the user area base address on the stack as the storage address of that particular variable In ciforth the UP is fixed See also VARIABLE ORIGIN CONTEXT gt DFA 8 4 7 VARIABLE Name VARIABLE No stackeffect Attributes ISO E LU Description A defining word used in the form VARIABLE cccc When VARIABLE is executed it creates the definition cccc with its data field pointing to a data location When cccc is later executed the content of its data field containing n is left on the stack so that a fetch or store may access this location See also
70. 11 UM MOD i i bir e EE REDE 112 UNLOCK ai 2 3 oir ito DAMM CHER 126 127 UNLODP 12cm ga era tee rnb EE HO ndn 64 UNTIL caridad 59 64 66 A ia Lot Sob aud 53 54 USER pacos CU RM Bex SS 19 20 69 V VARIABLE LL edes rurdpetor beet 2 dads 13 19 69 NERSLON bu uneven ERR REPERI PINE DES 83 NOCHEUNK so 220 3e byte RE rune ans waa he HOSTESS 139 VOCABULARY sssseee eese 12 69 136 139 W pM 29 30 WARM RD 94 WARNING sess ee 52 85 86 WHERE esses es 85 86 WHILE gt dobra 63 64 66 WITHIN 22 2 m a be GEEK 108 W RDE eee Ue ERREUR T2 709 91 123 WOIdS s erected mien ERROR RE SEES 43 WORDS sa AA A TT WRITESFILE usada ead oe aea RR REOR EEA 88 154 X aap thse cae othe ete races eared 31 A ees ee 29 CTE A TE TT ORT A 31 A 27 28 29 31 41 POY oa ceac eee ated aaae oh Gan 28 29 31 ciforth manual Ut ae ae mee CHEN 102 Z CIN DR 39 A E ett EEEE EEEE RERUM 114 A A E 28 Concept Index Concept Index 155 Mostly the first reference is where the concept is explained But sometimes in introductory and tutorial sections an explanation sometimes was considered too distracting A aligned v 656 ol rd wea I DLES 103 104 allocating criteria anas 12 ambiguous condition cess cssitierikarirerepuri 15 B blocks aria 10 13 50 51 C Gase SENSITIVE i iuba pP RELAY Re RU YER REUS 1 43 Cells iiv E tee bees 13 49 102 ciforth specific behaviour
71. 11 2 S Name S Stackeffect d1 d2 Attributes ISO FIG LO Description Generates ASCII text in the text output buffer by the use of until a zero double number d results Used between lt and st 8 11 3 Name Stackeffect d1 d2 Attributes ISO FIG LO Description Generate from a double number d1 the next ASCII character which is placed in an output string Result d2 is the quotient after division by BASE and is maintained for further processing Used between tt and gt See also HS 90 ciforth manual 8 11 4 lt Name lt No stackeffect Attributes ISO FIG LO Description Setup for pictured numeric output formatting using the words lt 4S SIGN gt The conversion is done on a double number producing text growing down from PAD See also DPL HLD HOLD FLD 8 11 5 NUMBER Name gt NUMBER Stackeffect udl addrl ul ud2 addr2 u2 Attributes ISO Description ud2 is the result of converting the characters within the character string specified by addr1 ul into digits using the number in BASE and adding each into ud1 after multiplying ud1 by the number in BASE Conversion continues until a character that is not convertible is encountered or the string is entirely converted addr2 is the location of the first unconverted character or the first character past the end of the string if the string was entirely co
72. 127 8 23 10 THRU Name THRU Stackeffect nl n2 Attributes ISO FIG LO Description Interrupt the current input source in order to interpret screen n1 through n2 inclusive The stack changes in according with the words executed At the end of the screens barring errors or forced changes it continues with the interrupted input source See also BUFF BLOCK LOAD QUIT EXIT gt 8 23 11 TRIAD Name TRIAD Stackeffect scr Attributes Description Display on the selected output device the three screens which include that numbered scr beginning with a screen evenly divisible by three Output is suitable for source text records and includes a reference line at the bottom taken from line 0 of the first error screen See also MESSAGE ERRSCR 8 23 12 UNLOCK Name UNLOCK Stackeffect n Attributes CI Description Unlock the block n Probably because it is no longer the current input source The result is that its buffer can again be reclaimed Unlocking without a previous lock may lead to a crash See also LOCK BUFF 8 23 13 BLK Name BLK Stackeffect addr Attributes U Description When the standard word BLK is used this user variable reflects the state of the current input source It indicates the block number being interpreted or zero if input is being taken from the terminal input buffer Changing
73. 16 lines of 64 characters They are used for source code and documentation Each screen is one BLOCK as required by ISO The SCREEN wordset contains facilities to view screens and load them that is compiling them and thus extending the base system A system is customized by loading source screens possibly one of these extension is a text editor for screens 8 23 1 LINE Name LINE Stackeffect nl n2 sc Attributes Description Convert the line number n1 and the screen n2 to a string sc the content of the line without the trailing new line See also LINE 8 23 2 gt Name gt No stackeffect Attributes I LO Description Continue interpretation with the next disc screen If the current input source is not from a block a crash will ensue If this new screen is left by throw of an exception the screen may remain locked until a QUIT or any uncaught exception See also LOCK CATCH LOAD 8 23 3 C L Name C L Stackeffect c Attributes Description A constant that leaves the number of characters on a line of a standard screen 64 The last character of each line is a LF See also LIST LINE 8 23 4 INDEX Name INDEX Stackeffect from to Attributes Description Print the first line of each screen over the inclusive range from to This is used to view the comment lines of an area of text on disc screens See also LIST
74. 25 3 DET rias 130 E A AA 130 8 25 5 ron 131 A TNNT PRAES 131 A MEME 131 pode MAMANS 131 Bond RDROP rra edades 131 8 25 10 RSP rara tii nia 132 A sedi e he a 132 EU 12 O E E E ME 132 EU STRING Poora E das tubae TS 132 8261 aia 132 AE E E E E E 133 E T E 133 E A densa E T 133 BG Mi a iaa duda 133 ciforth manual 8 20 06 BO Ported es pe da rd perched oce kae Ear 133 A A ete ace dates a aod caste a aces ada dla heaca Pete ane aves 134 O OO 134 8 20 0 lt T RATING seta seei iiano ee at 134 38 26 10 BCe ens pda rail ad dale neg AUR Bete 134 20611 COUNT td iia 134 SOI Se aa idad id dot 135 8 27 SUPERFLUOUS 222 ta aia 135 ROUTE ME PROPTER O ase 135 LII MENT Tcr 135 Ces M IA 135 QUIDNE E 136 8 27 5 2 a aa ab ate A a a a a a a E a dae a 136 5 2 Or Number eea e e a A 136 8 2T C Number 2 seese eis a Goel Biers kos oe 136 8 28 WORDLISTS 24532 6eR IUE ia dados a baton EU 136 323 ALSO TEMERE 137 8 28 2 ASSEMBLER erga re Aa de AE alaba 137 828 39 CONTEXT nic Roe Rare Rl nh RR eras 137 828 4 CURRENT ced au fue be cease Re e 137 8 28 5 DEFINITION Sita Gk erue eens hee eee add 138 8 28 6 ENVIRONMENT 0 00 0 cc ec eee 138 5 294 FORTH zer erento Gecko diia Wee ee 138 8 28 8 LXXTEST eg ebur ge keane e genes 138 9 28 90 ONLY 35 I aote ii aia did duke 139 8 28 10 PREVIOUS ira pic aid mee in 139 38 28 11 VOC LINK iR Deu esie b E Edo S 139 Glossary Index 22e nt Re ER S 141 Forth W
75. 32 SAVE ies cacas 55 SAVESTNPUT ici pics 55 SAVE SYSTEM Lud oi daratlarestaaneb ithe 1215 17 O E See ere eee 126 DET S1 RTT TEPORE TT TET 58 ia pase eta A Me 56 IS MARE TRIER ERES 29 A T I er Ale DeAnna Ri 97 122 123 o E E E ane em 97 c 29 O LI EN LE 113 SHOWN iy 05 204 eeper bits ia eben tr2Xsepe4bpkR4 28 SHOW OPCODES see eee 28 PUDE sU d Ra E eM E M ILLE 25 41 Tu MARRE RA 29 31 NR RCRUM 39 CU A uate sede ECRIRE CENT 29 o A A 31 A sk E alate ies 90 91 II cee Soe ee ee oP 63 SLITERAD 6 245 0 2nccdddcdddeddbcieeebelielviseed 14 OM REM A iti SOURCE pere anea i e DP ULL 94 123 SPACE i sisse e e e e sss loas 120 A 119 D MENO TEMERE 55 97 123 STO a OR MORTE aad 35 ST A A 35 Us PORTET TRO ES 32 BTALEST cocci seas cis bei ida ide 56 td dos UE 67 70 94 122 123 SUPPLIER A inesedens 83 CD CP 100 SYSTEM A LN aeni 22 113 114 T Tie caia dis dates 29 31 39 O doa a tere A 109 TERMI secs iS leDeeeri dbi RIPE PUDE Loi Ir RU 97 TIENE Do nen LA M I 4 153 THROW eoa has 14 43 84 85 86 A eae ae eR ENS Dow Ba ee 127 TIB hats Sates Sh eas a n neces 96 97 TOGGLE soc ceded ad SaaS Soa ee ee RARER See auris 108 TREAD icici teh rar ERR da ania dd bd dee 127 TUCK NN 10 TURNKEY 2 exp niat ee Eo e EROR E oS 23 TYPE e RE PIQI RIPE UPS 2h llc L9 120 U jp PE 120 Ma sh seed Goes ood ous diabete Ene Bed eii ois WEE 102 Doce 15 109 lj r 1
76. 4 78 A I Antec ate os 12 16 18 74 o A A eee eee eee 58 92 Preciado lodos pls aba Ase 84 99 DOP oui rad a 130 DOPO a ARAS 131 DUMP airada citen cios 11 19 DUP IA EN DE UN E 99 enee ee Mats sok A O S9 28 E EAX oe AR IA 30 EDITOR occu cbs deue ve os REX Rer ados ai 44 EISE cc ciahedkdedeeneecateeesnyeds 60 61 63 67 99 A tate dade HORE 20 106 EMIT desde red ds 16 21 119 EMPTY BUPPERS era id E YE 52 END UUDE aii EE Oda EAR di 2T ENVIRONMENT i esses eee 82 83 138 ENVIBDHMENIT 2025 cdee 54a 049506 pp wow Oe ES 83 138 ERADE esae peC3 as ERR RE E 106 A 84 85 86 122 ERRSGR ic sisas add de sar dde Daw wae 85 lec nenea eia ina Eri ei 30 Paca das as 119 EVALUATE lt n data ai aa di e d P VERE 122 EXECUTE ex 4ce4k eb RE beau Pe CREER RS IQ Med 109 ios ARR 59 61 65 67 EXTT CODE ccssar kia aoe EGRE d Ra PUER des 119 EXPEC 2220 vx p chee tees ee r ti 21 F EE PE ae ERE 122 Plinbiiiel 4ppe Rb PRAE MIS ie 29 31 39 PRASUP 122x232 bees Sos Ok RUE SCR a Roa dos de 112 FEARDUMP rd dui FARMOVE S Lore 9 DX E An 106 Forth Word Index PENCE md uum a ii e acres 46 80 EILL amv bereit Puede ed CY cen 104 106 FIND i4 reni esp eie Susie 72 73 74 EIRST 24 py dentine id idas 20 54 A A E T E 92 FLUSH coccion ar iaa aa 54 EM MOD esoo dd rias 110 FOR VOGCS 2 ooo de oi RUE led Rm 80 FOR WORDS sico enses RERO PRSE exa deed ds 80 FORGET sssssss esses 12 17 46 75 80 139 F RGEI VOGQ S cH pL Pen Oe Ma
77. 49 81 132 string Variable oe eet I PPP CH REED Rs 132 symmetric division 110 114 115 116 T A dfe 9r i miia RIDES 15 U USER BECA nsu a doa peo ERU ye iod oan 16 V VETOT ccoo dare is a 21 MEEA adi s 69 VOCADUlaPy carr I2 MID ssi ene xtd 12 69 77 79 136 137 138 139 NOB uis dut RERU E RPG Pee de teppOteriOs 945 we pd 3 word list centies 12 19 69 136 138 139 word list associated With o oooo 69 word list identifier o o o o ooo 12 69 136 WOLdSEU ciales 50 Short Contents l OVERVIEW zackwokeew dw Ode ee ee E i 2 Gentle dnbrodustloD aw sekaw mad ood ee ee ed 5 3 Rationale amp legalese 0 5220321122203 7 A Mammalia ai A E 121117 NE AA AAA a 9 5 Assembler saseda cir IAS 25 CM E eee ee NN 43 T Documentation summary sui See oo whe heed ware oe ADR 47 Ea A A oes 49 Glossary nd nara A AAA C 141 Forth Word Indes os a o amaaa AA TA a A A Roda 147 Concept Ende sssi assesses oten andaa cad Rr ORE EGG Re 155 ciforth manual Table of Contents l OVERVIEW 6 25 5055 555 63 49945 686 See da 1 2 Gentle introduction resorts 3 3 Rationale amp legalese omic o Re T 94b Legalese spressi toie ova pr add ado it 2 2 Rationale 2e rr ee cde Rh RR Rr Rl ha 1 0 IQUITOS T 3 4 The Generic System this Forth is based 0D 8 d BMISDUA e46seEE P3 E Y Eo eoe m e Plone unn 9 Al Getting started idisse bra ku Pa Xr e doe 9
78. 61 64 66 1 joue M LL ML 135 MM 95 135 2 et eee 103 A 136 BU UM dad O see Gus 136 O A ce os 103 A A 97 98 SOUP PERRO 98 Cu PRICE TTE E a neta RET 98 OGD eo dude E M T Dd LI ELO 98 A WORT oc pics een Peer e aedis 14 84 93 94 o ME 14 84 86 A EIL ree ee LEE 115 a A ER EE OT ETE T 95 97 DICT A A A O 59 67 A E TG 31 MN e a a RAM LEE 104 o A IN 103 ALD A 44 74 A EA 137 UD lu LU AE 100 101 un AMETE RR tis 149 C ri ERRORS 30 AB On idee 28 ASSEMBLER ce p rer ciebicsnstewvdeuer 14 70 197 Mendo es oe 30 A ects CRI 29 39 RG erecta 29 31 39 B CURRERE ERR RR TET RERPER AEE 29 Molero TEES 29 Des greta dene spss NONE 11 ius tues dedeessacaeseauanebads 20 51 B BUF CELLS CELL ciar a Pese DE vua ves 20 EEEE bee tenes 27 28 29 41 A A auc 28 A 66 MD a2 eves td ETE E EET E T 29 41 BASE ee ee aai 43 89 90 91 118 119 120 PECTIN ee E An 59 63 64 Pia ee ee eT ee ee eee eee S 28 o A 30 AU a 30 rece ean ieee OPER 104 134 AT MR a 104 BER NR a RR 14 127 128 BOCK A 51 52 54 125 A cod ebLorsDetrae iu 23 51 BLOCK FILE o n a oaaao nana 43 45 46 51 52 BLOCK HANDLE coc avide ied edevdckdiceciceeas 51 BLOCK INT T ON 51 52 56 Monsanto EATE EE TE 16 104 A 28 29 SA 74 BRANCH AN 59 60 63 66 67 UC TNR RC TTE T 31 ge ope E Ge nade 28 150 C CL ee ee eee eee a Oe ree eee 104 saute A ee ed eae 74 D Miu M M I LE T 125 A whi aigadsaaiens 104 BERI Zire ed ance ius e
79. 8 27 6 Number_1 Name Number_1 Stackeffect 1 Attributes Description Leave the number 1 See also CONSTANT 8 27 7 Number_2 Name Number_2 Stackeffect 2 Attributes Description Leave the number 2 See also CONSTANT 8 28 WORDLISTS The dictionary is subdivided in non overlapping subsets the word list s see Section 8 6 DICTIONARY page 73 They are created by the defining word VOCABULARY and filled by defining words while that vocabulary is CURRENT They regulate how words are found different vocabularies can have words with the same names A word list in the ISO sense has no name but a word list identifier or WID which is inconvenient We use vocabulary words created by the defining word VOCABULARY They are used to manipulate the word list s that are associated with them So vocabularies are nearly the wordlist s of the ISO standard the primary difference is that they have a name Chapter 8 Glossary 137 8 28 1 ALSO Name ALSO No stackeffect Attributes ISO Description Duplicate the topmost WID in the search order stack If there were already 16 WID s ciforth looses the last one This is not counting the ONLY search order You seldomly want to use this word because in ciforth by naming a vocabulary you add it to the order See also CONTEXT VOCABULARY 8 28 2 ASSEMBLER Name ASSEMBLER No stackeffect Attributes B NISO FIG I L1 Description The name o
80. 8 or only error numbers If you get an error 8 as soon as you try to LOAD or LIST a screen or use an option or if errors show up only as numbers without the mnemonic message this is because you cannot access the library file It may not be there or it may not be at the expected place ciforth contains a string BLOCK FILE that contains the name of the library file interpreter with as a default forth lab If this is not correct you may change it as appropriate by e g S usrlib ciforth forth lab BLOCK FILE The library is accessible for read and write access and mnemonic message will be fetched from it after you install it with 2 BLOCK INIT 1 WARNING 44 ciforth manual 6 2 3 Error 8 while editing a screen If after editing a screen you get error 8 the screen has not been written to disk because you have no write access for the library file You must issue DEVELOP which reopens the library file in READ WRITE mode Normally this should be part of loading the EDITOR It may be of course that you don t have privilege to write to the file As non privileged user you cannot edit the the system wide library file 6 You may always edit and use a private copy of the library file by the 1 option See Chapter 4 Manual page 9 for how opttions work The 1 option itself works only if at least the official library file has been correctly installed 6 3 Error explanations This section shows the explanation
81. ADD ADDI ADDI A ADDSI AND ANDI ANDII A ARPL AS BOUND BSF BSR BY BTI BTC BTCI BTR BTRI BTS BTSI CALL CALLFAR CALLFAROI CALLO CBW CLC CLD CLI CLTS CMC CMP CMPI CMPII A CMPS CMPSI CPUID CS CWD DAA DAS DEC DECI X DIVI AD DS ENTER ES Chapter 5 Assembler FS GS HLT IDIV AD IMUL IMUL AD IMULI IMULSI INC INCI X INS INT INT3 INTO INID INIP IRET J JI X Intel Jcc JCXZ JMP JMPFAR JMPFAROI JMPO JMPS LAHF LAR LDS LEA LEAVE LES LFS LGDT LGS LIDT LLDT LMSW LOCK LODS LOOP LOOPNZ LOOPZ LSL LSS LTR MOV MOVI CD MOV FA MOVISG MOVITA MOVI MOVII BR MOVII XR MOVS MOVSXIB MOVSXI W MOVZXI B MOVZX W MULI AD NEG 33 34 ciforth manual NOT OR ORI ORIIA OS OUTS OUT D OUTIP POP POPI ALL POP DS POP ES POP FS POP GS POPISS POPIX POPF PUSH PUSH ALL PUSH CS PUSH DS PUSHI ES PUSH FS PUSHI GS PUSH SS PUSHIX PUSHF PUSHI B PUSHII X RCL RCR REPNZ REPZ RET RET RETFAR RETFAR ROL ROR SAHF SAR SBB SBBI SBBI A SBBSI SCAS SET Intel SET cc SGDT SHL SHLD C SHLDI SHR SHRD C SHRDI SIDT SLDT SMSW SS STG STD STI STOS STR SUB SUBI SUBII A SUBSI TEST TESTI TESTII A Chapter 5 Assembler 35 VERR VERW WAIT XCHG XCHGI AX XLAT XOR
82. BLK has no effect and its content must be fetched before the current input source has changed See also BLOCK TIB 128 ciforth manual 8 23 14 BLK Name BLK Stackeffect addr Attributes ISO Description When the standard word BLK is used the content of the user variable BLK is refreshed to reflect the state of the current input source and its address is returned in addr It indicates the block number being interpreted or zero if input is being taken from the terminal input buffer In ciforth changing the content at addr has no effect and its content must be fetched before the current input source has changed See also BLOCK TIB 8 24 SECURITY The wordset SECURITY contains words that are used by control words to abort with an error message if the control structure is not correct Some say that this is not Forth like You only need to know them if you want to extend the CONTROL wordset 8 24 1 CSP Name CSP No stackeffect Attributes Description Save the stack position in CSP Used as part of the compiler security 8 24 2 COMP Name COMP No stackeffect Attributes Description Issue error message if not compiling See also ERROR 8 24 3 CSP Name CSP No stackeffect Attributes Description Issue error message if stack position differs from value saved in CSP 8 24 4 DELIM Name DELIM No stackeffect Attributes
83. CE Name SOURCE Stackeffect addr nl Attributes ISO Description Return the address and length of the current input source See also SRC SOURCE ID 8 22 11 SRC Name SRC Stackeffect addr Attributes Description Return the address addr of the current input source specification allocated in the user area It consists of three cells the lowest and non inclusive highest address of the parse area the non inclusive highest address of the parse area and a pointer to the next character to be parsed Changing SRC takes immediate effect and must be atomic by using RESTORE INPUT or changing only the third cell The third cell has the alias IN Words like gt IN BLK SOURCE SOURCE ID are secondary and return their output by second guessing SRC See also BLK SOURCE ID 8 22 12 STATE Name STATE Stackeffect addr Attributes ISO L0 U Description A user variable containing the compilation state A non zero value indicates com pilation 8 22 13 WORD Name WORD Stackeffect c addr Attributes ISO FIG LO Description Parse the current input source using c for a delimiter Skip leading delimiters then advance the input pointer to past the next delimiter or past the end of the input source Leave at addr a copy of the string that was surrounded by c in the input source This is an oldfashioned string to be fetched by COUNT
84. DISK ERROR 2 utbs te e 50 Glue B BUE sodio tUe dadas 51 84 BLOCK EXD vector tae RR dcs 51 3 15 BEOCK FTLE cuenta redes exten Peak mds pi 8 1 6 BLOCK HANDLE 0 0c cee eee eee 51 amp L7 BEOCKSINTE muscisitrasioapica lr br doors da 52 81 8 BLOCK asar eei und an ia aa 52 8 19 DISR ERRBORBR compa ecd beret e bs 52 8 1 10 EMPTY BUFFERS eeseen e 52 SALIA RAW PME 53 811412 UPDATE 2235 chaps bites teeta a id Da ALIS BUFEER 6 iad eiae ideada 53 Sb BUE seca ien ion d aider E dudar 53 S5 RIBST L5 eee tta acta tu e leds 54 8 16 PLUSH casitas er peal eda od eurn ed 54 BUY LIMITE ican sche chee dace qt ti Ro an hp Red teh 54 SUIS OBBSEL a eit toda eed esi dd 54 8 L19 PREV cosmos rta hate Ghee eee eee 54 8 1 20 RESTORE INPUT aiei enana a gaa ada ee 55 8 121 eRESTORBE Ree Renee RR ERE T ERE 55 8 1 22 SAVECINPUD gig tac ec rede da e 55 8 123 SAVE serca da be pu Re ue eee des 59 8124 SEER osans aada aaas eaten a we me oe 56 8 11 25 SALES T irascible 56 3 2 COMP USING succionar caldera ri ae 56 amp 2 l DLEIPBRAL enne id ent itio a a 56 8 2 2 Da BARAT Sg cuu cere oo e e ERO ERR i 56 82 3 POSTPONE onore hes dad PU quee AR eds 57 628 COMPTE caia air sida Di O 5T 8 26 SDLITERA Liconsa cee ta eas gag et ER Eee 58 8 3 CONTROL coimas fee eet teo aaa Ree dee Hon in s 58 8 31 LOOP cis eee ieee aera aa 58 Sn P MEUUIONME rrt 58 8 9 9 AGAIN coraa ite ne nied eae est QUE RU RR S ORA ae
85. E READ FILE WRITE FILE 8 10 10 WRITE FILE Name WRITE FILE Stackeffect addr n fd ul Attributes ISO Description Write n characters from addr to the file that is open at fd starting at its current position u1 is O for success or otherwise errno error code negated to be inspected using MESSAGE See also OPEN FILE READ FILE REPOSITION FILE RAW Chapter 8 Glossary 89 8 10 11 RW BUFFER Name RW BUFFER Stackeffect addr Attributes Description A constant that leaves the address of a disk buffer used by file i o words See also READ FILE OPEN FILE 8 11 FORMATTING The wordset FORMATTING generates formatted output for numbers i e printing the digits in a field with a certain width possibly with sign etc This is possible in any number base Normally base 10 is used which means that digits are found as a remainder by dividing by 10 Formatting in Forth is always based on double numbers Single numbers are handled by converting them to double first This requires some double precision operators to be present in the Forth core See Section 8 7 DOUBLE page 81 wordset See Section 8 18 MULTIPLYING page 110 wordset 8 11 1 gt Name gt Stackeffect d sc Attributes ISO FIG LO Description Terminates numeric output conversion by dropping d leaving the formatted string Ses See also lt 8
86. E ir nia 108 TRIAD ii ie ea 127 TYPE erener a aie bus eis eras 120 U Wie sig nda da ri glad Big o eri 120 WS ee aec sues ea dis mentes dod Diesen 2s 102 Dorm 109 UM ia 111 UM MOD jeden roh aree EC eH Mo PE PR ia UNLOCK cecorinics A aG 127 UNLOOP evisos IE RII a das o 64 UNTIL ocios es ii e ia tenes 64 ciforth manual USER a estie dudum els 69 VARTABLE cc v REP Ye mr eee RT HERE ERES 69 VERSTON xin ts tenet arte heute eu aee Dr ptus 83 VO G LINK adu e a E odds 139 VOCABULARY void iria Iesv 69 WARM lle ra puede deor ne bale Boe 94 WARNING sieto ists ag pepe do IPIE 86 WHERE 2e dis a ad eee ee M IDE ES 86 WATLE eei eget ced EE Dot esee dor Seta ala 64 WITHIN iden tias aud at e ESO ES 108 WORDS cuasi RP TE EH POI a quid 123 WORDS ciber id e 77 WEDLIEZEIEE 3 2 iG vx etse hss ablated Saag eon agree 88 X AUR ti A D bes 102 Z LEN p A ee dates Oke iS 114 Forth Word Index 147 Forth Word Index This index contains all references to a word Use the glossary index to find the glossary description of each word A 52 53 O A 13 102 CREATE add 19 44 70 A tere PAPE was c ee ET A E 390 0 60 65 FIND a Lien DR AIT heus 19 77 81 FORWARD iia hr Heda Seen pee PETS 66 67 E A tur bens ta a ee T 125 d ils nuces LLLI IAE 89 90 LOOP suicide ia 62 66 O iene Warn ca te hea need 89 90 91 NUMBER 0 0 0 0 ccc cece e e 91 KBUFE raid EE 50 QU ONSE 120 HS c E Pee RE 89 90 RB RW BL oS eee en ds 40 RES E RRRip
87. ERE ERU REG Rh dS 107 93 16 25 Plis ETSI 107 SN AAA 107 86 27 BC ak cu 108 8 16 28 POO AA aia ets le ast a abst eor e e uper ta ns 108 3 16 29 TOGGLE ind dt decree onde dite 108 8 16 30 WITHIN iir pna rh rea ca nc La 108 MAN p HEEL 108 Bl 3SIGNON uico cM Rice 109 O42 EXECUTE odas Se iubere a idis doe a 109 NE NOAA E a a E ia 109 Bd TASE Lu toca A telas 109 elf Ulsa PEG ERR did 109 ciforth manual gee esa oe ee ee 110 8 18 MULTIPLYING ioa sacred ke t trot C Rb o ob e 110 CUN so 7 110 I DAL A MONS 110 818 3 FM A reiti i ere a 110 BLSA Maia iH 8085s M MOD arde 111 8 18 6 BM BEN rara aorta cities 111 A PPM 111 8 18 8 UM MOD MERERI AME 112 8 19 OPERATINGSYSTEM 00000cc ee eee 112 8 19 1 ARGS E 119 Spi AMNEM MENTRE 112 8 19 3 EXIT CODE rats 112 8 19 4 IN Oe MMC MM 118 8 19 5 DING Gx oc adactus derit eed IRE cx UE 113 8 19 6 A rreren rrrn rn 113 RID SHELE ic casts a A E ARE 113 8 19 8 SYSTEM A A 114 8 19 9 A 114 8 20 OPERATOR unio eros 114 B0 NNMERO HM 114 O A E E 115 A O 115 8 204 JMOD nir rereb ieri EENE EE EEE 115 o d MMMENMONMLNDNEDPEMCMMNMMOMN 115 LU i MANC MEHR EN 115 A ououunonr ris ruorurrrerrre rrn 116 ROS MAX MERERETUR 116 8 20 9 MN trio polola 116 8 20 10 MOD reacio celia eE RETER 116 8 20 11 CAD co dae 116 8 20 12 RSHIFT i naiinidinniadades eiectus ed e qr 117 82I OUTPUT eae i ices Sin re dingo kien adnate 117 A MNT pH CUIU MM MR MM dio aed wasted a R 117 ST WE TEMERE CET 117 ROTA A e
88. FORTH vocabulary when xxx executes rather than at compile time See also POSTPONE 8 2 5 LIT Name LIT Stackeffect n Attributes FIG C2 L0 Description Within a colon definition LIT is compiled followed by a 32 bit literal number given during compilation Later execution of LIT causes the contents of this next dictionary cell to be pushed to the stack See also LITERAL 58 ciforth manual 8 2 6 SDLITERAL Name SDLITERAL Stackeffect d s d executing d compiling Attributes I Description If compiling compile a stack double number into a literal or double literal de pending on whether DPL contains a nil pointer or points into the input Later execution of the definition containing the literal will push it to the stack If executing the number will remain on the stack See also SLITERAL DLITERAL 8 3 CONTROL The wordset CONTROL contains words that influence the control flow of a program i e the sequence in which commands are executed in compiled words With control words you can have actions performed repeatedly or depending on conditions 8 3 1 LOOP Name LOOP Stackeffect nl run addr n2 compile Attributes ISO I C2 L0 Description Used in a colon definition in the form DO ni LOOP J At run time LOOP selectively controls branching back to the corresponding DO based on n1 the loop index and the loop limit The signed in
89. I C2 L0 Description Occurs in a colon definition in form E tp THEN Or ES tp ELSE fp THEN At run time IF selects execution based on a boolean flag If f is true non zero execution continues ahead thru the true part If f is false zero execution skips till just after ELSE to execute the false part After either part execution resumes after THEN ELSE and its false part are optional if missing false execution skips to just after THEN At compile time IF compiles OBRANCH and reserves space for an offset at addr addr and n are used later for resolution of the offset and error testing See also FORWARD 8 3 10 I Name I Stackeffect n Attributes ISO FIG C LO Description Used within a do loop to copy the loop index to the stack See also DO LOOP LOOP 62 ciforth manual 8 3 11 J Name J Stackeffect n Attributes ISO FIG C LO Description Used within a nested do loop to copy the loop index of the outer do loop to the stack See also DO LOOP LOOP 8 3 12 LEAVE Name LEAVE No stackeffect Attributes ISO Description Termination a do loop by branching to directly behind the end of a loop started by DO or D0 so after the corresponding LOOP or LOOP 8 3 13 LOOP Name LOOP Stackeffect run addr n compiling Attributes ISO I C2 L0 Description Occurs in a c
90. IL immediate data cell IW immediate data cell IB immediate data byte L address offset data cell W address offset data cell B address offset data byte SIB Scaled index byte an instruction with in an instruction OB Obligatory byte OW Obligatory word 16bits There are also RB RW RL based on RB RW RL They comma in an amount relative to the program counter based on an absolute address such that you can use labels These are used preferably and are made to appear in the disassemblies Otherwise no labels could appear in disassemblies 5 14 Assembler Errors Chapter 5 Assembler Al Errors are identified by a number They are globally unique so assembler error numbers do not overlap with other ciforth error numbers or errors returned from operating system calls Of course the error numbers are given in decimal always The errors whose message starts with AS are used by the PostIt FixUp assembler in the file asgen frt See Chapter 6 Errors page 43 for other errors ciforth ERROR 26 AS PREVIOUS INSTRUCTION INCOMPLETE You left holes in the instruction before the current one i e one or more fixups like X are missing Or you forget to supply data required by the opcode like OW With SHOW you can see what completions of your opcode are legal ciforth ERROR 27 AS INSTRUCTION PROHIBITED IRREGULARLY The instruction you try to assemble would have
91. LL bytes For this ciforth the number of disk buffers is configured at 8 The minimum possible is approximately 8 because nesting and locking requires that much blocks available at the same time The user area is configured to contain 0x40 cells most of it unused User variables can be added by the word USER but you have to keep track yourself which offset in the user area can be used The user area is just under the disc buffers So it ends at FIRST The terminal input buffer and the return stack share an area configured at a size of 0x10000 bytes The lower half is intended for the terminal input buffer and the higher part is used for the return stack growing down from the end The initial stack pointer is in variable RO The return stack grows downward from the user area toward the terminal buffer The computation stack grows downward from the terminal buffer toward the dictionary which grows upward The initial stack pointer is in variable SO During a cold start the user variables are initialised from the bootup parameters to contain the addresses of the above memory assignments They can be changed See Section 8 12 1 ORIGIN page 93 for the bootup area But take care You probably need to study the source for how and when they take effect If you need multi tasking you have to allocate a separate user area for each task as well as a separate return stack area and a separate data stack area A task that asks for input also
92. LO Description A user variable that holds the address of the latest character of text during numeric output conversion See also lt DPL FLD 8 11 16 NUMBER Name NUMBER Stackeffect s d Attributes Description This word is intended to be called from single character denotation words hence the parse pointer is decremented to include this first character Convert characters from the current input source into a number and compile or execute this number If the string contains a decimal point it is a double else a single integer number If numeric conversion is not possible an error message will be given See also BASE NUMBER Chapter 8 Glossary 93 8 12 INIT The wordset INIT contains words to initialise reinitialise or configure Forth 8 12 1 ORIGIN Name ORIGIN Stackeffect n addr Attributes Description Leave the memory address relative by n bytes to the area from which the user variables are initialised so one can access or modify the boot up parameters During run time user variables are fetched from the current user area via a pointer at 0 ORIGIN This can be swapped to get a fresh set of user variables for multi asking One can access or modify the boot up parameters prior to saving a customised boot image It will also change the initialisation by COLD See also USER 8 12 2 ABORT Name ABORT No stackeffect Attributes ISO FIG L
93. Macros for names in the documentation ciforth manual A close to ISO common intel computer intelligence CH forth This is a standard ISO Forth mostly see the section portability for the configuration called lina e version 4 0 6 e 32 bits protected mode e running under Linux e contains security words e kernel contains the full ISO CORE set e headers with source fields Albert van der Horst Dutch Forth Workshop Copyright 2000 Dutch Forth Workshop Permission is granted to copy with attribution Program is protected by the GNU Public License Chapter 1 Overview 1 1 Overview Forth is an interactive programming system ciforth is a family of Forth s that can be generated in many different version for many different operation systems It is sufficiently close to the ISO standard to run most programs intended to be portable It deviates where less used features where objectionable to implement See Chapter 4 Manual page 9 Section Portability This file documents what you as a user needs to know for using this particular version of ciforth called lina once it is installed on your system ciforth consists of three files e lina the program e ciforth ps ciforth html the documentation e forth lab source library for auxiliary programs These files are generated together by a generic system from the file fig86 gnr The documentation applies to the ciforth with which it goes If your F
94. N FILE READ FILE WRITE FILE CREATE FILE DELETE FILE 8 10 2 CREATE FILE Name CREATE FILE Stackeffect sc u fileid ior Attributes NISO Description for normal files this is just 0 Create a file with name sc and file access privileges u If the file already exists it is truncated to zero length Return a file handle into fileid and a result code into ior The latter is the errno negated to be inspected using MESSAGE The handle is open for READ_WRITE See also OPEN FILE READ FILE WRITE FILE CREATE FILE DELETE FILE 8 10 3 DELETE FILE Name DELETE FILE Stackeffect sc ior Attributes ISO Description Delete the file with name sc Return a result code into ior The latter is the errno negated to be inspected using MESSAGE See also OPEN FILE READ FILE WRITE FILE CREATE FILE DELETE FILE 8 10 4 GET FILE Name GET FILE Stackeffect scl sc2 Attributes Description Get the content of the file with name sc1 leave it as a string sc2 Any errors are thrown See also PUT FILE OPEN FILE THROW 8 10 5 INCLUDED Name INCLUDED Stackeffect scl i x Attributes ISO Description Interpret the content of the file with name sc1 as if it was typed from the console leaving result i x See also LOAD 88 ciforth manual 8 10 6 OPEN FILE
95. Name Stackeffect addr Attributes ISO FIG I LO Description Used in the form gt nnnn It leaves the execution token equivalent to the dictionary entry address of dictionary word nnnn If the word is not found after a search of the search order an appropriate error message is given If compiled the searching is done while the word being compiled is executed Because this is so confusing it is recommended that one never compiles or postpones Use a combination of WORD and FIND or any form of explicit parsing and searching instead Furthermore it is recommended that for non portable code is used in its denotation form without the space See also FOUND gt CFA gt DFA gt FFA LFA gt NFA gt SFA gt XFA 8 6 2 Name Stackeffect n Attributes ISO FIG LO Description Store n into the next available dictionary memory cell advancing the dictionary pointer See also DP C 8 6 3 gt BODY Name gt BODY Stackeffect dea addr Attributes ISO Description Given the dictionary entry address dea of a definition created with a CREATE DOES gt construct return its data field in the ISO sense addr See also gt CFA gt DFA gt PHA BODY gt 74 ciforth manual 8 6 4 ALLOT Name ALLOT Stackeffect n Attributes ISO FIG LO Description Add the signed number to t
96. O Description Restart the system In addition and before the actions of QUIT clear also the data stack and reset the search order reset the exception mechanism and set the numeric base to default As required by ISO it is silent This may be confusing at times because you can t tell the difference between a word that is still busy or that has aborted See also WARM 8 12 3 COLD Name COLD No stackeffect Attributes FIG Description Reinitialise the system Clear all block buffers Reinitialise all user variables to their boot up values values i a the stacks and the dictionary pointer Opens the file that contains the blocks Restart via ABORT May be called from the terminal to remove application programs and restart as long as there are no new vocabularies with definitions But it is better to say BYE to Forth and start again See also WARM BLOCK LIST 8 12 4 OK Name OK No stackeffect Attributes ISO FIG 94 ciforth manual Description Takes care of printing the okay message after interpreting a line Default it prints OK only for an interactive session in interpret STATE See also QUIT COLD 8 12 5 OPTIONS Name OPTIONS Stackeffect f1 f2 Attributes FIG LO Description Handle command line options i e execute the screen corresponding to the option letter Accept and return a flag f whether the signon message must be displayed By redefining this as a
97. OAD if the screen must be loaded manually In addition the signon message is suppressed e c name Compile the file name to an executable binary The name of the binary is name without the trailing frt or else a out Upon invocation of the binary the word defined latest is executed then Forth goes BYE name is a regular source file not a block file Also REQUIRED is made available 22 ciforth manual Le Load the elective screen screen 5 This contains preferences the tools you want to have available running an interactive Forth The default library file contans system wide default preferences See the 1 option if the default preferences don t suite you In a elective screen you just put commands you want to be executed after Forth starts up such as fortune f usr lib forthcookies SYSTEM or REQUIRE EDIT f forthcode Execute the forthcode in the order present Beware of the special characters in the shell Also the shell will collapse multiple spaces into one g number name Expand the system by number Megabytes then save it under the name name number may be negative and in that case the system is made smaller h Print overview of options i binpath libpath shellpath Install the forth in binpath and the library in libpath If the shellpath parameter is specified it will be installed as the com
98. RC by Forth parsing words like WORD The editing functions are those described by ACCEPT Immediately after REFILL TIB REMAINDER 20 defines the characters ready in the input buffer All characters are retained including the RET If the input is redirected such that reading after a RET occurs REMAINDER 2 contains the part of TIB that is not yet consumed by ACCEPT and outside the reach of SRC All system call errors result in an exception For redirected I O this word may generate an end of pipe exception See also ACCEPT ACCEPT 8 13 11 REMAINDER Name REMAINDER Stackeffect addr Attributes Description A pointer to a constant string that contains the balance of characters fetched into the input buffer but not yet consumed Used as in REMAINDER 20 See also REFILL TIB 8 13 12 SET TERM Name SET TERM Stackeffect len b Attributes Description Set the terminal length to len and toggle the c_lflag field with b in the termio structure TERMIO In particular toggling with Ox0A makes that the terminal doesn t wait for a RET This word is invalid for pipes and is replaced by a 2DROP in that case See also SET TERM 8 13 13 TERMIO Name TERMIO Stackeffect addr Attributes Description Leave the address of the terminal description this has the layout of a c structure termio See also SET TERM 98 ciforth manual 8 14 JUGGLING
99. S Stackeffect nl n2 Attributes ISO Description Return the equivalent of n1 chars in bytes n2 In ciforth this is a NOOP Unfortunately the ISO standard has no way to address bytes See also CELLS 8 16 16 CMOVE Name CMOVE Stackeffect from to count Attributes Description Move the specified quantity of characters beginning at address from to address to The contents of address from is moved first proceeding toward high memory such that memory propagation occurs As the Intel 86 family is byte addressing there are no restrictions in ciforth 106 ciforth manual 8 16 17 CORA Name CORA Stackeffect addrl addr2 len n Attributes CIF Description Compare the memory areas at addr1 and addr over a length len For the first bytes that differ return 1 if the byte from addr1 is less unsigned than the one from addr2 and 1 if it is greater If all len bytes are equal return zero This is an abbreviation of COMPARE AREA It would have been named COMPARE if that were not taken by ISO 8 16 18 EM Name EM Stackeffect addr Attributes Description A constant leaving the address just above the highest memory in use by Forth See also DP BM 8 16 19 ERASE Name ERASE Stackeffect addr n Attributes ISO Description This is shorthand for 0 FILL See also BLANK FILL 8 16 20 FARMOVE Nam
100. SP Stackeffect addr Attributes Description Initialize the return stack pointer with addr See also RSP 8 25 11 RSPO Name RSP Stackeffect addr Attributes Description Return the address addr of the current return stack position i e pointing the current topmost value See also RO RSP 8 25 12 SO Name SO Stackeffect addr Attributes U Description A user variable that contains the initial value for the data stack pointer See also DSP 8 26 STRING The wordset STRING contains words that manipulate strings of characters In ciforth strings have been given their civil rights So they are entitled to a denotation the word and have a proper fetch and store An address length pair is considered a string constant It may be trimmed but the data referring to via the address must not be changed It can be stored in a buffer a string variable that contains in its first cell the count Formerly this was in the first byte and these are called old fashioned string s or less flatteringly brain damaged 8 26 1 BD Name BD Stackeffect sc addr Attributes Description Store a string constant sc in the old fashioned string variable at address addr ie it can be fetched with COUNT Where would that BD come from See also COUNT 1 Chapter 8 Glossary 133 8 26 2 Name Stackeffect sc addr Att
101. SP It detects stack unbalance between and or wherever you choose to use the words CSP and CSP This means there is an error in the compiled code This message is given also if during compilation you try to use data that is put on the stack before Instead of lt generatedata gt name LITERAL use lt generatedata gt name _ SWAP LITERAL DROP to keep the stack at the same depth ciforth ERROR 21 IN PROTECTED DICTIONARY The word you are trying to FORGET is below the FENCE such that forgetting is not allowed ciforth ERROR 22 USE ONLY WHEN LOADING This error is reported by 7LOAD You try to use a word that only works while loading from the BLOCK FILE in casu gt ciforth ERROR 23 OFF CURRENT EDITING SCREEN ciforth ERROR 24 WARNING NOT PRESENT THOUGH REQUIRED This error is reported by REQUIRED The word you required has been looked up in the index lines It was not found in the index lines or it was a dummy item that only marks the screen to be loaded e g ASSEMBLER GENERIC In the latter case it can be safely ignored This must be a warning only because compilation can still succeed if the word is supplied by other means in particular conditional compilation ciforth ERROR 25 LIST EXPECTS DECIMAL This message is used by a redefined LIST to prevent getting the wrong screen See Section 8 28 2 ASSEMBLER page 137 f
102. TCH Name MATCH Stackeffect sc dea sc dea n Attributes Description Intended to cooperate with FIND Compares the string constant sc with the dea dea Returns into n the difference between the first characters that compare unequal or zero if the strings are the same up to the smallest length It is required that the dea has a non zero name field See also FIND CORA 8 7 DOUBLE The wordset DOUBLE contains words that manipulate double s In this 32 Forth you would hardly need doubles if it weren t for the NUMBER formatting wordset that uses them exclusively 8 7 1 D Name D Stackeffect d1 d2 dsum Attributes ISO FIG Description Leave the double number dsum the sum of two double numbers d1 and d See also DNEGATE 82 ciforth manual 8 7 2 DABS Name DABS Stackeffect d ud Attributes ISO FIG Description Leave the absolute value ud of a double number d See also DNEGATE ABS 8 7 3 DNEGATE Name DNEGATE Stackeffect d1 d2 Attributes ISO Description d2 is the negation of d1 See also D 8 7 4 S gt D Name S gt D Stackeffect n d Attributes ISO Description Sign extend a single number to form a double number 8 8 ENVIRONMENTS The wordset ENVIRONMENTS contains all words of the ENVIRONMENT vocabulary and those words needed to recognize them as For
103. TL Prefix i cc4 desk e p a PRE gee ep aceti LPS TL Prefix TIC A CAS dd e oA ra d T2 ciforth manual Profi A bbb derat E item M Tl Profiz A ue TL Pr fiXx PP chat USD dep estet T2 Prefix 0 o pue emi iire ro ari Wee RRE E TOTA Prefix T libe edes kath yeh O eas e ER EY re POE VB 25253 gd eri chkw Pu e Hens ASS T2 PRESENT daa E a n ts ger th E a E S 76 PREV PDT 53 54 PREVIOUS vele ERE RE Rec NPHEE Ee RS 139 PUT ETLE 6n actio tir LE RR Eon 16 88 Q QUIT isi heist beater ee bedi 14 93 94 125 R A O Be quiere toits 126 R Wa Leche A td rv EE S 16 RQ PncR 131 Ril iria iaa 21 aa ie da 60 61 130 131 pAV EE 53 o ETE 20 131 RB RW RL cosas ow Reese Ge XE 40 RD ROP Pcr 131 READ FEILE ee does be arbre ee 88 RECURSE 004 beachte Puma 62 REELLB 2506 5 gms qu rp ES pape adie eh ated vos 14 REELILE TIB x 21 e E EU io da 97 REMAINDER rese vo bee no ezo PR ace 97 A ak REX Nds 59 63 64 67 REP SITION EILE 5 fdas as PER LEUR qa 88 REQUIRE rr dica 10 11 21 REQUIRE ASSEMBLERi86 oooooo o o 30 REQUIRED 200004 tua isa 10 11 21 22 23 43 46 RESTORE can eiaa auct id ue Reg 55 RESTORE EINPUT e dp ERE atado er 55 RES aorta ta eaa ua 30 ROT edo 99 ROMDE TD ici ia ii 117 REP ds 132 RSPO muii bis a at da Soh buck 132 ROI io da ie 27 o PIER es ages ene ORT eda acne 21 96 E HEUTE 30 Forth Word Index S A A ee Cee RT 135 S Dae NER IRE 82 MET 20 1
104. a normal way with some editors To load such a screen has the same effect as typing its content from the terminal The extension lab stands for Library Addressable by Block Traditionally Forthers have things called number s words that are present in the source be it interpreted or compiled and are thought of not as being executed but rather being a description of something to be put on the stack directly In early implementations the word NUMBER was a catch all for anything not found in the dictionary and could be adapted to the application For such an extensible language as Forth and in particular where strings and floating point numbers play an increasing role numbers must be generalised to the concept of denotation s The need for a way to catch those is as present as it was in those early days Denotations put a constant object on the stack without the need to define it first Naturally they look and in fact are the same in both modes Here we adopt a practice of selecting a type of the denotations based on the first letter This is quite practical and familiar Examples of this are some from C some from assemblers some from this Forth 14 ciforth manual 10 a A ODEAD 8000403A 3487 0177 Arpeggio JAMES BROWN IS DEAD JK DROP DROP These examples demonstrate that a denotation may contain spaces and still are easy to scan And yes I insist that DROP is a denotation
105. adda 10 43 52 126 TES corrida dai 11 LOR RR RE 126 TOS PME RR ERE RR E RR 31 TOE MR Se RON 45 60 61 62 64 A A 116 M ri SUMI 6225 atte ccna dar us Ado S EE MC LEE 111 A Te AS 116 POM pects a cee A O 28 MESSAGE 00 0 c cece cee seen 85 87 88 A ek oe ae nee tke 116 JI SNR E ERREUR crios 114 116 A e o a E a 2T 152 MOV EA m ainda eed liada ates 32 MOV TAs sete 2ece0 vee cra iia 32 MOVE a cued ose sends A AA a he 107 ue A S MYTYPE 00d abans 2l N NAME 46e dixere E Esaiae ue InDPPDE STRE nep 83 NEGATE atar rd Deas 116 NEWSTE ui iaa da 45 NO DEBUG 4 2 Rep ti 10 NOOP e a In idu Y PES 109 NUMBER vas dnd ge eee qeu as TO TL 72 92 Number 1 45 2 aor sierra icbsela abia 136 Number Dox soli S UPSTIGWGM PERIERE 136 O E e E E data lhe ied desde Te 29 ug 29 QFE SET pr ERN eH een aes eye US d 54 K ode ds En ee id Bom adu dog ahs 93 ONLY iii 45 10 122 137 139 PEN EIDLE 2345 330 atinada 88 PPP 81 OPTIONS EPA UP be his a debra aoe ot aed ene 94 ij PPM 28 102 S IMPURT 2 21 25299 24 M RO PIE PIN PERPE des I atcp 30 31 085 o mr ORUM A TORRE RR 28 DUT seii rr dt aja Roa Ore td 119 120 OVER ob erreIqp e nie Eee dioses 99 D MF EET 41 P PU ond Matec ad Ruder s epe P EN Ies 107 sic a dd ratas 107 PAD scsi aiii ae 76 90 PO asia 108 PCG oi a ri 108 POSTPONE is a Ite ie ade 57 76 PREP ER ida eU Rates eee rad Pa 76 Protix Coss ti ne ila dudes e Srt Saree p
106. as etc qid taa 98 8143 JOVER caga dai dieta das 98 vil viii Sd IS WA Dt a tata atea 98 A A 99 8146 DROD id ao cP ES 99 SAT A O ce Guan E nants i ee 99 3 14 38 OVER irte sepia tidad be dee 99 S149 ROT osuere m OR ai Bagh i bee alana 99 8 14 14 SWAP adan co Ou im doa adde 100 SMIDEBEO CIS E 100 A CET P 100 LBS MM A E E E E A 100 loro do ED 100 SADA aos 101 SoD Suo ndue csl atabetha uti e qeu Nea EAE eu DEDE 101 MTM TT 101 Slr AND LIED Ch C LEN ere 101 8 15 8 INVERE duh ri PE eg has ada ba A 101 aX EQUI PT 102 8 15 10 Ue pant bU edet dau Etsi emus 102 8 5 11 KOR zs br ad noted pte aAa Ee eds d 102 8 16 MEMORY eec treten t tese oe t eto ated ace cedo 102 A EEEE E E E E E E EE ETT 102 SA F T 103 8 16 3 DUAR Ea 103 Slol A E E EE EREA A 103 dE C CC 103 8 16 6 ALIGNED eR e 103 S6 ALIGN srs imet eue etu etre da ecce due 104 8 16 8 BLANK eeeee RR ae 104 8 10 9 ABM Sea sanders ce daba rra io ad 104 MIS MEO T 104 OA a E a a A ER 104 8 1012 A eae eee a ees E A 105 8 10 13 CELOS Lo A AA 105 OA CHIARA e a 105 8 16 15 CHARS uso dete e be qi PED REIR 105 8 16 16 CMONVWBE c eene deca dias re ER te ed ote bbs 105 8 16 17 CORA eeeeeee hh hee ran 106 EAG A ood be a Pepe tiras aiam vts 106 8 16 19 ERASE seseeee nha 106 8 16 20 FARMOVE it endestus stati ate ais 106 A A A ratas envies aodio RR OT 106 O MET 107 81023 PET 107 8 16 24 MOVE cocci tank SER
107. ata segments After the directive BITS 32 code is generated for and checked against 32 bit code and data segments In a 16 bits segments the following commaers must be used W IW RW and RW In a 32 bits segments the following commaers must be used L IL RL and RL The prefix OS switches the following opcode to use IL instead of IW and vice versa Similarly the prefix AS switches between W and L or between RW and RL While mixing modes whenever you get error messages and you are sure you know better than the assembler put TALLY before the word that gives the error messages This will override the error detection Proper use of the BITS xx directives makes this largely unnecessary but it can be needed if you use e g an extra segment ES that is 16 bits in an otherwise 32 bits environment 5 8 The built in assembler From within ciforth one can load an assembler from the installed LAB library by the command REQUIRE ASSEMBLERi86 Automatically a 32 bit assembler is loaded if the Forth itself is 32 bits and a 16 bit assembler for the 16 bit forths This is a simplified version with no error checking and no provisions for 16 32 bit mixing Those are not needed because you can mix with impunity In the future this assembler is now since 4 0 6 fully compatible with the large file based one Consequently you can take a debugged program and run it through the LAB assembler The built in assembler has no error che
108. been legal if Intel had not made an excep tion just for this combination This situation is handled by special code to issue just this error ciforth ERROR 28 AS UNEXPECTED FIXUP COMMAER You try to complete an opcode by fixup s like X or comma ers like OW in a way that conflicts with what you specified earlier So the fixup comma er word at which this error is detected conflicts with either the opcode or one of the other fixups comma ers For example B byte size with a LEA opcode or with a DI operand ciforth ERROR 29 AS DUPLICATE FIXUP UNEXPECTED COMMAER You try to complete an opcode by fixup s like X or comma ers like OW in a way that conflicts with what you specified earlier So the fixup comma er word at which this error is detected conflicts with either the opcode or one of other fixups comma ers For example Bl byte size with a LEA opcode or with a DI operand ciforth ERROR 30 AS COMMAERS IN WRONG ORDER The opcode requires more than one data item to be comma ed in such as immediate data and an address However you put them in the wrong order Use SHOW ciforth ERROR 31 AS DESIGN ERROR INCOMPATIBLE MASK This signals an internal inconsistency in the assembler itself If you are using an assembler supplied with ciforth you can report this as a defect bug The remainder of this explanation is intended for the writers of assemblers The bits that are
109. buehiR e sdb dais Meebbe bin IRR 30 RW rra dade eet pla ee dee eee 30 WORD ee er eee 121 NEMPE MERC TIE 133 I BD uan 132 cr 133 T 6 nen i o EE 3 114 WM quo dasupiqs pre ptepepbatadeqtbpnbI ei ipid p SEE DONE 110 l 133 o dale 110 A DO ees 134 C MC 134 amp v Oq VEA 73 C PR 45 122 9 s 100 115 DT A AAA A A 45 72 73 RR A A 46 125 VNOEOS pri is ii pd ie ado Re 43 TRAIN Gil e IOS 134 c UT 67 SCODE vis sade A bs 67 tias 3 118 A A ae eee ee eee 117 P e a E E PUMA cite ak Ae te eens 14 117 o e Ro e can ir 130 SDUJ S crue cathe dete ae OR DU TRE Reed 65 D doradas arcoiris 58 64 A 109 opp 96 CABORT sio al decks 86 AOCEPT eei Rete d piu RLRE 94 95 97 BACK eee o rebote CO eoo rh Dies 65 66 RIVERA 114 115 148 m 4 12 13 46 67 A da ea usd ent Seta ees 4 46 67 CODE s patiendi ci ra aa E 70 Eon UARIIS EM LM EE 100 101 T Dd 118 TBDANK 30d a 127 COMP dora tese pre dens 45 128 POS ii ca cob ech ached de ub Urea red Bord nii 46 128 CDELIM rita dace pardoned ben EEDE Et 128 DISK ERROR cities dong Rae een alee coaster 45 50 px 58 65 PDUP ep sRRRIPSDSe dI P ebbe este e 99 PENVIRONMENT 0 0 0 0 cece enr 50 TERROR candado Lik as 43 84 86 TERB R atar tada cu ig 84 TEXEQ nidos i dere EM tee 129 PEXEO gt pedibus pee vedas eed E 45 LOAD seni eS RID IN RARE INIT 46 LOADING erini wae ele lege Fede bea eee ls 129 a ssc acacia ted fva bee aes er ERES 45
110. by a a null ended array of arguments strings then by a null ended array of environment strings See also SYSTEM 8 19 2 BYE Name BYE Stackeffect Attributes ISO Description Return to the host environment Linux See also COLD EXIT CODE 8 19 3 EXIT CODE Name EXIT CODE Stackeffect addr Attributes Description Return addr the address of a variable with the exit code Its content is passed to the host environment while going BYE It is custom to return zero if there are no errors Linux allows only single byte return codes See also BYE Chapter 8 Glossary 113 8 19 4 LINOS5 Name LINOS5 Stackeffect nl n2 n3 n4 n5 n ret Attributes Description Do a Linux system call n man 2 with parameters n1 n2 n3 n4 n5 ret is the return value of the call If it is negative it is mostly an error such as known by errno This makes available all facilities present in Linux See also ERRUR 8 19 5 LINOS Name LINOS Stackeffect nl n2 n3 n ret Attributes Description Do a Linux system call n man 2 with parameters n1 n2 n3 ret is the return value of the call If it is negative it is mostly an error such as known by errno This makes available all facilities present in Linux except those with 4 or 5 parameters that are handled by LINOS5 See also ERRUR 8 19 6 MS Name MS Stackeffect n Attributes
111. chine code sequence It is used after CREATE instead of DOES gt if the code following is assembler code instead of high level code See also CREATE CODE 8 4 10 CREATE Name CREATE Stackeffect sc Attributes Description This is the basis for all defining words It lays down the string sc in the dictionary then creates a dictionary entries with that string as the namefield It is linked into the CURRENT word list The code field and data field both point to the area owned by this header i e immediately following the completed header as appropriate for a low level assembler definition The flag field is empty so not HIDDEN See also CREATE 8 4 11 CODE Name CODE No stackeffect Attributes B ISO FIG I C LO Description Used in the form cccc CREATE CODE assembly mnemonics Stop compi lation and terminate a new defining word cccc by compiling CODE Set ASSEMBLER to the top of the search order order Start assembling to machine code the following mnemonics When cccc later executes in the form cccc nnnn the word nnnn will be created with its execution proceedure given by the machine code following cccc That is when nnnn is executed it does so by jumping to the code after nnnn Because of intimate relation to the assembler it is present in loadable form in the screens file forth lab See also CODE LOAD
112. ciforth s every DEA can serve as a WID It defines a wordlist consisting of itself and all earlier words in the same vocabulary If needed you can always derive the WID from the DEA of a vocabulary A word that is defined using is often called a colon definition Its code is called high level code Chapter 4 Manual 13 A high level word one defined by is little more than a sequence of addresses of other words The inner interpreter takes care to execute these words in order It acts by fetching the address pointed by HIP storing this value in register W It then jumps to the address pointed to by the address pointed to by W W points to the code field of a definition which contains the address of the code which executes for that definition This usage of indirect threaded code is a major contributor to the power portability and extensibility of Forth If the inner interpreter must execute another high level word while it is interpreting it must remember the old value of HIP and this so called nesting could go several levels deep Keeping this on the data stack would interfere with the data the words are expecting so they are kept on a separate stack the return stack The usage of two stacks is another hall mark of Forth A word that generates a new entry in the dictionary is called a defining word see Section 8 4 DEFINING page 67 The new word is created in the CURRENT word list Each proces
113. ck mechanism connects to the Forth system a single background storage divided in numbered blocks The wordset BLOCKS contains words to input and output to this mass storage In this ciforth blocks reside in a file by default named forth lab Most blocks are used for the SCREEN facility where each block contains source code 8 1 1 BUFF Name BUFF Stackeffect n Attributes Description A constant that leaves the number of block buffers Because a buffer that is being interpreted is locked in memory this is also a limit to the nesting depth of blocks loading other blocks See also BLOCK THRU LOAD LOCK 8 1 2 DISK ERROR Name DISK ERROR Stackeffect n Attributes Description Interpret n as the status of a disk i o call and signal an error if it contains an error condition See also BLOCK FILE BLOCK HANDLE BLOCK INIT BLOCK EXIT Chapter 8 Glossary 51 8 1 3 B BUF Name B BUF Stackeffect n Attributes Description This constant leaves the number of bytes per disc buffer the byte count read from disc by BLOCK The ISO standard fixes this to 1024 See also BUFFER 8 1 4 BLOCK EXIT Name BLOCK EXIT Stackeffect Attributes Description A block file must have been opened by BLOCK INIT Close the currently open block file BLOCK HANDLE i e the mass storage words no longer work and will result in error messages I
114. cking IMPORTANT NOTE The 4 0 6 version and later contains assembler code in the LAB file that has not yet been converted This code largely relates to a booting version It will be updated as soon as I have a booting version in a binary form available 5 9 A rant about redundancy You could complain about redundancy in postit fixup assemblers But there is an advantage to that it helps detect invalid combinations of instructions parts They look bad at first sight Chapter 5 Assembler 31 What about MOV B T BX SI RI AX MOV needs two operands but there is no primary operand in sight BX SI would not qualify and not even BX because the primary operand should be marked with a prime MOV X T BX AX looks bad because you know BX and AX work on the same bit fields so it easy to remember you need the prime T and F refer to the primary operands so gone is the endless confusion about what is the destination of the move MOV X T BX RI AL looks bad because AL could not possibly qualify as an X register MOV X T BX AXI looks bad because soon you will adopt the habit that one of the 8 main register always must be preceeded with T F or RI MOV X T BX RI AX looks right but you still can code MOV AX BX RI TI XI if you prefer your fixups in alphabetic order A nice rule for those Code Standard Police out there And yes ES OS MOV X T DI SIBI
115. crement n1 is added to the index and the total compared to the limit The branch back to DO occurs until the new index is equal to or greater than the limit n1 gt 0 or until the new index is equal to or less than the limit n1 lt 0 Upon exiting the loop the parameters are discarded and execution continues ahead At compile time LOOP compiles the run time word LOOP and the branch offset computed from HERE to the address left on the stack by DO n is used for compile time error checking 8 3 2 7DO Name DO Stackeffect n1 n2 execute addr n compile Attributes ISO I C2 L0 Description Occurs in a colon definition in form DO LOOP Chapter 8 Glossary 59 It behaves like DO with the exception that if nl and n2 are equal the loop body is not executed See also DO I LOOP LOOP LEAVE 8 3 3 AGAIN Name AGAIN Stackeffect addr n compiling Attributes ISO FIG I C2 L0 Description Used in a colon definition in the form BEGIN AGAIN At run time AGAIN forces execution to return to the corresponding BEGIN There is no effect on the stack Execution cannot leave this loop except for EXIT At compile time AGAIN compiles BRANCH with an offset from HERE to addr n is used for compile time error checking See also BEGIN 8 3 4 BEGIN Name BEGIN Stackeffect addr n compiling Attributes ISO FIG I L0
116. d E 59 8 94 BEGIN iii OUR er dd Rd wed 59 8 9 9 DO cere ated ten ce ee eae ep hae heehee 60 DN MMPIO PET 60 BO POE cece cases eas inpet a si eee 60 SUMMO HUM T PR ee gS a A 61 93 9 DB nid d iM aoe ces MERI DEM M MANUS 61 O O NO 61 ISBN MENS rer 62 8 3 12 LEAVE 22e ndo nn etd a pb abs ree pg rl ciue dig 62 S813 HOOP odd eed REA tidad sleds 62 8 314 IRECURSB erret teen ae tee 62 Bi 15 REPEAT a2 oda ele tn olaaa eal se beds 63 5 9 16 SISID usina iodo 63 al THEN rd ntc aia osa 63 S348 UNLOOP vete dada ceed orae ER as 64 83 19 TUN TEE a RE Mamta ieee 64 8 9 20 WHILE unii iA daras das 64 8 3 21 A 64 E A netstat MNNONAM 65 BOOS X TED O ies adc Ub a 65 8 3 24 BACK uo serra stiiycron dace noter sirop pia dede arl i 65 8 3 25 DO rad UR du dS 65 8296 FORWARD cis vain tnnialeschsansyu pera aca a 66 8397 LOOP A 66 8 328 OBRANCH naasia pe rara t a cele ele E 66 o nie e e e 66 8 8 80 BRANCH 0 0 0 ccc ncn ene EEEN 66 Sogl FORWARD eee aE e E oars 67 8 4 DEFINING oiae iiine aea eea a Ru Rae em a e as 67 SA TREE 67 A A E 67 BAS CONSTANT cuidad E RR OR 68 SAA CREATE i ei dies isa s 68 ado DOP cr 68 84 6 USER poesia ii aa 69 BET VARIABLE ui bd toca ede ini data isa ae Be 69 8 4 8 VOCABULARY ai Gnd ada dad ERAT eat 69 BAG GOODE it cidita aliadas 69 8410 TEN DATE tio iros dt 70 SATA CODE pcia pia rta ia t ad uod cs 70 3 0 DENOTATIONS srra iia eon ded e each t Vd e d et E 70 o dM 71 82 o en ane se
117. d new programs easily and test them easily by typing them at the keyboard It is considered bad style if a program is longer than a couple of lines Indeed the inventor of Forth Chuck Moore has written splendid applications with an average program length of about one line Cathedrals were built by laying stone upon stone never carved out of one rock The implementation of the language Forth you look at is old fashioned but simple You as a user have to deal with only three parts files this documentation the executable program and the library file a heap of small programs in source form There may be several documentation files but they contain the same information in a different format There is an ISO standard for Forth and this Forth doesn t fully comply to it Still by restricting yourself to the definitions marked as ISO in the glossary it is quite possible to write an application that will run on any ISO compliant system Because of the way Forth remembers numbers you can always interrupt your work and continue For example TEST AGAIN 12 34 12 OK Tx DK What happened here is that some one asked you to calculate 3 times 4 while you were busy with our test example No sweat You switch from compilation mode to normal interpret Chapter 2 Gentle introduction 5 mode by and back by In the meantime as long as you don t leave numbers behind you can do anything This doesn t apply to adding de
118. d words or for hex digits See the section Common problems in this chapter if you want to make ciforth case insensitive e ciforth ERROR 13 ERROR NO FURTHER INFORMATION This error is used temporily whenever there is need for an error message but there is not yet one assigned e ciforth ERROR 14 SAVE RESTORE MUST RUN FROM FLOPPY e ciforth ERROR tt 15 CANNOT FIND WORD TO BE POSTPONED The word following POSTPONE must be postponed but it can t be found in the search order e ciforth ERROR 16 CANNOT FIND WORD TO BE COMPILED The word following COMPILE must be postponed but it can t be found in the search order e ciforth ERROR 17 COMPILATION ONLY USE IN DEFINITION This error is reported by COMP You try to use a word that doesn t work properly in interpret mode This mostly refers to control words like IF and DO If you want control words to work in interpret mode require NEW IF e ciforth ERROR 18 EXECUTION ONLY This error is reported by EXEC You try to use a word that doesn t work properly in compile mode You will not see this error because all words in ciforth do e ciforth ERROR 19 CONDITIONALS NOT PAIRED This error is reported by PAIRS You try to improperly use control words that pair up like IF and THEN or DO and LOOP 46 ciforth manual e ciforth ERROR 20 STACK UNBALANCE STRUCTURE UNFINISHED This error is reported by C
119. dress described by a sib byte of 14 The SIB 14 SIB may be replaced by any sib specification of the kind AX 2 SIJ You can ask for a reminder of the 256 possibilities by SHOW SIB The SIB constituents are not normal fixups They must always appear between the normal fixups and the commaers and the first must be the base register the one with opening bracket such as AX Table 3 SIB byte fixups AX Base register CX Base register DX Base register BX Base register SP Base register BP Base register MEM Base memory SI Base register DI register 1 Scale by 1 byte 2 Scale by 2 bytes 4 Scale by 4 bytes 8 Scale by 8 bytes AX Scaled register CX Scaled register DX Scaled register BX Scaled register 0 No register Chapter 5 Assembler 39 BP Scaled register SI Scaled register DI Scaled register For the curious Explanation of LGDT BO SIB 10 SIB 14 B This way of specifying a sib byte would be perfectly legal had I not hidden those words It shows what is going on the instruction is completed by SIB telling the assembler that a comma er SIB is required Instead of the comma er we use a SIB instruction This specifies in fact a one byte opcode with three fields examplified by AX 2 SI and again you might say 2 SI AX with the same meaning Many subtleties are involved to get right the error detect
120. ds to allow FORGET to find all vocabularies See also VOCABULARY 140 ciforth manual Glossary Index 141 Glossary Index This index finds the glossary description of each word PARSE rivas 120 A 102 WORD id ib t21 Puan o la da EE 128 ab aa EE 114 A A E E E 89 RC 110 pm 89 MOD a dro endet dui dote d ena Edo or ad isto 110 HBUFF RE 50 A PVP LARES 89 9 Sade God Rs Sede ee A Decca vated eee tye Beech eee aah as 73 Dinero eras ieee att aes 133 A ead ad Hea ad oo Ed Pee aa EE des 182 in 133 EEE E EAEE EE EEE EEE 115 A a r aA 133 PATER a i58 A ps 133 oe AA izi T m 133 MM c 134 IT A aaa dd ee do n 134 O 118 9 o ce cae chested he ate ae eens ee oases 117 73 AN 117 Rida do 118 TEM MAC HS 130 SIGNON co dardo y DU 109 Em 121 AN 65 SCODE scsi 69 9DD ceci rd ape hears 65 EEN OE EEEE ETEEN 115 CHELOOP PTT 64 ZM D desi EEEE EE EE nee ata ideas 115 SIN E E a E E E E 96 ABORTE coerce deea rN 86 ACCEPT 22 2M sels din d a ado 95 BACK Lose d Manan dod ber ue bub A EC E BB 67 BLK it dig Wate aad Seek aa pared aeons 127 BUFFER secicimio pacien da dad eee nad due 53 CREATE rad 70 E aes nee 117 A 65 Errenteria 67 EIND O AA TpDO SCODE eee n 70 FORWARD acacia els 66 A been wale ition eee et 125 2 LOOP isis aaa pd 66 m 142 A 118 BLANK o arcada chs tye ee dani 191 PCOMP e 128 A 128 A A escribes 128 DISK EBRUR eere aires 50 DU ese bps eee E Ba Sent
121. e FARMOVE Stackeffect faraddrl faraddr2 count Attributes Description Move count bytes beginning at faraddr1 to faraddr2 Segments that are zero are replaced by defaults data segment selector for source extra segment selector for destination Copying is done from low to high offset so there may be memory propagating This is not easily seen from the selector s particularly not so in protected mode As the Intel 86 family is byte addressing there are no restrictions See also MOVE CMOVE 8 16 21 FILL Name FILL Stackeffect addr u b Attributes ISO FIG LO Description If u is not zero store b in each of u consecutive bytes of memory beginning at addr See also BLANK ERASE Chapter 8 Glossary 107 8 16 22 L Name L Stackeffect n faraddr Attributes Description Store 32 bits of n at segment address pair faraddr See also LO P CP 2 8 16 23 L Name L Stackeffect faraddr n Attributes Description Leave the 32 bit contents of segment address pair faraddr See also L C 2 8 16 24 MOVE Name MOVE Stackeffect from to count Attributes Description Move the count bytes beginning at address from to address to such that the destination area contains what the source area contained regardless of overlaps As the Intel 86 family is
122. e applies equally to that assembler A useful technique is to develop code using the full assembler Then with code that at least contains valid instruction enter the debugging phase with the assembler from the library forth lab equivalent to asgen frt plus asi86 frt plus asipentium frt but without error detection ass frt the 80 line 8086 assembler no error detection a prototype as6809s frt a small 6809 assembler no error detection asgen frt generic part of postit fixup assembler as80 frt 8080 assembler requires asgen frt asi86 frt 8086 assembler requires asgen frt asi386 frt 80386 assembler requires asgen frt aspentium frt general Pentium non 386 instructions requires asgen frt asalpha frt DEC Alpha assembler requires asgen frt asi6809 frt 6809 assembler requires asgen frt ps frt generate opcode sheets p0 asi386 ps first byte opcode for asi386 assembler pOF asi386 ps two byte opcode for same that start with OF test mak makefile i e with targets for opcode sheets De asi386 frt containing the full 80386 instruction set is in many respects non compliant to Intel syntax The instruction mnemonics are redesigned in behalf of reverse engineering There is a one to one correspondence between mnemonics and machine instructions In princi ple this would require a monumental amount of documenta
123. e dictionary A 16k byte total system is most typical It is indeed possible to do useful work like factoring numbers of a few hundred digits in a workspace of 2k bytes More typical a workspace is several megabytes to over hundred megabytes 32 bits system are set at 64Mbyte but this is arbitrary and could be set much higher or lower without consequences for system load or whatever Before long we will put the dictionary space on I86 Linux to 4G minus something and forget about this issue forver The boundary between this area and the previous one is pretty sharp it is where DP points The other areas are not clearly separated at all But even this boundary constantly changes as you add and forget definitions 4 7 Specific layouts 4 7 1 The layout of a dictionary entry We will divide the dictionary in entries A dictionary entry is a part of the dictionary that belongs to a specific word A dictionary entry address abbreviated DEA is a pointer to the header of a dictionary entry In ciforth a header extends from the lowest address of the entry where the code field is to the past header address just after the last field address A dictionary entry apart from the header owns a part of the dictionary space that can extend before the header mostly the name of the entry or after it mostly data and code A dictionary entry has fields and the addresses of fields directly offset from the dictionary entry address are called field addres
124. e nel cote eden es 80 FOR THe xen Maui nib ace ala Re 14 57 138 139 FORWARD 4 24 5560 cane rele p PER ee pU 67 FOUND nnn 75 G GEI EIBE D E EEE etd 87 H O E a ash 11 HANDLER cos ibero caia elle md dees 86 HERE 16 58 59 60 63 64 65 66 67 68 74 75 76 104 117 123 135 HEX O ess iene nee dete als 91 HIDDEN diia ep dda tenet eed 70 80 MD ir a a alii 92 HOLD vicodin 91 I i E bd RR ta veered ee eee HRS P 60 61 j TET 28 p MEME ATA OE EET 75 IF hecer ereis arabes 45 60 61 63 66 99 100 D EEE TE EE E E EAE 27 28 30 IMMEDIATE en td ve dupe gee db wee E 69 76 IMUL AD ooo a E RIT e ag 28 IN oL1iRPI6ee4REPRPRPbIfeeewrEk Pee Rig 95 96 120 INS arde tarde R HR 122 INCLUDE iaa dE TS 10 INCLUDED rirerire dradu Eria inari Ei 13 87 INDEX eria bhitgr ei deel oe aara a r 125 INTERPRET 2005 44 69 94 122 123 INVERT v0x c5cSinsesvienneoGudd OY cee needed Pip Peas 101 p EE 67 151 D NRI cs tasas URN 28 30 J quu MM LM MEUSE 62 DO ces bases eee ena twee eee senate se 29 LI RR acer aceite eet ae bees cede ous 29 K sche hs ae ER eee ogc eee ees 16 96 Due P hes ace eye ah eee ie 16 96 L P PTT 107 HERR 27 29 30 a Ce ee A ne ee 107 A ee ete ede orate aes Goat 32 A Assis 138 DM 32 A 32 A eens weedeat 26 41 TEAVE A eee antennas 62 64 LIMIT eoria citadas 20 54 o A o 113 o A II 113 A FERNER TTE 43 46 126 Ns ee eee eee Oe c A LI ree 57 A eee nant ET 56 OM PME SERO IR nie A
125. ed in with the mouse etc Consequently RUBOUT is not used 4 8 Libraries and options In ciforth there is no notion of object i e compiled libraries only of source libraries A Forth library is a block file adorned with one convention This is that the words defined in a screen are mentioned on the first line of that screen the index line This is of course quite established as a habit The word REQUIRED takes a string and loads the first screen where that name occurs in the index line For convenience also REQUIRE is there that looks ahead in the input stream These words are not in the kernel but are in screen 17 that corresponds to the r option Screen 0 and screen 1 to 31 are reserved When a Forth is started up with a first parameter that is a one letter option the correspond ing screen is to be executed So a or A is equivalent to 1 LOAD and z or Z is equivalent to 26 LOAD In fact all options are mapped onto screen 0 31 by a bitwise and 4 8 1 Options ciforth is a primitive system and can interpret just one option on the command line If the first argument is not starting with ciforth returns with error code 3 However the option 1 can bootstrap it into more sophisticated behaviour The following options can be passed to lina on the command line e a Make sure REQUIRED is available This is a copy of the r command because it is easier to remember 1 L
126. ee Serene errr renee A Her reneneer 118 BILS MAMMA 118 O tau aoa EE E O 118 AS 118 8 21 8 Diaries anar dica rrn 118 B210 PH 119 8 21 10 EMIT roscas ala detal 119 A e ta EEEE THEE tiui 119 8 21 12 OUT sanvachasdawns wiuarnnneaeunndiiaecn teamed 119 8 21 13 SPACES dia were 119 8 21 14 SPACE ds we bamvons 120 da Is ter lo RUE MS 120 Se MD MPO MPH ME 120 E 120 8 22 1 PARSE A ether ea ese Phe edd 120 8222 WORD AMEND 121 A E TTE 121 8 22 4 BLANK arcano rodas 121 8 225 CHAR MEET 121 8 22 6 EVALUATE us ern ge tres necare 122 8 22 7 INTERPRET rre a dr oes 122 oM MM 122 8220 SET SRC roer 122 8220 SO Otis lero T ae EAA S 123 A 123 82212 STATE rra tine 123 8 22 13 WORD NNNM 123 A A 124 E A OEE A E 124 OA mo MMMEMMMMEMMEMRRMEMNMEM 124 o A A 124 823 SCREEN PME 125 o EMITE 125 ID or E MMC n 125 A doped Md 125 AI INDEX des 125 a radares 126 8 23 6 LOAD RPM 126 8237 LOCK aeaiee te neii A EE eE SEADE 126 a 126 A 126 82310 a lisis 127 A dire amet udin ca a techn 127 8 23 12 UNO Oasis 127 E uo cpesoscatetrubiadi ved d etie pec Re ah 127 SE E ME NIS PI ae ere D 128 8 24 BECURIEY A rrenrrorrerirnn 128 BAL EE NR DEP 128 8 24 2 QUON ce psaqasqraxsausd e goa iaa 128 BA daro aac tiniest hte teat MM 128 E ene eerie 128 NI EEA RESNA 129 8 24 6 LOADING a lis 129 8 24 7 PPAR rcs bs nc crei evan ec ndedeindadd ats 129 BODAS TO lo iia 129 A A tend aan aot 129 A cca cpenacionpedtaniad nena cheer 130 p MM E E EE 130 BOD ra S 130 8
127. eference Pentium only BSWAP CMPXCHG CMPXCHGSB F2XMI FABS FADD FADDP FBLD FBSTP 36 FCHS FCLEX FCOM FCOMP FCOMPP FCOS FDECSTP FDIV FDIVP FFREE FIADD FICOM FICOMP FIDIV FILD FILD 64 FIMUL FINCSTP FINIT FIST FISTP FISTP 64 FISUB FLD FLDIe FLDI FLDCW FLDENV FLDL2E FLDL2T FLDLG2 FLDLN FLDZ FMUL FMULP FNOP FPATAN FPREM FPREMI FPTAN ciforth manual Chapter 5 Assembler FRNDINT FRSTOR FSAVE FSCALE FSIN FSINCOS FSQRT FST FST u FSTCW FSTENV FSTP FSTPle FSTP u FSTSW FSTSWI AX FSUB FSUBP FEST FUCOM FUCOMP FUCOMPP FXAM FXCH FXTRACT FYL2X FYL2XP1 INVD INVLPG Illegal 1 Illegal 2 RDMSR RDTSC RSM WBINVD WRMSR XADD Table 4 Fixups and their meanings Pentium only STO Register name ST1 ST2 37 38 ciforth manual ST3 ST4 ST5 ST6 ST7 s Single 16 bit d Double 32 bit m Register is modifiable ul Register is unmodifiable n STO is first operand normal r STO is second operand reverse 116 Int width in memory 132 Int width in memory 5 12 The dreaded SIB byte If you ask for the operands of a memory instruction one of the simple one is LGDT instead of all the sib scaled index byte possibilities you see LGDT BO SIB 14 SIB 18 B This loads the general description table from an ad
128. em See also BLOCK STALEST PREV BUFF LOCK UNLOCK 8 1 14 BUF Name BUF Stackeffect addrl addr2 ff Attributes FIG Description Advance the disc buffer address addr1 to the address of the next buffer addr2 Boolean ff is false when addr2 is the buffer presently pointed to by variable PREV See also BLOCK 54 ciforth manual 8 1 15 FIRST Name FIRST Stackeffect n Attributes Description A constant that leaves the address of the first lowest block buffer See also BLOCK LIMIT 8 1 16 FLUSH Name FLUSH No stackeffect Attributes ISO FIG LO Description Make sure that the content of all UPDATE d block buffers has been transferred to disk They are no longer associated with a block and their content is no longer available See also EMPTY BUFFERS BLOCK SCREEN 8 1 17 LIMIT Name LIMIT Stackeffect n Attributes Description A constant leaving the address just above the highest memory available for a disc buffer Actually this is the highest system memory See also BLOCK FIRST 8 1 18 OFFSET Name OFFSET Stackeffect addr Attributes U Description A user variable which contains a block offset to disc drives in this way a part of it is available for boot code As blocks are allocated in a file on the host operating system it is 0 The contents of OFFSET is added to the stack
129. er d right aligned in a field n characters wide Enlarge the field if needed So a field length of 0 results effectively in free format See also OUT D D R Chapter 8 Glossary 119 8 21 9 D Name D Stackeffect d Attributes ISO FIG L1 Description Print the signed double number d observing the current BASE followed by a blank See also OUT D R D R 8 21 10 EMIT Name EMIT Stackeffect Attributes ISO FIG LO Description Transmit ASCII character c to the output device For this ciforth all terminal I O goes through TYPE In this ciforth EMIT maintains OUT See also TYPE OUT 8 21 11 ETYPE Name ETYPE Stackeffect addr count Attributes Description Transmit count characters from addr to the standard error device It is high level so error output can be redirected by revectoring it Or you may use redirection by Linux In this ciforth strings may contain embedded LF s with the effect of a new line at that point in the output See also EMIT TYPE 8 21 12 OUT Name OUT Stackeffect addr Attributes U Description A user variable that reflects the position at the current line of the output device where the next character transmitted will appear The first position is zero Only an explicit CR will reset OUT not an LF embedded in a string that is TYPE d See also EMIT
130. eral Later execution of the definition containing the literal will push it to the stack If executing in ciforth the number will just remain on the stack See also LITERAL LIT 8 2 2 LITERAL Name LITERAL Stackeffect n n executing n compiling Attributes ISO I C2 L0 Description If compiling then compile the stack value n as a 32 bit literal The intended use is xxx calculate LITERAL Compilation is suspended for the compile time calculation of a value Compilation is resumed and LITERAL compiles this value Later execution of the definition containing the literal will push it to the stack If executing in ciforth the number will just remain on the stack See also LIT LITERAL Chapter 8 Glossary 57 8 2 3 POSTPONE Name POSTPONE No stackeffect Attributes ISO I C Description Used in a colon definition in the form xxx POSTPONE SOME WORD POSTPONE will postpone the compilation behaviour of SOME WORD to the definition being compiled If SOME WORD is an immediate word this is similar to COMPILE SOME WORD See also COMPILE 8 2 4 COMPILE Name COMPILE No stackeffect Attributes ISO I C Description Used in a colon definition in form XXX COMPILE FORTH COMPILE will force the compilation of an immediate definitions that would otherwise ex ecute during compilation The above example will select the
131. escription Leave the two s complement of a number i e n2 is n1 6L See also Chapter 8 Glossary 117 8 20 12 RSHIFT Name RSHIFT Stackeffect ul n u2 Attributes ISO Description Perform a logical shift of the bits of u1 to the right by n places Put zero into the places uncovered by the shift See also LSHIFT 2 8 21 OUTPUT The wordset OUTPUT contains words to output to the terminal and such See Section 8 10 FILES page 86 for disk I O See Section 8 1 BLOCKS page 50 for blocks 8 21 1 D R Name D R Stackeffect d n sc Attributes ISO FIG Description Format a signed double number d right aligned in a field n characters wide to the string sc Enlarge the field if needed So a field length of O results effectively in free format See also OUT D D R 8 21 2 Name No stackeffect Attributes ISO FIG I LO Description Used in the form cccc In a definition it compiles an in line string cccc as if the denotation cccc was used followed by TYPE In ciforth behaves the same way in interpret mode In ciforth the number of characters has no limit In ciforth always has an effect on HERE during interpretation In ISO programs you may only use this word during compilation We recommend that cccc is replaced by cccc TYPE See also OUT 8 21 3 Name N
132. f error messages were fetched from disk they no longer are See also BLOCK LIST LOAD DISK ERROR WARNING 8 1 5 BLOCK FILE Name BLOCK FILE Stackeffect addr Attributes Description Leave the address addr of a counted string the name of a library file in which blocks are to be allocated The name may contain a path and be at most 252 characters long The default name is forth lab This name may be changed and is used by the BLOCK INIT command See also BLOCK HANDLE BLOCK INIT BLOCK EXIT 8 1 6 BLOCK HANDLE Name BLOCK HANDLE Stackeffect n Attributes Description Leave a file handle in n If it is negative there is no block file open otherwise the handle is used by the system to access blocks See also BLOCK FILE BLOCK INIT BLOCK EXIT 52 ciforth manual 8 1 7 BLOCK INIT Name BLOCK INIT Stackeffect n Attributes Description Map the blocks on the block file BLOCK FILE i e the mass storage words refer to the blocks in this file The handle BLOCK HANDLE can be used to access it with access code n 2 for read and write This command fails silently You must activate mnemonic error messages explicitly by setting WARNING See also BLOCK LIST LOAD BLOCK EXIT OPEN FILE 8 1 8 BLOCK Name BLOCK Stackeffect n addr Attributes ISO FIG LO Description Leave addr
133. f the vocabulary to make machine code definitions In ciforth execution it pushes the associated word list to the top of the CONTEXT stack For ISO compliance it would replace the top ASSEMBLER is immediate so it will execute during the creation of a colon definition to select this vocabulary at compile time This word makes only sense in combination with the words that belong to it So it is present in loadable form in the screens file forth lab See also VOCABULARY LOAD 8 28 3 CONTEXT Name CONTEXT Stackeffect addr Attributes FIG U LO Description The context is the address where the WID is found of the wordlist that is searched first In ciforth addr actually points to the search order a row of WID s ending with the minimum search order WID The corresponding wordlists are searched in that order for definitions during interpretation This row of WID s is allocated in the user variable space allowing for compilation in threads It may contain up to 16 WID s in this ciforth while the ISO Search Order wordset requires a capacity of at least 8 CONTEXT is the last user variable at offset 37 such that new user variables may be allocated using offsets of 37 16 and up See also PRESENT VOCABULARY CURRENT USER 8 28 4 CURRENT Name CURRENT Stackeffect addr Attributes FIG U LO Description A user variable containing the WID of a vocabulary to which new words will be
134. ff Attributes ISO Description Return into ff return whether a character is available The next execution of KEY will return the character immediately See also KEY ACCEPT KEY 8 13 6 KEY Name KEY Stackeffect c Attributes ISO FIG LO Description Leave the ASCII value of the next terminal key struck See also ACCEPT KEY 8 13 7 RUBOUT Name RUBOUT Stackeffect c Attributes Description A user variable leaving the key code that must delete the last character from the input buffer In this ciforth it is not used as the terminal input editing is left to the host operating system See also USER 8 13 8 TIB Name TIB Stackeffect addr Attributes ISO FIG U Description A user variable containing the address of the terminal input buffer See also QUIT 8 13 9 gt IN Name gt IN Stackeffect addr Attributes Description If the standard word gt IN is used this variable contains the offset from the start within the current input text buffer terminal or disc from which the next text will be accepted All parsing words use and move the value of IN See also gt IN IN Chapter 8 Glossary 97 8 13 10 REFILL TIB Name REFILL TIB Stackeffect Attributes Description Accept characters from the terminal input stream such as to fill up TIB Normally this means until a RET It is now consumable by ACCEPT or after SET S
135. filled in by an assembler word are outside of the area were it is supposed to fill bits in The latter are specified separately by a mask ciforth ERROR 32 AS PREVIOUS OPCODE PLUS FIXUPS INCONSISTENT The total instruction with opcode fixups and data is bad Somewhere there are parts that are conflicting This may be another one of the irregularities of the Intel instruction set Or the BAD data was preset with bits to indicate that you want to prohibit this instruction on this processor because it is not implemented Investigate BAD for two consecutive bits that are up and inspect the meaning of each of the two bits 42 ciforth manual Chapter 6 Errors 43 6 Errors Errors are uniquely identified by a number The error code is the same as the THROW code In other words the Forth exception system is used for errors A ciforth always displays the text ciforth ERROR 77 plus the error number immediately and directly Of course the error numbers are given in decimal irrespective of BASE This allows you to look the error up in the section Error explanations More specific problems are addressed in the section Common Problems 6 1 Error philosophy If you know the error number issued by ciforth the situation you are in is identified and you can read an explanation in the next section Preferably in addition to the number a mnemonic message is displayed It is fetched from the library file But this is no
136. finitions as you are in the process of adding one already ciforth manual Chapter 3 Rationale amp legalese 7 3 Rationale amp legalese 3 1 Legalese This application currently is copyright by Albert van der Horst This Forth is called ciforth and is made available by the D F W All publications of the D F W are available under GPL the GNU public license The file COPYING containing the legal expression of these lines must accompany it Because Forth is programming by extending the language the GPL could be construed to mean that systems based on ciforth always are legally obliged to make the source available But we consider this fair use in the Forth sense as expressed by the following statement In addition to the GPL Albert van der Horst grants the following rights in writing The GPL is interpreted in the sense that a system based on ciforth and intended to serve a particular purpose that purpose not being a general purpose Forth system is fair use of the system even if it could accomplish everything ciforth could under the condition that the ciforth it is based on is available in accordance to the GPL rules and this is made known to the user of the derived system 3 2 Rationale This Forth is meant to be simple What you find here is a Forth for the Intel 86 You need just the executable to work You choose the format you prefer for the documentation They all have the same content You can use
137. forth this is the content of SRC ciforth needs 3 cells and is always able to RESTORE an input saved like this In practice the use of SAVE INPUT should be restricted to restoring input of the same stream See also RESTORE RESTORE INPUT 8 1 23 SAVE Name SAVE Stackeffect Attributes Description Save the content of SRC on the return stack prior to changing the current input source This must be balanced by a RESTORE in the same definition See also RESTORE SAVE INPUT 56 ciforth manual 8 1 24 SEEK Name SEEK Stackeffect n Attributes Description A block file must have been opened by BLOCK INIT Position the file pointer at block n in behalf of subsequent reads and writes See also BLOCK LIST LOAD 8 1 25 STALEST Name STALEST Stackeffect addr Attributes Description A variable containing the address of the oldest block buffer the first candidate to be claimed if a new one is needed See also BLOCK 8 2 COMPILING The wordset COMPILING contains words that compile See Section 8 6 13 IMMEDIATE page 76 words and numbers You need special precautions because these words would execute during compilation Numbers are compiled in line behind a word that fetches them 8 2 1 DLITERAL Name DLITERAL Stackeffect d d executing d compiling Attributes I Description If compiling compile a stack double number into a lit
138. ful as a placeholder 8 17 4 TASK Name TASK No stackeffect Attributes Description A no operation word which marks the boundary between the forth system and applications See also COLD 8 17 5 UO Name UO Stackeffect addr Attributes Description A user variable leaving the start address of the user area This is for reference only What is taken into account by user variables is the initialisation variable at O ORIGIN This might be used for task switching See also USER ORIGIN 110 ciforth manual 8 17 6 _ Name _ Stackeffect x Attributes Description Leave an undefined value x Presumably it is to be dropped at some time or it is a place holder 8 18 MULTIPLYING The original 16 bits Forth s have problems with overflow see Section 8 20 OPERATOR page 114 Operators with intermediate results of double precision mostly scaling operators solve this and are present in the MULTIPLYING wordset In this 32 bit Forth you will have less need Formatting is done with double s exclusively and relies on this wordset Operators with mixed precision and unsigned operators allow to build arbitrary precision operators from them in high level code 8 18 1 MOD Name MOD Stackeffect n1 n2 n3 n4 n5 Attributes ISO FIG LO Description Leave the quotient n5 and remainder n4 of the operation n1 n2 n3 using symmetric division A double p
139. he dictionary pointer DP May be used to reserve dictionary space or re origin memory As the Pentium is a byte addressable machine n counts bytes See also CELL 8 6 5 BODY gt Name BODY gt Stackeffect addr dea Attributes Description Convert the data field addr of a definition created with a CREATE DOES gt construct to its dea Where gt BODY keeps working after revectoring BODY gt does not There is some logic to this because the DEA to which the body belongs is no longer unique See also gt BODY 8 6 6 C Name C Stackeffect b Attributes ISO FIG Description Store 8 bits of b into the next available dictionary byte advancing the dictionary pointer See also DP 8 6 7 DP Name DP Stackeffect addr Attributes FIG U L Description A user variable the dictionary pointer which contains the address of the next free memory above the dictionary The value may be read by HERE and altered by ALLOT 8 6 8 FIND Name FIND Stackeffect addr xt 1 xt 1 addr 0 Attributes ISO Description For the old fashioned string stored with a preceding character count at addr find a Forth word in the current search order Return its execution token xt If the word is Chapter 8 Glossary 75 immediate also return 1 otherwise also return 1 If it is not found leave the original addr and a zero See also CONTEXT
140. his method allows definitions to handle unusual compiling situations rather than build them into the fundamental compiler The user may force compilation of an immediate definition by preceding it with POSTPONE 8 6 14 PAD Name PAD Stackeffect addr Attributes ISO FIG LO Description Leave the address of the text output buffer which is a fixed offset above HERE The area growing downword from PAD is used for numeric conversion 8 6 15 PREFIX Name PREFIX No stackeffect Attributes Description Mark the most recently made definition a prefix If searching the wordlists for a name that starts with the prefix the prefix is a match for that name This method allows to define numbers and other denotations such as strings in a modular and extensible fashion A prefix word finds the interpreter pointer pointing to the remainder of the name or number sought for and must compile that remainder Prefix words are most mostly both immediate and smart i e they behave differently when compiled than interpreted The result is that the com piled code looks the same and behaves the same than the interpreted code It is recommended that the only smart words present are prefix words See also IMMEDIATE 8 6 16 PRESENT Name PRESENT Stackeffect sc dea Attributes Description If the string sc is present as a word name in the current search order return its dea else leave a nil pointer For a a denotati
141. ia a aaa ia 83 NEGATE gt niue pb ere ache ea are vat URS 116 NOUR 4d uvae uy Pace ani xcii epa nece 109 NUMBER eden reete nee Recent denen 92 Number lid hee we d gue t ER CEPR es 136 Number 2 turre aa aar uote Wane 136 O OFFSET P 54 nj deena Rois paves eye cheat 93 NLY ta teei Sede eee oe ecb cive E ded 139 OPEN ETDE cidad dead 88 DAT a ei 81 DPTO Sot io is 94 R 25 RO 102 QUT od poe eet Rete eta EE 119 nuo idear ia as abs 99 P li EL 107 rin 107 Dr 76 POL loris 4p e RARO os 108 PCG cech e ko eEker beware pea rev ree Es 108 POSTPONE 4 242 43e060 e EPPPOIGwwe d PEE PTS DT PREETIX vepres pn aped ees 76 Prefix Wb ged vein ek bw dag gene EE Aue d aet be reb a TL PreflxXc 54e uWedose cpu atr den trit UR dor eae TL Prefix TIGK s isie aynina ongles is T2 PRESTA 5 l2 sde TL Profis jv cider deu arch purae a pedo ie S PME TL Prefi smeo ee ee ee anr E E e Te Pre fix Di di wakes beta y T Prefix Tori aaa ei 72 Prefix A ie v 9 pnr YR eS d tener Es T2 PRESENT oe oes 76 PREV amp ad 5 dee abe gy eo tha ae d Reg esha 54 PREVIOUS eid secs sacle erant Rad Rn OR Ugo eem dates 139 PUT ETLE eun cd feka dui e abe depone 88 145 Q A does qoid pependit tus vultu r n atate 94 R A en a a a a a 126 HQ ea e a bra 131 por EET 131 RW os enn dep ea b rt d dices baies Rue 53 RO st eves tho dq e dias 131 RDROP qe M 131 READ EPLE 2r dat amd a E de dia Es 88 RECURS Es seiad ea r id
142. idenas asaeeete hess 31 o Los ate ce sui Ls ea Eann iiai 31 CASE INSENSITIVE sse 43 CASE SENSITIVE o on unanou nananana 43 CATO a 14 23 84 85 86 o EEEE IE ERIT 15 105 at E A DR RN ERA 105 GER AA 79 MU riadas 151 195 TE RIEN ERU 105 CHARS NR IRR REPRE RR RP RR 105 CLOSE FIDE Sacos bad prete cajas io iba haga 87 WOVE EEEE EPE EEEN UR RE 105 A ERR 60 e EENE TEENETE 23 93 COMPARE AREA oc esc recede sd d cie ee d u 106 CONSTANT ooann aoaaa eee eee 3 4 13 19 68 CUSTEDE LLL eise Lebe sh I pna 69 137 138 CORA oem et cM peii ota E 106 Ucero ines 82 COUN Loose pir eara pti Mia bts 123 132 134 o SL edu MO ESSET ots d 82 109 A RET 16 21 118 119 HACK RETE TET ERR TRE ji CREATE ocx Lise Prin Sis ve 18 67 68 70 73 74 78 CREATE FILE idas ret ebve ER I ESO REL YA d 87 AA NER PET NR 128 129 CURRENT 13 67 70 77 136 137 138 D MUR MEET 119 a 118 A se 81 A S 82 DECIMAL tito caseta E 90 DEFINEN coordina codes 138 DELETE A enel ee PORE basibus 87 DENOTATIONS seen 139 EPI A A EEA 130 ciforth manual T o oo alta ato ee ee 11 Mae T E cia 41 DEG LT ds AAA 91 DISK BRHDBAS 2 V ees Ue eq REPE Y ee ee ee PESE E 52 DLITERA DL sc sae gp dwkag e bx RA XR RR eee Reseed 56 DNEGATE 2zuuwedo CE C mx vr PER ee ees oad Ede dd 82 DO 2iorsesdiddicieroiindbacand 45 58 60 61 62 65 D DEBUG 5b ise55en0 eos raed E dbase B RE RR e 10 DOES esses 18 20 67 68 69 70 73 7
143. ing in SG builtin fixup segments require SG which is always 16 bits For Xells in the presence of width overrules the programmer should carefully insert W or L whatever appropriate With r m you can have offsets for BO and X0 that must be assembled using B or L but mind the previous point Instruction with r m can have a register instead of memory indicated by the normal fixups AX etc If instructions with r m have another register that one is indicated by a prime such as AX Or if an instruction can handle two general registers the one that cannot be replaced by a memory reference gets a prime Unless T F to from are present a primed register is the modifiable one else T F refer to the primed register The primed register is the one that cannot be replaced by a memory reference At the start of an instruction the mask of the previous instruction plus fixup should add up non overlappingly to a full field Offsets and immediate data should have been comma ed in in that order This is diagnosed in the great assembler Instructions ending in are prefixes and are considered in their own right They have no fixups The Scaled Index Byte is handled internally in the following way The fixup SIB closes the previous instruction i e fill up its bit field but possible immediate data and offsets are kept Then SIB starts a new instruction The user merely needs to use a fixup with an unbalanced opening
144. ion and the disassembly 5 13 An incomplete and irregular guide to the instruction mnemonics The following is an attempted overview of the suffixes and fixup s used It may be of some help for using the assembler because it gives some idea of some of the names It doesn t contain all mnemonics you have to consult an Intel manual anyway just a few of them that I find hard to remember It also doesn t contain all fixup s only those that are particularly hard or irregular Neither does it contain fixups that are part of a SIB byte treated elsewhere So beware Note that some of the instruction are Pentium and as yet not present in the asi386 frt Be careful with fixups that end in a such as BP IS They are to be used in incidental 16 bits code so in 16 bits code segments or for instructions preceeded by an address size overwrite prefix The primed registers have a prime after the register name such as AX compared to AX Some opcodes allow two registers Whether the primed register is a source or destination is explicitly covered by T and F not by any order in which the operands appear The primed conditions such as Z have a different reason Those cannot be the same as the unprimed ones because they occur at a different place in the opcode though I would prefer them to be Some instructions CPUID CPU Identification L Load Full Pointer LLDT Load Local Descriptor Table Register LGDT Load General
145. is immediate so it will execute during the creation of a colon definition to select this word list at compile time See also CONTEXT VOCABULARY 8 28 8 LATEST Name LATEST Stackeffect addr Attributes FIG Description Leave the dictionary entry address addr of the topmost word in the CURRENT word list See also VOCABULARY Chapter 8 Glossary 139 8 28 9 ONLY Name ONLY No stackeffect Attributes NISO Description Set the minimum search order such that only denotation s numbers etc can be found plus the word FORTH By using FORTH one can regain control towards a startup search order ONLY is actually a regular VOCABULARY The associated word list contains mainly prefix words that scan denotations and are described in the chapter DENOTATIONS If found the parse pointer is moved back to immediately after the prefix and the corresponding denotation definition executed If you want to add a denotation See also PREFIX 8 28 10 PREVIOUS Name PREVIOUS No stackeffect Attributes ISO Description Pop the topmost WID from the search order stack If empty still the ONLY search order is left See also CONTEXT VOCABULARY 8 28 11 VOC LINK Name VOC LINK Stackeffect addr Attributes U Description A user variable containing the dictionary entry address address of the word most recently created by VOCABULARY All vocabulary names are linked by these fiel
146. itions The user definitions contain primarily definitions involving user interaction compiling aids finding forgetting listing and number formating Some of these are fixed by the ISO standard too These definitions are placed above the standard definitions to facilitate modification That is you may FORGET part of the high level and re compile altered definitions from disc This applies even to the ISO standard words from the TOOLS wordset like DUMP show a memory area as numbers and text and S show the data stack Again these words are perfectly normal dictionary entries A number of entries that could easily be made loadable are integrated in the assembler source of this ciforth version You can forget them and load your own version from files or blocks Again user definitions words are perfectly normal dictionary entries 4 6 6 System Tools The boundary between categories are vague A system tools is contrary to a user tool a larger set of cooperating words A text editor and machine code assembler are the first tools normally available An assembler is not part of ciforth as delivered but it is available after REQUIRE ASSEMBLERi86 It automatically loads the proper 32 bits version You can load a more elaborate assembler See Chapter 5 Assembler page 25 Section Overview They are among the first candidates to be integrated into your system by SAVE SYSTEM An editor is not part of ciforth as delivered Development
147. ix_ Name Prefix_ Stackeffect s d Attributes CI Description Implements NUMBER for numbers that start with 8 5 4 Prefix Name Prefix Stackeffect s d Attributes CI Description Implements NUMBER for numbers that start with 8 5 5 Prefix 0 Name Prefix O Stackeffect s d Attributes CI Description Implements NUMBER for numbers that start with O Similar words are present for all decimal and hex digits ISO compatibility ony requires that denotators for decimal digits are present one can always use a leading zero See also B 7 72 ciforth manual 8 5 6 Prefix_7 Name Prefix_7 Stackeffect s d Attributes CI Description Implements NUMBER for numbers that start with 7 Similar words are present for all decimal and hex digits See also 0 B 8 5 7 Prefix_B Name Prefix_B Stackeffect s d Attributes CI Description Implements NUMBER for numbers that start with B Similar words are present for all decimal and hex digits See also 0 7 8 5 8 Prefix Name Prefix Stackeffect b Attributes CI Description Leave b the control character value of the char that follows i e A results in 1 and so on Skip another blank character This is a denotation during compilation this behaviour is compiled See also amp 8 5 9 Prefix TICK Name Prefix TICK Stackeffect addr Attributes ISO FIG I LO Descri
148. l programs are called execute machine code directly if you invoke them from the terminal or from some other definition The other definitions called high level code ultimately execute a sequence of the machine executable code words The Forth inner interpreter takes care that these code words are executed in turn In the assembler source if you care to look at it you will see that they are interspersed with the high level Forth definitions In fact it is quite common to decide to rewrite a code definition in high level Forth or the other way around Again code words are perfectly normal dictionary entries 4 6 4 High level Standard Definitions The high level standard definitions add all the colon definitions user variables constants and variables that must be available in a Forth stack computer according to the ISO standard They comprise the bulk of the system enabling you to execute and compile from the terminal execute and load code from disk to add definitions etc Changes here will result in deviations from the standard so you probably want to leave this area alone Again these words are perfectly normal dictionary entries The technique described for the next section forget and recompile is not always possible here because of circular references That is in fact no problem with an assembler listing but it is if you load Forth code Again standard definitions words are perfectly normal dictionary entries 4 6 5 User defin
149. mand interpreter used for SYSTEM All of them must be full path names not just directories The ciforth that is running is copied to binpath and the block file is copied to libpath For system wide installation on a modern large system the following is recommended su lina g 60 lina lina i usr bin lina usr lib forth lab chmod 755 usr bin lina chmod 644 usr lib forth lab For a smallish system you may expand by 0 Mbyte g 0 If the system has no swap space and less than 8 Mbyte of memory use g 3 diminish from 4 to 1 Mbyte Pensa Gs help version m In ciforth all options are mapped onto a letter All options that start with are mapped onto m The result is the combination of h and v so both help and version information is printed This conforms to the FSF conventions 1 name more Use a library name Restart Forth with as a block file name and as options the remainder of the line shifted such that 1 name disappears and the next option becomes the first A file specified via 1 is opened for reading and writing Options ara again handled as as described in the begining of this section In this way options may be added or reconfigured for personal use Note that the default file is opened for reading only Make sure REQUIRED is available s script Load the file script but ignore its first line This is intended
150. match by FIND The IMMEDIATE bit 1 for IMMEDIATE definitions it is called the immediate bit The DUMMY bit 1 for a dictionary header contained in the data of a vocabulary This indicates that it should not be executed The DENOTATION bit 1 for a prefix word This means that it is a short word used as a prefix that can parse all denotation s numbers that start with that prefix e g 7 or amp Usually it is a one letter word but not necessarily All built in prefix words are part of the minimum search order After the last letter follow zero bytes up till the next cell boundary CREATE takes care to generate this data structure it is called by all defining words For all colon definition s the code field contains a pointer to the same code the inner interpreter called DOCOL For all words defined via CREATE DOES gt the code field contains the same code DODOES on At the data field address we find a pointer to an area with a length and content that depends the type of the word For a code word it contains machine code The code field of this word points to it too For a word defined by VARIABLE USER or CONSTANT it has a width of one cell and contains data 20 ciforth manual e For all colon definition s the data field address contains a pointer to an area with a variable length It contains the compiled high level code a sequence of code field address address es e For a wo
151. mber from the data stack and place as the most accessable on the return stack Use should be balanced with R in the same definition See also RQ 8 25 3 DEPTH Name DEPTH Stackeffect n1 Attributes ISO Description Leave into n1 the number of items on the data stack before n1 was pushed See also DSP 8 25 4 DSP Name DSP Stackeffect addr Attributes Description Initialize the data stack pointer with addr See also DSP Chapter 8 Glossary 131 8 25 5 DSPO Name DSP Stackeffect addr Attributes Description Return the address addr of the data stack position as it was before DSP was executed See also SO DSP 8 25 6 RO Name RO Stackeffect addr Attributes U Description A user variable containing the initial location of the return stack See also RSP 8 25 7 R gt Name R gt Stackeffect n Attributes ISO FIG LO Description Remove the top value from the return stack and leave it on the data stack See also gt R RQ 8 25 8 RO Name R Stackeffect n Attributes ISO Description Copy the top of the return stack to the data stack See also gt R lt R 8 25 9 RDROP Name RDROP Stackeffect Attributes Description Remove the top value from the return stack See also gt R RO R gt 132 ciforth manual 8 25 10 RSP Name R
152. ms can be specified on the same line interspersed with numbers Also names can be anything as long as they don t contain spaces A program may leave one or more results and the next program can use it The latest result is used up first hence the name lifo buffer last in first out For example albert apple forth fig86 gt lina 80386 ciforth beta RCSfile ci86 gnr v Revision 3 275 12 7 OK 21 OK 1 2 and 7 are numbers and are just remembered as they are typed in OK and 21 OK are the answer of the computer is a small program with an appropriate name It adds the two numbers that were entered the latest in this case 1 and 2 The result 3 remains but 1 and 2 are consumed Note that a name can be anything as long as it doesn t contain spaces The program multiplies the 3 and the 7 and the result is 21 The program prints this results It could have been put on the same line equally easily Programs can be added to the database by special programs the so called defining word s A defining word generally gets the name of the new word from the input line For example a constant is just a program that leaves always the same value A constant is created in this way by the defining word CONSTANT 127 CONSTANT MONKEY 12 12 OK You may get constant ciforth ERROR 12 NOT RECOGNIZED That is because you didn t type in what I said lina is case sensitive If you want
153. n adoret EEEE NEA 71 m ia 71 BA o uuu eue Mapes sien ania ae age I UE 71 moo PreK serin ae sted ets dein Eum quelque dues eee 71 n e ud eost autre tenta detest en ee ead a a dde 72 Sibert Pe BuozciaseePbesbrtbeissU nud dad 72 arc MB CMT 72 8 09 Preis TICK oon d ente Ud Ud A a 12 8 amp 6 DIGTIONARY ute ret duae a cie Ro e el Rd T9 8 6 1 This addition because texinfo won t accept a single n M C m T9 O E E E E E E EE N 73 80 8 SBODY airis stan re eh e dr aieo 73 BOA ALLO Ticos admi eerie on ete oie 74 ciforth manual I o MERIT 74 BOT D A mur euius deme ada ds 74 86 8 FIND ised A 74 B60 FORGET errada 75 STU OU Dado oro a DRE 75 B611 HERB ETT 75 S612 Desa ea ET 75 8 6 13 IMMEDIATE odas ea alenaipiacca mowed 76 AO A A 76 A O dei i qut tence at toe aioe 76 8 6 16 PRESENT iaceo ci xdi dac eniro etd 76 8 6 17 OBS secs Shane miu etuer deb 77 2 2 RM CMRRAMMR 77 8 619 FIND A pk Vp pias esu an 17 co MiTo S e RR 77 E etnies quu pu P D Rd dde 78 8 6 22 c CNN HRS 78 op WE erg sont MEM E EN 78 8624 A E EE EEA 78 8 6 25 PHA arcano enreda wound ea vallarta aaa 78 BO PAE rd ta pi ected 79 8697 SVEA MRNA 79 E MER e a a ER 79 8 6 29 A ddin nreti dE tata bream autenalg a 79 86 30 CFA eree ennen kE EPRE EEE EITA EIEEE EE 79 8 6 31 PENCE 2 grccterracunanel Ira rite EE RR EEG din 80 o E diea tedio rest ud cu icu d aset castas 80 8 6 33 TOR WORDS coal a Rasa epica aab A d 80 8 6 34 FORGET VOO unir eee iste 80 8
154. n stack where the looping bookkeeping is kept See also D0 8 3 24 BACK Name BACK Stackeffect addr Attributes Description Start a backward branch by leaving the target address HERE into addr Usage is BACK POSTPONE BRANCH BACK See also BACK BEGIN DO 8 3 25 DO Name DO No stackeffect Attributes C Description The run time proceedure compiled by DO which prepares the return stack where the looping bookkeeping is kept See also DO 66 ciforth manual 8 3 26 FORWARD Name FORWARD Stackeffect addr Attributes Description Start a forward branch by leaving the address that must be backpatched with an offset into addr Usage is POSTPONE BRANCH FORWARD FORWARD See also IF 8 3 27 LOOP Name LOOP No stackeffect Attributes C2 Description The run time proceedure compiled by LOOP which increments the loop index and tests for loop completion See also LOOP 8 3 28 OBRANCH Name OBRANCH Stackeffect f Attributes FIG C2 Description The run time proceedure to conditionally branch If f is false zero the following in line parameter is added to the interpretive pointer to branch ahead or back Compiled by IF UNTIL and WHILE See also BRANCH 8 3 22 BACK Name BACK Stackeffect addr Attributes Description Complete a backward branch by compiling an offset from HERE to
155. nd at Q gt DFA ORIGIN 4 Adjust version information if needed 5 Copy your lina to a new file using PUT FILE The difficult part is to add to the system specific header information about the new size of the system which is the area from BM to HERE The command REQUIRE SAVE SYSTEM loads a version that does that correctly for your hosted system 4 6 Memory organization A running ciforth has 3 distinct memory areas They occur sequentially from low memory to high e The dictionary e Free memory available for dictionary from below and stacks from above e Stacks disk block buffers and terminal input buffer The lowest part of the free memory is used as a scratch area The program as residing on disk may contain startup code but that is of no concern for the usage The dictionary area is the only part that is initialised the other parts are just allocated Logically the Forth system consists of these 7 parts e Boot up parameters e Machine code definitions e Installation dependant code e High level standard definitions e High level user definitions e System tools optional e RAM memory workspace 4 6 1 Boot up Parameters The boot up area contains initial values for the registers needed for the Forth engine like stack pointers the pointers to the special memory area s and the very important dictionary pointer DP that determines the boundary between the dictionary and free space Instead they a
156. nterpreter need not be very smart because its capabilities can be extended by new words based on those building blocks 8 22 1 PARSE Name PARSE Stackeffect c sc Attributes Description Scan the current input source for the character c Return sc a string from the current position in the input stream ending before the first such character or at the end of the current input source if it isn t there The character is consumed As it goes with string constants Chapter 8 Glossary 121 you may not alter its content nor assume anything is appended So no leading delimiters are skipped The difference with an ISO PARSE is that ISO considers control characters a match for a blank See also WORD WORD 8 22 2 WORD Name WORD Stackeffect sc Attributes CI LO Description Parse the current input source for a word i e blank delimited as per BLANK Skip leading delimiters then advance the input pointer to past the next delimiter or past the end of the input source Leave the word found as a string constant sc As it goes with string constants you may not alter its content nor assume anything is appended Note that this is more deserving of the name WORD than what is in the ISO standard that can be used to parse lines See also BLK WORD IN 8 22 3 Name No stackeffect Attributes ISO FIG I LO Description Used in the form cccc Ign
157. nverted u2 is the number of unconverted characters in the string If ud2 overflows in ciforth ud2 will be incorrect but no crash will result Both and are considered unconvertible character s by gt NUMBER See also NUMBER DIGIT 8 11 6 BASE Name BASE Stackeffect addr Attributes ISO FIG U LO Description A user variable containing the current number base used for input and output conversion See also DECIMAL HEX i 8 11 7 DECIMAL Name DECIMAL No stackeffect Attributes ISO FIG LO Description Set the numeric conversion BASE for decimal input output See also HEX Chapter 8 Glossary 91 8 11 8 HEX Name HEX No stackeffect Attributes ISO FIG LO Description Set the numeric conversion BASE for hexadecimal base 16 input output See also DECIMAL 8 11 9 HOLD Name HOLD Stackeffect Attributes ISO FIG Description Add the character c to the beginning of the output string It must be executed for numeric formatting inside a lt and gt construct See also DIGIT 8 11 10 SIGN Name SIGN Stackeffect n Attributes ISO FIG Description Stores an ASCII minus sign just before a converted numeric output string in the text output buffer when n is negative Must be used between lt and gt See also HOLD 8 11 11 NUMBER Name NUMBER Stackeffect d1 Attributes
158. o stackeffect Attributes I LO Description In ciforth this is an alias for except that the string is closed with instead of parsed as per In ISO programs you may only use this word while interpreting We recommend that cccc is replaced by cccc TYPE See also OUT 118 ciforth manual 8 21 4 R Name R Stackeffect nl n2 Attributes Description Print a signed number n1 right aligned in a field n2 characters wide Enlarge the field if needed So a field length of 0 results effectively in free format See also OUT D R 8 21 5 Name Stackeffect n Attributes ISO FIG LO Description Print the number n1 observing the current BASE followed by a blank See also OUT U R D R D D R 8 21 6 Name Stackeffect addr Attributes ISO FIG LO Description Print the value contained at the address addr observing the current BASE followed by a blank See also OUT 8 21 7 CR Name CR No stackeffect Attributes ISO FIG LO Description Transmit character s to the terminal that result in a carriage return and a line feed This means that the cursor is positioned at the start of the next line if needed the display is scrolled See also OUT 8 21 8 D R Name D R Stackeffect d n Attributes ISO FIG Description Print a signed double numb
159. of the errors in ascending order In actual situations sometimes you may not see the part after the semi colon If in this section an explanation is missing this means that the error is given for reference only the error cannot be generated by your lina but maybe by other version of ciforth or even a differently configured lina For example for a version without security you will never see error 1 If it says not used this means it is not used by any ciforth The errors whose message starts with AS are used by the PostIt FixUp assembler in the file asgen frt see Chapter 5 Assembler page 25 Negative error numbers are those reported by Linux If possible mnemonic error messages are shown But no explanation of the error is available Here are the error explanations e ciforth ERROR 1 EMPTY STACK The stack has underflowed This is detected by STACK at several places in particular in INTERPRET after each word interpreted or compiled There is ample slack but malicious intent can crash the system before this is detected e ciforth ERROR 2 DICTIONARY FULL Not used e ciforth ERROR 3 FIRST ARGUMENT MUST BE OPTION If you pass arguments to ciforth your first argument must be an option such as a otherwise it doesn t know what to do with it e ciforth ERROR 4 ISN T UNIQUE Not being unique is not so much an error as a warning The word printed is the latest defined word with
160. olon definition in form DO LOOP At run time LOOP selectively controls branching back to the corresponding DO based on the loop index and limit The loop index is incremented by one and compared to the limit The branch back to DO occurs until the index equals or exceeds the limit at that time the parameters are discarded and execution continues ahead At compile time LOOP compiles LOOP and uses addr to calculate an offset to DO n2 is used for compile time error checking See also LOOP 8 3 14 RECURSE Name RECURSE Stackeffect varies Attributes ISO Description Do a recursive call of the definition being compiled bs See also Chapter 8 Glossary 63 8 3 15 REPEAT Name REPEAT Stackeffect addrl nl addr2 n2 compiling Attributes ISO FIG I C2 Description Used within a colon definition in the form BEGIN WHILE REPEAT At run time REPEAT forces an unconditional branch back to just after the corresponding BEGIN At compile time REPEAT compiles BRANCH and the offset from HERE to addr Then it fills in another branch offset at addr1 left there by WHILE n1 n is used for error testing See also WHILE 8 3 16 SKIP Name SKIP No stackeffect Attributes C2 L0 Description Skip over an area in memory where the length is given in the next cell This length doesn t include the length cell so it is compatible with 0
161. ometimes easier to use than ACCEPT See also KEY KEY ACCEPT 8 13 2 gt IN Name gt IN Stackeffect addr Attributes ISO Description Return a variable that contains the offset from the start within the current input text buffer terminal or disc from which the next text will be accepted All parsing words use and move the value of IN The variable gt IN is not actually used and its content must be fetched immediately See also gt IN IN 8 13 3 ACCEPT Name ACCEPT Stackeffect addr count n Attributes ISO Description Transfer at most count characters from the terminal to address until a RET is received The simple tty editing functions of Linux are observed i e the erase delete a character and kill delete a line characters Typically these are the backspace key and U Note that excess characters after count are ignored The number of characters not including the RET is returned into n See also ACCEPT KEY KEY ACCEPT 8 13 4 IN Name IN Stackeffect addr Attributes Description A user variable containing a pointer within the current input text buffer terminal or disc from which the next text will be accepted All parsing words use and move the value of IN See also gt IN WORD WORD NUMBER PARSE IN 96 ciforth manual 8 13 5 KEY Name KEY Stackeffect
162. on word the name must match sc exactly See also FOUND CONTEXT FIND FIND VOCABULARY Chapter 8 Glossary 77 8 6 17 WORDS Name WORDS No stackeffect Attributes ISO Description List the names of the definitions in the topmost word list of the search order See also CONTEXT 8 6 18 Name Stackeffect addr Attributes ISO I Description Used in the form nnnn In compilation mode it leaves the execution token equivalent to the dictionary entry address of dictionary word nnnn So as a compiler directive it compiles the address as a literal If the word is not found after a search of the search order an appropriate error message is given It is recommended that where you can t use a denotation See also FOUND EXECUTE 8 6 19 FIND Name FIND Stackeffect sc wid sc dea Attributes Description Search down from the WID wid for a word with name sc A WID is mostly a dummy DEA found in the data field of a vocabulary fetched from CURRENT or an other wid in the search order Leave the dictionary entry address dea of the first entry found else leave a zero Do not consume the string sc as this is a repetitive action See also MATCH FIND PRESENT gt WID 8 6 20 gt CFA Name gt CFA Stackeffect dea addr Attributes Description Given a dictionary entry addres
163. or errors generated by the assembler These have numbers that are all higher than the general errors Chapter 7 Documentation summary 47 7 Documentation summary This is copied from the FIG documentation 1978 It is probably out of date now The following manuals are in print Caltech FORTH Manual an advanced manual with internal details of Forth Has Some implementation peculiarities Approx 6 50 from the Caltech Book Store Pasadena CA Kitt Peak Forth Primer 20 00 postpaid from the Forth Interest Group P O Box 1105 San Carlos CA 94070 microFORTH Primer 15 00 Forth Inc 815 Manhattan Ave Manhattan Beach CA 90266 Forth Dimensions newsletter of the Forth Interest Group 5 00 for 6 issues including mem bership F I G P O Box 1105 San Carlos CA 94070 48 ciforth manual Chapter 8 Glossary 49 8 Glossary Wherever it says single precision number or cell 32 bits is meant Wherever it says double or double precision number a 64 bits number is meant The first line of each entry shows a symbolic description of the action of the proceedure on the parameter stack The symbols indicate the order in which input parameters have been placed on the stack The dashes indicate the execution point any parameters left on the stack are listed In this notation the top of the stack is to the right Any symbol may be followed by a number to indicate different data items passed to or from a Forth word The
164. ord Index 529 e esos se Sees eo ee ees 147 Concept Index i 15300 rana rai 155 xii ciforth manual
165. ore a comment that will be delimited by a right parenthesis that must be in the same input source i e on the same line for terminal input or in the same string block or file when that is the input It is an immediate word so colon definitions can be commented too A blank after the word is required See also 8 22 4 BLANK Name BLANK Stackeffect c ff Attributes Description For the character c return whether this is considered to be white space into the flag ff At least the space ASCII null the tab and the carriage return and line feed characters are white space See also BL SPACE 8 22 5 CHAR Name CHAR Stackeffect c Attributes ISO I 122 ciforth manual Description Parse a word and leave c the first non blank char of that word in the input source If compiled the searching is done while the word being compiled is executed Because this is so confusing it is recommended that one never compiles or postpones CHAR See also Prefix_ amp CHAR 8 22 6 EVALUATE Name EVALUATE Stackeffect sc Attributes ISO Description Interpret the content of sc Afterwards return to the current input source See also LOAD INCLUDE SET SRC 8 22 7 INTERPRET Name INTERPRET Stackeffect Attributes Description Repeatedly fetch the next text word from the current input source and execute it STATE i
166. orth doesn t fit the description below get a new version The information below allows an expert to reconstruct how to generate a corresponding version Not all of it may make sense to you Tell him whether you want to fit the Forth to the description or vice versa see Chapter 3 Rationale amp legalese page 7 These are the features All ciforth s are case sensitive This is version 4 0 6 It is running in protected mode It is running under Linux A number has a precision of 32 bits It calls linux system from Forth directly It has compiler security sacrificing some bizarre ISO compatibity It doesn t use IN exactly in the way prescribed by ISO It contains the full ISO CORE in the kernel more than is needed to make it self contained It contains a field in the header to point to source It is indirect threaded If you are new to Forth you may want to read the Gentle Introduction otherwise you better skip it The third chapter most users will not be interested in ciforth manual Chapter 2 Gentle introduction 3 2 Gentle introduction A Forth system is a database of small programs The database is called the dictionary The programs are called word s or definitions The explanation of words from the dictionary is called a glossary First of all a Forth system is an environment that you enter by running it lina Like in a Disk Operating System a word is executed by typing its name but unlike in a DOS several progra
167. ows to make a disassembler that is independant of the instruction information one that will work for the 8086 look at the pop family First I had 38 C1 02 4 1FAMILY POP PUSH RST C B cause I started from an existing assembler But of course RST the restart instruction has nothing to do with registers so it gets a separated out Then the exception represented by the hole disappears The bottom line is the assembler proper now takes 22 lines of code Furthermore the call conditional and return conditional instructions where missing This became apparent as soon as I printed the opcode sheets For me this means turning jump conditional into a family 28 ciforth manual 5 5 Opcode sheets Using test mak on a linux computer in lina you can generate opcode sheets by make asi386 ps For the opcode sheets featuring a n byte prefix you must pass the PREFIX to make and a MASK that covers the prefix and the byte opcode e g make asi386 ps MASK FFFF PREFIX OF The opcode sheets p0 asi386 ps and pOF asi386 ps are already part of the distribution and can be printed on a PostScript printer or viewed with e g gv Compare the opcode sheets with Intel s to get an overview of what I have done to the instruction set In essence I have re engineered it to make it reverse assemblable i e from a disassembly you can regenerate the machine code This is not true for Intel s
168. ption Used in the form nnnn In interpret mode it leaves the execution token equivalent to the dictionary entry address of dictionary word nnnn If the word is not found after a search of the search order an appropriate error message is given In ciforth it can be used in compilation mode too it then compiles the address as a literal It is recommended that one never compiles or postpones it Use a combi nation of WORD and FIND or any form of explicit parsing and searching instead Furthermore it is recommended that for non portable code is used in its denotation form without the space Note that if you separate by a space the ISO conforming version of is found See also CONTEXT PRESENT gt CFA gt DFA gt FFA gt LFA NFA gt SFA Chapter 8 Glossary 73 8 6 DICTIONARY The wordset DICTIONARY contains words that at a lower level than the wordset DEFINING concern the memory area that is allocated to the dictionary They may add data to the dictionary at the expense of the free space one cell or one byte at a time or allocate a buffer at once The dictionary space may also be shrunk and the words that were there are lost The dictionary entry address or DEA represents a word It is the lowest address of a record with fields Words to access those fields also belong to this wordset 8 6 1 This addition because texinfo won t accept a single quote
169. rd containing and or is a fixup that it is addressing mode related and that the addressing is indirect 3 Families can be constructed from instructions or fixups with the same tally bit fields pro vided the instructions differ by a fixed increment The tallies also contain information about data and addresses following These fields must be the same too 4 The part before a possible in an instruction but excluding an optional trailing I is the opcode Opcodes define indeed a same action 5 The part after in an instruction may be considered a built in fixup where irregularity forbids to use a real fixup A X stands for xell or natural data width This is 16 bit for a 16 bit assembler and 32 bit for a 32 bit assembler These can be overruled with AS applying to DX and MEM and with OS applying to tdata required where there is an I suffix The commaers always reveal their true width It is either IW or IL 6 Width fixups determine the data width X xell or natural data width 16 32 or B 8 bit unless implied Offset fixups determine the offset or address width XO xell or natural data width 16 32 or BO 8 bit or ZOI 7 Instruction ending in I have an immediate data field after all fixups This can be either IB IW IL 816 32 bit If there are width fixups they should correspond with the data Chapter 5 Assembler 29 10 11 12 13 14 15 16 17 1 Instructions end
170. rd defined via CREATE DOES gt the first cell of this area contains a pointer to the high level code defined by DOES gt and the remainder is data A pointer to the data is passed to this DOES gt code A dictionary entry address can be turned into any of these fields by words that are in the vocabulary DICTIONARY See Section 8 6 DICTIONARY page 73 for those field words They customarily start with gt A dictionary falls apart into the 1 Headers with their fields 2 Names pointed to by some name field address 3 Data pointed to by some data field address This includes high level code that is merely data fed into the high level interpreter 4 Code pointed to by some code field address This is directly executable machine code 4 7 2 Details of memory layout The disc buffers are mainly needed for source code that is fetched from disk were it resides in a file The disc buffer area is at the upper bound of RAM memory So it ends at EM It is comprised of an integral number of buffers each B BUF bytes plus two cells B BUF is the number of bytes read from the disc in one go originally thought of as one sector In ciforth s B BUF is always the size of one screen according to ISO 1024 bytes The constant FIRST has the value of the address of the start of the first buffer LIMIT has the value of the first address beyond the top buffer The distance between FIRST and LIMIT is a multiple of B BUF CELL CE
171. rdlist given by wid This works too if links have been redirected such that some earlier words point back to later defined words Leave addr as FORGET VOC is intended to be used with FOR VOCS If any whole vocabulary is removed the search order is reset to ONLY FORTH The space freed is not recovered See also FORGET 8 6 35 HIDDEN Name HIDDEN Stackeffect dea Attributes Chapter 8 Glossary 81 Description Make the word with dictionary entry address dea unfindable by toggling the smudge bit in a definitions flag field If however it was the dea of an unfindable word it is made findable again Used during the definition of a colon word to prevents an uncompleted definition from being found during dictionary searches until compiling is completed without error It also prevents that a word can be used recursively See also IMMEDIATE RECURSE 8 6 36 OPT Name OPT Stackeffect sc dea sc deal Attributes Description Search down from the DEA dea for a word with name sc Replace dea with deal if the dictionary part between both could not contain the name searched for deat being a null pointer means that the dictionary doesn t contain the name This is an vector in behalf of optimisation that starts as a noop and can be filled in if the extra field is used for optimisation See also MATCH FIND gt XFA 8 6 37 MA
172. re copied to a separate area the user area each time Forth is started The bootup area itself is not changed but the variables in the user area are By having several user area s and switching between them ciforth could support multitasking When you have made extensions to your system like for instance you have loaded an editor you can make these permanent by updating the initial values in the boot area and saving the result to disk as an executable program The boot up parameters extends from O ORIGIN and has initial value for all of the user area This is the image for the user area So in ciforth the bootup parameters are more or less the data field of the ORIGIN word Executing 0 ORIGIN leaves a pointer in this area 4 6 2 Installation Dependent Code KEY EMIT KEY CR and R W are indeed different for different I O models This is of little concern to you as a user because these are perfectly normal dictionary entries and the different implementations serves to make them behave similarly There will however be more differences between the different configurations for ciforth for these words than habitually Chapter 4 Manual TT 4 6 3 Machine Code Definitions The machine executable code definitions play an important role because they convert your computer into a standard Forth stack computer It is clear that although you can define words by other words you will hit a lowest level The code word s as these lowest leve
173. recision intermediate product is used giving correct results unless n4 or n5 overflows n1 n2 n3 gives an incorrect answer as soon as ni n2 overflows See also MOD 8 18 2 Name Stackeffect nl n2 n3 n4 Attributes ISO FIG LO Description Leave the ratio n4 ni n2 n3 where all are signed numbers using symmetric division A double precision intermediate product is used giving correct results unless n4 overflows See also MOD MOD 8 18 3 FM MOD Name FM MOD Stackeffect d nl n2 n3 Attributes ISO Chapter 8 Glossary 111 Description A mixed magnitude math operator which leaves the signed remainder n2 and signed quotient n3 from a double number dividend d and divisor n1 This is floored division i e the remainder takes its sign from the divisor See also SM REM M MOD Mx 8 18 4 M Name Mx Stackeffect nl n2 d Attributes ISO FIG LO Description A mixed magnitude math operation which leaves the double number d the signed product of two signed number n1 and n See also M MOD SM REM 8 18 5 M MOD Name M MOD Stackeffect udl u2 u3 ud4 Attributes CIF FIG Description An unsigned mixed magnitude math operation which leaves a double quotient ud4 and remainder u3 from a double dividend ud1 and single divisor u2
174. relative to absolute or look up and show the name for a label 5 7 16 and 32 bits code and segments Note that the handling of segments and mixing thereof changed starting ciforth version 4 0 6 Contrary to the old situation commaers are checked correctly in the presence of prefixes and you have never to overrule error checking The description of 16 or 32 bits in the Intel manuals is messy These are the rules 30 ciforth manual 1 In real mode all sizes are 16 bits 2 In protected mode the size of an address or Xell offset agrees with the size of the code segment 3 In protected mode the size of an immediate data Xell agrees with the size of the applicable data segment Mostly this is the data segment but it may be the stack segment or some extra segment 4 In all previous cases the code length can be swapped between 16 and 32 bits by a code length override prefix OS the data length by a data length override prefix AS The 16 bit indexing in a 32 bit assembler have separate fixup s that all end in a sign In fixup X is used to mean Xell or the natural word length This is 16 bits for 16 bits segments and 32 bits for 32 bits segments Likewise in PostIt FixUp AX means Intel s AX for 16 bits segments and EAX for 32 bits segments In comma ing you must always select the proper one xell wide commaers always contain either Wor L After the directive BITS 16 code is generated for and checked against 16 bit code and d
175. rescribed by ISO The gt IN that is there is a fake that can only be read not changed Vocabularies are wordlists with a name However they push the wordlist to the search order instead of replacing the topmost one In this sense FORTH and ASSEMBLER words are not strictly conforming This is not strictly non conforming but worth mentioning here In fact lina contains only one state smart word besides SLITERAL that word is All denotations are state smart but the result is correct ISO behaviour for numbers Knowledge of this is used freely in the libraries of ciforth it is the right of a system developer to do so The library is not a supposedly ISO conforming program It tends to rely on ciforth specific and lina specific Chapter 4 Manual 15 but hopefully documented behaviour Understanding it requires some study of non portable facilities Here we will explain how you must read the glossary of lina in relation to terminology in the ISO standard Whenever the glossary specifies under which conditions a word may crash then you will see the euphemism ambiguous condition in the ISO standard For example Using HOLD other than between s and gt leads to a crash Whenever we explicitly mention ciforth in a sentence that appears in a glossary entry the behaviour may not apply to other ISO standard systems This is called ciforth specific behaviour If it mentions this ciforth or lina you cannot even trust
176. rested in subjects like history of Forth the rationale behind the design and such you might want to read the manual for the generic Forth 8 ciforth manual 3 4 The Generic System this Forth is based on The source and executable of this ciforth was generated out of at least dozens of possibilities by a generic system You can configure the operating system memory sizes file names and minor issues like security policy You can select between a 16 and 32 bit word size You may undertake more fundamental changes by adapting one or more of the macro header files An important goal was to generate exactly fitting documentation that contains only relevant information and with some care your configuration will have that too This generic system can be obtained via http home hccnet nl a w m van der horst ciforth html Chapter 4 Manual 9 4 Manual 4 1 Getting started 4 1 1 Hello world Type lina to get into your interactive Forth system You will see a signon message While sitting in your interactive Forth doing a hello world is easy Hello world TYPE Hello world OK Making it into an interactively usable program is also easy HELLO Hello world TYPE CR OK HELLO Hello world OK This means you type the command HELLO while you are in lina As soon as you leave lina this command is gone In order to make a stand alone program to say hello you have to save the source to a
177. ributes Description Store a string constant sc in the string variable at address addr See also O C 8 26 3 Name Stackeffect sc addr Attributes Description Append a string constant sc to the string variable at address addr See also 0 C 8 26 4 Name Stackeffect sc addr Attributes Description Allocate and store a string constant sc in the dictionary and leave its address addr See also 8 26 5 Name Stackeffect addr sc Attributes Description From address addr fetch a string constant sc See also O CP 8 26 6 C Name C Stackeffect c addr Attributes Description Append a char c to the string variable at address addr See also 1 134 ciforth manual 8 26 7 I Name I Stackeffect sc c addr Attributes Description Find the first c in the string constant sc and return its addr if present Oth erwise return a nil pointer A null string 0 0 or an empty string are allowed and result in not found See also S CORA 8 26 8 S Name S Stackeffect sc c scl sc2 Attributes Description Find the first c in the string constant sc and split it at that address Return the strings after and before c into sci and sc
178. rlance It hides the normal working of the underlying Forth In fact this is what in other languages would be called just compiling but compiling in Forth means adding definitions to an interactive Forth In ciforth just compiling is as easy as in any language see Chapter 4 Manual page 9 Hello world Of course whether you have a hosted system like this one or a booted system it is clear that some system dependant information goes into accomplishing this This has all been sorted out for you Just use SAVE SYSTEM This accepts a string the name you want the program file to have In the following it is explained We use the naming convention of ISO about cells A cell is the fundamental unit of storage for the Forth engine Here it is 32 bits 4 bytes The change of the boot up parameters at ORIGIN in combination with storing an image on disk goes a long way to extending the system This proceeds as follows 1 All user variables are saved by copying them from UO to 0 ORIGIN The user variable UO points to the start of the user area The length of the area is 0x40 cells If in doubt check out the variable US in the assembler code 2 If all user variables are to be initialised to what they are in this live system skip the next step 16 ciforth manual 3 Adjust any variables to what you want them to be in the saved system in the ORIGIN area The initialisation for user variable Q can be fou
179. s This is a bit strange terminology but it makes a distinction between those addresses and other addresses For example this allows to make the distinction between a data field address that is always present and a data field in the ISO sense that has only a differing meaning for CREATE DOES gt definitions Typically a field address contains a pointer A data field address contains a pointer to near the data field whenever the latter exists They go from lowest in memory to highest Chapter 4 Manual 19 The code field This is one cell A pointer to such a field is called a code field address It contains the address of the code to be executed for this word The data field of the DEA not in the ISO sense This is one cell A pointer to such a field is called a data field address It contains a pointer to an area owned by this definition The flag field This is one cell A pointer to such a field is called a flag field address For the meaning of the bits of the flag field sea below The link field This is one cell A pointer to such a field is called a link field address It contains the dictionary entry address of the last word that was defined in the same word list before this one The name field This is one cell This contains a pointer to a string A pointer to such a field is called a name field address The name itself is stored outside of the dictionary header in a regular string i e a one cell count followed
180. s been filled It is just the address where the last data item has been stored in the buffer The dictionary is the part of the memory where the word s are see Section 8 6 DICTIO NARY page 73 Each word owns a part of the dictionary starting with its name and ending where the name of the next word starts This structure is called a dictionary entry Its ad dress is called a dictionary entry address or DEA In ciforth s this address is used for external reference in a consistent way For example it is used as the execution token of a word in the ISO sense In building a word the boundary between the dictionary and the free space shifts up This process is called allocating and the boundary is marked by a dictionary pointer called DP A word can be executed by typing its name Each word in the dictionary belongs to precisely one word list or as we will say here vocabulary Apart from the name a word con tains data and executable code interpreted or not and linking information see Section 8 4 8 VOCABULARY page 69 The concept word list is part of the ISO standard but we will use vocabulary A vocabulary is much more convenient being a word list with a name created by VOCABULARY ISO merely knows word list identifier s a kind of handle abbreviated as WID A new word list is created by the use of VOCABULARY and by executing the vocabulary word the associated word list is pushed to the front of the search order In fact in
181. s espesas 89 OIM MONUMENTI 89 Out HSin a EE E E D 89 as ere e e EER AE E 89 Our P R hac E E 90 8 11 5 gt NUMBER todita 90 8 11 6 BASE s center ecretbtstexadu edad i eatis 90 8 11 7 DECHIMAL m epe ke m oor er el tom ds 90 8 11 89 HB neces a caters et eed dn idum DR Ces d EE LU Ed 91 DIIS HOPES beste te ans ite cupa Me seass 91 8 11 10 O sean 91 8 11 11 NUMBER sepia webride narrada 91 8 1112 DIGIT eree eneee run s nia EEE KEENER RE OE ane 91 EIE DPE eee oth E A E caida 92 SA FED E A 92 8 11 15 HDD o 322 tenses et detta aho dac Dis weaeeses 92 8 11 16 NUMBER diezezneti Rr Ru ei eade 92 CEN EU UPPER HORAM MENS 93 AA 93 8 12 2 ABORT escorias sata eee cadete ici ee y 93 A Succ udcsidodud coelos Doe teda tr cepe 93 ODE NE C A EA D T A 93 8 12 5 OPTIONS cesped daca does d DUC Dee 94 Are nu TERCER cee re oe 94 8 127 WARM osos os ae acon 94 813 INPUE rro pat li eee ita 94 811 ACCEPI A A 95 m di oa 95 8 13 3 SOOBEPT esae pernos cei habia ati paras 95 2 193 IN cites h chests doe cesa a ne r EE 95 8135 MMC TREE 96 UU AA icc AME 96 8 13 7 OBUBOUT ades nt etra acid acce ot haee er dns 96 8 13 8 TIBescneiena enoi iar d n M MI DEDIT 96 8 13 9 IN oua taeda ute mre dU oed cat igh dre 96 8 13 10 REFILL T B odd neidki aeni Pb atada 97 8 13 11 REMAINDER acacia dba 97 8 13 12 SET TERM cteciacesioc coli asa pesada 97 8 13 13 TERMIO ee doe raei aca bead ra EEE EEEE 97 cra JUGGLING NNMERO 98 Sida DROP ONES 98 8 14 2 2DUP secede citaron criad
182. s not 1 or compile it STATE is 1 A word is blank delimited and looked up in the vocabularies of search order Note that the denotations in the ONLY wordlist match numbers If it is not found at all it is an ERROR A denotation is a number a double number a character or a string etc Denotations are handled respectively by the words 0 F and any other word of the ONLY wordlist depending on the first character or characters A number is converted according to the current base If a decimal point is found as part of a number the number value that is left is a double number otherwise it is a single number Comma s are ignored in ciforth See also WORD NUMBER BLK DPL 8 22 8 INI Name IN Stackeffect addr c Attributes CI LO Description Parse the current input source leaving the next character c and its address addr If at the end of the input source leave a pointer past the end and a zero Advance the input pointer to the next character See also BLK WORD IN 8 22 9 SET SRC Name SET SRC Stackeffect sc Attributes Chapter 8 Glossary 123 Description Make the string constant sc the current input source This input is chained i e exhausting it has the same effect as exhausting the input that called SET SRC In practice this word is almost always followed by a call to INTERPRET See also EVALUATE INTERPRET 8 22 10 SOUR
183. sor has a natural size for the information This is sometimes called a machine word For an Pentium processor this is 32 bit for the older Intel 8086 it is 16 bit The pendant in Forth is called a cell and its size may deviate from the processor you are running on For this ciforth it is 32 It applies to the data remembered in the data stack the return addresses on the return stack memory accesses and the size of VARIABLE s and CONSTANT s In Forth a cell has no hair It is interpreted by you as a signed integer a bit map a memory address or an unsigned number The operator can be used to add numbers to set a bit in a bitmap or advance a pointer a couple of bytes In accordance with this there are no errors such as overflow given Sometimes we use data of two cells a double The high order cell are most accessible on the stack and if stored in memory it is highest The code for a high level word can be typed in from the terminal but it can also fed into Forth by redirection from a file INCLUDED from a file or you can load it from the file forth 1lab because you can load a piece of this library at will once you know the block number This file is divided into blocks of 1 Kbyte They may contain any data but a most important application is containing source code A block contain source code is called a screen It consists of 16 lines of 64 characters In ciforth the 64 th character is J such that they may be edited in
184. square bracket such as AX that handles this transparently The SET instruction unfortunately requires a duplicate of the 0 etc fixups of the J and J X instructions called 0 etc Similarly some single byte instructions require X and B instead of X and B that are used for the ubiquitous instructions with r m This is the way the disassembler works Find the first instruction that agrees with the data at the program counter Tally the bits The instructions length follows from the instruction As does the presence of address offsets and immediate data In the current implementation the search follows dictionary links The dictionary must be organized such that the correct instruction is found first If two instructions agree with the data in general the one that covers the most bits must be found first Find the first fixup that agrees with untallied bits Note that opcode and previous fixups may have set bits in the BAD variable Any fixups that set a bit in BAD that would result in a conflict are not considered If not all bits have been tallied go to 2 searching the dictionary from where we left off Disassemble the address offsets and immediate data in accordance with the instruction Length is determined from fixups and prefix bytes The commaers that were used to assem ble the data have an associated execution token to disassemble the data This is used to advantage to change the representation from program counter
185. t Name 0 lt Stackeffect n ff Attributes ISO FIG LO Description Leave a true flag if the number is less than zero negative otherwise leave a false flag See also lt 8 15 2 0 Name 0 2 Stackeffect n ff Attributes ISO FIG LO Description Leave a true flag ff is the number n is equal to zero otherwise leave a false flag t gt See also 8 15 3 lt gt Name lt gt Stackeffect nl n2 ff Attributes ISO LO Description Leave a true flag if n1 is not equal than n otherwise leave a false flag See also gt 0 lt Chapter 8 Glossary 101 8 15 4 lt Name lt Stackeffect n1 n2 ff Attributes LO ISO Description Leave a true flag if n1 is less than n2 otherwise leave a false flag See also gt 0 lt 8 15 5 Name Stackeffect nl n2 ff Attributes ISO FIG LO Description Leave a true flag if n1 n2 otherwise leave a false flag See also lt gt Q 8 15 6 gt Name gt Stackeffect n1 n2 ff Attributes ISO LO Description Leave a true flag if n1 is greater than n otherwise leave a false flag See also lt 0 lt 8 15 7 AND Name AND Stackeffect n1 n2 n3 Attributes ISO FIG LO Description Leave the bitwise logical and of n1 and n as n3 See also XOR
186. t NFA Name gt NFA Stackeffect dea nfa Attributes Description Given a dictionary entry addres return the name field address See also gt CFA gt DFA gt FFA LFA gt SFA 8 6 25 gt PHA Name gt PHA Stackeffect dea addr Attributes Description Given a dictionary entry addres return the past header address Here starts the area that no longer belongs to the header of a dictionary entry but most often it is owned by it See also gt CFA gt BODY Chapter 8 Glossary 79 8 6 26 gt SFA Name gt SFA Stackeffect dea addr Attributes Description Given a dictionary entry addres return the source field address addr See also gt CFA gt DFA gt FFA LFA gt NFA 8 6 27 gt VFA Name gt VFA Stackeffect dea cfa Attributes Description Given the dictionary entry addres of a vocabulary return the address of the link to the next vocabulary See also VOCABULARY gt CFA gt WID 8 6 28 gt WID Name gt WID Stackeffect dea wid Attributes Description Given the dictionary entry addres dea of a vocabulary return its WID wid a dummy DEA that serves as the start of a dictionary search See also VOCABULARY gt CFA FIND 8 6 29 gt XFA Name gt XFA Stackeffect dea addr Attributes Description Given a dictionary entry addres return the ex
187. t always possible such is the nature of error situations A mnemonic message has a size limited to 63 characters and is therefore seldomly a sufficient explanation A good error system gives additional specific information about the error In a plain ciforth this is limited to the input line that generated the error Via the library file you may install a more sophisticated error reporting if available Within ciforth itself all error situation have their unique identification You may issue errors yourself at your discretion using THROW or preferably ERROR and use an error number with an applicable message However unless yours is a quick and dirty program you are encouraged to use some other unique error number 6 2 Common problems 6 2 1 Error 11 or 12 caused by lower case If you type a standard word like words in lower case it will not be recognised resulting in error 11 Similarly words results in error 12 This is because lina is case sensitive i e the difference between lower and upper case is significant and only words that match in this respect too are found in the dictionary After 1 LOAD or if started up using lina r you have REQUIRED available You may now issue CASE INSENSITIVE REQUIRED and switch the system into case insensitivity and back by issuing the words CASE INSENSITIVE and CASE SENSITIVE Case insensitivity applies to the words looked up in the dictionary not to hex digits 6 2 2 Error
188. t is not in this set 2 They are assembled 3 They are disassembled again and compared with the original code which must be the same 4 They are disassembled by a different tool GNU s objdump and the output is compared with 3 This has been done manually just once This leaves room for a defect of the following type A valid instruction is rejected or has been totally overlooked But opcode maps reveal their Terra incognita relentlessly So I am quite confident to promise a bottle of good Irish whiskey to the first one to come up with a defect in this assembler The full set of instructions with all operand combinations sit in a file for reference This is all barring the 256 way SIB construction and prefixes or combinations thereof This would explode this approach to beyond the practical Straightforward generation of all instructions is also not practical for the Alpha with 32K register combinations per instruction This is solved by defining interesting registers that are used as examples and leaving out opcode operand combinations with uninteresting registers 5 3 Principle of operation In making an assembler for the Pentium it turns out that the in between step of creation defining words for each type of assembly gets in the way There are just too many of them MASM heavily overloads the instruction in particular MOV Once I used to criticise Intel because they had an unpleasant to use instruction set
189. th environment queries Note that these are not environ ment variables in the sense that are passed from an operating system to a program 8 8 1 CORE Name CORE Stackeffect ff Attributes ISO Description An environment query whether the CORE wordset is present See also ENVIRONMENT 8 8 2 CPU Name CPU Stackeffect d Attributes CI Description An environment query returning the cpu type to be printed as a base 36 number See also ENVIRONMENT Chapter 8 Glossary 83 8 8 3 ENVIRONMENT Name ENVIRONMENT Stackeffect sc i x true false Attributes ISO Description If the string sc is a known environment attribute leave into i x the information about that attribute and a true flag else leave a false flag In fact the flag indicates whether the words is present in the ENVIRONMENT vocabulary and i x is what is left by the word if executed See also VOCABULARY 8 8 4 NAME Name NAME Stackeffect sc Attributes CI Description An environment query giving the name of this Forth as a string constant See also ENVIRONMENT 8 8 5 SUPPLIER Name SUPPLIER Stackeffect sc Attributes CI Description An environment query giving the SUPPLIER of this Forth as a string constant See also ENVIRONMENT 8 8 6 VERSION Name VERSION Stackeffect sc Attributes CI Description An environment query giving the version of this Forth as a
190. the example file with blocks you have the assembler source for your Forth but you can ignore both 3 3 Source In practice the GPL means this is an explanation and has no legal value They may be further reproduced and distributed subject to the following conditions The three files comprising it must be kept together and in particular the reference section with the World Wide Web sites The latest version of lina is found at http home hccnet nl a w m van der horst ciforth html Via that link you can also download ciforth s for other OS s and the generic system if you want to make important modifications Also you can see how you can contact the author Oth erwise in case of questions about this ciforth contact the person or organisation that generated it for you This Forth builds on fig Forth It is based on the work of Charlie Krajewski and Thomas Newman Hayward Ca still available via taygeta The acknowledgments for systems that serves as a base in particular the original fig Forth are found in the generic documentation including detailed information how these systems can be obtained Important If you just want to use a Forth you most certainly do not want the generic system Great effort is expended in making sure that this manual contains all that you need and nothing that might confuse you The generic system on the contrary contains lots that you don t need and is confusing as hell If you are inte
191. tion comparable to parts of Intel s architecture manuals Not to mention the amount of work to check this I circumvent this Opcode sheets for this assembler are generated by tools automatically and you can ask inter actively how a particular instructions can be completed This is a viable alternative to using manuals if not more practical Of course someone has to write up the descriptions I am happy Intel has done that So look at my opcode sheets If you think an instruction would be what you want use SHOW to find out how it is to be completed If you are at all a bit familiar most of the time you can understand what your options are If not compare with an Intel opcode sheet and look up the instruction that sits on the same place If you don t understand them you can still experiment in a Forth to find out The assembler in the Library Addressable by Blocks block file hasn t the advanced features of disassembly completion and error detection It is intended for incidental use to speed up a crucial word But the code is fully compatible so you can develop using the full assembler 26 ciforth manual 5 2 Reliability I skimped on write up I didn t skimp on testing All full assemblers like asi386 frt and aspentium frt are tested in this way 1 All instructions are generated Because this uses the same mechanism as checking during entry it is most unlikely that you will get an instruction assembled tha
192. to be used for scripts i e a piece of code to be interpreted rather than compiled The first line is probably lina s Chapter 4 Manual 23 or some such as t lina 1 usr lib forth cgi forth lab s In a script REQUIRED is available and you can use standard in and standard out e t sourcefile Try to load the file script automatically by possibly unsafe means Report facilities that were required This is a first step in a porting activity Redefinition messages are issued on the error channel that can be redirected to dev nul leaving the report e y Print version and copy right information The remaining screens are available for options to be added at a later time or for user defined options in a private library 4 8 2 Private libraries Working with source in files is quite comfortable using the default block library especially if sufficient tools have been added to it In principle all ISO words should be made available via REQUIRED In order to customize the forth library you have to make a copy of the default usr lib ciforth forth lab to your home directory preferably to a lib subdirectory Then you can start up using a 1 option or make a customized lina See Chapter 4 Manual page 9 Subsection Configuring Most shells allow you to redefine commands such as e g in bash alias lina lina 1 SHOME lib forth lab Note that the 1 option hides itself such that such an alias can be
193. to change that consult the section Common problems see Chapter 6 Errors page 43 This must not be read like a number two programs and again a number etc but as a number a program and a name that is consumed and after that life goes on The 12 we put there for demonstration purposes to show that 4 ciforth manual CONSTANT reads ahead only one word On this single line we do two things defining MONKEY and printing the number 12 We see that CONSTANT like any other program consumes some data in this case the 127 that serves as an initial value for the constant called MONKEY A very important defining word is with its closure TEST 12 7 12 12 OK In this case not only the name TEST is consumed but none of the remaining numbers and programs are executed up till the semicolon Instead they form a specification of what TEST must do This state where Forth is building up a definition is called compilation mode After the semicolon life continues as usual Note that is a program in itself too But it doesn t become part of TEST Instead it is executed immediately It does little more than turning off compilation mode TEST TEST 42 OK TEST 1 TEST 1 TEST 1 22 OK We see that TEST behaves as a shorthand for the line up till the semi colon and that in its turn it can be used as a building block The colon allows the Forth programmer to ad
194. tra field address addr See also gt CFA gt DFA gt FFA LFA gt NFA 8 6 30 CFA gt Name CFA gt Stackeffect cfa dea Attributes Description Convert the code field address of a definition to its dictionary entry address dea See also gt CFA 80 ciforth manual 8 6 31 FENCE Name FENCE Stackeffect addr Attributes FIG U Description A user variable containing an address below which FORGET ting is trapped To forget below this point the user must alter the contents of FENCE 8 6 32 FOR VOCS Name FOR VOCS Stackeffect x1 xn xt x1 xn Attributes Description For all vocabularies execute xt with as data the DEA of those words xt must have the stack diagram x1 xn dea x1 xn See also FOR WORDS EXECUTE 8 6 33 FOR WORDS Name FOR WORDS Stackeffect x1 xn xt wid x1 xn Attributes Description For all words from a word list identified by wid execute xt with as data x1 xn plus the DEA of those words xt must have the stack diagram x1 xn dea x1 xn Note that you can use the DEA of any word as a WID and the remainder of the word list will be searched See also FOR VOCS EXECUTE 8 6 34 FORGET VOC Name FORGET VOC Stackeffect addr wid addr Attributes Description Remove all words whose DEA is greater later defined than addr from a wo
195. using this library mechanism It is used immediately It is handy during development after every line it shows you what numbers Forth remembers for you Also from now on the header of each block that is LOAD ed is shown Type 1 LOAD may not be necessary 1 LOAD DO DEBUG REQUIRED OK DO DEBUG S OK 1 S 1 OK You can turn DO DEBUG off with NO DEBUG If you try to INCLUDE a program you may get errors like TUCK ciforth ERROR 12 NOT RECOGNIZED See Chapter 6 Errors page 43 Section Explanations Apparently lina doesn t know about a forth word named TUCK but after TUCK REQUIRED maybe it does You may try again The convention about the way the library file must be organized for REQUIRED to find some thing is simple It is divided into blocks of 16 lines The first line is the header of the block If the word we are looking for is mentioned in the header that block is compiled The library file contains examples for you to load using REQUIRE Try REQUIRE SIEVE LIM 4 ISN T UNIQUE OK 10 SIEVE KEY FOR NEXT SCREEN ERATOSTHENES SIEVE PRIMES LESS THAN 10 000 0 002 003 lots of prime numbers 4 1 3 Development If you want to try things out or write a program as opposed to just running a ready made program you best start up lina by lina e That is e for elective That name means that Chapter 4 Manual 11 you can configure this screen 5
196. with MOV MVR and MVI for move instructions In hindsight I find the use of different opcodes correct I mean they are really different instructions it might have been better if they weren t But an assembler must live up to the truth Where the Intel folks really go overboard is with the disambiguation of essentially ambiguous constructs by things as OFFSET BYTE POINTER ASSUME You can no longer find out what the instruction means by itself A simple example to illustrate this problem is INC BX Are we to increment the byte or the word at BX Intel s solution is INC BYTE POINTER BX Contrarily here we adapt the rule if an instruction doesn t determine the operand size some do like LEA then a size fixup is needed X or BI In this assembler this looks like INC B DO BX Chapter 5 Assembler 27 This is completely unambiguous These are the phases in which this assembler handles an instruction e POSTIT phase MOV assembles a two byte instruction with holes e FIXUP phase X or Bl fits in one of the holes left Other fixups determine registers and addressing mode e COMMA phase First check whether the fixups have filled up all holes Then add addresses or offsets and or immediate data using e g IL or L e Check whether all commaers requested either by postit s or fixup s are present This check is actually executed by a postit like

Download Pdf Manuals

image

Related Search

Related Contents

user manual manual de instrucciones notice d`utilisation  13エクスセンスDC 取扱説明書 - Shimano  Consolle per telecamera dome TVCD  diflomar catálogo  HP Adjustable Dual Display Stand  Pro Charge Ultra    Protección de equipos electrónicos contra descargas  

Copyright © All rights reserved.
Failed to retrieve file