Syscall 2: Firmware, home

DriverChapter 4: Stars and hubs

D6SIGN WRITER

The task

Deliver printable bytes in capitals; drop the rest.

The sign has only capital letters and no control characters; anything else garbles the display.

Deliver received bytes to the host with two changes. Drop every byte below $20 or above $7E. Change the lowercase letters a to z into the capitals A to Z, which are 32 lower.

The board

The line card of SIGN WRITERThe line card: registers A, 10 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 ENDRXTXCARDREGISTERSAROM10 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 character in single quotes, such as 'a', is its code. JLT and JGT compare signed numbers, but every byte from the line is between 0 and 255, so that does not matter here.

Hints

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

Hint 1Show

Use JLT A, $20, TOP and JGT A, $7E, TOP to throw out bytes that are out of range.

Hint 2Show

A letter is lowercase when it is not below 'a' and not above 'z'. Subtract 32 from those.

Hint 3Show

After the range checks: JLT A, 'a', PASS and JGT A, 'z', PASS skip the subtraction, then SUB A, 32, then PASS: HOUT A.

Solution

Reveal the Full SolutionThe complete program for SIGN WRITER. 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
        JLT A, $20, TOP
        JGT A, $7E, TOP
        JLT A, 'a', PASS
        JGT A, 'z', PASS
        SUB A, 32
PASS:   HOUT A
TICKS
250
at par
LINES
7
at par