Syscall 2: Firmware, home

SignalChapter 5: Half duplex

31INTERCOM

The task

P on the left must receive X plus Y. Q on the right must receive Y minus X.

One wire joins the two cores, and only one end can write to it at a time.

The board

The board of INTERCOM2 cores: left and right. Inputs X and Y; outputs P and Q.leftSC-2 8 LINESrightSC-2 15 LINESP0P1P2P0P1P2XYPQ
The board as the puzzle screen lays it out. Cyan pins read, lemon pins write, violet pins go both ways. On a narrow screen, scroll the board sideways to see all of it.

Key idea

Both ends need both values; one speaks first and the reply carries a worked out value.

Hints

Each hint goes a step further than the one before. Open them one at a time.

Hint 1Show

If both ends write at once it is a HEAD ON, so let one end speak first.

Hint 2Show

What you send back can be something you worked out, not just what you read.

Hint 3Show

A core that knows one value and the sum can work out the difference.

Solution

Reveal the Full SolutionThe complete program for INTERCOM. Open it only when you want the answer.

The reference program

The game's own solution. It passes every test and scores exactly par on every benchmark.

rightSC-2 standard

IN P0
OUT P1
ADD A
MOV B, A
IN P1
SUB B
NEG
OUT P2

leftSC-2 standard

IN P1
MOV B, A
IN P0
ADD B
OUT P2
OUT P1
CYCLES
547
at par
ENERGY
3276
at par
NODES
2
at par
INSTRUCTIONS
14
at par

Another way: Left first

A second program that also passes, and matches par on every benchmark.

With the left core speaking first; it gets back Y minus X and works out X plus Y from that.

leftSC-2 standard

IN P0
OUT P1
ADD A
MOV B, A
IN P1
ADD B
OUT P2

rightSC-2 standard

IN P1
NEG
MOV B, A
IN P0
ADD B
OUT P2
OUT P1
CYCLES
547
at par
ENERGY
3276
at par
NODES
2
at par
INSTRUCTIONS
14
at par