WORM Solution
THE EXCHANGE
WORM row 10

Prerequisites
Unlocks
w50 solved
Active cores0, 1, 2, 3, 4, 6, 7
Program lines48
DetailWORM row 10
Walkthrough
THE EXCHANGE: opcode-routed transforms over frames of 3 with a checksum
trailer. A on core 0, B (opcode) on core 1; output on core 8.
card 1: per frame read opcode B[k], discard B[k+1]/B[k+2], and feed the JRX
distance 2*op+1 leftward to card 0 three times (one per A).
card 0: per A, JRX RIGHT lands on the matching one-op transform
(+1/-1/double/zero) and sends the result DOWN to card 4.
card 4: forwards each transformed value DOWN (to card 8) and RIGHT (to the
summer card 5); after three, relays the checksum DOWN too.
card 5: sums the three transformed values, reduces (((s%100)+100)%100), and
hands the trailer back LEFT.
card 8: writes the assembled stream to output.
Rack Solution
# THE EXCHANGE: opcode-routed transforms over frames of 3 with a checksum
# trailer. A on core 0, B (opcode) on core 1; output on core 8.
#
# card 1: per frame read opcode B[k], discard B[k+1]/B[k+2], and feed the JRX
# distance 2*op+1 leftward to card 0 three times (one per A).
# card 0: per A, JRX RIGHT lands on the matching one-op transform
# (+1/-1/double/zero) and sends the result DOWN to card 4.
# card 4: forwards each transformed value DOWN (to card 8) and RIGHT (to the
# summer card 5); after three, relays the checksum DOWN too.
# card 5: sums the three transformed values, reduces (((s%100)+100)%100), and
# hands the trailer back LEFT.
# card 8: writes the assembled stream to output.
@0
MOV ACC, UP
JRX RIGHT
ADD 1
JMP S
SUB 1
JMP S
ADD ACC
JMP S
SUB ACC
S: MOV DOWN, ACC
@1
F: MOV ACC, RIGHT
ADD ACC
ADD 1
MOV LEFT, ACC
MOV LEFT, ACC
MOV LEFT, ACC
MOV NIL, RIGHT
MOV NIL, RIGHT
JMP F
@3
MOV ACC, UP
MOV RIGHT, ACC
MOV DOWN, ACC
MOV ACC, UP
MOV RIGHT, ACC
MOV DOWN, ACC
MOV ACC, UP
MOV RIGHT, ACC
MOV DOWN, ACC
MOV DOWN, RIGHT
@4
G: MOV ACC, LEFT
ADD LEFT
ADD LEFT
M: JL D
SUB 100
JMP M
D: ADD 100
MOV LEFT, ACC
JMP G
@6
MOV RIGHT, UP
@2
MOV LEFT, UP
@7
MOV DOWN, LEFT