Node 412

In this node we scan incoming symbols and separate tags and characters. If tag is a token, we expand it into characters. Symbols are sent for display to 512. Cursor pointer is also kept here, and signal is sent to node 512 when rendering symbol where cursor should be displayed. In this node we also generate empty lines that fill the frame past end-of-block.

Source code

usb node 512 node 413 node 312 node 411 node 412
412 words
cur! 00 p @p drop !p ;
cur 01 ps-ps over 3FFFF cur or if drop ; then drop 40 or ;
key 07 a io a! @ 200 uw and if up a! @ cur! then drop a! ;
tag? 10 -ps @ @ 30 over over and or if drop ;
then drop pop drop ;
chrs 16 t-pt !b begin tag? cur !b end
toks 1A t-pt tag? push over cur !b right a! pop ! @
begin !b @ while end then drop drop left a! toks ;
go 25 -pt @ @
tag 26 pt -if dup 2* . -if @ key -if go ;
then for 19 for 20030 !b next next go ;
then drop !b go ;
then dup 3E and 30 or if drop cur chrs tag ;
then drop toks tag ; 3F

init down b! left a! go ; 43

3 d 2 r 0 ether


Store cursor position into second word of cur.
Keep current cursor position in your second word. If set to 3FFFF, no cursor is displayed. It expects current pointer p and symbol s on stack. If pointer equals cur, bit 6 (40) of the symbol is set to signalize cursor position.
Update cursor pointer. Check UP port and fetch a new position which is stored with cur!.
Fetch new pointer and symbol. It the symbol is a tag, pop and drop return address, and return from caller (either chrs or toks). Otherwise just return.
Send tag t DOWN and call tag? to get next character, call cur to set cursor bit if appropriate, and send the resulting word DOWN for display. Repeat till tag? encounters a tag and exits from chrs.
First check tag? and if the next symbol is not a tag, save it on return stack, call cur to flag cursor position, and send the token tag t DOWN. Then pop the token from return stack, send it RIGHT, and read characters of this token until it is zero. Send those characters DOWN except the zero. Finally, restore A and jump back to toks.

It is important that token tag is not sent for display itself, but it is sent before each token string; this is what makes spaces between token strings and also makes place to display cursor at.

Prefetch pointer and symbol, and fall through to tag.
Check if tag t is a format mark. If so, check if it is end-of-row (20030), and if so send it DOWN and jump to go. If the format mark is end-of-block (30030) then fetch number of empty rows less one to be displayed, (negative if none), call key to update cursor pointer, and jump to go if there's no empty line. Otherwise use this number as a loop index and send that many end-of-row format marks, 20 times for each empty row. Then return to go.

If the tag is not any of the format marks, check if it is a token tag (either 30 or 31). If so, call toks and jump to tag. Otherwise call cur to set cursor bit if appropriate, call chrs, and jump to tag.

Set registers A and B, and jump to go.


This node receives a stream of pairs composed of a pointer and a symbol from node 411. It starts execution in go, where it prefetches one pair, and then falls through to tag, which is an endless loop until end-of-row or end-of-block is received, in which case we jump again to go.

Pointers are compared in word cur with the current cursor position (literal in word cur). If the pointer matches the current cursor position, bit 6 of the symbol is set. This indicates that cursor shall be rendered at this position by node 512. Cursor position is set to 3FFFF out of reset so that no cursor is displayed during boot up.

Word tag expects that the symbol on stack is a tag. It first tests if it is any of the format marks. If so, it either sends it to node 513 if it is end-of-row to generate spaces till the end of row, or it generates empty rows here if end-of-block format mark has been received. If the number of empty rows received from node 412 is -1, meaning no empty rows, we jump back to go. Note that end-of-block also initiates execution of key, which allows node 212 to update cursor position.

If the tag tested by tag is not any of the format marks we process it as a token tag with word toks, or character tag with word chrs. Word chrs sends characters to node 512, checking cursor position for each character, until it receives a tag, in which case it returns to tag.

Word toks also tests for cursor position, then sends each token to node 413, and reads back the token expanded into characters, which are forwarded to node 512. In order to render spaces between expanded tokens, we send the current tag to node 512 before each token string. When we receive a new tag instead of a token, we return to tag.

What leaves this node is a stream of tags, characters, and end-of-row format marks that starts each frame with a tag.