home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / timer / timerzen / testimer.asm < prev    next >
Encoding:
Assembly Source File  |  1991-05-28  |  947 b   |  58 lines

  1. ;
  2. ; *** Listing 2 ***
  3. ;
  4. ; Program to measure performance of code that takes less than
  5. ; 54 ms to execute.
  6. ;
  7. ; Link with Listing 1.
  8. ;
  9. COM    =    1
  10. EXE    =    0
  11.  
  12. if    EXE
  13. stack    segment    para stack 'STACK'
  14.     db    512 dup(?)
  15. stack    ends
  16. endif
  17.  
  18. CODE    segment    para public 'CODE'
  19.     assume    cs:CODE, ds:CODE
  20.     extrn    _TimerOn:near, _TimerOff:near, _TimerReport:near
  21.  
  22. if    COM
  23.     org    100H        ;Let's make this a .COM file, eh?    v1.1
  24. endif
  25.  
  26. Start    proc    near
  27. ; Start the timer.
  28.     call    _TimerOn
  29.  
  30. IFDEF    REALLY_DUMB_CODE
  31. ; ***** Code to be measured starts here *****
  32.     rept    1000
  33.     shr    dx,1
  34.     shr    dx,1
  35.     shr    dx,1
  36.     add    ax,dx
  37.     endm
  38. ; ***** Code to be measured ends here *****
  39. ELSE
  40.     mov    cx,1000
  41. testlup:
  42.     xor    dx,dx        ;clear
  43.     mul    ax        ;this takes time .. and not code!
  44.     loop    testlup
  45. ENDIF
  46. ;
  47. ; Stop the timer.
  48.     call    _TimerOff
  49. ; Display the results.
  50.     call    _TimerReport
  51. ; Terminate the program.
  52.     mov    ah,4ch
  53.     int    21h
  54. Start    endp
  55.  
  56. CODE    ends
  57.     end    Start
  58.