Twenty four more sites, and the interesting part is which ones were left alone. A rule emerged while reading them and it held all the way through: apply where the repetition is INSIDE one operation, skip where the author's own structure says it is a new thought, and never where two equal values mean different things. Taken: - Five registers reassigned to a value they already held, where both are the same quantity: two masks in one expression in Snake, two spaces printed by the monitor, both halves of block zero in waitTest, and a RSTA in Pour that the very next instruction overwrote. - Eighteen SETDs that reload a pointer inside one operation - a store back into the variable just read, or an INCD stepping to the second byte of a two byte value. Those read correctly without the reload. - sbfsNext, which branched to the label on the line below it. Left, with reasons that are the useful part of this: - Eight registers where the same number means two different things. CosmOS and the loader set A to 1 for a blit command and then to 1 again for a bank number; Asm compares a type against 3 and then a status against 3. Removing those couples one quantity to another that is equal by accident and would part company silently. - Ten RSTAs that open the RSTA/RSTB/CCF/ADD "return zero" block. The redundancy is what makes that idiom self contained; taking it out makes the return value depend on the line above. - Eleven SETDs that begin an arm of a comparison chain. Each arm loads, compares and branches, and they get reordered - the repetition is the reason a new arm can be dropped in anywhere. - Twenty five SETDs separated from their pointer by a blank line or a comment, which is the author saying a new thought starts here. - Two CCFs before arithmetic, which this codebase writes unconditionally. - Three redundant branches in test programs whose recorded output includes addresses, where three fewer bytes moves what the test demonstrates. Nine recorded outputs moved and every one is a size in a listing or, for Life, five more generations inside the same cycle budget. Behaviour is unchanged everywhere: cosmosSnake and cosmosEdit pass byte for byte while Snake loses eight bytes and Edit twelve. CosmOS is 10,902 bytes of program against 10,937, and the native assembler 12,173 against 12,183. The CosmOS README's size for Edit moved twice in one sitting, and this morning's check caught it both times - which it could not have done before that claim was reworded to name what it was about.
59 lines
1.5 KiB
NASM
59 lines
1.5 KiB
NASM
; waitTest.asm
|
|
; WAIT, on a disk slow enough to be worth waiting for.
|
|
;
|
|
; Two reads, waited for rather than spun on, with INTERRUPTS MASKED and no handler
|
|
; installed anywhere. That is the shape this instruction exists for: a program sleeps on a
|
|
; device it has no handler for and reads the device's status when it wakes.
|
|
;
|
|
; THE SECOND READ IS THE TEST. A line that wakes the CPU without being dispatched has to
|
|
; be taken down by the WAIT itself; left standing, it is found by the next WAIT, which
|
|
; returns at once, and the program spins for the whole of the second read while looking
|
|
; exactly as though it slept. Both reads print, so a hang fails here - but a program that
|
|
; spun would print the same two characters, and what tells them apart is the emulator's
|
|
; count of idle cycles against bus cycles. Tests/terminal.sh is where that is checked,
|
|
; because settle() strips cycle counts out of every recorded output including this one.
|
|
;
|
|
; Written by Anachronaut
|
|
|
|
#Program
|
|
start:
|
|
CIF
|
|
INIA 0d3
|
|
OUTA 0xE3
|
|
INIA 0x20
|
|
OUTA 0xE2
|
|
INIA 0x03
|
|
OUTA 0xE8
|
|
RSTA
|
|
OUTA 0x20
|
|
OUTA 0x21
|
|
INIA 0x01
|
|
OUTA 0x22
|
|
CALL waitDisk
|
|
INIA 0x31 ; "1"
|
|
OUTA 0x00
|
|
RSTA
|
|
OUTA 0x20
|
|
INIA 0x01
|
|
OUTA 0x21 ; Block 1, a different one.
|
|
INIA 0x01
|
|
OUTA 0x22
|
|
CALL waitDisk
|
|
INIA 0x32 ; "2"
|
|
OUTA 0x00
|
|
INIA 0x0A
|
|
OUTA 0x00
|
|
HALT
|
|
|
|
waitDisk:
|
|
INA 0x23
|
|
INIB 0x01
|
|
AND
|
|
BRQ waitDone
|
|
WAIT
|
|
BRI waitDisk
|
|
waitDone:
|
|
RET
|
|
#Vectors
|
|
Boot start
|