; diskLineTest.asm ; A device's line comes down when its status port is read. ; Written by Anachronaut ; ; ---- The idiom with the race in it ---- ; ; This is the shape the manual gives for waiting on a device, and it has a hole. It reads the ; status, branches out if the device has already finished, and only WAITs otherwise. On a disk ; fast enough to finish before the first look - which is every disk here - the WAIT is never ; reached, and WAIT was the only thing that took the line down for a program with no handler. ; ; The line then stood for the rest of the machine's life. Nothing else was going to answer it: ; the program is masked and has nowhere to dispatch to. So the next program to set the ; Interrupt Flag was interrupted on behalf of a read that finished before it was loaded, and ; faulted on the instruction after the SIF. ; ; That is not a story about the disk. It is what happens to any program CosmOS loads, because ; the boot chain reads the disk to load it. Playing Examples/tune.asm through Once is how it ; was found: the program set its whole patch up and died four bytes before its first note. ; ; So reading the status takes the line down, the same way taking the byte takes the console's ; down. This program is the check on that: read the disk without ever waiting, then let ; interrupts in with no handler installed anywhere. If a line were standing, SIF would find it ; and there would be nothing to catch it. #Program start: ; Block 0, read. RSTA OUTA 0x20 OUTA 0x21 INIA 0x01 OUTA 0x22 waitDisk: INA 0x23 INIB 0x01 AND BRQ readDone ; Already finished, so the WAIT below never runs. WAIT BRI waitDisk readDone: ; No handler is installed for anything, and none is installed below either. This is the ; instruction the fault used to land on. SIF INIA 0d110 OUTA 0x00 INIA 0d111 OUTA 0x00 INIA 0d32 OUTA 0x00 INIA 0d108 OUTA 0x00 INIA 0d105 OUTA 0x00 INIA 0d110 OUTA 0x00 INIA 0d101 OUTA 0x00 INIA 0d10 OUTA 0x00 HALT #Vectors Boot start