home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / modem / byepc300.arc / BYESTAT.ARC / TDELAY.ASM < prev    next >
Assembly Source File  |  1987-04-20  |  3KB  |  112 lines

  1.           page 60,132
  2.           title Hardware Timing Function MSC 3.00 & 4.00
  3. ;
  4. YES    equ    1
  5. NO    equ    0
  6. ;
  7. ;---------------------------------------------------------------------------
  8. ;  Memory Model selector for Microsoft C v3.0, ASM files.
  9. ;---------------------------------------------------------------------------
  10. ;  -- model --              -- equates --
  11. ; {small}            _LDATA = NO    _LCODE = NO
  12. ; {medium}            _LDATA = NO    _LCODE = YES
  13. ; {compact}            _LDATA = YES   _LCODE = NO
  14. ; {large}            _LDATA = YES   _LCODE = YES
  15. ;---------------------------------------------------------------------------
  16. ;
  17. ;    -- Small Memory Model --
  18. ;
  19. _LDATA    equ   NO          ; data area size
  20. _LCODE    equ   NO          ; code pointers far.
  21. ;
  22. ;
  23. include MODEL.H           ; get memory model header
  24. ;
  25. ;---------------------------------------------------------------------------
  26. ;  Set up the program segment for the memory model selected.
  27. ;---------------------------------------------------------------------------
  28. ;
  29. if _LCODE
  30.     pseg utils
  31. else
  32.     pseg
  33. endif
  34. ;
  35. ;---------------------------------------------------------------------------
  36. ;
  37. ;  void tdelay( n )
  38. ;  int n;        -- Number of 1/18.2 sec intervals to delay
  39. ;
  40. ;  Provide a timed delay of the indicated number of 1/18.2 second
  41. ;  intervals.  This permits timing of all manner of things.
  42. ;
  43. ;---------------------------------------------------------------------------
  44. ;
  45. if _LCODE
  46.     dynx    struc
  47.     xscx    dw        ?         ; tdelay data storage area
  48.     xsdx    dw        ?
  49.     x_bp    dw        ?
  50.     xret    dd        ?
  51.     xarg1   dw        ?
  52.     dynx    ends
  53. else
  54.     dynx    struc
  55.     xscx    dw        ?
  56.     xsdx    dw        ?
  57.     x_bp    dw        ?
  58.     xret    dw        ?
  59.     xarg1   dw        ?
  60.     dynx    ends
  61. endif
  62. ;
  63.     public _tdelay
  64. ;
  65. if _LCODE
  66. _tdelay proc     far
  67. else
  68. _tdelay proc     near
  69. endif
  70.     push    bp
  71.     sub    sp,4            ; local variables
  72.     mov    bp,sp
  73.     push    si
  74.     push    di
  75.     xor    ah,ah            ; see what ticker says first
  76.     int    1Ah            ; CX:DX is starting point.
  77.     mov    [bp].xsdx,dx        ; save it on the stack
  78.     mov    [bp].xscx,cx
  79.  
  80. tloop:    xor    ah,ah            ; function to get tdelay
  81.     int    1Ah            ; get tdelay tiks to CX:DX
  82.     cmp    cx,word ptr [bp].xscx    ; check hi-order part
  83.     je    tl2            ; if same
  84. ;
  85. ;  Hi-order part has rolled over, so add instead of subtracting
  86. ;  the lo-order parts, with increment
  87. ;
  88.     add    dx,[bp].xsdx
  89.     inc    dx
  90.  
  91. tl2:    sub    dx,[bp].xsdx        ; low-order part
  92.     cmp    dx,word ptr [bp].xarg1    ; is elapsed = specified ?
  93.     jl    tloop
  94.     add    sp,4
  95.     pop    di
  96.     pop    si
  97.     pop    bp
  98.     ret
  99. _tdelay  endp
  100. ;
  101. ;---------------------------------------------------------------------------
  102. ;   End of program code
  103. ;---------------------------------------------------------------------------
  104. ;
  105. if          _LCODE
  106.           endps utils
  107. else
  108.           endps
  109. endif
  110.           end
  111.  
  112.