; 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