.TITLE CDATIE .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 14-Jul-80 Phil Stephensen-Payne ; ; Calling Sequence: ; ; This subroutine is called via the standard FORTRAN calling sequence as: ; ; CALL CDATIE (DAY,MONTH,YEAR,ENCDAT [,STATUS]) ; or ; STATUS = CDATIE (DAY,MONTH,YEAR,ENCDAT) ; ; or ; CALL CDATIE from MACRO-11 with ; R5 = 0 ; R1 = DAY ; R2 = MONTH ; R3 = YEAR ; R0 = STATUS on output ; R1 = ENCDAT on output ; ; Where: ; DAY = Number of day (1-31) ; MONTH = Number of month (1-12) ; YEAR = Year since 1950 (1950=0) ; ENCDAT = Encoded Date ; 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 ; ; ; CDATIE:: 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 #5,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 MOVB @(R5)+,R1 ; Get the parameters MOVB @(R5)+,R2 ; MOVB @(R5)+,R3 ; BIT #1,(R5) ; Next parameter a word? BEQ 20$ ; If eq yes - carry on OK MOV #-1,R0 ; No - parameter error BR END ; Exit ; 20$: CALL CDCHKI ; Check the date is valid BCS ERR ; If CS it isn't - return error CMP R3,#50. ; Really after 2000? BGE 30$ ; If GE no - carry on ADD #100.,R3 ; Yes - add on 100 years ; 30$: SUB #50.,R3 ; Adjust the date to year since 1950 MOV R1,R4 ; Store day MOV R3,R1 ; Get year since 1950 ASH #4,R1 ; Shift it up ADD R2,R1 ; Add the month number ASH #5,R1 ; Shift again ADD R4,R1 ; Add the day number TST R5 ; Was it a MACRO-11 call? BEQ 60$ ; Yes - just return MOV R1,@(R5)+ ; No - return it normally ; 60$: CLR R0 ; END: RETURN ; ERR: MOV #-2,R0 ; Invalid date RETURN ; .END