Files
SplitBit-Emulator/Programs/testPrograms/registryTest.asm
T
AnachronautandClaude Opus 5 43a05b3df1 Replace the escape parser with cursor registers
The console had grown an ANSI parser, and that was the wrong shape. ANSI exists because a
screen used to be on the other end of a serial line and a byte stream was the only channel
there was. This screen is memory the program can already address, so reaching it by sending
characters for a state machine to take apart is a middleman for something the machine does
better - and it meant accepting an open protocol somebody else defines, in hardware, with no
natural end to it. Everything else on this machine is registers.

So the console gets three: cursor row at 0x03, cursor column at 0x04, and a command port at
0x05 where 1 clears the screen. Both cursor registers are READ as well as written, which is
the thing an escape cannot do without sending a query and parsing a reply - a routine that
wants to put the cursor back where it found it can now ask.

Clearing is one command against a thousand cells walked one at a time. Snake and Life are
smaller for it: 2,168 bytes to 2,163 and 1,410 to 1,396.

A HOST TERMINAL STILL SPEAKS ANSI, and bridging to the host is the emulator's job, the same
job it does reading standard input. So the escapes are now GENERATED, outbound, for the set
this device chooses, rather than parsed inbound as though the machine were a terminal. The
set cannot grow behind our backs because we are the ones saying it. The cursor is announced
lazily, at the next character rather than at the register write, so setting a row and a
column costs one sequence rather than two.

The console's block widens from three ports to six, which registryTest noticed: it had been
asking about port 0x05 precisely BECAUSE nothing was there, and the console had just moved
in. Re-blessing it would have left it checking nothing, so it asks about 0x80 instead -
clear of the console, the disk, the screen, the controller, and the sound device coming to
0x40.

Six checks in Tests/video.sh swapped from the sequences to the registers, including that the
cursor reads back and that one sent past the edge is clamped rather than refusing. Those
checks also stopped counting bytes from the ends of a file, which had quietly started
measuring an escape the moment the console began announcing the cursor.

SplitLint caught the one thing worth catching in the port: the clear command leaves A at 1
and key mode is also 1, so the second load looks redundant. Acting on it would tie a console
command to a console mode by coincidence, and break silently if either ever moved, so it is
suppressed with that reason rather than removed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
2026-08-28 23:08:52 -04:00

56 lines
1.7 KiB
NASM

; Asks the bus registry what this machine is made of.
;
; Writing a port number to the registry selects the port being asked about. Reading
; gives that port's record a byte at a time: its device class, then its flags, then
; zeroes once the record has run out. Nothing here touches the device being asked
; about, which is the whole point: reading port 0x00 to find out what it is would take
; a character off standard input and wait for one that never comes.
;
; Port 0x80 has nothing on it, and reads as class 0. That is the same answer a machine
; with no registry at all would give, so software finds out whether it can enumerate by
; enumerating.
;
; It used to ask about 0x05, until the console grew cursor registers and took it. The empty
; port has to be one nothing is likely to want: 0x80 is clear of the console below it, the
; disk and the screen, the memory controller at the top, and the sound device that is coming
; to 0x40.
;
; Correct output is:
; 00 02 00 the console, class 2, no flags
; 10 10 00 the test device, class 0x10, no flags
; FF 01 00 the registry itself, class 1, no flags
; 05 00 00 nothing there
#Include print.asm
#Program
start:
RSTA
CALL reportPort
INIA 0x10
CALL reportPort
INIA 0xFF
CALL reportPort
INIA 0x80
CALL reportPort
HALT
; Prints the port number, then the two bytes of its record. A is the port to ask about.
reportPort:
PSHA
CALL printByteHex ; The port we are asking about.
CALL blankSpace
POPA
OUTA 0xFF ; Select it. This is the only write the registry accepts.
INA 0xFF ; The device class.
CALL printByteHex
CALL blankSpace
INA 0xFF ; The flags.
CALL printByteHex
CALL lineFeed
RET