fCPU


Factorio Customizable Processing Unit. Allow to write any logic on low level machine code. The fCPU acts like a programmable microcontroller with a vector coprocessor that supports many useful instructions.

Content
18 days ago
0.18 - 2.0
10.2K
Logistic network Circuit network

a Function with call back

2 years ago
(updated 2 years ago)

;; 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

2 years ago

F.e.

0eNrtXWtv27gS/StcfdkWV/Y1ScmyHRRF4m3QYrvdRZvF4iIJAsWmE+7VaykpaVD4v++Q8iOWTdly4zSJGQSJHiRn5swM5TmS6G/WZZCzRPAos3rfLD6Io9TqnX6zUn4V+YE8lt0lzOpZPGOhZVuRH8q90SDJrbFt8WjIvlo9PD63LRZlPOOs6K927i6iPLxkAhrMeqahHwSNwA8TGC2JU+gSR1IODNPAtN10bevO6pFu04XxQZ9MxMHFJbv2b3gsZMMBF4OcZxdwbjjrPeIizS6WtL7hIsvhyFy8atGQ+jdEHlmFjDTzJQBY7oSJL/xMirLeyNN5ykBUEAswLBM5K3pEbCBFp1IWln8EG943nMMelahcCcai8hkyPh+Px/YSTGSm51SpBih0ySOl0Cq8nEW8hlwUilk9ZzV6Ix5kTGicrIOrMEJZnk+AmnteA8hKw7HGc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