home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / ASM / ALIB30B / TIME3.ASM < prev    next >
Assembly Source File  |  1994-10-15  |  2KB  |  94 lines

  1.     page    66,132
  2. ;******************************** TIME3.ASM  *********************************
  3.  
  4. LIBSEG           segment byte public "LIB"
  5.         assume cs:LIBSEG , ds:nothing
  6.  
  7. ;----------------------------------------------------------------------------
  8. .xlist
  9.     include  mac.inc
  10.     include  common.inc
  11. .list
  12. comment 
  13. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -(  TIME  )
  14. GET_TIME - Returns the current SYSTEM time.
  15. ;
  16. ; input:  None
  17. ;
  18. ; output: DH        hours (0-23)
  19. ;      DL        minutes (0-59)
  20. ;      AH        seconds (0-59)
  21. ;      AL        hundredths of seconds (0-99)
  22. ;* * * * * * * * * * * * * *
  23. 
  24.     public        get_time
  25. get_time    proc    far
  26.         push    cx
  27.         mov    ah,2Ch        ;dos function to get time
  28.         int    21h        ;returns time in CX:DX
  29.         xchg    ax,dx        ;move time to DX:AX...
  30.         mov    dx,cx
  31.         pop    cx
  32.         retf
  33. get_time    endp
  34. comment 
  35. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -(  TIME  )
  36. ASC_TIME - Creates a time string of the form HH:MM Xm.
  37. ;
  38. ; input: DS:SI        destination string ("string")
  39. ;    Time in dword format ("time"):
  40. ;      DH        hours (0-23)
  41. ;      DL        minutes (0-59)
  42. ;      
  43. ; output: SI points past last store point      
  44. ;* * * * * * * * * * * * * *
  45. 
  46.     public        asc_time
  47. asc_time    proc    far
  48.         apush    ax,dx,di
  49.  
  50.         push    es
  51.         push    ds
  52.         pop    es        ;ensure ES = DS in large data models
  53.  
  54.         mov    di,si        ;DI = SI
  55.         mov    al,dh        ;Al = hours (24 hr clock)
  56.         mov    dh,"p"        ;set DH for pm
  57.         cmp    al,12        ;is it pm?
  58.          jae    asc_time_100    ;  y: leave DH setup for pm
  59.         mov    dh,"a"        ;  n: set DH for am
  60. asc_time_100:    cmp    al,13        ;is time 1pm or later?
  61.          jb    asc_time_120    ;  n: skip 24 to 12 hr clock adjust
  62.         sub    al,12        ;AL = hours (12 hr clock)
  63. asc_time_120:    cmp    al,0        ;is time 12 am?
  64.          jne    asc_time_140    ;  n: skip 12am adjust
  65.         mov    al,12        ;  y: make hour 0 = 12am
  66. asc_time_140:    aam            ;AX = hours in BCD format
  67.         add    ax,"00"        ;AX = hours in decimal digits
  68.         xchg    al,ah
  69.         stosw            ;write hours to string
  70.         mov    al,":"
  71.         stosb            ;write ":" to string
  72.         mov    al,dl        ;AL = minutes
  73.         aam            ;AX = minutes in BCD format
  74.         add    ax,"00"        ;AX = minutes in decimal digits
  75.         xchg    al,ah
  76.         stosw            ;write minutes to string
  77.         mov    al," "
  78.         stosb            ;write space character to string
  79.         mov    ah,"m"
  80.         mov    al,dh        ;AX = am/pm indicator
  81.         stosw            ;write am/pm indicator
  82.         xor    al,al
  83.         stosb            ;write NULL to end of string
  84.  
  85.         pop    es
  86.  
  87.         apop    ax,dx,di
  88.         retf
  89. asc_time    endp
  90.  
  91.  
  92. LIBSEG    ENDS
  93.     end
  94.