.TITLE QUADAS .IDENT /V1.0/ ; ; B. Z. Lederman 22-Jun-85 ; ; This FORTRAN callable subroutine makes the $CDTTA and ; $CATDT routines which convert between Quadword ; Binary date/time values in clunks (such as values ; from VMS, DATATRIEVE, and System Accounting) and ; ASCII strings available to FORTRAN (77 and IV-Plus) ; programs and other lanquages using the FORTRAN ; calling convention. ; ; These routines use R0, R1, R2, and R4. They don't save or ; restore any registers because the FORTRAN compiler ; assumes they will all be distroyed and saves them ; when neccessary. ; ; Errors are handled in the simplest manner. If the routine ; is called with the wrong number of arguments, it ; simply does nothing and returns. If the conversion ; fails, the system routine returns with carry set, but ; this isn't passed back. The easiest way to check for ; errors is to zero your output area before calling and ; check it after calling: if it's still zero, the ; conversion failed. The most likely cause is an ; incorrect date format to CATDT: nearly any positive ; INTEGER passed to CDTTA will result in a date. Note ; that the routines have no way of checking to see that ; you have allocated sufficent space for the output ; data, so if you haven't one of your other variables ; will be clobbered. ; ; The neccessary routines should be in SYSLIB or in ; [1,24]RMSUTL.OLB ; ; ; CDTTA: Convert Quad Word to ASCII (this routine does the date ; portion only). ; ; CALL CDTTA( IN, OUT, [FLAG]) ; ; Where IN is a four word INTEGER*2 array (or equivalent) ; which holds the 64 bit binary time, and OUT is a ; byte array (at least 11 bytes long) to hold the ; converted date. It must be this long because the ; year is four digits (as in 12-JUN-1985). FLAG is ; an optional argument to specify the items converted ; (see documents on $CDTTA): if absent, only the date ; (no time) is converted. ; .PSECT $CODE2, RO, I CDTTA:: MOV (R5)+, R4 ; get number of arguments passed BEQ 50$ ; if no arguments, quit CMP R4, #2 ; are there at least two arguments? BLT 50$ ; quit if no MOV (R5)+, R1 ; retrieve address of input data CMP #-1, R1 ; was this a dummy argument? BEQ 50$ ; no dummy arguments allowed MOV (R5)+, R0 ; retrieve address of output area CMP #-1, R0 ; was this a dummy? BEQ 50$ ; quit if yes CMP R4, #2 ; were there only two arguments BEQ 20$ ; branch if yes (third is optional) CMP R4, #3 ; double check for 3 arguments BNE 50$ ; not valid unless 2 or 3 arguments MOV (R5), R4 ; get address of flags CMP #-1, R4 ; is it a dummy? BEQ 20$ ; yes, fill in our own value MOV (R4), R2 ; use the callers flags BR 30$ ; skip our flags 20$: MOV #2, R2 ; flag conversion of date only 30$: CALL $CDTTA ; call system routine 50$: RTS PC ; all done ; CATDT: Convert ASCII TIME and Date to Quad Word: ; (Must have a time, even if it's 00:00) ; ; CALL CATDT( IN, OUT) ; ; Where IN is a byte array which holds the time and date to ; be converted, and OUT is a four word INTEGER*2 array ; (or equivalent) which holds the 64 bit binary time. ; CATDT:: CMP (R5)+, #2 ; were there two arguments? BNE 150$ ; quit if not exactly two arguments MOV (R5)+, R0 ; retrieve address of input data CMP #-1, R0 ; was it a dummy argument? BEQ 150$ ; quit if dummy MOV (R5), R1 ; retrieve address of output area CMP #-1, R1 ; was this a dummy? BEQ 150$ ; quit if dummy CALL $CATDT ; call system routine 150$: RTS PC ; all done ; GDTIM: Get the System Date/Time as a quad word ; ; CALL GDTIM( OUT) ; ; Where OUT is a four word INTEGER*2 array (or equivalent) ; which holds the 64 bit binary time. ; GDTIM:: CMP (R5)+, #1 ; was there exactly one argument? BNE 250$ ; quit if no MOV (R5), R1 ; retrieve address of output area CMP #-1, R1 ; was this a dummy? BEQ 250$ ; quit if dummy address CALL $GDTIM ; call system routine 250$: RTS PC ; all done .END