;; v0.3 Супер пупер кру-то-та[ru]
;; mem3[vsB, ...] new_function(mem1[vsC, vsB, ...])
;; The function accepts an array via the red wire,
;; and sends a response via it
;; Required at the entrance vsC,vsB if it's not main()
;; Returns an array containing [vsB,...]
;; Connect all functions with a red wire
;; Yes, and inputs and outputs
;; !WITH looping
clr
emit m4 ???[virtual-signal=signal-C] ; Set a unique address, f.e. 8[virtual-signal=signal-C]
;; for the function here
fid r7 m4 [virtual-signal=signal-C] ; For the first call
;; If you wain main()
;; comment this line,
;; and "jmp :BOUT"
jmp :CALL ; Waiting for a call
:START
;; Paste your code here... =)
;; Dont cng: mem1,mem4,r7,r8 (if u d't knw wt u do)
;; reg6 for calling funcs
;; and filters, use with caution
;; Now to call the function is always used mem3
;; How to call another function:
;emit m3 2[virtual-signal=signal-C]
;emit m3 123456[item=iron-plate]
;mov r6 ipt
;jmp :COUT
;; !We always get mem3 already WITHOUT [virtual-signal=signal-B] if COUT
;; !but always get mem1 already WITHOUT [virtual-signal=signal-C][virtual-signal=signal-B] if CALL
;; For put in answer:
;emit [R/CT]
;; or
;xmove [M]
;; !Signal [vsB] adding automatically
;; For filter from vsB mem3
;mov r6 ipt
;jmp :FILTERm3m3
jmp :BOUT
;xmov out m??? ; m2 or m3
;slp ???
;clr out
jmp :END
;-----------------------------------------------------
:COUT ; Calling another function
fid r7 m4 [virtual-signal=signal-C]
sst r7 [virtual-signal=signal-B]
emit m3 r7
xmov out m3
slp 4
clr out
clr m3
fid r7 m4 [virtual-signal=signal-C]
:BACK ; Waiting for a response
mov r8 0[virtual-signal=signal-B]
btrc r8
bne r8 r7 :BACK
xmov m3 red
clr m4
fid r1 m3 [virtual-signal=signal-B]
mul r1 -1
emit m4 r1
xuni m3 m3 m4
clr m4
emit m4 r7
jmp r6 2
;-----------------------------------------------------
:BOUT ; Answer
fid r7 m1 [virtual-signal=signal-B]
emit m2 r7
xmov out m2
slp 4
clr out
clr m3
clr m2
clr m1
fid r7 m4 [virtual-signal=signal-C]
:CALL ; Waiting for a call
mov r8 0[virtual-signal=signal-C]
btrc r8
bne r8 r7 :CALL
xmov m1 red
fid r1 m1 [virtual-signal=signal-C]
mul r1 -1
emit m2 r1
fid r2 m1 [virtual-signal=signal-B]
mul r2 -1
emit m2 r2
xuni m2 m1 m2
jmp :START ; Start programmmm)
;-----------------------------------------------------
:FILTERm1m2
fid r1 m1 [virtual-signal=signal-C]
mul r1 -1
emit m2 r1
fid r2 m1 [virtual-signal=signal-B]
mul r2 -1
emit m2 r2
xuni m2 m1 m2
jmp r6 2
;-----------------------------------------------------
:FILTERm3m3
clr m4
fid r7 m4 [virtual-signal=signal-C]
fid r1 m3 [virtual-signal=signal-C]
mul r1 -1
emit m4 r1
fid r2 m3 [virtual-signal=signal-B]
mul r2 -1
emit m4 r2
xuni m3 m3 m4
clr m4
emit m4 r7
jmp r6 2
;-----------------------------------------------------
:END