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

  1.     page    66,132
  2. ;******************************** TIME4.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. ;----------------------------------------------------------------------------
  13.     EXTRN    DATE_TO_DAYS:FAR
  14. comment 
  15. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -(  TIME  )
  16. GET_DATE - Returns the current SYSTEM date and day of the week.
  17. ;
  18. ; input:  None
  19. ; output: Current SYSTEM date, in dword format:
  20. ;      DX        year (1980-2099)
  21. ;      AH        month (1-12)
  22. ;      AL        day (1-31)
  23. ;         CL        day-of-the-week (number of days since Sunday)
  24. ;* * * * * * * * * * * * * *
  25. 
  26.     public        get_date
  27. get_date    proc    far
  28.         push    bx        ;save temporary register
  29.         mov    bh,ch        ;BH holds original CH
  30.         mov    ah,2Ah        ;DOS function to get date
  31.         int    21h
  32.         xchg    ax,cx        ;CL=day-of-week (AX=year)
  33.         xchg    ax,dx        ;DX=year; AX=month and day
  34.         mov    ch,bh        ;restore CH
  35.         pop    bx
  36.         retf
  37. get_date    endp
  38. comment 
  39. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -(  TIME  )
  40. GET_DAY - Returns the day of the week for a given date.
  41. ;
  42. ; input: Date for which day of week should be determined, in dword
  43. ;      DX        year (1980-2099)
  44. ;      AH        month (1-12)
  45. ;      AL        day (1-31)
  46. ;
  47. ; output: CL        day of the week (0-6)
  48. ;* * * * * * * * * * * * * *
  49. 
  50.     public        get_day
  51. get_day    proc    far
  52.         apush    ax,bx,dx
  53.         call    date_to_days    ;AX = days since 01-01-80 
  54.         add    ax,2        ;because 01-01-80 was Tuesday
  55.         xor    dx,dx        ;DX = 0
  56.         mov    bx,7        ;mod 7...
  57.         div    bx        ;DX = day of week
  58.         mov    cl,dl        ;CL = day of week
  59.         apop    ax,bx,dx
  60.         retf
  61. get_day        endp
  62.  
  63.  
  64. LIBSEG    ENDS
  65.     end
  66.