Get DOS Time

From CometWiki

Revision as of 11:23, 13 June 2009 by Badge (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Get DOS Time

Syntax:

 DOSMS(AX-value,BX-value,CX-value,DX-value) EXCP=statement-label  

Entry:

 AX-value = "@2C00@"
 BX-value = "@0000@"
 CX-value = "@0000@"
 DX-value = "@0000@"


Return:

 Byte 2 of the CX register (i.e., the CH byte) contains the hour (0 to 23; in hex).
                                                                                  .
 Byte 1 of the CX register (i.e., the CL byte) contains the minute (0 to 59; in hex).
                                                                                    .
 Byte 2 of the DX register (i.e., the DH byte) contains the second (0 to 59; in hex).
                                                                                    .
 Byte 1 of the DX register (i.e., the DL byte) contains the hundredths of seconds (0 to 99; in hex).


Discussion:
The DOSMS function call can be used to get the DOS system time. This function requires that the AX-value be set to "@2C00@", and that the other entry values be set to null.
After the function is executed, the DOS time is returned in the registers as described above. Note that the values are returned in hex and must be converted to decimal for meaningful use.

Example:

 ! S STIME,DSK
 ! O TIME,DSK
 ! L T00,E
 ! R QMONITOR
 !
 !==========  GET DOS TIME =======================================
 !
 LENGTH 2 & LOCAL AX$,BX$,CX$,DX$        ! Define registers
            LOCAL HOUR$,MIN$,SEC$,HUND$  ! Define time variables
 LENGTH 1 & LOCAL CH$,CL$,DH$,DL$        ! Define sub-registers
 LENGTH 2.0 & LOCAL HOUR,MIN,SEC,HUND    ! Define numeric times
 !
 100 FORMAT (ET)                         ! Screen format
 !
 CLEAR                        ! Initialize all variables
 !
 AX$="@2C00@"                 ! Set AX register for "GET TIME"
 BX$="@0000@"                 ! Set BX register to null
 CX$="@0000@"                 ! Set CX register to null
 DX$="@0000@"                 ! Set DX register to null
 !
 DOSMS(AX$,BX$,CX$,DX$)       ! Perform DOSMS system call
 !
 HOUR$ = SUB(CX$,2,1)         ! Hour (hex) = CH byte of CX
 MIN$  = SUB(CX$,1,1)         ! Minute (hex) = CL byte of CX
 SEC$  = SUB(DX$,2,1)         ! Second (HEX) = DH byte of DX
 HUND$ = SUB(DX$,1,1)         ! Hundredths (hex) = DL byte of DX
 !
 HOUR$ = "@00@" + HOUR$       ! Addleading null byte to HOUR$
 MIN$  = "@00@" + MIN$        ! Add leading null byte to MIN$
 SEC$  = "@00@" + SEC$        ! Add leading null byte to SEC$
 HUND$ = "@00@" + HUND$       ! Add leading null byte to HUND$
 !
 HOUR = HEXDEC(HOUR$)         ! Convert hex HOUR$ to decimal HOUR
 MIN  = HEXDEC(MIN$)          ! Convert hex MIN$ to decimal MIN
 SEC  = HEXDEC(SEC$)          ! Convert hex SEC$ to decimal SEC
 HUND = HEXDEC(HUND$)         ! Convert hex HUND$ to decimal HUND$
 !
 PRINT (0,100)                ! Set typewriter mode
 !
 PRINT (0) "HOUR:      ";HOUR
 PRINT (0) "MINUTE:    ";MIN
 PRINT (0) "SECONDS:   ";SEC
 PRINT (0) "HUNDREDTHS:";HUND
 INPUT (0) ""
 RUN "QMONITOR"
 END
Personal tools