home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / GRLF-C-1.ZIP / GCOMM / TIMER.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-08-14  |  3.0 KB  |  88 lines

  1.                 page    58,132
  2. ;
  3. ; timer.asm
  4. ; contains: timer()
  5. ;
  6. ;
  7. ; The Greenleaf Comm Library
  8. ;
  9. ; Copyright (C) 1984-90 Greenleaf Software Inc.  All Rights Reserved.
  10. ;
  11. ;
  12.                 include model.h
  13.                 include prologue.h
  14.                 name    timer
  15.                 pseg    timer
  16.  
  17. ;==>--  void timer(n)
  18. ;
  19. ;;      ARGUMENTS:
  20. ;         (unsigned) n  -  Number of 1/18.2 second intervals to delay
  21. ;
  22. ;;      DESCRIPTION:
  23. ;         This function provides a timed delay of the indicated number
  24. ;         of 1/18.2 second intervals.  It calls the ROM-BIOS timer routine
  25. ;         via interrupt 0x1a.
  26. ;
  27. ;;      SIDE EFFECTS:
  28. ;         The ROM-BIOS maintains a flag at ROMDATA:TIMER_OFL that is set
  29. ;         when the timer rolls over to the next day.  Calling interrupt
  30. ;         0x1A causes this flag to be cleared.  Subsequent calls to the
  31. ;         ROM-BIOS timer routine by MS-DOS will not detect that it is time
  32. ;         for the date to be rolled over.  If this timer() function detects
  33. ;         that the day has rolled over the ROMDATA:TIMER_OFL flag is set back
  34. ;         to 1 and the DOS get time function is called so that MS-DOS can
  35. ;         update the date.  This feature is controlled by the conditional
  36. ;         CHKROLOVR.  Setting it to 0 will disable.
  37. ;
  38. ;;      AUTHOR:
  39. ;        ""   03-FEB-1987  10:18:44.38
  40. ;
  41. ;;      MODIFICATIONS:
  42. ;        ""   25-MAR-1987  09:24:39.08
  43. ;          Modified to fix date rollover problem (with conditional
  44. ;          CHKROLOVR).
  45. ;;;
  46. CHKROLOVR       equ     1
  47.         if      CHKROLOVR
  48. ROMDATA         equ     40h             ;ROM Bios Data Segment
  49. TIMER_OFL       equ     70h             ;Offset of timer overflow flag
  50.         endif
  51.         cproc   timer,,,,,<NOSI,NODI>
  52.         call    _rdtime                 ;see what ticker says first
  53.         mov     bx,dx                   ;save initial low order count
  54. tloop:  call    _rdtime                 ;function to get timer
  55.         cmp     bx,dx                   ;see if low order has changed
  56.         jz      tloop                   ;if not get it again
  57.         mov     bx,dx                   ;update bx with new low order count
  58.         dec     word ptr parm1_         ;--interval
  59.         jnz     tloop                   ;if not down to 0
  60.         cproce
  61. _rdtime proc    near
  62.         xor     ah,ah
  63.         int     1ah                     ;get time to cx:dx
  64.         or      al,al                   ;has date rolled?
  65.         jnz     fixd
  66.         ret
  67. fixd:
  68.         if      CHKROLOVR
  69.          push   bx
  70.          push   dx
  71.          push   bp
  72.          push   ds
  73.          mov    ax,ROMDATA              ;We set the timer overflow flag
  74.          mov    ds,ax                   ;then make the DOS call to get
  75.          mov    bx,TIMER_OFL
  76.          mov    byte ptr [bx],1
  77.          pop    ds
  78.          mov    ah,2ch
  79.          int    21h
  80.          pop    bp
  81.          pop    dx
  82.          pop    bx
  83.         endif
  84.         ret
  85. _rdtime endp
  86.         endps
  87.         end
  88.