News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Quick play with GetVersionEx()

Started by hutch--, April 07, 2007, 02:18:52 PM

Previous topic - Next topic

hutch--




; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

comment * -----------------------------------------------------
                        Build this  template with
                       "CONSOLE ASSEMBLE AND LINK"
        ----------------------------------------------------- *

    .code

start:
   
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    call main
    inkey
    exit

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

main proc

    LOCAL viex  :OSVERSIONINFOEX
    LOCAL w2k   :DWORD
    LOCAL wxp   :DWORD

    mov w2k, 0
    mov wxp, 0

  ; -----------------------------------------------
  ; load structure size before calling API function
  ; -----------------------------------------------
    mov viex.dwOSVersionInfoSize, sizeof OSVERSIONINFOEX

    invoke GetVersionEx,ADDR viex

  ; ------------------
  ; display OS version
  ; ------------------
    .if viex.dwMajorVersion < 4
      print "Version unknown or old version",13,10
    .elseif viex.dwMajorVersion == 4
      print "Windows version is NT4",13,10
    .elseif viex.dwMajorVersion == 5
      .if viex.dwMinorVersion == 0
        print "Windows version is Win 2000",13,10
        mov w2k, 1
      .elseif viex.dwMinorVersion == 1
        print "Windows version is Win XP",13,10
        mov wxp, 1
      .elseif viex.dwMinorVersion == 2
        print "Windows version is Server 2003 or XP64",13,10
      .endif
    .elseif viex.dwMajorVersion == 6
      print "Windows version is Vista or Server Longhorn",13,10
    .endif

  ; --------------------
  ; display build number
  ; --------------------
    print "Windows build number "
    print str$(viex.dwBuildNumber),13,10

  ; ----------------------------------------
  ; display service pack number if installed
  ; ----------------------------------------
    movzx eax, BYTE PTR viex.szCSDVersion
    .if eax == 0
      print "No service pack installed",13,10
    .else
      print ADDR viex.szCSDVersion,13,10
    .endif

    print chr$(13,10)

    invoke IsProcessorFeaturePresent,8
    .if eax == 0
      print "RDTSC not supported",13,10
    .else
      print "RDTSC supported",13,10
    .endif

    invoke IsProcessorFeaturePresent,3
    .if eax == 0
      print "MMX not available",13,10
    .else
      print "MMX available",13,10
    .endif

    invoke IsProcessorFeaturePresent,6
    .if eax == 0
      print "SSE not available",13,10
    .else
      print "SSE available",13,10
    .endif


    .if w2k == 0
    invoke IsProcessorFeaturePresent,18
    .if eax == 0
      print "SSE2 not available",13,10
    .else
      print "SSE2 available",13,10
    .endif
    .endif

    invoke IsProcessorFeaturePresent,7
    .if eax == 0
      print "3D NOW not available",13,10
    .else
      print "3D NOW available",13,10
    .endif

    ret

main endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

end start


Output on my Win2000 sp4

Windows version is Win 2000
Windows build number 2195
Service Pack 4

RDTSC supported
MMX available
SSE available
3D NOW not available
Press any key to continue ...
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Ratch

hutch--,

    .if w2k == 0
    invoke IsProcessorFeaturePresent,18
    .if eax == 0
      print "SSE2 not available",13,10
    .else
      print "SSE2 available",13,10
    .endif
    .endif


     I do believe you have a typo.  That constant should be 10, not 18.  Ratch

http://msdn2.microsoft.com/en-us/library/ms724482.aspx

hutch--

Thanks, you are right. I lost one lense out of my prescription glasses last night and am using a spare pair that are the wrong strength.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Vortex

It works fine :

Windows version is Win XP
Windows build number 2600
Service Pack 2

RDTSC supported
MMX available
SSE available
SSE2 available
3D NOW not available

ecube

says SSE2 not available but marks code(http://www.masm32.com/board/index.php?topic=1909.0) says sse2 is supported on my processor :(

hutch--

Cube,

The limitation is in the API used, on win 2000 even if the processor support SSE2 or SSE3 it wil not display it.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php