etherforth_logo

Node 214

This code is responsible for expanding compressed data from packet templates in node 215 into byte and token stream passed via node 114 to the transmitter.

Source code

usb node 215 node 114 node 214
214 expander
read 00 a-n @p !b !b @p @p a! @+ dup FF , @p !b !b .
@p and push !p @b @p !b ; begin @+ !p unext .
hi 07 n-b 2/ 2/ 2/ 2/ 2/ 2/ 2/ 2/ ;
lo 0A n-b FF and ;
chunk 0C n dup 30000 and if 30000 or if drop ! ;
then drop 8000 over and if drop push ex ;
then drop lo ! ; then drop dup hi ! lo ! ;
send 1D @ read dup hi ! lo for @b chunk next send ;
eop 24 20000 ! 12016 clr ! 20003 ! ;
eop@ 29 eop 20033 ! ;
crc@ 2C 20000 ! 1001C crc! ! 20003 ! 20033 ! ; 33

init up a! right b! send ; 37

4 d 5 r 0 ether

Definitions

read
Execute yellow code in RIGHT of 215. Take address of template in T, initiate its expansion and streaming back. First number returned is number of words to be expected.
hi, lo
Return high and low byte from number in T.
chunk
Take word in T and send RIGHT bytes/tokens encoded into this word. It uses push ex to call code encoded in 380cc format.
send
Get address of a template from 114, return number of bytes/tokens back to 114 and then the stream of bytes/tokens expanded from the template. When done, repeat.
eop
Restart CRC16 calculator jumping to clr in 115 and executing eop in node 216.
eop@
Same as eop plus execute rx in 216, i.e. switch 217 to receiver.
crc@
Stop CRC16 calculator in 115, jump to crc! and transmit the calculated CRC16, which also restarts CRC16 calculation, then execute rx in 217.
init
Set registers A and B, and jump to send.

Description

This node reads a word from UP, which is address of a template in node 215. It then request the template, extracts count (number of bytes and/or tokens contained in the template less one), and sends it and extracted individual bytes/tokens as a stream back to node 115.