Syscall 2: Firmware, home

DriverChapter 4: Stars and hubs

D3UPLINK

The task

Transmit each host message, then $0D $0A.

The order terminal is the host: it hands the card one message at a time.

HIN reads the next byte of the current message. When the message has ended, HIN gives -1 instead of a byte, and the next HIN starts on the following message.

Transmit each message, then the end of line pair $0D $0A.

The board

The line card of UPLINKThe line card: registers A, 8 lines of ROM, no RAM, a 16 byte receive buffer, a stack 8 deep. It talks to the line and to a host.LINENO PEERRXTXCARDREGISTERSAROM8 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

JEQ A, -1, EOL jumps to EOL when A holds -1. Labels end with a colon.

Hints

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

Hint 1Show

Read a byte with HIN. If it is -1, the message is over; otherwise transmit it and read the next.

Hint 2Show

Use a label at the top of the read loop and another where the line ending is sent. JEQ A, -1, EOL goes to EOL at the end of a message.

Hint 3Show

LOOP: HIN A, JEQ A, -1, EOL, OUT A, JMP LOOP, then EOL: OUT $0D, OUT $0A. The card wraps back to LOOP by itself.

Solution

Reveal the Full SolutionThe complete program for UPLINK. 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.

LOOP:   HIN A
        JEQ A, -1, EOL
        OUT A
        JMP LOOP
EOL:    OUT $0D
        OUT $0A
TICKS
114
at par
LINES
6
at par