home *** CD-ROM | disk | FTP | other *** search
/ Groovy Bytes: Behind the Moon / groovybytes.iso / GROOVY / SND_TOOL / FUNK108A.ZIP / DOS32V30.ZIP / EXAMPLES / EG7.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-05-16  |  5.9 KB  |  234 lines

  1. ;***************************************************************************
  2. ; EG8.ASM        A program will show the video card memory write speed.
  3. ;
  4. ;***************************************************************************
  5.  
  6. .386
  7.  
  8. .MODEL FLAT
  9. .STACK 4000h
  10.  
  11. CYCLES          EQU     18
  12. FREQ            EQU     18
  13.  
  14.  
  15.  
  16. ;  Macro to print some text on the screem
  17. ;
  18. Print MACRO string
  19. local @text,@skip
  20.     mov edx,offset @text
  21.     mov ah,9
  22.     int 21h
  23.     jmp @skip
  24. @text db string,36
  25. @skip:
  26. ENDM
  27.  
  28.  
  29.     .DATA
  30.  
  31. Video_Mem       DD      ?
  32. Ticks           DD      ?
  33. Writes          DD      8 DUP (0)
  34. old_INT8        DF      ?
  35.  
  36.     .CODE
  37.  
  38.  
  39. Video_Speed:                                     ; Start of program
  40.  
  41.  
  42.         mov     ax,3                    ; Reset TEXT mode
  43.         int     10h
  44.  
  45.         mov     ax,0EE02h
  46.         int     31h
  47.         neg     ebx
  48.         add     ebx,0b8000h
  49.         mov     Video_Mem,ebx
  50.  
  51.     ;****** hook timer interrupt **********
  52.         mov     ax,204h
  53.         mov     bl,8
  54.         int     31h
  55.         mov     dword ptr old_INT8,edx          ; save old vector
  56.         mov     word ptr old_INT8[4],cx
  57.  
  58.         mov     ax,205h
  59.         mov     edx,Offset Timer_ISR            ; put in new vector
  60.         mov     cx,cs
  61.         int     31h
  62.  
  63.  
  64.  ;------------ fill memory with REP STOSB for a set amount of time --------
  65.         cld
  66.         mov     ticks,0
  67.         xor     eax,eax
  68. Loop00:
  69.         mov     edi,Video_Mem
  70.         mov     ecx,4000
  71.         rep     stosb
  72.         inc     al
  73.         add     Writes[0],4000 * FREQ
  74.         cmp     ticks,CYCLES
  75.         jb Loop00
  76.  
  77.  
  78.  ;------------ fill memory with REP STOSW for a set amount of time --------
  79.         mov     ticks,0
  80.         xor     eax,eax
  81. Loop01:
  82.         mov     edi,Video_Mem
  83.         mov     ecx,2000
  84.         rep     stosw
  85.         inc     al
  86.         inc     ah
  87.         add     Writes[4],4000 * FREQ
  88.         cmp     ticks,CYCLES
  89.         jb  Loop01
  90.  
  91.  
  92.  ;------------ fill memory with REP STOSD for a set amount of time --------
  93.         mov     ticks,0
  94.         xor     eax,eax
  95. Loop02:
  96.         mov     edi,Video_Mem
  97.         mov     ecx,1000
  98.         rep     stosd
  99.         add     Writes[8],4000 * FREQ
  100.         inc     al
  101.         inc     ah
  102.         push    ax
  103.         push    ax
  104.         pop     eax
  105.         cmp     ticks,CYCLES
  106.         jb Loop02
  107.  
  108.  
  109.  ;------------ fill CPU memory with REP STOSD for a set amount of time --------
  110.         mov     ticks,0
  111.         xor     eax,eax
  112.         sub     esp,2000h           ; Allocate 8K on the stack
  113.         mov     ebx,esp
  114. Loop03:
  115.         mov     edi,ebx
  116.         mov     ecx,2000h/4
  117.         rep     stosd
  118.         add     Writes[12],2000h * FREQ
  119.         inc     al
  120.         inc     ah
  121.         push    ax
  122.         push    ax
  123.         pop     eax
  124.         cmp     ticks,CYCLES
  125.         jb Loop03
  126.  
  127. skip:
  128.  
  129.         ;******* reset text mode **********
  130.         mov     ax,3
  131.         int     10h
  132.  
  133.  
  134.         ;******* return origonal interrupt vector **********
  135.         mov     ax,205h
  136.         mov     edx,dword ptr old_INT8
  137.         mov     cx,word ptr old_INT8[4]
  138.         mov     bl,8
  139.         int     31h
  140.  
  141.         ;******* print transfer rates on the screen **********
  142.  
  143.         Print   ' Video transfer speed using 8bit writes:  '
  144.         mov     eax,Writes[0]
  145.         mov     ebx,CYCLES
  146.         xor     edx,edx
  147.         div     ebx
  148.         shr     eax,10
  149.         call    Print_DecDword
  150.         Print   <' Kb/s',10,13>
  151.  
  152.         Print   ' Video transfer speed using 16bit writes:  '
  153.         mov     eax,Writes[4]
  154.         mov     ebx,CYCLES
  155.         xor     edx,edx
  156.         div     ebx
  157.         shr     eax,10
  158.         call    Print_DecDword
  159.         Print   <' Kb/s',10,13>
  160.  
  161.         Print   ' Video transfer speed using 32bit writes:  '
  162.         mov     eax,Writes[8]
  163.         mov     ebx,CYCLES
  164.         xor     edx,edx
  165.         div     ebx
  166.         shr     eax,10
  167.         call    Print_DecDword
  168.         Print   <' Kb/s',10,13,10,13>
  169.  
  170.         Print   ' CPU memory fill rate using 32bit writes:  '
  171.         mov     eax,Writes[12]
  172.         mov     ebx,CYCLES
  173.         xor     edx,edx
  174.         div     ebx
  175.         shr     eax,10
  176.         call    Print_DecDword
  177.         Print   <' Kb/s',10,13,10,13>
  178.  
  179.         Print   <' If this is a genuine 32bit video card then the 32bit transfer',10,13>
  180.         Print   <' rate should be significatly greater (a factor between 1.5 and 2) than ',10,13>
  181.         Print   <'the 16bit rate.',10,13>
  182.  
  183.         mov   ax,4C00h                          ; Termiate the program
  184.         int   21h
  185.  
  186.  
  187.  
  188. Timer_ISR PROC
  189.         Push    eax
  190.         Push    ds
  191.         mov     ax,SEG Timer_ISR
  192.         mov     ds,ax
  193.         inc     Ticks
  194.         mov     al,20h
  195.         out     20h,al
  196.         Pop     ds
  197.         Pop     eax
  198.         iretd
  199. Timer_ISR ENDP
  200.  
  201.  
  202. ;╒══════════════════════════════════════════════════════════════════════════╕
  203. ;│                                                                          │
  204. ;│  procedure to print the Decimal value of EAX                             │
  205. ;│                                                                          │
  206. ;└──────────────────────────────────────────────────────────────────────────
  207. ; ***************  prints decimal EAX  ******************
  208. Print_DecDword   PROC
  209.         pushad
  210.         mov     ESI,4*5
  211.         mov     ecx,eax
  212. dec83:
  213.         mov    eax,ECX
  214.         xor    edx,edx
  215.         div     Dec_divider[ESI]
  216.         mov    ECX,EDX        ; reuse remainder
  217.                 add al,'0'      ; use quotient as digit number
  218.                 mov     dl,al
  219.                 mov     ah,2
  220.                 int     21h             ; send character to screen
  221.         sub ESI,4
  222.         jge dec83
  223.         popad
  224.         RET
  225. Print_DecDword        ENDP
  226.  
  227.  
  228. align 4
  229. dec_divider dd 1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000
  230. ;-------------------------------------------------------
  231.  
  232.  
  233. END  Video_Speed
  234.