home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / pcmag / vol10n20.zip / DELAYC.ZIP / DELAYC.ASM
Assembly Source File  |  1991-07-23  |  3KB  |  63 lines

  1.               PAGE  96,132
  2. ;**********************************************************************
  3. ; DELAYC.ASM                      Clipper UDF to delay n timer ticks
  4. ; Author..: Sal Ricciardi
  5. ;
  6. ; Use this file for program delays that are the same irregardless
  7. ; of CPU type and speed.  Relies on the BIOS timer tick count.
  8. ; Maximum delay is 65535 ticks (about 1 hr).  Does not validate
  9. ; passed parameters.
  10. ;
  11. ; Usage:
  12. ;
  13. ; DELAY(10*18.2)             && for 10 seconds
  14. ;
  15. ; Create .OBJ with:   TASM delayc  (Borland Turbo Assembler 2.5)
  16. ;
  17. ; To link into your Clipper 5 app:
  18. ;   RTLINK FILE yourapp.obj, DELAYC.OBJ LIB CLIPPER, EXTEND
  19. ;
  20. ; To link into your Clipper Summer 87 app:
  21. ;   PLINK86 FILE yourapp.obj, DELAYC.OBJ LIB CLIPPER, EXTEND
  22. ;
  23. ;**********************************************************************
  24.               .MODEL LARGE
  25.               EXTRN __parni:FAR, __ret:FAR
  26.               PUBLIC delay
  27.               .CODE
  28.  
  29. Timerlow      EQU   WORD PTR ds:[06ch]
  30.  
  31. delay         PROC  FAR                         ;entry point
  32.               push  ax                          ;save registers
  33.               push  bx                          ;
  34.               push  cx                          ;
  35.               push  dx                          ;
  36.               push  ds                          ;
  37.               mov   ax,1                        ;routine to get a numeric
  38.               push  ax                          ;parameter from Clipper,
  39.               call  __parni                     ;converted to an int in
  40.               add   sp,2                        ;ax
  41.               mov   cx,ax                       ;put it in cx
  42.               jcxz  d999                        ;skip if cx==0
  43.               mov   ax,040h                     ;
  44.               mov   ds,ax                       ;ds == 040h
  45. d010:                                           ;
  46.               mov   ax,Timerlow                 ;get timer tick count low
  47. d020:                                           ;
  48.               cmp   ax,Timerlow                 ;watch for it to change
  49.               je    d020                        ;keep watching until it does
  50.               loop  d010                        ;keep looping until cx == 0
  51. d999:                                           ;
  52.               call  __ret                       ;post NIL return value
  53.  
  54.               pop   ds                          ;restore registers
  55.               pop   dx                          ;
  56.               pop   cx                          ;
  57.               pop   bx                          ;
  58.               pop   ax                          ;
  59.               ret                               ;return to caller
  60. delay         ENDP
  61.  
  62.               END
  63.