WORM Solution

PAIR SORT

WORM row 8

In-game screenshot of PAIR SORT
In-game view
FamilyWORM Graph0.723 Difficulty0.723 Ring04 IDw38

Prerequisites

Keystream

Unlocks

ROR SPARK

Reference rack program w38 solved
Active cores1, 4, 7 Program lines23 DetailWORM row 8

Walkthrough

PAIR SORT: frames of 2 emitted (low, high). 13 in -> 6 pairs -> 12 outs.

Pipelined compare-route across three cores down column 0:

core0 (feeder): per pair sends v0, then v1 twice: one sacrificial v1 for the

compare and one surviving v1; v0 is preserved by core4 in BAK.

core4 (compare): reads v0 (SAV), subtracts the sacrificial v1 to get the sign

d=v0-v1, then forwards d, the held v0, and the surviving v1 down to core8.

core8 (route+out): reads d; if d>0 (v0>v1) emit v1 then v0, else emit v0 then v1.

The lone 13th input has no partner; the 12 outs land before core0 blocks on the

absent 14th read, so the run completes (no deadlock).

Rack Solution
# PAIR SORT: frames of 2 emitted (low, high). 13 in -> 6 pairs -> 12 outs.
# Pipelined compare-route across three cores down column 0:
#   core0 (feeder): per pair sends v0, then v1 twice: one sacrificial v1 for the
#     compare and one surviving v1; v0 is preserved by core4 in BAK.
#   core4 (compare): reads v0 (SAV), subtracts the sacrificial v1 to get the sign
#     d=v0-v1, then forwards d, the held v0, and the surviving v1 down to core8.
#   core8 (route+out): reads d; if d>0 (v0>v1) emit v1 then v0, else emit v0 then v1.
# The lone 13th input has no partner; the 12 outs land before core0 blocks on the
# absent 14th read, so the run completes (no deadlock).
@1
L: MOV ACC, UP
MOV DOWN, ACC
MOV ACC, UP
MOV DOWN, ACC
MOV DOWN, ACC
@4
L: MOV ACC, UP
SAV
SUB UP
MOV DOWN, ACC
XCH
MOV DOWN, ACC
MOV DOWN, UP
@7
S: MOV ACC, UP
JG GT
MOV DOWN, UP
MOV DOWN, UP
JMP S
GT: MOV ACC, UP
MOV DOWN, UP
MOV DOWN, ACC