Node 311

Primary function of this node is to provide a command line buffer in its RAM, and pass data from video buffer or command line buffer whenever node 411 wishes to display it. This node also allows node 310 to access both buffers when it needs to write data from SRAM to a buffer or write content of a buffer back. The command line buffer also holds a string representing the number of block last open in Editor, wich is updated when necessary.

Source code

usb node 411 node 312 node 211 node 310 node 311
311 command line
727272 o, 727272 o, 727272 o, 727272 o,
727272 o, 727272 o, 727272 o, 727272 o,
727272 o, 727272 o, 727272 o, 727272 o,
727272 o, 727275 o, 0E 505050 ... o, 717472 o, 10

2D5 org --u/mod 10 org
blk! 10 n @p drop !p ;
blk 11 @p @p b! . 1 , 1D5 right , !b ;
6* 15 2* 2* 2* 2* 2* 2* ;
10/m 17 n-rq push dup dup or pop -10 --u/mod ;
num 1B n-ccc0 10/m 10/m 10/m ;
.blk 1E down a! @ if dup blk! then num E a! drop 6* or 6* or ! left a! ;
.scr 2A begin @b - -while - 5600 pass ! ! @ !b end then
.cl 2F 300 for @b a! @ !b next left a!
mem io b! @b 8000 rw and if r--- else 12011 nav ! then
up b! .scr ; 40

init left a! up b! .scr ; 44

3 d 2 r 0 ether


blk, blk!
This variable keeps the number of block last block open in Editor, to be used by node 410. When blk is executed, its content is sent to RIGHT.
Shift T six bits left, i.e. by one symbol.
Divide n by 10, leave remainder r (least significant digit of the number to string conversion) on stack below the quotient q.
Convert n into character string. Leave individual characters c on stack. Final zero quotient is discarded later in .blk.
Fetch block number from DOWN. If non-zero (i.e. cursor not in command line) keep its copy in blk!. Then convert the number into character string and write it into block number indicator at the end of command line buffer.
Start an endless loop. First, fetch an address form UP. While the address is positive, call pass in 312, write the address LEFT, get back content from that address in block buffer, and send it UP. If value fetched from UP is negative, stop reading block buffer and fall through to .cl.
Run 301 cycles of the following code: Fetch address from UP, read content of that address in command line buffer, and send it back UP. When finished, whole command line buffer has been rendered on screen. Reset A to LEFT and continue in mem.
Test if buffers are being accessed by node 310, and if so, execute from RIGHT. Else call nav in 312 to allow cursor position update if needed. Then jump back to .scr.
Set registers A and B, and jump to .scr.


First 16 words of this node's RAM are reserved for command line buffer. Command line can hold up to 39 symbols (first 13 words). The line is filled with spaces out of reset. Last symbol of word at address 0D is white character tag, and following word at address 0E holds three-character string indicating number of the currently open block. When cursor is in command line it shows block number zero. This is due to the fact that block zero is reserved for storage of command line content in SRAM. During boot up the block number indicator shows ... string. The last word of the buffer contains eol, eob, and space symbols.

After booting up this node, word .scr starts executing. It suspends while reading UP port, where node 411 writes an address pointing to a word in block buffer it wants to read. This address is passed through node 312 to block buffer nodes, and the word read is sent back, and forwarded to node 411. Note that we don't leave word .scr until node 411 sends a flag (negative number) instead of address. The number of words read from block buffer depends on its content. Thus we can't use for next loop, and have to wait for a flag instead. This negative flag indicates that 23 rows have been rendered on screen, and the last to be rendered is command line. Thus, the execution continues to word .cl.

The number of words sent to node 411 by .cl is always 301, i.e. one word from address zero, which is kept in node 411 so it does not need to be retrieved again, plus next 15 words read 20 times, i.e. once for each scan line. After the last scan line has been rendered, node 411 encounters eob symbol, and stops reading data till the end of vertical blanking period.

During that time execution continues to mem. Here we first check if node 310 attempts to write to RIGHT port. If so, we call RIGHT, which effectively hands control over to 310. Node 310 can use it to manipulate content of either of the two buffers or blk variable. Whatever node 310 does, it must not take longer than vertical blanking period, and execution must always end with ; (return) instruction so it may continue past r---. If 310 didn't attempt to write to RIGHT, word nav is called in node 312, which allows cursor position update. Finally, B is set back to UP, we jump to .scr, and wait for 411 to start a new frame.

When node 310 controls execution, it may call word .blk in order to update block number string. This word first fetches a new block number from node 211 via DOWN port, keeps it in variable blk if non-zero, then calls word num. This word divides the block number by 10 three times, keeping each remainder on stack. Since etherforth character set starts with digits, remainders on stack represent corresponding characters. After conversion the three characters are packed into one word, which is stored in RAM at address 0E.