src/cpuinfo/SDL_cpuinfo.c
changeset 3499 4cf8a1423d57
parent 3498 a4ce84c4f211
child 3515 d94e331e85fa
     1.1 --- a/src/cpuinfo/SDL_cpuinfo.c	Mon Nov 30 19:52:34 2009 +0000
     1.2 +++ b/src/cpuinfo/SDL_cpuinfo.c	Mon Nov 30 21:04:25 2009 +0000
     1.3 @@ -153,17 +153,17 @@
     1.4  /* *INDENT-OFF* */
     1.5  #if defined(__GNUC__) && defined(i386)
     1.6  	__asm__ (
     1.7 -"        pushl   %%ebx\n"
     1.8  "        xorl    %%eax,%%eax         # Set up for CPUID instruction    \n"
     1.9 +"        pushl   %%ebx                                                 \n"
    1.10  "        cpuid                       # Get and save vendor ID          \n"
    1.11  "        cmpl    $1,%%eax            # Make sure 1 is valid input for CPUID\n"
    1.12  "        jl      1f                  # We dont have the CPUID instruction\n"
    1.13  "        xorl    %%eax,%%eax                                           \n"
    1.14  "        incl    %%eax                                                 \n"
    1.15  "        cpuid                       # Get family/model/stepping/features\n"
    1.16 +"        popl    %%ebx                                                 \n"
    1.17  "        movl    %%edx,%0                                              \n"
    1.18  "1:                                                                    \n"
    1.19 -"        popl    %%ebx\n"
    1.20  	: "=m" (features)
    1.21  	:
    1.22  	: "%eax", "%ecx", "%edx"
    1.23 @@ -173,12 +173,10 @@
    1.24  "        xorl    %%eax,%%eax         # Set up for CPUID instruction    \n"
    1.25  "        pushq   %%rbx\n"
    1.26  "        cpuid                       # Get and save vendor ID          \n"
    1.27 -"        popq    %%rbx\n"
    1.28  "        cmpl    $1,%%eax            # Make sure 1 is valid input for CPUID\n"
    1.29  "        jl      1f                  # We dont have the CPUID instruction\n"
    1.30  "        xorl    %%eax,%%eax                                           \n"
    1.31  "        incl    %%eax                                                 \n"
    1.32 -"        pushq   %%rbx\n"
    1.33  "        cpuid                       # Get family/model/stepping/features\n"
    1.34  "        popq    %%rbx\n"
    1.35  "        movl    %%edx,%0                                              \n"
    1.36 @@ -190,32 +188,34 @@
    1.37  #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
    1.38  	__asm {
    1.39          xor     eax, eax            ; Set up for CPUID instruction
    1.40 +        push    ebx
    1.41          cpuid                       ; Get and save vendor ID
    1.42          cmp     eax, 1              ; Make sure 1 is valid input for CPUID
    1.43          jl      done                ; We dont have the CPUID instruction
    1.44          xor     eax, eax
    1.45          inc     eax
    1.46          cpuid                       ; Get family/model/stepping/features
    1.47 +        pop     ebx
    1.48          mov     features, edx
    1.49  done:
    1.50  	}
    1.51  #elif defined(__sun) && (defined(__i386) || defined(__amd64))
    1.52  	    __asm(
    1.53 -"        movl    %ebx,%edi\n"
    1.54  "        xorl    %eax,%eax         \n"
    1.55 +"        pushl   %ebx              \n"
    1.56  "        cpuid                     \n"
    1.57  "        cmpl    $1,%eax           \n"
    1.58  "        jl      1f                \n"
    1.59  "        xorl    %eax,%eax         \n"
    1.60  "        incl    %eax              \n"
    1.61  "        cpuid                     \n"
    1.62 +"        popl    %ebx              \n"
    1.63  #ifdef __i386
    1.64  "        movl    %edx,-8(%ebp)     \n"
    1.65  #else
    1.66  "        movl    %edx,-8(%rbp)     \n"
    1.67  #endif
    1.68  "1:                                \n"
    1.69 -"        movl    %edi,%ebx\n" );
    1.70  #endif
    1.71  /* *INDENT-ON* */
    1.72      return features;
    1.73 @@ -228,16 +228,16 @@
    1.74  /* *INDENT-OFF* */
    1.75  #if defined(__GNUC__) && defined(i386)
    1.76  	__asm__ (
    1.77 -"        pushl   %%ebx\n"
    1.78  "        movl    $0x80000000,%%eax   # Query for extended functions    \n"
    1.79 +"        pushl   %%ebx                                                 \n"
    1.80  "        cpuid                       # Get extended function limit     \n"
    1.81  "        cmpl    $0x80000001,%%eax                                     \n"
    1.82  "        jl      1f                  # Nope, we dont have function 800000001h\n"
    1.83  "        movl    $0x80000001,%%eax   # Setup extended function 800000001h\n"
    1.84  "        cpuid                       # and get the information         \n"
    1.85 +"        popl    %%ebx                                                 \n"
    1.86  "        movl    %%edx,%0                                              \n"
    1.87  "1:                                                                    \n"
    1.88 -"        popl    %%ebx\n"
    1.89  	: "=m" (features)
    1.90  	:
    1.91  	: "%eax", "%ecx", "%edx"
    1.92 @@ -245,15 +245,13 @@
    1.93  #elif defined(__GNUC__) && defined (__x86_64__)
    1.94  	__asm__ (
    1.95  "        movl    $0x80000000,%%eax   # Query for extended functions    \n"
    1.96 -"        pushq   %%rbx\n"
    1.97 +"        pushq   %%rbx                                                 \n"
    1.98  "        cpuid                       # Get extended function limit     \n"
    1.99 -"        popq    %%rbx\n"
   1.100  "        cmpl    $0x80000001,%%eax                                     \n"
   1.101  "        jl      1f                  # Nope, we dont have function 800000001h\n"
   1.102  "        movl    $0x80000001,%%eax   # Setup extended function 800000001h\n"
   1.103 -"        pushq   %%rbx\n"
   1.104  "        cpuid                       # and get the information         \n"
   1.105 -"        popq    %%rbx\n"
   1.106 +"        popq    %%rbx                                                 \n"
   1.107  "        movl    %%edx,%0                                              \n"
   1.108  "1:                                                                    \n"
   1.109  	: "=m" (features)
   1.110 @@ -263,30 +261,32 @@
   1.111  #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
   1.112  	__asm {
   1.113          mov     eax,80000000h       ; Query for extended functions
   1.114 +        push    ebx
   1.115          cpuid                       ; Get extended function limit
   1.116          cmp     eax,80000001h
   1.117          jl      done                ; Nope, we dont have function 800000001h
   1.118          mov     eax,80000001h       ; Setup extended function 800000001h
   1.119          cpuid                       ; and get the information
   1.120 +        pop     ebx
   1.121          mov     features,edx
   1.122  done:
   1.123  	}
   1.124  #elif defined(__sun) && ( defined(__i386) || defined(__amd64) )
   1.125  	    __asm (
   1.126 -"        movl    %ebx,%edi\n"
   1.127  "        movl    $0x80000000,%eax \n"
   1.128 +"        pushl   %ebx             \n"
   1.129  "        cpuid                    \n"
   1.130  "        cmpl    $0x80000001,%eax \n"
   1.131  "        jl      1f               \n"
   1.132  "        movl    $0x80000001,%eax \n"
   1.133  "        cpuid                    \n"
   1.134 +"        popl    %ebx             \n"
   1.135  #ifdef __i386
   1.136 -"        movl    %edx,-8(%ebp)   \n"
   1.137 +"        movl    %edx,-8(%ebp)    \n"
   1.138  #else
   1.139 -"        movl    %edx,-8(%rbp)   \n"
   1.140 +"        movl    %edx,-8(%rbp)    \n"
   1.141  #endif
   1.142  "1:                               \n"
   1.143 -"        movl    %edi,%ebx\n"
   1.144  	    );
   1.145  #endif
   1.146  /* *INDENT-ON* */