home *** CD-ROM | disk | FTP | other *** search
- TITLE DateTime.ASM - Reports Verbose System Date & Time
- _TEXT SEGMENT
- ASSUME DS:_TEXT, SS:_TEXT, CS:_TEXT, ES:_TEXT
- ORG 100H
- Main Proc Far
- BEGIN: JMP START
- DB 13
- Program DB "Date Time Version 1.0 Copyright (c) 1988"
- Usage DB " for NON-Commercial Use ONLY!",13,10
- DB " Use and distribution without charge"
- DB 13,10," IS authorized and encouraged"
- Author DB 13,10,9,"by Tom Gilbert's Heart&Mind",26
- Msg_St DB 10,"Today is "
- Day_St DB " day, "
- Day_No DB " "
- Mon_St DB 10 DUP(' ')
- Year_N DB " ",13,10,"Current Computer Time is "
- Time DB " : : ",13,10
- MessageLength EQU $-Msg_St ;Fixed Length Message Area
- Day_Na DB " Sun"," Mon"," Tues","Wednes"
- DB " Thurs"," Fri"," Satur"
- Mon_Na DB " January"," February"," March"
- DB " April"," May"," June"
- DB " July"," August","September"
- DB " October"," November"," December"
- MON DB ?
- DAY DB ?
- Year DW ?
- START: Mov AH,2Ah ; GetDate function returns
- Int 21h ; weekday (0 - 6) in AL
- Cbw ; Convert AL Byte to AX Word
- Mov MON,DH ; Store Month Value Byte
- Mov DAY,DL ; Store Day Value Byte
- Mov Year,CX ; Store Year Word
- Mov CX,6 ; Calculate
- Mul CL ; day offset
- Mov SI,Offset Day_Na ; Point to Sunday
- Add SI,AX ; and add offset
- Mov DI,Offset Day_St ; Transfer first
- Rep MovSB ; part up to day
- Mov AL,MON ; Get Month Number
- Dec AL ; as a Zero Based
- Mov CL,9 ; Offset into the
- Mul CL ; Month Table
- Mov SI,Offset Mon_Na ; Point to January
- Add SI,AX ; and add Offset
- Mov DI,Offset Mon_St ; Transfer Month
- Rep MovSB ; including spaces
- Mov AL,DAY ; Get Day Number
- Aam ; as Two Byte
- Add AX,"00" ; ASCII Digits
- Xchg AH,AL ; for Hi/Lo
- Mov DI,Offset Day_No ; Transfer to
- StoSW ; Day String
- Mov AX,Year ; Get Year and
- Mov BX,4 ; Transfer four
- Mov DI,Offset Year_N ; ASCII Digits to
- Call BinToDec ; Year Digit Area
- Mov AH,2Ch ; Get Time function returns
- Int 21h ; CH=hh, CL=mm DH=ss DL=ss/100
- Mov DI,Offset Time ; Transfer to Time String
- Mov AL,CH ; Hours as
- Aam ; Two Byte
- Add AX,"00" ; ASCII Digits
- Xchg AH,AL ; in Hi/Lo
- StoSW ; order and
- Inc DI ; skip the ":"
- Mov AL,CL ; Minutes
- Aam ; Two Byte
- Add AX,"00" ; ASCII Digits
- Xchg AH,AL ; in Hi/Lo
- StoSW ; order and
- Inc DI ; skip the ":"
- Mov AL,DH ; Seconds
- Inc AL ; Rounded Up
- Aam ; as Two Byte
- Add AX,"00" ; ASCII Digits
- Xchg AH,AL ; in Hi/Lo
- StoSW ; order
- Mov SI,Offset Msg_St ; Display "Today is "
- Mov CX,MessageLength ; weekday name then
- Xor DX,DX ; "day," dd Month
- GetByt: LodSB ; Name but don't
- Cmp DL," " ; display any of
- Jnz NotSp ; multiple spaces
- Cmp AL,DL ; then add in
- Jz LoopGB ; year four ASCII
- NotSp: Mov DL,AL ; Decimal Year Digits
- Mov AH,2 ; Display Time Line
- Int 21h ; With Time Digits
- LoopGB: Loop GetByt ; Until All Displayed
- Mov AX,4C00h ; Return to DOS, with
- Int 21h ; no error message.
- Main EndP
- ; Procedure BinToDec
- ; Purpose Convert binary number in AX to String
- ; Input Value in AX; Length in BX and
- ; ES & DS:DI @ Data Segment
- ; Output Value as ASCII decimal digits to [DI]
- BinToDec Proc
- Mov CX,10 ; Divide by Decimal Base
- GetDigit: Sub DX,DX ; Clear top
- Div CX ; Remainder is last digit
- Add DL,'0' ; Convert to ASCII
- Dec BX ; Back-Up Index
- Mov DS:[DI+BX],DL ; Store Digit
- Or AX,AX ; If Quotient NOT 0
- Jnz GetDigit ; Then Get another
- Ret ; Else Done
- BinToDec EndP
- _TEXT ENDS
- END BEGIN
-