home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH09 / EX9_3.ASM < prev    next >
Encoding:
Assembly Source File  |  1996-02-08  |  1.6 KB  |  96 lines

  1. ; Ex9_3.asm
  2. ; Software Delay Loop
  3.  
  4.         .xlist
  5.         include     stdlib.a
  6.         includelib    stdlib.lib
  7.         .list
  8.  
  9. dseg        segment    para public 'data'
  10.  
  11.  
  12. ; TimerValue is the count-down value that produces a 55 millisecond delay.
  13. ; This is a magic number empirically determined for a 66 Mhz 80486 System.
  14.  
  15. TimerValue    dword    222000
  16.  
  17.  
  18. dseg        ends
  19.  
  20.  
  21. cseg        segment    para public 'code'
  22.         assume    cs:cseg, ds:dseg
  23.  
  24. wp        textequ    <word ptr>
  25.  
  26.  
  27. ; Delay-    This is a software timer procedure that counts down a timer value
  28. ;        until it hits zero.  This procedure is extremely senstive to type
  29. ;        of CPU and CPU clock rate.
  30.  
  31. Delay        proc
  32.         push    es
  33.         push    ax
  34.  
  35.         push    wp TimerValue+2
  36.         push    wp TimerValue
  37.  
  38. TimeRTC:    sub    wp TimerValue, 1
  39.         sbb    wp TimerValue+2, 0
  40.         jne    TimeRTC
  41.         cmp    wp TimerValue, 0
  42.         jne    TimeRTC
  43.  
  44.  
  45. DelayDone:
  46.         pop    wp TimerValue
  47.         pop    wp TimerValue+2
  48.         pop    ax
  49.         pop    es
  50.         ret
  51. Delay        endp
  52.  
  53.  
  54.  
  55.  
  56. Main        proc
  57.         mov    ax, dseg
  58.         mov    ds, ax
  59.         mov    es, ax
  60.  
  61.  
  62.  
  63.         printf
  64.         byte    cr,lf
  65.         byte    "Software delay loop test",cr,lf
  66.         byte    "------------------------",cr,lf,lf
  67.         byte    "Delay factor: %ld",cr,lf
  68.         byte    cr,lf
  69.         byte    "Press any key to begin an 11 second delay "
  70.         byte    "(approx).",0
  71.         dword    TimerValue
  72.  
  73.         getc
  74.         putcr
  75.         mov    cx, 200        ;55 msec * 200 = 11 sec.
  76. Delay18:    call    Delay
  77.         loop    Delay18
  78.  
  79.  
  80. Quit:        ExitPgm            ;DOS macro to quit program.
  81. Main        endp
  82.  
  83. cseg            ends
  84.  
  85.  
  86.  
  87. sseg        segment    para stack 'stack'
  88. stk        db    1024 dup ("stack   ")
  89. sseg        ends
  90.  
  91.  
  92. zzzzzzseg    segment    para public 'zzzzzz'
  93. LastBytes    db    16 dup (?)
  94. zzzzzzseg    ends
  95.         end    Main
  96.