1 proper documentation will follow... maybe.
2 but please, read this document if you want to use UrForth.
3 UrForth is not a standard Forth system (it is a mixture of ANS, FIG,
4 and my own creations), and this document contains valuable bits of
5 knowledge about some non-standard UrForth features.
7 one of the non-standard UrForth features is locals support. it is
17 here, "args:" will declare local variables, and automatically fill them
18 with arguments from the data stack. "locals:" declare "free" locals.
19 there can be more than one "locals:" section, but all such sections should
20 come before anything else. to use local, you must prepend its name with a
21 colon. the usual "TO" word is used to set local values.
23 "DOES>" works only on CREATEd words.
25 some global variables are state-local. also, each state has its own TIB,
26 independent of other states.
39 offset in current TIB.
43 default TIB address. WARNING! if this user var contains a handle, that
44 handle will be freed on destroying the task. if you want to replace the
45 default TIB, make sure that you will free the old handle (if it is a handle).
49 address of the variable contains first free user area address.
52 ( -- uvar-begin-addr )
53 start address of the user area.
57 maximum user area size in bytes.
67 show current backtrace (slow!)
71 decompile given forth word.
83 return PAD address. this is area that can be used for storing
84 temporary values. you can assume to have at least 4096 bytes there.
85 WARNING! some words may use PAD for their own needs. this is mostly
86 words which need to create some temporary strings.
89 note that address for memory operations may be a handle too. with handles,
90 low bits are used as offset, so you can directly address some bytes in handle
91 data area. currently, low 12 bits are reserved for offset, so you can address
92 4096 bytes inside a handle. but don't hardcode it, use "FORTH:(MAX-HANDLE-OFS)"
93 constant to get the maximum allowed offset (because it may change in the future).
95 also, UrForth is 32-bit system, and stores all numbers as little-endian. this
96 will not change, so you can write your code without checking cell size, or
130 compile 16-bit value.
134 compile 32-bit value.
139 read 4 bytes immediately following this word, and push them
140 to the data stack. adjust IP to skip those bytes.
144 read 4 bytes immediately following this word, and push them
145 to the data stack. adjust IP to skip those bytes. this is
146 the same as "(LIT)", but used to store CFAs of words. using
147 different words for different data types helps the debugger
152 the same as "(LIT)", but for vocids.
156 inline byte-counted string literal. note that the string
157 always have a trailing zero byte (which is not counted),
158 and always padded so it ends on a 4-byte boundary.
161 read next 4 bytes, and set IP to that address.
165 skip next 4 bytes if `flag` is 0, otherwise perform "(BRANCH)".
169 skip next 4 bytes if `flag` is not 0, otherwise perform "(BRANCH)".
174 pop word CFA address, and execute it.
178 pop word CFA address, and execute it. returning from the executed
179 word will return to the upper word. i.e. this performs a tail call.
183 internal compiler word, placed at the end of colon definition.
184 pops a number from return stack, and sets IP to that number.
187 this word is used to implement local variables and arguments.
188 it doesn't matter how it works, you should not used it anyway.
189 read the source code, if you're curious.
192 this word is used to implement local variables and arguments.
193 it doesn't matter how it works, you should not used it anyway.
194 read the source code, if you're curious.
198 read local variable with the given index. indices are 1-based.
202 write local variable with the given index. indices are 1-based.
206 duplicates a number on the data stack.
209 ( n -- n n ) | ( 0 -- 0 )
210 duplicates a number on the data stack, but only if that number is not 0.
213 ( n0 n1 -- n0 n1 n0 n1 )
228 ( n0 n1 -- n0 n1 n0 )
231 ( n0 n1 -- n0 n1 n0 )
234 ( n0 n1 n2 -- n1 n2 n0 )
237 ( n0 n1 n2 -- n2 n0 n1 )
247 the same as "DUP", but for the return stack.
251 the same as "DROP", but for the return stack.
255 the same as "SWAP", but for the return stack.
258 ( n0 n1 -- n0 n1 n0 )
259 the same as "OVER", but for the return stack.
262 ( n0 n1 n2 -- n1 n2 n0 )
263 the same as "ROT", but for the return stack.
266 ( n0 n1 n2 -- n2 n0 n1 )
267 the same as "NROT", but for the return stack.
271 move number from the data stack to the return stack.
275 move number from the return stack to the data stack.
279 copy number from the return stack to the data stack.
283 copy n-th element at the data stack. "0 PICK" is the same as "DUP".
287 the same as "PICK", but for the return stack.
291 move n-th element at the data stack to the top. "1 ROLL" is the same as "SWAP".
295 the same as "ROLL", but for the return stack.
299 read next input line. can cross include boundaries. pushes 0 if
300 there are no more input lines. TIB contents is undefined in this case.
304 read next input line. cannot cross include boundaries. pushes 0 if
305 there are no more input lines. TIB contents is undefined in this case.
309 get address of the current TIB position.
310 WARNING! do not try to emulate "TIB-GETCH" and such with this word!
311 TIB usually ends with 0 byte, and if you will advance beyond
312 that 0, Bad Things will happen.
316 push current TIB char, do not advance >IN.
320 peek TIB char with the given offset. "0 TIB-PEEKCH-OFS" is the same as "TIB-PEEKCH".
324 push current TIB char, advance >IN. it is safe to call this even
325 when you reached the end of TIB. in this case, returned char code
326 will be 0. i.e. "0" means "end of TIB".
330 skip current TIB char. it is safe to call this even when you reached
335 ( delim skip-leading-delim? -- addr count TRUE / FALSE )
336 does base TIB parsing; never copies anything.
337 as our reader is line-based, returns FALSE on EOL.
338 EOL is detected after skipping leading delimiters.
339 passing -1 as delimiter skips the whole line, and always returns FALSE.
340 finishing delimiter is always skipped.
344 skip all chars with codes <=32.
346 (PARSE-SKIP-COMMENTS)
347 ( allow-multiline? -- )
348 skip all blanks and comments. if multiline skip is not allowed, reaching
349 end of TIB while still waiting for the comment terminator is error.
350 single-line comments are ok, though.
354 advance >IN to the end of TIB.
358 parse with leading blanks skipping. doesn't copy anything.
359 return empty string on EOL.
362 ( delim -- addr count TRUE / FALSE )
363 parse without skipping delimiters; never copies anything.
364 as our reader is line-based, returns FALSE on EOL.
365 passing 0 as delimiter skips the whole line, and always returns FALSE.
366 finishing delimiter is always skipped.
374 "safe" char printer. all non-printable chars (including newline and such)
375 will be printed as "?".
379 was last printed char a newline?
383 force-set the flag for "LASTCR?" word.
395 print `n` spaces. if `n` is negative, prints nothing.
399 prints newline if the last printed char was not a newline.
403 print the string. negative count is ok, in this case the word prints nothing.
407 the same as "TYPE", but uses "XEMIT".
411 output can be buffered. it usually flushed when newline is printed, but
412 you can flush it manually using this word.
440 note that the results are swaped, contrary to ANS idiocity.
441 i don't fuckin' know why ANS morons decided to make the stack
442 effect that contradicts the word name. "/MOD" clearly indicates
443 that quotient comes first.
447 note that the results are swaped, contrary to ANS idiocity.
448 i don't fuckin' know why ANS morons decided to make the stack
449 effect that contradicts the word name. "/MOD" clearly indicates
450 that quotient comes first.
454 this uses 64-bit intermediate value.
458 this uses 64-bit intermediate value.
461 ( a b c -- a*b/c a*b%c )
462 this uses 64-bit intermediate value.
463 note that the results are swaped, contrary to ANS idiocity.
464 i don't fuckin' know why ANS morons decided to make the stack
465 effect that contradicts the word name. "/MOD" clearly indicates
466 that quotient comes first.
470 this uses 64-bit intermediate value.
473 ( a b -- lo(a*b) hi(a*b) )
474 this leaves 64-bit result.
477 ( a b -- lo(a*b) hi(a*b) )
478 this leaves 64-bit result.
481 ( alo ahi b -- a/b a%b )
482 note that the results are swaped, contrary to ANS idiocity.
483 i don't fuckin' know why ANS morons decided to make the stack
484 effect that contradicts the word name. "/MOD" clearly indicates
485 that quotient comes first.
488 ( alo ahi b -- a/b a%b )
489 note that the results are swaped, contrary to ANS idiocity.
490 i don't fuckin' know why ANS morons decided to make the stack
491 effect that contradicts the word name. "/MOD" clearly indicates
492 that quotient comes first.
564 arithmetic shift; positive `n` shifts to the left.
568 logical shift; positive `n` shifts to the left.
571 ( addr count -- addr new-count )
572 process string escapes. modifies string in-place. the resulting string is
573 never bigger than the source one. negative counts are allowed.
576 ( addr count allowsign? base -- num TRUE / FALSE )
577 tries to convert the given string to the number, using the given
578 default base. if "allowsign?" is non-zero, properly process leading
579 number sign. this words understands numbers in non-default bases too
580 (like "0x29a", for example).
584 switch to interpretation mode.
587 switch to compilation mode.
590 ( addr count word-flags -- )
591 create word header in the dictionary, link word to the current vocabulary.
594 (CREATE-NAMELESS-WORD-HEADER)
596 create nameless word header in the dictionary, link word to the current vocabulary.
600 ( addr count -- cfa TRUE / FALSE)
601 general word finder. checks wordlist stack, performs colon resolution.
604 ( addr count vocid allowhidden -- cfa TRUE / FALSE)
605 find word in the given wordlist. does no name resolution, and
606 doesn't look in parent wordlists.
608 FIND-WORD-IN-VOC-AND-PARENTS
609 ( addr count vocid allowhidden -- cfa TRUE / FALSE)
610 find word in the given wordlist. does no name resolution, but searches
611 parent wordlists if "vocid" is nested.
614 check if we are in interpretation mode, and throws an error if we aren't.
617 check if we are in compilation mode, and throws an error if we aren't.
624 this word is used internally to work with wordlist stack.
628 this word is used internally to work with wordlist stack.
632 this word is used internally to work with wordlist stack.
636 this word is used internally to work with wordlist stack.
673 convert CFA to word end address.
677 convert instruction pointer to NFA. return 0 if cannot.
680 ( ip -- addr count line TRUE / FALSE )
681 name is at PAD; it is safe to use PAD, because each task has its own temp image.
684 ( a0 c0 a1 c1 -- bool )
687 ( a0 c0 a1 c1 -- bool )
688 case-insensitive compare (only for ASCII).
691 ( addr count -- hash )
694 ( addr count -- hash )
695 case-insensitive hash (only for ASCII).
699 add new conditional define. case-insensitive (for ASCII).
703 remove conditional define. case-insensitive (for ASCII).
706 ( addr count -- bool )
707 check if we have a conditional define. case-insensitive (for ASCII).
711 print error message and abort.
714 ( errflag addr count -- )
715 if "errflag" is not zero, print error message and abort.
718 ( errflag addr count -- )
719 if "errflag" is zero, print error message and abort.
723 return number of items in the include stack.
727 isp 0 is current, then 1, etc.
728 each include file has unique non-zero id.
734 ( isp -- addr count )
735 current file name; at PAD.
738 ( addr count soft? system? -- )
739 push current file to the include stack, open a new one. used internally.
745 includes file only once; unreliable on shitdoze, i believe.
750 allocate a new handle with the given typeid. typeid is just a number
751 without any special meaning. any number except "-1" is allowed.
752 new handle size is 0.
756 deallocate a handle, free all allocated handle memory.
769 resize memory allocated for handle data.
773 "used" is just a number, which means nothing for most code.
774 it is used to implement dynamic arrays.
789 ( value idx hx -- value )
798 ( addr count -- stx )
799 load file with the given name into newly allocated handle.
800 aborts if there is no such file.
804 get address register contents.
808 set address register contents.
812 swap TOS and the address register.
816 increment the address register.
820 copy the address register to the return stack.
824 restore the address register from the return stack.
846 safe way to access both dictionary memory, and handle memory.
847 "idx" is used as offset from address register contents.
851 safe way to access both dictionary memory, and handle memory.
852 "idx" is used as offset from address register contents.
856 safe way to access both dictionary memory, and handle memory.
857 "idx" is used as offset from address register contents.
861 safe way to access both dictionary memory, and handle memory.
862 "idx" is used as offset from address register contents.
866 safe way to access both dictionary memory, and handle memory.
867 "idx" is used as offset from address register contents.
871 safe way to access both dictionary memory, and handle memory.
872 "idx" is used as offset from address register contents.
874 DEBUG:(DECOMPILE-CFA)
880 DEFER (UFO-INTERPRET-FINISHED)
882 this is called by INTERPRET when it is out of input stream. internally,
883 it simply sets a flag to tell the VM that it should stop.
888 push current dictionary pointer to the data stack.
889 NOTE: there are actually two DPs -- normal, and temporary. "(DP-TEMP)" is
890 the temp one, and if it is 0, "(DP)" is used. UrForth has 1MB temp area
891 (that's where PAD is too), it had different addresses, and vocabularies
892 created in that area are not linked to the main voclink list. this is used,
893 for example, in locals engine, to store names of locals. so if you're using
894 locals in your word, do not use temp area while compiling that word.
898 push LFA of the latest defined word in the current vocabulary. note that
899 "smudge" bit doesn't matter here, it is always the last word you created
900 header for. this includes "nonamed" words (which have empty string as a name).
904 does nothing. at all.
906 COMPILER:(TRACE-COLON) DEFER
908 this defered word is called in colon, after creating word header and CFA.
909 you can compile your own debug code into the new word.
911 COMPILER:(TRACE-SEMI)
913 this is called by semicolon, right before compiling "(EXIT)" and such.
914 you can compile your own debug code into the new word.
916 COMPILER:(TRACE-DOES)
918 this is called by "DOES>".
919 you can compile your own debug code into the new word.
921 COMPILER:(CTLID-COLON)
923 semicolon expects this on the data stack.
927 find word, push its CFA to the data stack. note that the tick
928 is NOT immediate. use "[']" if you need to compile next word CFA.
931 start new word definition.
934 end new word definition.
936 ALIAS oldword newword
938 "newword" will do exactly the same as "oldword". word attributes
939 will be copied too (hidden, immediate, etc.).
969 mark last defined word as immediate (or remove immediate mark if it is already set).
972 mark last defined word as hidden. DO NOT USE. this is obsolete feature,
973 and it will be removed. it is here for compatibility with my other Forth system.
976 the opposite of "(HIDDEN)".
983 skip all comments and blanks, multiline mode.
985 PARSE-SKIP-LINE-COMMENTS
986 skip all comments and blanks, single line mode.
990 add (OR) default flag for new words.
1001 (RESET-DEF-WORD-FLAGS)
1003 remove (~AND) default flag for new words.
1007 all following words will be public.
1011 all following words will be hidden.
1015 all following words will be protected. you cannot redefine
1020 all following words will not be protected.
1024 clear the wordlist stack.
1028 push context vocabulary onto the wordlist stack.
1032 pop vocabulary from the wordlist stack, and make in context.
1036 make context vocabulary also current. "current" is the vocabulary
1037 that will receive new word definitions. "context" is the vocabulary
1038 that will be used to search words.
1113 ( a -- [a>>16]&0xffff )
1119 ( a -- [a>>8]&0xff )
1140 ( addr -- addr+1 count )
1143 ( addr -- addr+4 count )
1158 ( value a b -- value>=a&&value<b )
1161 ( value a b -- value>=a&&value<b )
1164 ( value a b -- value>=a&&value<=b )
1165 numbers are unsigned.
1169 check if the given addres is actually a handle.
1173 set "smudge" bit for the latest word.
1175 COMPILER:RESET-SMUDGE
1177 reset "smudge" bit for the latest word.
1181 set argument type for the latest word. each word has "argument type" field,
1182 which inditates word argument type in the compiled code. arguments are:
1194 this mask can be used to get only argument type bits from the first NFA cell.
1196 COMPILER:(GET-NEW-WORD-FLAGS)
1198 get sanitized new word flags. currently, only "hidden" and "protected" flags
1199 are retained, all other flags will be reset.
1201 COMPILER:(CREATE-HEADER)
1203 create new named word header with the default flags. additionally, sets
1204 "smudge" flag on the new word.
1206 COMPILER:(CREATE-NAMELESS)
1208 create new nameless word header with the default flags. additionally, sets
1209 "smudge" and "hidden" flags on the new word.
1210 return CFA address of the new word. CFA contents is not filled yet.
1212 COMPILER:(MK-CONST-VAR)
1214 don't bother using this.
1216 COMPILER:FORTH-WORD?
1218 check if the given word is normal Forth word (i.e. defined with the colon).
1222 compiles CFA to be executed.
1224 use the following words to compile branch destinations. this way your code
1225 will be independent of branch instruction operand format.
1228 ;; compile (0branch)
1238 COMPILER:(BRANCH-ADDR!)
1239 ( destaddr addr -- )
1240 write "branch to destaddr" address to addr.
1242 COMPILER:(BRANCH-ADDR@)
1243 ( addr -- dest ) @ ;
1244 read branch address.
1249 return addr suitable for "(<J-RESOLVE)".
1253 use after "(<J-MARK)" to reserve jump and append it to jump chain.
1255 COMPILER:(<J-RESOLVE)
1257 patch "forward jump" address to HERE. "addr" is the result of "(<J-MARK)".
1260 reserve room for branch address, return addr suitable for "(RESOLVE-J>)".
1263 use after "(MARK-J>)" to reserve jump and append it to jump chain.
1265 COMPILER:(RESOLVE-J>)
1267 compile "forward jump" (possibly chain) from address to HERE. addr is the
1268 result of "(MARK-J>)". this resolves the whole "jump chain".
1273 throw error if a <> b.
1277 throw error if a <> b and a <> c.
1282 compile number from the data stack as literal. NOT IMMEDIATE.
1287 immediate version of "LITERAL".
1298 [COMPILE] <wordname>
1299 force the next word to be compiled as normal word, even if it is an immediate one.
1302 compile next word CFA as CFA literal.
1304 COMPILER:(COMPILE-CFA-LITERAL)
1306 compile cfa literal to be compiled. ;-)
1308 COMPILER:END-COMPILE-FORTH-WORD
1310 push colon ctlid and call ";".
1314 compile next word to the currently defining word.
1318 push/compile first char of the next word as char code.
1319 note that words with more than one char will cause an error.
1322 recursively call the currently defining word. this is required
1323 due to currently defining word being invisible yet (because it
1327 tail-call recursion.
1331 create new constant.
1335 create new variable.
1339 this is what "CREATE" is using to create a new word.
1343 create new word. when executed, this new word will push its PFA.
1344 note that new word is not smudged.
1348 finish CREATEd word. this is required to correctly set SFA.
1349 note that "DOES>" automatically takes care of SFA, so you don't have
1350 to call this if you're using "DOES>".
1354 patch CREATEd word. put doer address to its CFA, VM will do the rest.
1355 this is used internally by the compiler.
1359 makes CFA word to execute "doer-pfa" as doer.
1360 this is used internally by the compiler. do not try to understand this.
1364 the usual Forth "CREATE" -- "DOES>" support.
1369 ALIAS 4U* CELLS ( n -- n*cells )
1372 ALIAS 4+ CELL+ ( n -- n+cell )
1375 ALIAS 4- CELL- ( n -- n-cell )
1379 ( a n -- a+n*cells )
1383 ( a n -- a+n*cells )
1387 immediately print the text.
1390 compile text printer.
1394 allocate n *bytes* in the current DP, return the address of
1395 the first allocated byte.
1399 allocate n *bytes* in the current DP.
1404 ( E: -- addr count )
1407 COMPILER:(NEW-WORDLIST)
1408 ( parentvocid need-hashtable? -- vocid )
1409 create new empty wordlist.
1411 COMPILER:(CREATE-NAMED-VOCAB)
1412 ( vocid addr count -- )
1413 create vocabulary word.
1415 COMPILER:(CREATE-VOCAB) <vocname>
1417 create vocabulary word.
1419 COMPILER:(IS-VOC-WORD?)
1421 check if the given CFA defined as a vocabulary header.
1423 COMPILER:(WORD->VOCID)
1425 get vocid from the vocabulary word. doesn't check arguments.
1427 COMPILER:(VOCID-PARENT@)
1429 get vocid parent vocabulary. return 0 if there is no parent.
1430 doesn't check arguments.
1432 COMPILER:(VOCID-PARENT!)
1433 ( parent-vocid vocid -- )
1434 set vocid parent vocabulary. doesn't check arguments.
1436 COMPILER:(VOCID-TYPEID@)
1438 internal helper for STRUCT support.
1440 COMPILER:(VOCID-TYPEID!)
1441 internal helper for STRUCT support.
1444 ( addr count parent need-hashtbl? -- )
1445 useful low-level words to create vocabs with already parsed names.
1452 creates vocabulary without a hash table.
1457 (SIMPLE-NESTED-VOCABULARY)
1460 VOCABULARY <vocname>
1462 SIMPLE-VOCABULARY <vocname>
1464 NESTED-VOCABULARY <vocname>
1466 SIMPLE-NESTED-VOCABULARY <vocname>
1470 return vocid for the given vocabulary. this word is immediate.
1474 return latest word LFA for the given vocid.
1476 ALSO-DEFS: <vocname>
1478 this does "ALSO <vocname> DEFINITIONS"
1482 this does "PREVIOUS DEFINITIONS".
1484 VOCAB-IF-NONE <vocname>
1485 create vocabulary if we don't have such word yet.
1487 NESTED-VOCAB-IF-NONE <vocname>
1488 create nested vocabulary if we don't have such word yet.
1491 decrement value by n.
1494 increment value by n.
1497 decrement value by 1.
1500 increment value by 1.
1505 ... FORTH:(TO-EXTENDER) ...
1506 ( addr count FALSE -- addr count FALSE / TRUE )
1507 "TO" can be extended to support things it doesn't know about yet.
1508 after parsing a name, "(TO-EXTENDER)" will be called (this is
1509 scattered colon word). note that due to how scattered colon works,
1510 you'd better DON'T use "EXIT", but pass a flag if you need to stop
1511 further processing. also, do not forget to check the flag at the
1512 start of your extender, because some other extender may already
1513 did its work before yours.
1515 ... FORTH:(EXIT-EXTENDER) ...
1517 this scattered colon word allows you to extend "EXIT". "EXIT" is
1518 the immediate word that compiles word leaving instructions. you
1519 can compile your cleanup code before the standard cleanup.
1521 ... FORTH:(INTERPRET-CHECK-WORD) ...
1522 ( addr count FALSE -- addr count FALSE / TRUE )
1523 this is called by INTERPRET before the standard word processing.
1525 ... FORTH:(INTERPRET-WORD-NOT-FOUND) ...
1526 ( addr count FALSE -- addr count FALSE / TRUE )
1527 this is called by INTERPRET when word resolution failed.
1530 UrForth supports cooperative multitasking. it is also used to implement
1531 interactive debugger. tasks are called "execution states", or simply
1536 create new state, return state id.
1540 free state. state id should be valid, and should not be an active state.
1543 ( stid -- addr count )
1544 copy state name to PAD.
1547 ( addr count stid -- )
1548 set new state name. maximum name length is 127 chars. state name
1549 should not include char with code 0.
1553 get first state in the list of all created states. this is used to
1554 iterate over all states.
1555 WARNING! do not mutate state list while iterating! result will be UB.
1558 ( stid -- stid / 0 )
1559 get next state id. used to iterate over all states.
1560 WARNING! do not mutate state list while iterating! result will be UB.
1563 ( ... argc stid -- )
1564 yield to another state. move argc numbers from the current state data
1565 stack to the new state data stack. push args to the new state data
1566 stack, and then push current state id. i.e. new state data stack will
1568 ( ... argc old-stid )
1569 it is ok to swith to the currently active state (it is a no-op).
1571 MTASK:SET-SELF-AS-DEBUGGER
1573 register current task as system debugger. you can yeild from the debugger
1578 breakpoint. debugger task receives debugge stid on the data stack,
1579 and `-1` as yield argument count. i.e. debugger stack will be:
1582 MTASK:DEBUGGER-RESUME
1584 resume debugee execution.
1586 MTASK:DEBUGGER-SINGLE-STEP
1588 execute one debuggee instruction, and return to debugger.
1589 this is basically "YIELD", but to use in the debugger
1590 (and it doesn't pass any arguments). debugger stack will be:
1595 get state instruction pointer.
1599 set state instruction pointer.
1603 get address register contents.
1607 set address register contents.
1610 ( addr stid -- valie )
1611 get other state user area cell.
1614 ( value addr stid -- )
1615 set other state user area cell.
1617 MTASK:STATE-RPOPCFA@
1619 VM has special mode when it gets next CFA from the return stack
1620 instead of the address pointed by IP. this is used to implement
1621 "EXECUTE", for example. use this word to retrieve that flag.
1623 MTASK:STATE-RPOPCFA!
1625 VM has special mode when it gets next CFA from the return stack
1626 instead of the address pointed by IP. this is used to implement
1627 "EXECUTE", for example. use this word to set that flag.
1631 return state id of the currently executing state.
1635 return state which called "MTASK:YIELD-TO" last.
1639 get the data stack depth for the given state.
1643 get the return stack depth for the given state.
1647 get local stack ptr.
1651 get local stack base ptr.
1655 set the data stack depth for the given state.
1659 set the return stack depth for the given state.
1663 set local stack ptr.
1667 set local stack base ptr.
1670 ( idx stid -- value )
1671 read the data stack of the given state. note that the index is bound-checked.
1674 ( idx stid -- value )
1675 read the return stack of the given state. note that the index is bound-checked.
1678 ( idx stid -- value )
1679 read the locals stack of the given state. note that the index is bound-checked.
1682 ( value idx stid -- )
1683 write the data stack of the given state. note that the index is bound-checked.
1684 i.e. if you want to push some value, increase stack depth first.
1687 ( value idx stid -- )
1688 write the return stack of the given state. note that the index is bound-checked.
1689 i.e. if you want to push some value, increase stack depth first.
1692 ( value idx stid -- )
1693 write the locals stack of the given state. note that the index is bound-checked.
1694 i.e. if you want to push some value, increase stack depth first.
1697 there are some words to work with TTY (only GNU/Linux).
1701 check if input and output are valid TTY(s).
1705 check if current TTY mode is raw.
1709 get TTY size. for non-TTYs retur default 80x24.
1713 switch TTY to raw mode.
1717 switch TTY to cooked mode.
1721 type char without any filtering or safety nets.
1725 type string without any filtering or safety nets.
1729 the output of the two words above is buffered. this words flushes
1730 the buffer. buffering is done because raw TTY is mostly used to
1731 build user interfaces, and sending accumulated terminal commands
1732 in one big chunk looks much better (most terminal emulators will
1733 process the whole chunk before refreshing their windows).
1737 -1 returned on error, or on EOF.
1738 read one char (without any interpretation) if TTY is in raw mode.
1739 note that 0 is a valid char (it is used to send Ctrl+Space in some
1740 terminal emulators). also note that there is no way to tell if we
1741 hit a EOF, or some error occured. in practice, it doesn't matter,
1742 because in both cases it means that TTY is unusable anymore.
1746 check if raw TTY has some data to read.