.TITLE GETC0 RT11 support input routine .ident /000001/ ; 28-Jul-79 Original edit .ENABL LC .LIST MEB .NLIST BEX ; ; GETC0 reads one byte from a specified input file. ; ; GETC0 calling sequence: ; ; MOV FDB,R1 ;R1 -> file data block ; MOV SP,R5 ;Caller SP for error return ; JSR PC,GETC0 ;And do it ; ; On return: ; R0 has the byte. Other registers are preserved. ; Note, on an error, the stack will be cut back to the R5 ; value and the original caller returned to with the C-bit ; set and the RT11 error code in $ERROR and in R0. ; ; The FDB has the following format: ; ; .WORD Address of the CSI block for this file ; FDB: .WORD Channel number ; .WORD Number of bytes left in the buffer ; .WORD Address of the first free byte in the buffer ; .WORD Current block number ; .BLKB 512. The buffer itself ; ; ; Edit history ; 000001 28-Jul-79 MM Original edit ; .GLOBL SAVREG ;Register save routine .GLOBL $ERROR ;Error code (byte) ; GETC0:: MOV R1,-(SP) ;Save FDB for return TST (R1)+ ;Skip over the channel DEC (R1)+ ;Drop bytes left count BGE 20$ ;Jump if buffer satisfies CLR -(SP) ;Start building .READW argument block MOV #256.,-(SP) ;Get 256 words CMP (R1)+,(R1)+ ;R1 := buffer address MOV R1,-(SP) ;Stuff where to read to MOV -(R1),-(SP) ;Stuff the block number CMP -(R1),-(R1) ;R1 -> number of bytes left MOV -2(R1),-(SP) ;Stuff the channel number BIS #<10*400>,(SP) ;Stuff the .READW command MOV SP,R0 ;R0 -> argument block EMT 375 ;Do it BCC 10$ ;Continue if ok MOV R5,SP ;Cut the stack MOVB @#52,R0 ;No, remember error code MOV R0,$ERROR ;In the global location MOV R0,2(SP) ;And in caller's R0 RTS PC ;And return to the original caller ; 10$: MOV #511.,(R1)+ ;Fix up the FDB, 511 bytes left CMP (SP)+,(SP)+ ;Pop some stack MOV (SP)+,(R1) ;Pop off the buffer start INC 2(R1) ;Bump the block number CMP (SP)+,(SP)+ ;Pop off the rest of the arg. block 20$: CLR R0 ;Get the byte into R0 BISB @(R1)+,R0 ;Without extending the sign INC -(R1) ;Step the byte pointer MOV (SP)+,R1 ;Recover the FDB pointer RTS PC ;Back to the caller. .END