Node 413

This node, together with node 414, converts tokens into character strings.

Source code

usb node 414 node 412 node 413
413 tokens
!s 00 w 3F and dup !b if drop ; then pop ;
syms 05 w dup 2/ 2/ 2/ 2/ 2/ 2/
dup 2/ 2/ 2/ 2/ 2/ 2/ !s !s !s syms ;
tok 0E @b 2* 1A table + dup a! 40 and if
a left a! ! then @+ @ over syms tok ; 19

table 1A org
; 520000 o, 0 o, ex 164100 o, 0 o,
end 162715 o, 0 o, begin 131620 o, 222700 o,
unext 362716 o, 413500 o, next 271641 o, 350000 o,
if 221700 o, 0 o, -if 552217 o, 0 o,
@p 463100 o, 0 o, @+ 465700 o, 0 o,
@b 461300 o, 0 o, @ 460000 o, 0 o,
!p 473100 o, 0 o, !+ 475700 o, 0 o,
!b 471300 o, 0 o, ! 470000 o, 0 o,
+* 574400 o, 0 o, 2* 24400 o, 0 o,
2/ 24500 o, 0 o, 40

init right b! tok ; 43

2 d 4 r 0 ether


Get character from word w in bits 0-5 by masking other bits off, send it to node 412, and return from the caller (i.e. back to tok) if character code just sent is 00. Otherwise return back.
Extract three symbols from word w and send them with !s to RIGHT, then jump back to syms. Leave the word after sending code 00.
Fetch code of a token, double the code value and add an offset 1A to get address in the table. If the address is greater than 3F, send it to LEFT. Then fetch two words with token string, either from LEFT or from RAM, extract symbols and send them back to RIGHT with word syms. Then jump back to tok.
Set register B, and jump to tok.


This node expects a token from node 412, finds corresponding string in its own or in adjacent node's RAM, and sends the string character by character back. It ends when it finds character code 00, corresponding to digit 0. Since no token contains any digit, we can use it that way. Each string occupies two words so it can be at most five 6-bit characters long; the last position being reserved for 0.

Code in this node is relatively simple. The node continuously runs word tok. It calculates position of a string from value of the token received. If it is outside of its own RAM, it sends it to node 414. Register A is set either to the position of the string in RAM or to LEFT port. Thus, we read from where A points to, extract characters until we reach zero, and send them back to node 412.