.TITLE CDATDW .IDENT /V01/ .ENABLE LC ; ; This module forms part of the suite of Date Routines returning the ; current date in one of the following forms, or converting one form to ; another. ; Form I - Day, Month & Year since 1950 as 3 byte values ; Form A - ASCII DD-MMM-YY ; Form D - Integer*2 days since 1st January 1950 ; Form E - Integer*2 encoded date ; Form W - Weekday Number (0 = Sunday) ; ; Author: V01 30-Jun-80 Phil Stephensen-Payne ; ; Calling Sequence: ; ; This subroutine is called via the standard FORTRAN calling sequence as: ; ; CALL CDATDW (DAYNO,WEKDAY [,STATUS]) ; or ; STATUS = CDATDW (DAYNO,WEKDAY) ; ; or ; CALL CDATDW from MACRO-11 with ; R5 = 0 ; R1 = DAYNO ; R0 = STATUS on output ; R1 = WEKDAY on output (0 = Sunday) ; ; Where: ; DAYNO = Number of days since 1/1/50 (1/1/50 = 1) ; WEKDAY = Weekday number (0 = Sunday) ; STATUS = Optional error return ; ; Errors returned: ; ; STATUS = 0 if the operation was successful ; = -1 if a parameter error was detected ; = -2 if an invalid input date was specified ; ; External references: ; ; This module calls the subroutines PRMCHK & CDCHKI ; ; ; CDATDW:: TST R5 ; Called directly from MACRO-11? BEQ 20$ ; If eq yes - omit PRMCHK ; ; Specify number of parameters including error return. R5 not affected. ; MOV #3,R0 ; Check Number of Parameters CALL PRMCHK ; BCC 10$ ; If CC parameters OK - carry on JMP END ; Else error - exit immediately ; 10$: TST (R5)+ ; Ignore Number of parameters BIT #1,(R5) ; Word-aligned parameter? BEQ 15$ ; If EQ OK - carry on MOV #-1,R0 ; No - parameter error BR END ; Exit ; 15$: MOV @(R5)+,R1 ; Get the parameter ; 20$: TST R1 ; Valid date? BEQ ERR ; If EQ no - error CMP R1,#36525. ; Sure? BHI ERR ; If HI no - error DEC R1 ; Adjust for 0 = Sunday CLR R0 ; Clear for division DIV #7,R0 ; Divide by 7 (Remainder in R1) TST R5 ; Was it a MACRO-11 call? BEQ 30$ ; Yes - just return MOV R1,@(R5)+ ; No - return it normally ; 30$: CLR R0 ; END: RETURN ; ERR: MOV #-2,R0 ; Invalid date RETURN ; .END