.TITLE DXREAD read sector .IDENT /01/ .LIST ME .ENABL REG ; ; DXREAD reads a sector from a RX01 floppy. It is designed to be run ; standalone, without the assistance of an operating system. ; Input: R0 - drive number (bit 0) ; R1 - logical block number (0 - 2001) ; R2 - address of output buffer ; Output: contents of logical block in ouptut buffer ; Error: carry flag set iff logical block number illegal, other errors ; cause DXREAD to be restarted (unlimited retry) ; Linkage: PC ; affects no registers ; ; 15-JUL-2004 H. Rosenfeld ; RXCS=177170 ; RX11 command & status register RXDB=177172 ; RX11 data buffer register RXTA=RXDB ; RX11 track address register RXSA=RXDB ; RX11 sector address register RXES=RXDB ; RX11 error status register DRVSEL=177776 ; low bit drive select EMPTYB=000003 ; empty buffer & go RDSECT=000007 ; read sector & go INIT=040000 ; init bit DONE=000040 ; done bit DXREAD::MOV R0,-(SP) MOV R1,-(SP) MOV R2,-(SP) MOV R3,-(SP) MOV R4,-(SP) MOV R5,-(SP) BIC #DRVSEL,R0 ; drive select ASL R0 ASL R0 ASL R0 ASL R0 ; drive select is bit 4 of RXCS MOV R1,R5 CLR R4 DIV #32,R4 ; R4 = track, R5 = sector INC R5 ; sector range is 1 to 26 CMP #114,R4 BMI SECERR ; track number too high BIS #RDSECT,R0 ; read sector command | drive select MOV R0,@#RXCS ; do it! 1$: TSTB @#RXCS ; transfer request bit set? BEQ 1$ ; actually, this should be BPL (test for bit 7) MOVB R5,@#RXSA ; sector address 2$: TSTB @#RXCS ; transfer request bit set? BEQ 2$ ; actually, this should be BPL (test for bit 7) MOVB R4,@#RXTA ; track address 3$: BIT #done,@#RXCS ; done? BEQ 3$ ; nay. TST @#RXCS ; error? BMI ERROR ; error bit set MOV #EMPTYB,@#RXCS ; empty buffer command 4$: TSTB @#RXCS ; read status BPL 5$ ; no transfer request MOVB @#RXDB,(R2)+ ; store byte BR 4$ ; and continue 5$: BIT #DONE,@#RXCS ; done? BEQ 4$ ; not yet. TST @#RXCS ; test for error BMI ERROR CLC ; everything went smooth MOV (SP)+,R5 MOV (SP)+,R4 MOV (SP)+,R3 MOV (SP)+,R2 MOV (SP)+,R1 MOV (SP)+,R0 RTS PC SECERR: SEC ; illegal sector number, set carry and leave MOV (SP)+,R5 MOV (SP)+,R4 MOV (SP)+,R3 MOV (SP)+,R2 MOV (SP)+,R1 MOV (SP)+,R0 RTS PC ERROR: MOV (SP)+,R5 ; we don't care about errors, so we just MOV (SP)+,R4 ; try again MOV (SP)+,R3 MOV (SP)+,R2 MOV (SP)+,R1 MOV (SP)+,R0 BR DXREAD .END