home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / util2 / timer.lzh / TIMER.ASM next >
Assembly Source File  |  1985-12-08  |  9KB  |  376 lines

  1. eseg    segment at 0000h
  2.         org 4*60h
  3. irq60ip dw ?
  4. irq60cs dw ?
  5. eseg    ends
  6.  
  7. dseg    segment
  8. Header  db '╔═════════════════════════════════════════════════════════════════════════════╗',0ah,0dh
  9.         db '║             IBM PC Timing Program - Tests speed of 8088 µProcessor          ║',0ah,0dh
  10.         db '║             ───────────────written by Allen Priest────────────────          ║',0ah,0dh
  11.         db '║                                                                             ║',0ah,0dh
  12.         db '║             Times are based on the internal clock and are only              ║',0ah,0dh
  13.         db '║             accurate to 1/18 of a second. The number of clock               ║',0ah,0dh
  14.         db '║             cycles is based on an 8088 µP running at 4.77 MHz.              ║',0ah,0dh
  15.         db '╠═════════════════════════════════════════════════════════════════════════════╣',0ah,0dh,'$'
  16. Last    db '╚═════════════════════════════════════════════════════════════════════════════╝',0ah,0dh,'$'
  17. TotTime dw 0
  18. E_Time  dw ?
  19. Sec     db ' 1/100 seconds  $'
  20. Clocks  db ' Clock Cycles/Instruction ║',0ah,0dh,'$'
  21. LOPMess db '║ Loops:                  $'
  22. DivMess db '║ Divides:                $'
  23. IdiMess db '║ Signed Divides:         $'
  24. MulMess db '║ Multiplies:             $'
  25. ImuMess db '║ Signed Multiplies:      $'
  26. AAMMess db '║ Ascii Adjusts for Mul:  $'
  27. AADMess db '║ Ascii Adjusts for Div:  $'
  28. ADDMess db '║ Additions:              $'
  29. SUBMess db '║ Subtractions:           $'
  30. CALMess db '║ Subroutine Calls:       $'
  31. INTMess db '║ Interrupt Calls:        $'
  32. JMPMess db '║ Short Jumps:            $'
  33. CMPMess db '║ Compares:               $'
  34. P_PMess db '║ Pushes and Pops:        $'
  35. LoopCnt dw 0
  36.  
  37. dseg    ends
  38.  
  39. cseg    segment
  40.         assume cs:cseg,ds:dseg,es:eseg
  41. main    proc far
  42. start:  push ds
  43.         xor ax,ax
  44.         push ax
  45.         mov ax,dseg
  46.         mov ds,ax
  47.         mov ax,eseg
  48.         mov es,ax
  49.         mov es:[irq60ip],offset DummyInt
  50.         mov es:[irq60cs],seg DummyInt
  51.         mov dx,offset header
  52.         mov ah,09h
  53.         int 21h
  54.         Call Set_Start
  55.         Call Get_Start
  56.         mov di,4
  57. LOP:    mov cx,0ffffh
  58.         mov bx,00001h
  59.         mov ax,00001h
  60.         mov dx,00000h
  61. Bloopl: loop bloopl
  62.         dec di
  63.         jnz LOP
  64.         Call Get_Finish
  65.         mov dx,offset LOPMess
  66.         mov ah,09h
  67.         int 21h
  68.         Call Out_Time
  69.         Mov LOOPCnt,ax
  70.         Call Get_Start
  71.         mov di,4
  72. Div:    mov cx,0ffffh
  73.         mov bx,00001h
  74.         mov ax,00001h
  75.         mov dx,00000h
  76. Bloop1: div bx
  77.         loop bloop1
  78.         dec di
  79.         jnz Div
  80.         Call Get_Finish
  81.         mov dx,offset DivMess
  82.         mov ah,09h
  83.         int 21h
  84.         Call Out_Time
  85.         Call Get_Start
  86.         mov di,4
  87. IDiv:   mov cx,0ffffh
  88.         mov bx,00001h
  89.         mov ax,00001h
  90.         mov dx,00000h
  91. Bloop4: idiv bx
  92.         loop bloop4
  93.         dec di
  94.         jnz Idiv
  95.         Call Get_Finish
  96.         mov dx,offset IdiMess
  97.         mov ah,09h
  98.         int 21h
  99.         Call Out_Time
  100.         Call Get_Start
  101.         mov di,4
  102. Mul:    mov cx,0ffffh
  103.         mov bx,00000h
  104.         mov ax,00001h
  105.         mov dx,00000h
  106. Bloop2: mul bx
  107.         loop bloop2
  108.         dec di
  109.         jnz Mul
  110.         Call Get_Finish
  111.         mov dx,offset MulMess
  112.         mov ah,09h
  113.         int 21h
  114.         Call Out_Time
  115.         Call Get_Start
  116.         mov di,4
  117. IMul:   mov cx,0ffffh
  118.         mov bx,00000h
  119.         mov ax,00001h
  120.         mov dx,00000h
  121. Bloop5: imul bx
  122.         loop bloop5
  123.         dec di
  124.         jnz IMul
  125.         Call Get_Finish
  126.         mov dx,offset ImuMess
  127.         mov ah,09h
  128.         int 21h
  129.         Call Out_Time
  130.         Call Get_Start
  131.         mov di,4
  132. AAM:    mov cx,0ffffh
  133.         mov bx,00000h
  134.         mov ax,00001h
  135.         mov dx,00000h
  136. Bloop3: aam
  137.         loop bloop3
  138.         dec di
  139.         jnz AAM
  140.         Call Get_Finish
  141.         mov dx,offset AAMMess
  142.         mov ah,09h
  143.         int 21h
  144.         Call Out_Time
  145.         Call Get_Start
  146.         mov di,4
  147. AAD:    mov cx,0ffffh
  148.         mov bx,00000h
  149.         mov ax,00001h
  150.         mov dx,00000h
  151. Bloop6: aad
  152.         loop bloop6
  153.         dec di
  154.         jnz AAD
  155.         Call Get_Finish
  156.         mov dx,offset AADMess
  157.         mov ah,09h
  158.         int 21h
  159.         Call Out_Time
  160.         Call Get_Start
  161.         mov di,4
  162. ADDING: mov cx,0ffffh
  163.         mov bx,00000h
  164.         mov ax,00001h
  165.         mov dx,00000h
  166. Bloop7: add ax,[0000]
  167.         loop bloop7
  168.         dec di
  169.         jnz ADDING
  170.         Call Get_Finish
  171.         mov dx,offset ADDMess
  172.         mov ah,09h
  173.         int 21h
  174.         Call Out_Time
  175.         Call Get_Start
  176.         mov di,4
  177. SUBING: mov cx,0ffffh
  178.         mov bx,00000h
  179.         mov ax,00001h
  180.         mov dx,00000h
  181. Bloop8: sub ax,[0000]
  182.         loop bloop8
  183.         dec di
  184.         jnz SUBING
  185.         Call Get_Finish
  186.         mov dx,offset SUBMess
  187.         mov ah,09h
  188.         int 21h
  189.         Call Out_Time
  190.         Call Get_Start
  191.         mov di,4
  192. CALL:   mov cx,0ffffh
  193.         mov bx,00000h
  194.         mov ax,00001h
  195.         mov dx,00000h
  196. Bloop9: Call Dummy
  197.         loop bloop9
  198.         dec di
  199.         jnz CALL
  200.         Call Get_Finish
  201.         mov dx,offset CALMess
  202.         mov ah,09h
  203.         int 21h
  204.         Call Out_Time
  205.         Call Get_Start
  206.         mov di,4
  207. INT:    mov cx,0ffffh
  208.         mov bx,00000h
  209.         mov ax,00001h
  210.         mov dx,00000h
  211. Bloop0: Int 60h
  212.         loop bloop0
  213.         dec di
  214.         jnz INT
  215.         Call Get_Finish
  216.         mov dx,offset INTMess
  217.         mov ah,09h
  218.         int 21h
  219.         Call Out_Time
  220.         Call Get_Start
  221.         mov di,4
  222. JMP:    mov cx,0ffffh
  223.         mov bx,00000h
  224.         mov ax,00001h
  225.         mov dx,00000h
  226. Bloopa: jmp Dumb
  227. Dumb:   loop bloopa
  228.         dec di
  229.         jnz JMP
  230.         Call Get_Finish
  231.         mov dx,offset JMPMess
  232.         mov ah,09h
  233.         int 21h
  234.         Call Out_Time
  235.         Call Get_Start
  236.         mov di,4
  237. CMP:    mov cx,0ffffh
  238.         mov bx,00000h
  239.         mov ax,00001h
  240.         mov dx,00000h
  241. Bloopb: cmp ax,[0000]
  242.         loop bloopb
  243.         dec di
  244.         jnz CMP
  245.         Call Get_Finish
  246.         mov dx,offset CMPMess
  247.         mov ah,09h
  248.         int 21h
  249.         Call Out_Time
  250.         Call Get_Start
  251.         mov di,4
  252. P_P1:   mov cx,0ffffh
  253.         mov bx,00000h
  254.         mov ax,00001h
  255.         mov dx,00000h
  256. Bloopc: push ax
  257.         pop  ax
  258.         loop bloopc
  259.         dec di
  260.         jnz P_P1
  261.         Call Get_Finish
  262.         mov dx,offset P_PMess
  263.         mov ah,09h
  264.         int 21h
  265.         Call Out_Time
  266.         mov dx,offset last
  267.         mov ah,09h
  268.         int 21h
  269.         Call Set_End
  270.         ret
  271. main    endp
  272.  
  273. Dummy   proc near
  274.         ret
  275. Dummy   endp
  276.  
  277. DummyInt   proc near
  278.         iret
  279. DummyInt   endp
  280.  
  281. Set_Start proc near
  282.         mov ah,02ch
  283.         int 21h
  284.         xor bx,bx
  285.         mov bl,dl
  286.         mov al,dh
  287.         mov cl,100
  288.         mul cl
  289.         add bx,ax
  290.         mov TotTime,bx
  291.         ret
  292. Set_Start endp
  293.  
  294. Set_End proc near
  295.         mov ax,TotTime
  296.         mov cl,100
  297.         div cl
  298.         mov TotTime,ax
  299.         mov ah,02ch
  300.         int 21h
  301.         mov dx,TotTime
  302.         cmp dh,60
  303.         jl SetTime
  304.         inc cl
  305.         sub dh,60
  306.         cmp cl,60
  307.         jl SetTime
  308.         inc ch
  309.         sub cl,60
  310.         cmp ch,23
  311.         jl SetTime
  312.         mov ch,00
  313. SetTime:
  314.         mov ah,02dh
  315.         int 21h
  316.         ret
  317. Set_End endp
  318.  
  319. Get_Start proc near
  320.         mov ah,02ch
  321.         int 21h
  322.         mov dx,0000h
  323.         mov ah,02dh
  324.         int 21h
  325.         ret
  326. Get_Start endp
  327.  
  328. Get_Finish proc near
  329.         mov ah,02ch
  330.         int 21h
  331.         mov E_Time,DX
  332.         ret
  333. Get_Finish endp
  334.  
  335. Out_Time proc near
  336.         mov ax,E_Time
  337.         mov bx,ax
  338.         xor bh,bh
  339.         mov al,ah
  340.         mov cl,100
  341.         mul cl
  342.         add bx,ax
  343.         add TotTime,bx
  344.         push bx
  345.         call binidec
  346.         mov dx,offset sec
  347.         mov ah,09h
  348.         int 21h
  349.         pop bx
  350.         mov ax,bx
  351.         shl ax,1
  352.         mov dx,0000
  353.         mov cx,11
  354.         div cx
  355.         cmp dx,3
  356.         jl  OutDec
  357.         add ax,1
  358. OutDec: sub ax,LoopCnt         ;subtract time of LOOP instruction
  359.         mov bx,ax
  360.         push ax
  361.         call binidec
  362.         mov dx,offset clocks
  363.         mov ah,09h
  364.         int 21h
  365.         pop ax
  366.         ret
  367. Out_Time endp
  368.  
  369. include outdec.asm
  370.  
  371. cseg    ends
  372.         end start
  373.  
  374.  
  375.  
  376.