Syscall 2: Firmware, home

DriverChapter 6: Trees

D14NIBBLES

The task

Split each received byte. Transmit the high four bits, then the low four bits.

Split each received byte. Transmit the high four bits, then the low four bits.

The board

The line card of NIBBLESThe line card: registers A B, 10 lines of ROM, no RAM, a 16 byte receive buffer, a stack 8 deep. It talks to the line.LINETHE FAR ENDRXTXCARDREGISTERSA BROM10 LINESRAMNONERX BUFFER16 BYTESSTACK8 DEEPUNITSNONE
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 nibble is four bits. $3C splits into $03 then $0C.

Hints

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

Hint 1Show

MOV B, A keeps the whole byte. SHR A, 4 slides the high half down to the low end.

Hint 2Show

AND A, $0F keeps four bits. The saved copy in B still holds the low half.

Hint 3Show

IN A, MOV B, A, SHR A, 4, AND A, $0F, OUT A, AND B, $0F, OUT B.

Solution

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

        IN A
        MOV B, A
        SHR A, 4
        AND A, $0F
        OUT A
        AND B, $0F
        OUT B
TICKS
33
at par
LINES
7
at par