.TITLE ASG Assign subroutine .NLIST BEX .ENABL LC ; ; Assign subroutine ; ; This subroutine is used to assign a logical device to an open channel. It ; first searches the logical-device table for either an entry that matches ; lognam or, failing that, a free entry. It then copies the channel info from ; the open channel into the table, leaving the channel closed. ; ; Entry symbols ; .GLOBL ASG ; ; System definitions ; .ASECT .MCALL .COM,.CHR,.PSA,.CLP,.IOD ;dcnlib definitions .MCALL .GVAL,.SAVES ;rt-11 macroni .COM ;define common data .CHR ;define ascii character codes .PSA ;define psa and par areas .CLP ;define rt-11 monitor area extension .IOD ;emulator monitor area extension ; ; Module definitions ; ; Return codes ; ER.OVF = 1 ;device table full ER.CHN = 2 ;channel not open ; ; Stack frame area (ag) ; . = 0 AG.ARG: .BLKW 5 ;rt-11 argument block AG.PTR: .BLKW 1 ;device-table pointer AG.LEN: .BLKW 3 ;register save area AG.NAM: .BLKW 1 ;logical device name AG.CHN: .BLKW 1 ;rt-11 channel number ; ; Procedure segment ; .PSECT $BOSI,RO,I ; ; ASG (asg) assign logical device ; Ulp/c calling sequence: code = asg( lognam, chan) ; code (see above) ; lognam logical device name (rad50) ; chan rt-11 channel number ; ASG: MOV R1,-(SP) ;ulp/c entry MOV R5,-(SP) SUB #AG.LEN,SP MOV SP,R5 .GVAL R5,#CONFIG ;is this a fuzzball BIT #FUZZY$,R0 BEQ 5$ ;branch if no MOV @#SYSPTR,R1 ;grab par pointer MOV IOHPAR(R1),R1 MOVB PARLNG(R1),R0 ;scan device table ADD #PARLDN,R1 CLR AG.PTR(R5) 1$: TST @R1 ;is this slot assigned BNE 2$ ;branch if yes MOV R1,AG.PTR(R5) ;no. save pointer 2$: CMP AG.NAM(R5),@R1 ;do names match BEQ 3$ ;branch if yes ADD #10,R1 SOB R0,1$ MOV AG.PTR(R5),R1 ;no more. was there a hole BNE 3$ ;branch if yes MOV #ER.OVF,R0 ;device table full BR 6$ ; 3$: .SAVES R5,AG.CHN(R5),R5 ;get channel info BCC 4$ ;branch if open MOV #ER.CHN,R0 ;channel not open BR 6$ ; 4$: MOV AG.NAM(R5),(R1)+ ;initialize device table entry MOVB C.STAT(R5),(R1)+ MOVB C.DEVQ+1(R5),(R1)+ MOV C.SBLK(R5),(R1)+ MOV C.LENG(R5),(R1)+ 5$: CLR R0 ;no error 6$: MOV R5,SP ;ulp/c exit ADD #AG.LEN,SP MOV (SP)+,R5 MOV (SP)+,R1 RTS PC ; .END