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