home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / asm / OKTIMDAT.ZIP / DATETIME.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-11-23  |  5.5 KB  |  113 lines

  1. TITLE   DateTime.ASM - Reports Verbose System Date & Time
  2. _TEXT   SEGMENT
  3.         ASSUME DS:_TEXT, SS:_TEXT, CS:_TEXT, ES:_TEXT
  4.         ORG     100H
  5. Main    Proc    Far
  6. BEGIN:  JMP START
  7.         DB  13
  8. Program DB  "Date Time Version 1.0 Copyright (c) 1988"
  9. Usage   DB  " for NON-Commercial Use ONLY!",13,10
  10.         DB  " Use and distribution without charge"
  11.         DB  13,10,"  IS authorized and encouraged"
  12. Author  DB  13,10,9,"by Tom Gilbert's Heart&Mind",26
  13. Msg_St  DB      10,"Today is "
  14. Day_St  DB      "      day, "
  15. Day_No  DB      "   "
  16. Mon_St  DB      10 DUP(' ')
  17. Year_N  DB      "    ",13,10,"Current Computer Time is "
  18. Time    DB      "  :  :  ",13,10
  19. MessageLength   EQU $-Msg_St    ;Fixed Length Message Area
  20. Day_Na  DB      "   Sun","   Mon","  Tues","Wednes"
  21.         DB      " Thurs","   Fri"," Satur"
  22. Mon_Na  DB      "  January"," February","    March"
  23.         DB      "    April","      May","     June"
  24.         DB      "     July","   August","September"
  25.         DB      "  October"," November"," December"
  26. MON     DB      ?
  27. DAY     DB      ?
  28. Year    DW      ?
  29. START:  Mov     AH,2Ah                  ; GetDate function returns
  30.         Int     21h                     ; weekday (0 - 6) in AL
  31.         Cbw                             ; Convert AL Byte to AX Word
  32.         Mov     MON,DH                  ; Store Month Value Byte
  33.         Mov     DAY,DL                  ; Store Day Value Byte
  34.         Mov     Year,CX                 ; Store Year Word
  35.         Mov     CX,6                    ; Calculate
  36.         Mul     CL                      ; day offset
  37.         Mov     SI,Offset Day_Na        ; Point to Sunday
  38.         Add     SI,AX                   ; and add offset
  39.         Mov     DI,Offset Day_St        ; Transfer first
  40.         Rep     MovSB                   ; part up to day
  41.         Mov     AL,MON                  ; Get Month Number
  42.         Dec     AL                      ;  as a Zero Based
  43.         Mov     CL,9                    ;  Offset into the
  44.         Mul     CL                      ;  Month Table
  45.         Mov     SI,Offset Mon_Na        ; Point to January
  46.         Add     SI,AX                   ; and add Offset
  47.         Mov     DI,Offset Mon_St        ; Transfer Month
  48.         Rep     MovSB                   ; including spaces
  49.         Mov     AL,DAY                  ; Get Day Number
  50.         Aam                             ; as Two Byte
  51.         Add     AX,"00"                 ; ASCII Digits
  52.         Xchg    AH,AL                   ; for Hi/Lo
  53.         Mov     DI,Offset Day_No        ; Transfer to
  54.         StoSW                           ; Day String
  55.         Mov     AX,Year                 ; Get Year and
  56.         Mov     BX,4                    ; Transfer four
  57.         Mov     DI,Offset Year_N        ; ASCII Digits to
  58.         Call    BinToDec                ; Year Digit Area
  59.         Mov     AH,2Ch                  ; Get Time function returns
  60.         Int     21h                     ; CH=hh, CL=mm DH=ss DL=ss/100
  61.         Mov     DI,Offset Time          ; Transfer to Time String
  62.         Mov     AL,CH                   ; Hours as
  63.         Aam                             ; Two Byte
  64.         Add     AX,"00"                 ; ASCII Digits
  65.         Xchg    AH,AL                   ; in Hi/Lo
  66.         StoSW                           ; order and
  67.         Inc     DI                      ; skip the ":"
  68.         Mov     AL,CL                   ; Minutes
  69.         Aam                             ; Two Byte
  70.         Add     AX,"00"                 ; ASCII Digits
  71.         Xchg    AH,AL                   ; in Hi/Lo
  72.         StoSW                           ; order and
  73.         Inc     DI                      ; skip the ":"
  74.         Mov     AL,DH                   ; Seconds
  75.         Inc     AL                      ; Rounded Up
  76.         Aam                             ; as Two Byte
  77.         Add     AX,"00"                 ; ASCII Digits
  78.         Xchg    AH,AL                   ; in Hi/Lo
  79.         StoSW                           ; order
  80.         Mov     SI,Offset Msg_St        ; Display "Today is "
  81.         Mov     CX,MessageLength        ; weekday name then
  82.         Xor     DX,DX                   ; "day," dd Month
  83. GetByt: LodSB                           ; Name but don't
  84.         Cmp     DL," "                  ; display any of
  85.         Jnz     NotSp                   ; multiple spaces
  86.         Cmp     AL,DL                   ; then add in
  87.         Jz      LoopGB                  ; year four ASCII
  88. NotSp:  Mov     DL,AL                   ; Decimal Year Digits
  89.         Mov     AH,2                    ; Display Time Line
  90.         Int     21h                     ; With Time Digits
  91. LoopGB: Loop    GetByt                  ; Until All Displayed
  92.         Mov     AX,4C00h                ; Return to DOS, with
  93.         Int     21h                     ; no error message.
  94. Main    EndP
  95. ; Procedure BinToDec
  96. ; Purpose Convert binary number in AX to String
  97. ; Input   Value in AX; Length in BX and
  98. ;                  ES & DS:DI @ Data Segment
  99. ; Output  Value as ASCII decimal digits to [DI]
  100. BinToDec  Proc
  101.           Mov  CX,10               ; Divide by Decimal Base
  102. GetDigit: Sub  DX,DX               ; Clear top
  103.           Div  CX                  ; Remainder is last digit
  104.           Add  DL,'0'              ; Convert to ASCII
  105.           Dec  BX                  ; Back-Up Index
  106.           Mov  DS:[DI+BX],DL       ; Store Digit
  107.           Or   AX,AX               ; If Quotient NOT 0
  108.           Jnz  GetDigit            ; Then Get another
  109.           Ret                      ; Else Done
  110. BinToDec  EndP
  111.         _TEXT   ENDS
  112. END     BEGIN
  113.