Syscall 2: Firmware, home

DriverChapter 4: Stars and hubs

D4DOWNLINK

The task

Deliver received bytes to the host, except $0D.

The sign expects each line to end with $0A alone; the dispatch system ends lines with $0D $0A, and the sign prints the $0D as a box.

Deliver every received byte to the sign controller, which is the host, except $0D. HOUT delivers the low byte of a register to the host.

The board

The line card of DOWNLINKThe line card: registers A, 4 lines of ROM, no RAM, a 16 byte receive buffer, a stack 8 deep. It talks to the line and to a host.LINETHE FAR ENDRXTXCARDREGISTERSAROM4 LINESRAMNONERX BUFFER16 BYTESSTACK8 DEEPUNITSNONEHOSTMESSAGES
The line card this ticket gives you, with its registers, memory, buffers, and units. On a narrow screen, scroll the board sideways to see all of it.

Key idea

A jump can skip instructions as well as repeat them: jumping back to the top passes over everything below the jump.

Hints

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

Hint 1Show

Receive a byte. If it is $0D, go back and receive the next one without delivering it.

Hint 2Show

JEQ A, $0D, TOP sends the card back to the top when A holds $0D.

Hint 3Show

TOP: IN A, then JEQ A, $0D, TOP, then HOUT A.

Solution

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

The reference program

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

TOP:    IN A
        JEQ A, $0D, TOP
        HOUT A
TICKS
114
at par
LINES
3
at par