etherforth_logo

Node 107

This node receives requests from other modules to read from/write to blocks stored in SRAM. With Async link module we can also fill SRAM with source blocks from a PC. This node also assists Utilities module to write text into block 001.

Source code

sram node 106 node 108 node 107
107 ether to/from sram
9/8 00 n-n' dup 2/ 1FFFF and 2/ 2/ . + ;
block 04 n 2* 2* 2* 2* 2* 2* 2* 2* 9/8 a ! ;
words 08 @b c dup 8 . + -8 and -1 . + dup ! @b
block over push .. zif then begin @b ! unext
fill - . + - 1 . + push zif r--u ;
then begin dup ! unext r--u ;
write 1A n a ! 562A +write ! 255 ! block
127 for @b ! unext @b foc
127 for @b ! unext r--u ; 26
2F org
head 2F @b p a ! 562A +write ! dup or words ;
read 33 n a ! 5616 +read ! 255 ! block
255 for @ !b unext r--u ; 3C

init 1C5 r--u b! left a! r--u ; 41

1 l 4 d 0 ether

Definitions

9/8
Multiplie n by 9/8, which converts number of 18-bit words n to number of 16-bit words n'.
block
From block number n calculate its starting address in 16-bit wide SRAM.
words
.
write
.
head
Remove focus, call, and path from incoming ether message. Then send focus call to 108, and instruction word @p +write, set T zero for filling non-justified 8-tuplets. Now read number of words in payload (cnt) from ether, keep its copy on stack, round up to multiple of 8 (less one since we use it as a loop parameter), and send to 108 (this is c in word +write). Keep this loop parameter on stack as cnt8 so the stack looks like this: 0 cnt cnt8. Now read destination block (first word of payload), multiply by 256 (this is max number of 18-bit words we can store in one block), multiply by 9/8 so we get number or 16-bit words, and this address in SRAM is passed by node 108 to node 8, where it is used in word ad (called by write, which is called by +write). Now start reading data words and send them to 108. Push cnt on return stack, use zif to decrement it so we can use begin unext loop (keep in mind that cnt starts from one; we need to do -1 . + but since the value is on return stack it's faster and shorter to use zif then). When all data words have been transfered to SRAM, we have to fill up the last 8-tuplets (data from PC are not rounded up to 8-tuplets). Calculate filling words as cnt8 - cnt8 + 1 (- . + - 1 . +). If the result is zero we skip filling with zif and jump to head. Else we fill the last 8-tuplet with zero that has been prepared on stack at the end of word head and jump back to head.
read
Read one block.
init
Set A and B, and jump back to RIGHT and UP.

Description