.TITLE XITSTA ; ; Sets program exit code into RT-11's system communication area ; and optionally displays a user defined message before exiting ; ; Called from FORTRAN by: ; CALL XITSTA(NAME,CODE,MESAGE) ; or ; CALL XITSTA(NAME,CODE,) ; where: ; NAME - Program name text string (maximum of 6 chars.) ; CODE - An appropriate RT-11 program exit state code ; MESAGE - Optional argument, containing text of message ; to be displayed. ; .GLOBL XITSTA .MCALL .PRINT,.EXIT USERRB = 53 ;User Error Byte .PSECT USER$I RW,I,LCL,REL,CON XITSTA: CMP #3,(R5)+ ;Are there three arguments? BNE 4$ ;No, just quietly exit MOV #6,R1 ;Routine's name must be <= 6 bytes MOV (R5)+,R2 ;Load pointer to routine's name MOV #PREAMB+1,R3 ;Point to display string 1$: MOVB (R2)+,(R3)+ ;Copy in a byte BEQ 2$ ;Done if null found DEC R1 ;Count down from maximum string size BNE 1$ ;Loop till zero INC R3 ;Allow for the effect of next inst. 2$: MOVB #'-,-1(R3) ;Install program name delimiter MOVB @(R5)+,R0 ;Load State code argument MOV #STATE,R1 ;Point to list of exit state codes MOV #20,R2 ;Start with highest error value 3$: CMPB R0,(R1)+ ;Matched argument state code BEQ 4$ ;Yes, display message ASR R2 ;Decrease error value BNE 3$ ;Search complete list BR 6$ ;No match found, quietly exit 4$: MOVB R0,(R3)+ ;Install state code in preamble MOVB #'-,(R3)+ ;Add in exit state code delimiter MOVB #200,(R3)+ ;Request no line delimiters CMP #-1,(R5)+ ;Check third argument address BEQ 5$ ;If null, just set code & exit .PRINT #PREAMB ;Display preamble .PRINT -(R5) ;Print the rest of the message 5$: BISB R2,@#USERRB ;Install code in Sys. Comm. Area CLR R0 ;Request a HARD exit 6$: .EXIT ;DO IT .PSECT USER$D RW,D,LCL,REL,CON .NLIST BEX STATE: .ASCII /UFEWI/ PREAMB: .ASCII /?NNNNNN-X-/<200> .EVEN .END