.TITLE CTIMIA .IDENT /V01/ .ENABLE LC .MCALL GTIM$S ; ; This module forms part of the suite of Time Routines returning the ; current date in one of the following forms, or converting one form to ; another. ; Form I - Hours, Minutes, Seconds & Tenths of a Second ; Form A - ASCII HH:MM:SS.S ; Form D - Integer*4 seconds since midnight ; ; Author: V01 15-Jul-80 Phil Stephensen-Payne ; ; Calling Sequence: ; ; This subroutine is called via the standard FORTRAN calling sequence as: ; ; CALL CTIMIA (TIMTBL,ZTIME,ILEN [,STATUS]) ; or ; STATUS = CTIMIA (TIMTBL,ZTIME,ILEN) ; ; or ; CALL CTIMIA from MACRO-11 with ; R5 = 0 ; R1 = Address of TIMTBL ; R2 = Address of ZTIME for output ; R3 = ILEN ; R0 = STATUS on output ; ; Where: ; TIMTBL = 4-byte array for Hour, Minute, Second etc. ; ZDATE = 10-byte array for ASCII Time ; ILEN = Length of ZDATE in bytes (0 => 10) ; STATUS = Optional error return ; ; Errors returned: ; ; STATUS = 0 if the operation was successful ; = -1 if a parameter error was detected ; = -2 if the time was invalid ; ; External references: ; ; This module calls the subroutines PRMCHK ; ; BUFF: .WORD 0,0,0,0,10. ; Buffer for $TIM ; ; CTIMIA:: TST R5 ; Called directly from MACRO-11? BEQ 10$ ; If eq yes - omit PRMCHK ; ; Specify number of parameters including error return. R5 not affected. ; MOV #4,R0 ; Check Number of Parameters CALL PRMCHK ; BCS END ; If CS parameter error - exit at once TST (R5)+ ; Ignore number of parameters MOV (R5)+,R1 ; Get Address of Input MOV (R5)+,R2 ; Get Address for Output CLR R3 ; Assume full length CMP (R5),#-1 ; Parameter omitted? BEQ 10$ ; If eq yes - leave default MOVB @(R5)+,R3 ; Get length ; 10$: CALL CTCHKI ; Check the time BCS ERR ; If CS error - log it MOVB (R1)+,BUFF ; Insert the time as word-values MOVB (R1)+,BUFF+2 ; MOVB (R1)+,BUFF+4 ; MOVB (R1)+,BUFF+6 ; MOV R2,R0 ; Store address for output TST R3 ; Was length specified? BNE 20$ ; If NE yes - carry on MOV #10.,R3 ; No - default it ; 20$: MOV R3,R1 ; Propagate count BLE ERR2 ; If LE parameter error ; 30$: MOVB #' ,(R2)+ ; Initialise output buffer SOB R1,30$ ; CMP R3,#10. ; Do we want it all? BLT 40$ ; No - carry on MOV #11.,R3 ; Yes - set to 11 for calculation ; 40$: INC R3 ; Convert to 1-4 CLR R2 ; DIV #3,R2 ; TST R2 ; was it valid BEQ ERR2 ; No - parameter error MOV #BUFF,R1 ; Get address of values CALL $TIM ; Yes - do the conversion CLR R0 ; Show success ; END: RETURN ; ERR: MOV #-2,R0 ; Invalid time RETURN ; ; ERR2: MOV #-1,R0 ; Invalid parameters RETURN ; .END