home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 1998 April / Freeware-CD.bin / cputst / cpuinfo / cpuinfo.EXE / SOURCE / CPUSPEED / TIMEPROC.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-10-26  |  3.1 KB  |  124 lines

  1. ;***************************************************************
  2. ; MASM file: timeproc.asm... for CPUSPEED.EXE
  3. ;
  4. ;       This program has been developed by Intel Corporation.  
  5. ;        You have Intel's permission to incorporate this code 
  6. ;       into your product, royalty free.  Intel has various 
  7. ;        intellectual property rights which it may assert under
  8. ;       certain circumstances, such as if another manufacturer's
  9. ;       processor mis-identifies itself as being "GenuineIntel"
  10. ;        when the CPUID instruction is executed.
  11. ;
  12. ;       Intel specifically disclaims all warranties, express or
  13. ;       implied, and all liability, including consequential and
  14. ;        other indirect damages, for the use of this code, 
  15. ;        including liability for infringement of any proprietary
  16. ;        rights, and including the warranties of merchantability
  17. ;        and fitness for a particular purpose.  Intel does not 
  18. ;        assume any responsibility for any errors which may 
  19. ;        appear in this code nor any responsibility to update it.
  20. ;
  21. ;****************************************************************
  22.  
  23. ITERATIONS equ 1500
  24.  
  25. .8086
  26. .model medium,c
  27. .code
  28.  
  29.  
  30. .386        ; Allow 386 opcode throughout program
  31.  
  32.  
  33.             ; Declare functions to be public and therefore accessible by C programs.
  34. public Time_Processor_bsf
  35. public GrabTime
  36.  
  37.  
  38. ;***************************************************************
  39. ; TIME_PROCESSOR_BSF() -- Perform nITERATIONS of the BSF 
  40. ;                         instructions.
  41. ;
  42. ; Inputs: none
  43. ;
  44. ; Returns:
  45. ;    # of ticks instruction sequence ran.
  46. ;***************************************************************
  47.  
  48. Time_Processor_bsf proc    far
  49.  
  50. ;---------- Initialize and Clear Timer -------------------------
  51.  
  52.             mov al,10111000b    ; Channel 2, LSB+MSB, mode 4,
  53.             out 43h,al          ;    binary
  54.  
  55.             in    al,61h
  56.             or    al,1
  57.             out 61h,al
  58.  
  59.             xor al,al           ; Reset timer
  60.             out 42h,al
  61.             out 42h,al
  62.                             
  63.                             
  64. ;---------- Run nIterations of the BSF Instruction -------------
  65.  
  66.         mov eax,80000000h
  67.         mov bx,ITERATIONS
  68.     
  69. loop1:    bsf ecx,eax
  70.         
  71.         dec    bx
  72.         jnz    loop1
  73.                             
  74.                             
  75. ;---------- Read Timer Ticks -----------------------------------
  76.  
  77.         in    al,42h                ; MSB timer
  78.         mov    ah,al
  79.         in    al,42h                ; LSB timer
  80.         xchg    al,ah
  81.         neg    ax
  82.  
  83.          retf                    ; Set return type to be far
  84.  
  85. Time_Processor_bsf endp
  86.  
  87.  
  88.  
  89. ;***************************************************************
  90. ; GRABTIME -- Read Time from Counter.
  91. ;
  92. ; -- this code is in timeproc.asm
  93. ;
  94. ; Inputs: none
  95. ;
  96. ; Returns:
  97. ;    Value in PC Chipset Timer.
  98. ;***************************************************************
  99.  
  100. GrabTime proc
  101.  
  102. ;---------- Initialize Timer -----------------------------------
  103.  
  104.         mov al,10111000b    ; Channel 2, LSB+MSB, mode 4,
  105.         out 43h,al            ;   binary
  106.         in al,61h
  107.         or al,1
  108.         out 61h,al                                              
  109.         
  110.  
  111. ;---------- Read Timer Ticks -----------------------------------
  112.  
  113.         in al,42h    ;MSB     ; Read timer ticks.
  114.         mov ah,al
  115.         in al,42h    ;LSB
  116.         xchg al,ah
  117.         neg ax
  118.  
  119.         retf                    ; Set return type to be far.
  120.  
  121. GrabTime endp
  122.  
  123. end
  124.