Syscall 2: Firmware, home

DriverChapter 10: Meshes

D35BUSY SIGNAL

The task

Ask with $05 until the far end answers $06, then transmit the record and $04.

Head office takes one sale record at a time and is often busy. Before each record, the ticket office asks whether it is ready by transmitting ENQ, $05.

The far end answers $06 when it is ready, or $15 when it is busy. On $15, transmit $05 again and wait for the next answer. On $06, transmit the record, then EOT, $04.

The host hands over one record per message, never empty. Ask only when you hold a record: take its first byte from the host before you transmit $05.

The board

The line card of BUSY SIGNALThe line card: registers A B, 12 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 ENDRXTXCARDREGISTERSA BROM12 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

The far end can stay busy for several questions in a row. Ask as often as it takes.

Hints

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

Hint 1Show

Each answer comes only after a question, so after every $05 wait with IN for the answer before doing anything else.

Hint 2Show

Hold the first byte of the record in B while you ask. Once the answer is $06, transmit B and then the rest of the message as it comes from the host.

Hint 3Show

TOP: HIN B. ASK: OUT $05, IN A, JEQ A, $15, ASK. SEND: OUT B, HIN B, JNE B, -1, SEND, OUT $04.

Solution

Reveal the Full SolutionThe complete program for BUSY SIGNAL. 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:    HIN B
ASK:    OUT $05
        IN A
        JEQ A, $15, ASK
SEND:   OUT B
        HIN B
        JNE B, -1, SEND
        OUT $04
TICKS
393
at par
LINES
8
at par