etherforth_logo

Node 210

In this node we prepare parameters for editing functions performed in node 309. Current cursor position in block is expressed as sequence number n (starting from zero and incremented for each symbol). Length of the currently edited word is expressed as index i, which is incremented by ins, and decremented by bsp.

Source code

usb node 211 node 110 node 209 node 210
210 edit
2D5 org --u/mod 0 org
fill 00 a 5600 fill !b !b . . ;
seq 03 p-n dup 2/ 2/ dup 2* . + push 3 and pop . + ;
ptr 08 n-p push dup dup or pop -3 --u/mod 2* 2* . + ;
aim 0E -ni 1202C ptr ! @ seq dup dup or ;
adr 12 -a 12000 blk ! 12003 288* !
get 16 @p ! @ ; !p ..
ins 18 nic-ni' 5604 ins !b !b over over . + !b 1 . + adr !b
flush 1F adr 5602 flush !b !b ;
upd 22 ni-n'0 + . dup ptr right a! 5616 upd ! ! dup dup or ;
bsp 29 ni-ni' if over over . + -1 . +
5609 bsp !b !b adr !b -1 . + flush then ;
del 34 nx 560E del !b !b !b adr !b flush ;
start 38 @b ! right a! rl-u ;
bk' 3C -n 12034 bk' ! get ; 3F

init up a! left b! dup or dup start ; 44

4 d 1 r 0 ether

Definitions

fill
Pass address a and call fill in 209.
seq
Calculate sequence number n from pointer p.
ptr
Calculate pointer p from sequence number n.
aim
Read current pointer from 110, convert it to sequence number, and push zero in T as current index.
adr
Return address a in SRAM of the current block.
get
Get T from 211.
ins
Insert character c at sequence number n and increment index i by calling ins in 309 via 209.
flush
Write current block content back to SRAM by calling flush in 209.
upd
Add index i to the current sequence number n, convert the sum to a pointer, send it to 110 and call upd there. A new sequence number n' is left in S and zero is pushed in T as a new index.
bsp
Remove one character at sequence number n+i by calling bsp in 309 via 209, and leave decremented i' on stack.
del
Delete x characters starting from sequence number n by calling del in 309 via 209.
start
Wait for signal from 209, set A to RIGHT and jump to RIGHT and UP.
bk'
.
init
Set registers A and B, prepare initial n and i (both zero) on stack and jump to start.

Description