X-Git-Url: http://www2.svjatoslav.eu/gitweb/?p=fifth.git;a=blobdiff_plain;f=doc%2Fcommands%2Fcmp%26misc.txt;fp=doc%2Fcommands%2Fcmp%26misc.txt;h=0000000000000000000000000000000000000000;hp=97446fbea404af851f35ced44863aec2e0659fea;hb=7ad7475c2abf891a92b457339aaa0c20c40634d1;hpb=791dce846c524feca7b344307597c1d1224ba1de diff --git a/doc/commands/cmp&misc.txt b/doc/commands/cmp&misc.txt deleted file mode 100644 index 97446fb..0000000 --- a/doc/commands/cmp&misc.txt +++ /dev/null @@ -1,166 +0,0 @@ - Compilation & misc - ------------------ - - -init module ( -- ) - First module, control is passed to on startup. Contains - initialization routines. Also it is the last core module. - All new modules on top of it comes as result of executing - external source files. - -head ( -- ) compiles new dictionary entry without specifying - new module type. - ex: head myentry - -: ( -- ) creates new code module -; ( -- ) ends module (immideate) - ex: : hello ." hi there" ; - -const ( n -- ) defines new constant. - ex: 2147483647 const max - -:i ( -- ) same as ":" but this module will be executed - immideately even in compile mode. - ex: :i ( 41 scan ; - -create ( -- ) same as "head" , but specify module type as data. - ex: create LotoResults 5 , 13 , 52 , 12 , 11 , 3 , - -allot ( n -- ) allocate n bytes in dictionary. - ex: create MyArray 100 allot - -" " ( -- ) compile string and its size into core. - ex: create Mystring " This is it's contects" - -str " ( -- ) just shorter way for defining strings. - ex: str Mystring This is it's contenc" - -var ( -- ) define new 32 bit variable. - ex: var result - -' ( -- n ) return memory address of given entry. - ex: ' init - -forget ( -- ) erases from RAM given entry and all entries what was - defined after it. - ex: forget myprog - -[ ( -- ) set interpret mode (immideate) -] ( n -- ) set compile mode and compile top stack element - in as literal. Together [ .... ] cobination provides good - way to compute some values only once, at compile time, - rather than every time while program is running. - ex: : calculate - [ 4 MyConst1 + MyConst2 * ] ; - -defer ( -- ) creates new module, with jump instruction. - Later address where to jump can be modified by "is" command. - This provides method of foward referencing. So you can use - modules what not jet exist. -is ( address1 address2 -- ) address1 - where to jump, address2 - - address of module created by defer command. - ex: defer dispver - : run dispver ." running ..." ; - ... whatever ... - : (dispver ." Version 9.99 " ; - ' (dispver ' dispver is - - Now if I type "run" on the screen appears: - Version 9.99 running ... - -asc ( -- ) reads char ascii code and treats it as literal. - (immideate) - ex: : BreakLine 30 do asc - emit loop ; - same as: - : BreakLine 30 do 45 emit loop ; - -dyninc ( handle -- ) execute code in dynamic memory handle. - automatically deallocates it when done. - -include ( filenumber -- ) execute code in specified file. - -words ( -- ) display existing blocks in core. - -bye ( -- ) exit from Fifth - -fkey ( -- c ) - Read one byte from input stream. - -sadd ( c addr -- ) - Add one byte "c" to string located at "addr" and updates - string length. - -scan ( c -- ) - Read input stream and store it to pad until it finds c . - It ignores all "c" bytes until it finds any non "c" byte. - in other words: - c is: " - input stream: """"This is test !"aoeu idh - result: This is test ! - - Is useful for breaking text lines into words. - -skey ( -- c ) - So called safe "fkey". Reads data from input stream - but converts characters with ASCII codes: 9 13 10 - to spaces. - -str=str? ( adr1 adr2 -- result ) - Compares string at "adr1" with string at "adr2", returns - true flag if they are equal or false if they are not. - true = -1 - false = 0 - -find ( -- addr ) - Searches whole dictionary for word in "pad". If found, - returns it address, if not, returns 0. - -execute ( -- ) - Execute word located in "pad". Depending on "mode". - -dta ( addr -- DataAddr ) - Calculates address of dictionary entry data area, from - entry point. - -2num ( -- num result ) - Attempt to convert string located in "pad" into numeric - value. If succeed returns number and true as result. - If not, returns whatever and false as result. - -dadd ( addr length -- ) - Add to dictionary data located at "addr", with specified - length. - -lit ( n -- ) - Act with number depending on "mode". When interpreting, - leaves it in stack. - - -incmod ( addr -- ) - Add to dictionary data located at "addr"+1 , length is taken - from "addr". - -here ( -- n ) - return "h" contents. - -mode var 8 bit - Holds input stream parser operation mode. - 0 = interpreting - 1 = compiling - -pad var 128 bytes - Holds temprorary strings. - -h var 32 bit - Pointer to free byte in memory, always at the end of the - dictionary. Each time when something is stored - by "c," command, pointer is incareased. - -lp var 32 bit - Pointer to last dictionary word. Each time when new word is - compiled or erased by "forget", this pointer is updated. - -modulechk ( Dstr -- ) check if module is loaded, if not - immideately load it. - -ne ( entrydata entrytype -- ) Compile new dictionary entry. - It's name must be in "pad".