home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / GRLF-C-2.ZIP / GFUNC / TIMER.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-05-30  |  2.1 KB  |  82 lines

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