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.
609 ( addr count vocid -- cfa TRUE / FALSE)
610 find word in the given wordlist. does no name resolution, and
611 doesn't look in parent wordlists. skips hidden words.
613 (FIND-WORD-IN-VOC-AND-PARENTS)
614 ( addr count vocid allowhidden? -- cfa TRUE / FALSE)
615 find word in the given wordlist. does no name resolution, but searches
616 parent wordlists if "vocid" is nested.
618 FIND-WORD-IN-VOC-AND-PARENTS
619 ( addr count vocid -- cfa TRUE / FALSE)
620 find word in the given wordlist. does no name resolution, but searches
621 parent wordlists if "vocid" is nested. skips hidden words.
624 check if we are in interpretation mode, and throws an error if we aren't.
627 check if we are in compilation mode, and throws an error if we aren't.
634 this word is used internally to work with wordlist stack.
638 this word is used internally to work with wordlist stack.
642 this word is used internally to work with wordlist stack.
646 this word is used internally to work with wordlist stack.
683 convert CFA to word end address.
687 convert instruction pointer to NFA. return 0 if cannot.
690 ( ip -- addr count line TRUE / FALSE )
691 name is at PAD; it is safe to use PAD, because each task has its
694 DEBUG:IP->FILE-HASH/LINE
695 ( ip -- len hash line TRUE / FALSE )
696 return unique file hash and name length instead of string name.
700 ( a0 c0 a1 c1 -- bool )
703 ( a0 c0 a1 c1 -- bool )
704 case-insensitive compare (only for ASCII).
707 ( addr count -- hash )
710 ( addr count -- hash )
711 case-insensitive hash (only for ASCII).
715 add new conditional define. case-insensitive (for ASCII).
719 remove conditional define. case-insensitive (for ASCII).
722 ( addr count -- bool )
723 check if we have a conditional define. case-insensitive (for ASCII).
727 print error message and abort.
730 ( errflag addr count -- )
731 if "errflag" is not zero, print error message and abort.
734 ( errflag addr count -- )
735 if "errflag" is zero, print error message and abort.
739 return number of items in the include stack.
743 isp 0 is current, then 1, etc.
744 each include file has unique non-zero id.
750 ( isp -- addr count )
751 current file name; at PAD.
754 ( addr count soft? system? -- )
755 push current file to the include stack, open a new one. used internally.
761 includes file only once; unreliable on shitdoze, i believe.
766 allocate a new handle with the given typeid. typeid is just a number
767 without any special meaning. any number except "-1" is allowed.
768 new handle size is 0.
772 deallocate a handle, free all allocated handle memory.
787 resize memory allocated for handle data.
791 "used" is just a number, which means nothing for most code.
792 it is used to implement dynamic arrays.
808 ( value idx hx -- value )
817 ( addr count -- stx / FALSE )
818 load file with the given name into newly allocated handle.
819 return 0 (FALSE) if there is no such file.
823 get address register contents.
827 set address register contents.
831 swap TOS and the address register.
835 increment the address register.
839 copy the address register to the return stack.
843 restore the address register from the return stack.
865 safe way to access both dictionary memory, and handle memory.
866 "idx" is used as offset from address register contents.
870 safe way to access both dictionary memory, and handle memory.
871 "idx" is used as offset from address register contents.
875 safe way to access both dictionary memory, and handle memory.
876 "idx" is used as offset from address register contents.
880 safe way to access both dictionary memory, and handle memory.
881 "idx" is used as offset from address register contents.
885 safe way to access both dictionary memory, and handle memory.
886 "idx" is used as offset from address register contents.
890 safe way to access both dictionary memory, and handle memory.
891 "idx" is used as offset from address register contents.
893 DEBUG:(DECOMPILE-CFA)
899 DEFER (UFO-INTERPRET-FINISHED)
901 this is called by INTERPRET when it is out of input stream. internally,
902 it simply sets a flag to tell the VM that it should stop.
907 push current dictionary pointer to the data stack.
908 NOTE: there are actually two DPs -- normal, and temporary. "(DP-TEMP)" is
909 the temp one, and if it is 0, "(DP)" is used. UrForth has 1MB temp area
910 (that's where PAD is too), it had different addresses, and vocabularies
911 created in that area are not linked to the main voclink list. this is used,
912 for example, in locals engine, to store names of locals. so if you're using
913 locals in your word, do not use temp area while compiling that word.
917 push LFA of the latest defined word in the current vocabulary. note that
918 "smudge" bit doesn't matter here, it is always the last word you created
919 header for. this includes "nonamed" words (which have empty string as a name).
923 does nothing. at all.
925 COMPILER:(TRACE-COLON) DEFER
927 this defered word is called in colon, after creating word header and CFA.
928 you can compile your own debug code into the new word.
930 COMPILER:(TRACE-SEMI)
932 this is called by semicolon, right before compiling "(EXIT)" and such.
933 you can compile your own debug code into the new word.
935 COMPILER:(TRACE-DOES)
937 this is called by "DOES>".
938 you can compile your own debug code into the new word.
940 COMPILER:(CTLID-COLON)
942 semicolon expects this on the data stack.
946 find word, push its CFA to the data stack. note that the tick
947 is NOT immediate. use "[']" if you need to compile next word CFA.
950 start new word definition.
953 end new word definition.
955 ALIAS oldword newword
957 "newword" will do exactly the same as "oldword". word attributes
958 will be copied too (hidden, immediate, etc.).
988 mark last defined word as immediate (or remove immediate mark if it is already set).
991 mark last defined word as hidden. DO NOT USE. this is obsolete feature,
992 and it will be removed. it is here for compatibility with my other Forth system.
995 the opposite of "(HIDDEN)".
1002 skip all comments and blanks, multiline mode.
1004 PARSE-SKIP-LINE-COMMENTS
1005 skip all comments and blanks, single line mode.
1007 (SET-DEF-WORD-FLAGS)
1009 add (OR) default flag for new words.
1020 (RESET-DEF-WORD-FLAGS)
1022 remove (~AND) default flag for new words.
1026 all following words will be public.
1030 all following words will be hidden.
1034 all following words will be protected. you cannot redefine
1039 all following words will not be protected.
1043 clear the wordlist stack.
1047 push context vocabulary onto the wordlist stack.
1051 pop vocabulary from the wordlist stack, and make in context.
1055 make context vocabulary also current. "current" is the vocabulary
1056 that will receive new word definitions. "context" is the vocabulary
1057 that will be used to search words.
1132 ( a -- [a>>16]&0xffff )
1138 ( a -- [a>>8]&0xff )
1159 ( addr -- addr+1 count )
1162 ( addr -- addr+4 count )
1177 ( value a b -- value>=a&&value<b )
1180 ( value a b -- value>=a&&value<b )
1183 ( value a b -- value>=a&&value<=b )
1184 numbers are unsigned.
1188 check if the given addres is actually a handle.
1192 set "smudge" bit for the latest word.
1194 COMPILER:RESET-SMUDGE
1196 reset "smudge" bit for the latest word.
1200 set argument type for the latest word. each word has "argument type" field,
1201 which inditates word argument type in the compiled code. arguments are:
1213 this mask can be used to get only argument type bits from the first NFA cell.
1215 COMPILER:(GET-NEW-WORD-FLAGS)
1217 get sanitized new word flags. currently, only "hidden" and "protected" flags
1218 are retained, all other flags will be reset.
1220 COMPILER:(CREATE-HEADER)
1222 create new named word header with the default flags. additionally, sets
1223 "smudge" flag on the new word.
1225 COMPILER:(CREATE-NAMELESS)
1227 create new nameless word header with the default flags. additionally, sets
1228 "smudge" and "hidden" flags on the new word.
1229 return CFA address of the new word. CFA contents is not filled yet.
1231 COMPILER:(MK-CONST-VAR)
1233 don't bother using this.
1235 COMPILER:FORTH-WORD?
1237 check if the given word is normal Forth word (i.e. defined with the colon).
1241 compiles CFA to be executed.
1243 use the following words to compile branch destinations. this way your code
1244 will be independent of branch instruction operand format.
1247 ;; compile (0branch)
1257 COMPILER:(BRANCH-ADDR!)
1258 ( destaddr addr -- )
1259 write "branch to destaddr" address to addr.
1261 COMPILER:(BRANCH-ADDR@)
1262 ( addr -- dest ) @ ;
1263 read branch address.
1268 return addr suitable for "(<J-RESOLVE)".
1272 use after "(<J-MARK)" to reserve jump and append it to jump chain.
1274 COMPILER:(<J-RESOLVE)
1276 patch "forward jump" address to HERE. "addr" is the result of "(<J-MARK)".
1279 reserve room for branch address, return addr suitable for "(RESOLVE-J>)".
1282 use after "(MARK-J>)" to reserve jump and append it to jump chain.
1284 COMPILER:(RESOLVE-J>)
1286 compile "forward jump" (possibly chain) from address to HERE. addr is the
1287 result of "(MARK-J>)". this resolves the whole "jump chain".
1292 throw error if a <> b.
1296 throw error if a <> b and a <> c.
1301 compile number from the data stack as literal. NOT IMMEDIATE.
1306 immediate version of "LITERAL".
1310 ( E: -- addr count )
1313 immediate version of the previous word.
1323 [COMPILE] <wordname>
1324 force the next word to be compiled as normal word, even if it is an immediate one.
1327 compile next word CFA as CFA literal.
1329 COMPILER:(COMPILE-CFA-LITERAL)
1331 compile cfa literal to be compiled. ;-)
1333 COMPILER:END-COMPILE-FORTH-WORD
1335 push colon ctlid and call ";".
1339 compile next word to the currently defining word.
1343 push/compile first char of the next word as char code.
1344 note that words with more than one char will cause an error.
1347 recursively call the currently defining word. this is required
1348 due to currently defining word being invisible yet (because it
1352 tail-call recursion.
1356 create new constant.
1360 create new variable.
1364 this is what "CREATE" is using to create a new word.
1368 create new word. when executed, this new word will push its PFA.
1369 note that new word is not smudged.
1373 finish CREATEd word. this is required to correctly set SFA.
1374 note that "DOES>" automatically takes care of SFA, so you don't have
1375 to call this if you're using "DOES>".
1379 patch CREATEd word. put doer address to its CFA, VM will do the rest.
1380 this is used internally by the compiler.
1384 makes CFA word to execute "doer-pfa" as doer.
1385 this is used internally by the compiler. do not try to understand this.
1389 the usual Forth "CREATE" -- "DOES>" support.
1394 ALIAS 4U* CELLS ( n -- n*cells )
1397 ALIAS 4+ CELL+ ( n -- n+cell )
1400 ALIAS 4- CELL- ( n -- n-cell )
1404 ( a n -- a+n*cells )
1408 ( a n -- a+n*cells )
1412 immediately print the text.
1415 compile text printer.
1419 allocate n *bytes* in the current DP, return the address of
1420 the first allocated byte.
1424 allocate n *bytes* in the current DP.
1428 align DP to 4-byte boundary.
1430 COMPILER:(NEW-WORDLIST)
1431 ( parentvocid need-hashtable? -- vocid )
1432 create new empty wordlist.
1434 COMPILER:(CREATE-NAMED-VOCAB)
1435 ( vocid addr count -- )
1436 create vocabulary word.
1438 COMPILER:(CREATE-VOCAB) <vocname>
1440 create vocabulary word.
1442 COMPILER:(IS-VOC-WORD?)
1444 check if the given CFA defined as a vocabulary header.
1446 COMPILER:(WORD->VOCID)
1448 get vocid from the vocabulary word. doesn't check arguments.
1450 COMPILER:(VOCID-PARENT@)
1452 get vocid parent vocabulary. return 0 if there is no parent.
1453 doesn't check arguments.
1455 COMPILER:(VOCID-PARENT!)
1456 ( parent-vocid vocid -- )
1457 set vocid parent vocabulary. doesn't check arguments.
1459 COMPILER:(VOCID-TYPEID@)
1461 internal helper for STRUCT support.
1463 COMPILER:(VOCID-TYPEID!)
1464 internal helper for STRUCT support.
1467 ( addr count parent need-hashtbl? -- )
1468 useful low-level words to create vocabs with already parsed names.
1475 creates vocabulary without a hash table.
1480 (SIMPLE-NESTED-VOCABULARY)
1483 VOCABULARY <vocname>
1485 SIMPLE-VOCABULARY <vocname>
1487 NESTED-VOCABULARY <vocname>
1489 SIMPLE-NESTED-VOCABULARY <vocname>
1493 return vocid for the given vocabulary. this word is immediate.
1497 return latest word LFA for the given vocid.
1499 ALSO-DEFS: <vocname>
1501 this does "ALSO <vocname> DEFINITIONS"
1505 this does "PREVIOUS DEFINITIONS".
1507 VOCAB-IF-NONE <vocname>
1508 create vocabulary if we don't have such word yet.
1510 NESTED-VOCAB-IF-NONE <vocname>
1511 create nested vocabulary if we don't have such word yet.
1514 decrement value by n.
1517 increment value by n.
1520 decrement value by 1.
1523 increment value by 1.
1528 ... FORTH:(TO-EXTENDER) ...
1529 ( addr count FALSE -- addr count FALSE / TRUE )
1530 "TO" can be extended to support things it doesn't know about yet.
1531 after parsing a name, "(TO-EXTENDER)" will be called (this is
1532 scattered colon word). note that due to how scattered colon works,
1533 you'd better DON'T use "EXIT", but pass a flag if you need to stop
1534 further processing. also, do not forget to check the flag at the
1535 start of your extender, because some other extender may already
1536 did its work before yours.
1538 ... FORTH:(EXIT-EXTENDER) ...
1540 this scattered colon word allows you to extend "EXIT". "EXIT" is
1541 the immediate word that compiles word leaving instructions. you
1542 can compile your cleanup code before the standard cleanup.
1544 ... FORTH:(INTERPRET-CHECK-WORD) ...
1545 ( addr count FALSE -- addr count FALSE / TRUE )
1546 this is called by INTERPRET before the standard word processing.
1548 ... FORTH:(INTERPRET-WORD-NOT-FOUND) ...
1549 ( addr count FALSE -- addr count FALSE / TRUE )
1550 this is called by INTERPRET when word resolution failed.
1553 UrForth supports cooperative multitasking. it is also used to implement
1554 interactive debugger. tasks are called "execution states", or simply
1559 create new state, return state id.
1563 free state. state id should be valid, and should not be an active state.
1566 ( stid -- addr count )
1567 copy state name to PAD.
1570 ( addr count stid -- )
1571 set new state name. maximum name length is 127 chars. state name
1572 should not include char with code 0.
1576 get first state in the list of all created states. this is used to
1577 iterate over all states.
1578 WARNING! do not mutate state list while iterating! result will be UB.
1581 ( stid -- stid / 0 )
1582 get next state id. used to iterate over all states.
1583 WARNING! do not mutate state list while iterating! result will be UB.
1586 ( ... argc stid -- )
1587 yield to another state. move argc numbers from the current state data
1588 stack to the new state data stack. push args to the new state data
1589 stack, and then push current state id. i.e. new state data stack will
1591 ( ... argc old-stid )
1592 it is ok to swith to the currently active state (it is a no-op).
1594 MTASK:SET-SELF-AS-DEBUGGER
1596 register current task as system debugger. you can yeild from the debugger
1601 breakpoint. debugger task receives debugge stid on the data stack,
1602 and `-1` as yield argument count. i.e. debugger stack will be:
1605 MTASK:DEBUGGER-RESUME
1607 resume debugee execution.
1609 MTASK:DEBUGGER-SINGLE-STEP
1611 execute one debuggee instruction, and return to debugger.
1612 this is basically "YIELD", but to use in the debugger
1613 (and it doesn't pass any arguments). debugger stack will be:
1618 get state instruction pointer.
1622 set state instruction pointer.
1626 get address register contents.
1630 set address register contents.
1633 ( addr stid -- valie )
1634 get other state user area cell.
1637 ( value addr stid -- )
1638 set other state user area cell.
1640 MTASK:STATE-RPOPCFA@
1642 VM has special mode when it gets next CFA from the return stack
1643 instead of the address pointed by IP. this is used to implement
1644 "EXECUTE", for example. use this word to retrieve that flag.
1646 MTASK:STATE-RPOPCFA!
1648 VM has special mode when it gets next CFA from the return stack
1649 instead of the address pointed by IP. this is used to implement
1650 "EXECUTE", for example. use this word to set that flag.
1654 return state id of the currently executing state.
1658 return state which called "MTASK:YIELD-TO" last.
1662 get the data stack depth for the given state.
1666 get the return stack depth for the given state.
1670 get local stack ptr.
1674 get local stack base ptr.
1678 set the data stack depth for the given state.
1682 set the return stack depth for the given state.
1686 set local stack ptr.
1690 set local stack base ptr.
1693 ( idx stid -- value )
1694 read the data stack of the given state. note that the index is bound-checked.
1697 ( idx stid -- value )
1698 read the return stack of the given state. note that the index is bound-checked.
1701 ( idx stid -- value )
1702 read the locals stack of the given state. note that the index is bound-checked.
1705 ( value idx stid -- )
1706 write the data stack of the given state. note that the index is bound-checked.
1707 i.e. if you want to push some value, increase stack depth first.
1710 ( value idx stid -- )
1711 write the return stack of the given state. note that the index is bound-checked.
1712 i.e. if you want to push some value, increase stack depth first.
1715 ( value idx stid -- )
1716 write the locals stack of the given state. note that the index is bound-checked.
1717 i.e. if you want to push some value, increase stack depth first.
1720 there are some words to work with TTY (only GNU/Linux).
1724 check if input and output are valid TTY(s).
1728 check if current TTY mode is raw.
1732 get TTY size. for non-TTYs retur default 80x24.
1736 switch TTY to raw mode.
1740 switch TTY to cooked mode.
1744 type char without any filtering or safety nets.
1748 type string without any filtering or safety nets.
1752 the output of the two words above is buffered. this words flushes
1753 the buffer. buffering is done because raw TTY is mostly used to
1754 build user interfaces, and sending accumulated terminal commands
1755 in one big chunk looks much better (most terminal emulators will
1756 process the whole chunk before refreshing their windows).
1760 -1 returned on error, or on EOF.
1761 read one char (without any interpretation) if TTY is in raw mode.
1762 note that 0 is a valid char (it is used to send Ctrl+Space in some
1763 terminal emulators). also note that there is no way to tell if we
1764 hit a EOF, or some error occured. in practice, it doesn't matter,
1765 because in both cases it means that TTY is unusable anymore.
1769 check if raw TTY has some data to read.