Files
SplitBit-Emulator/Programs/testPrograms/registryTest.asm
T
Anachronaut e1273337c4 Two mechanical fixes SplitLint found: MVQA, and RSTA for zero
Twenty four places moved Q into A or B by pushing it and popping it back.
That is four bus cycles and two bytes to do what MVQA does in one of each,
and several of them are inside loops - Life, the calculator, int8. Nineteen
more loaded zero with INIA 0d0 where RSTA says the same thing in one byte.

Both are equivalent at the CPU rather than by assertion: RSTA and INIA both
leave Status alone, and PSHQ followed by POPA nets to A = Q with the Stack
Pointer where it started. The one difference is that the pair leaves a copy
of Q in memory just below the Stack Pointer and MVQA does not, which
nothing here reads.

Five recorded outputs moved and every one of them says the change worked:

- 16x16Life fits five more generations into the same cycle budget, the
  first 457 lines identical, because the loop got cheaper.
- Life.sbx is 1409 bytes rather than 1411, in three tests that list it.
- Edit.sbx is 1995 rather than 1996.

That last one broke a check I added this morning, and the hole is worth
recording: the CosmOS README's claim about Edit's size did not have the
word "Edit" on the same line as the number, because the subject was in the
sentence before, so the check that measures quoted sizes skipped it
silently. The sentence now names what it is talking about, which makes it
both checkable and clearer, and the check fails on a wrong number there.

Comments on either half of a replaced pair are carried onto the
instruction that replaces them, so nothing anybody wrote was lost.
2026-08-26 17:53:10 -04:00

51 lines
1.4 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 0x05 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.
;
; 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 0x05
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