.TITLE .MAIN. ; Archetypal main program for resident library usage ; Define "FORTRN" for Fortran jobs ; Define "FAOTS" if $AOTS context-switching is required FORTRN=0 FAOTS=0 .IIF DF FAOTS FORTRN=0 .MCALL .DSTAT,.CNTXSW,.PRINT,.EXIT .GLOBL LB$ADR ; Expected address of loaded LB handleroid .GLOBL LB$VER ; Expected LB handleroid version number .IF DF FORTRN .GLOBL $$OTI ; Fortran OTS initialization routine .GLOBL $EXIT ; Fortran exit routine .ENDC .IF DF FAOTS .GLOBL $AOTS ; Address of Fortran OTS impure area pointer .ENDC .GLOBL MAIN ; Subroutine which was formerly main program .IF DF FORTRN .IIF NDF USRSW USRSW=0 ; Default is /SWAP .IIF NDF NLCHN NLCHN=6 ; Default is /UNITS:6 .IIF NDF LRECL LRECL=132. ; Default is /RECORD:132. $USRSW == USRSW ; USR swap flag ("/SWAP" --> 0, "/NOSWAP" --> 1) $NLCHN == NLCHN ; Number of I/O channels needed ("/UNITS") $LRECL == LRECL ; Maximum record size ("/RECORD") .ENDC START: .DSTAT #DSTBLK,#LBDEV ; Has the LB handleroid MOV H.ADDR,R1 ; been loaded? BEQ NOLB ; If not, go complain SUB #6,R1 ; Point to start of handleroid MOV R1,R2 ; Point to end of handleroid (to get ADD H.SIZE,R2 ; word containing prologue size) ADD -6(R2),R1 ; Bump past null handler code CMP (R1),#LB$VER ; Is it the correct version? BNE BADVER ; If not, go complain CMP R1,#LB$ADR ; Is handleroid at correct address? BNE BADADR ; If not, go complain .IF DF FAOTS MOV #CNTXSW,R0 ; Context-switch the .CNTXSW ; impure area pointer .ENDC .IF DF FORTRN JSR R4,$$OTI ; Initialize the .WORD PRGNAM ; Fortran OTS MOV #ARGBLK,R5 ; Set up Fortran argument pointer .ENDC JSR PC,MAIN ; Call the (formerly) main program ; (We should never get here, but just in case .....) .IF DF FORTRN JMP $EXIT ; Go exit .IFF .EXIT ; Goodbye ..... .ENDC NOLB: .PRINT #NLBMSG ; Print error message .EXIT ; and exit BADVER: .PRINT #VERMSG ; Print error message .EXIT ; and exit BADADR: .PRINT #ADRMSG ; Print error message .EXIT ; and exit LBDEV: .RAD50 /LB / ; Handleroid device name (Radix-50) DSTBLK: .BLKW 4 ; BLock to receive .DSTAT information H.SIZE = DSTBLK+2 ; .DSTAT returns handler size here, H.ADDR = DSTBLK+4 ; and + 6 here .IF DF FAOTS CNTXSW: .BYTE 0,33 ; EMT argument block for .WORD .+2,$AOTS,0 ; context-switching $AOTS .ENDC .IF DF FORTRN PRGNAM: .RAD50 '.MAIN.' ; Name of new (this) main program ARGBLK: .WORD 0 ; Arg block for calling old main program .PSECT OTS$I,RW,I,LCL,REL,CON $$OTSI:: .PSECT .ENDC BEL = 007 ; ASCII "Bell" character NLBMSG: .ASCIZ "LB not loaded" VERMSG: .ASCIZ "LB version incorrect" ADRMSG: .ASCIZ "LB address wrong" .END START