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

  1.     page    66,132
  2. ;******************************** TIME2.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. MONTH_TO_ASCII - get ASCII string for specified month
  15. ;
  16. ; inputs:    CX = month (1 - 12, January = 1)
  17. ; output:    ES:[DI] = pointer to month name string
  18. ;            CX = length of month string
  19. ;
  20. ; Note: the day name string is not zero-terminated
  21. ;* * * * * * * * * * * * * *
  22. 
  23.     public    MONTH_TO_ASCII
  24. MONTH_TO_ASCII    PROC    FAR
  25.     mov    di,offset months
  26.     call    lookup
  27.     retf
  28. MONTH_TO_ASCII    ENDP    
  29.  
  30. months    label    byte
  31.     DB    'January  '
  32.     db    'February '
  33.     db    'March    '
  34.     db    'April    '
  35.     db    'May      '
  36.     db    'June     '
  37.     db    'July     '
  38.     db    'August   '
  39.     db    'September'
  40.     db    'October  '
  41.     db      'November '
  42.     db    'December '
  43. comment 
  44. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -(  TIME  )
  45. DAY_TO_ASCII - get string for specified day of the week
  46. ;
  47. ; inputs:    CX = day of week (1 - 7, Sunday = 1)
  48. ; output:    ES:[DI] = pointer to day name string
  49. ;            CX = length of new string
  50. ;            
  51. ; Note: the day name string is not zero-terminated
  52. ;* * * * * * * * * * * * * *
  53. 
  54.     public    DAY_TO_ASCII
  55. DAY_TO_ASCII    proc    far
  56.     mov    di,offset days
  57.     call    lookup
  58.     retf
  59. DAY_TO_ASCII    ENDP    
  60.     
  61. days    label    byte        
  62.     db    'Sunday   '
  63.     db    'Monday   '
  64.     db    'Tuesday  '
  65.     db    'Wednesday'
  66.     db    'Thursday '
  67.     db    'Friday   '
  68.     db    'Saturday '
  69. ;--------------------------------------------------------
  70. ; local subroutine to index into a table
  71. ;  inputs:  cs:di points at table
  72. ;              cx is increment into table (1-12)
  73. ;  output:  es:di points at table entry
  74. ;              cx is length of table entry
  75. ;
  76. lookup:    cld
  77.     push    cs
  78.     pop    es        ;setup es
  79.     dec    cx
  80.     jcxz    lookup_exit    ;jmp if done
  81. lookup_lp:    
  82.     add    di,9        ;move to next table entry
  83.     loop    lookup_lp    ;loop till done
  84. lookup_exit:
  85.     push    di
  86.     mov    al,' '
  87.     mov    cx,9
  88.     repnz    scasb        ;find length of table entry
  89.     je    lookup_set    ;jmp if lenght found
  90.     mov    cx,-1
  91. lookup_set:    
  92.     sub    cx,9
  93.     neg    cx
  94.     dec    cx
  95.     pop    di        ;get ptr to table entry
  96.     ret    
  97.  
  98.  
  99. ;-----------------------------------------------------
  100.  
  101. LIBSEG    ENDS
  102.     end
  103.