1.2 branch: fixed assembly code register clobbering. SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Sun, 01 Nov 2009 17:51:39 +0000
branchSDL-1.2
changeset 4372ca91f36ef3de
parent 4371 6f74b80cca1d
child 4373 ab06accf1b96
1.2 branch: fixed assembly code register clobbering.
src/cpuinfo/SDL_cpuinfo.c
     1.1 --- a/src/cpuinfo/SDL_cpuinfo.c	Wed Oct 28 19:42:16 2009 +0000
     1.2 +++ b/src/cpuinfo/SDL_cpuinfo.c	Sun Nov 01 17:51:39 2009 +0000
     1.3 @@ -148,7 +148,7 @@
     1.4  	int features = 0;
     1.5  #if defined(__GNUC__) && defined(i386)
     1.6  	__asm__ (
     1.7 -"        movl    %%ebx,%%edi\n"
     1.8 +"        pushl   %%ebx\n"
     1.9  "        xorl    %%eax,%%eax         # Set up for CPUID instruction    \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 @@ -158,14 +158,14 @@
    1.13  "        cpuid                       # Get family/model/stepping/features\n"
    1.14  "        movl    %%edx,%0                                              \n"
    1.15  "1:                                                                    \n"
    1.16 -"        movl    %%edi,%%ebx\n"
    1.17 +"        popl    %%ebx\n"
    1.18  	: "=m" (features)
    1.19  	:
    1.20 -	: "%eax", "%ecx", "%edx", "%edi"
    1.21 +	: "%eax", "%ecx", "%edx"
    1.22  	);
    1.23  #elif defined(__GNUC__) && defined(__x86_64__)
    1.24  	__asm__ (
    1.25 -"        movq    %%rbx,%%rdi\n"
    1.26 +"        pushq   %%rbx\n"
    1.27  "        xorl    %%eax,%%eax         # Set up for CPUID instruction    \n"
    1.28  "        cpuid                       # Get and save vendor ID          \n"
    1.29  "        cmpl    $1,%%eax            # Make sure 1 is valid input for CPUID\n"
    1.30 @@ -175,10 +175,10 @@
    1.31  "        cpuid                       # Get family/model/stepping/features\n"
    1.32  "        movl    %%edx,%0                                              \n"
    1.33  "1:                                                                    \n"
    1.34 -"        movq    %%rdi,%%rbx\n"
    1.35 +"        popq    %%rbx\n"
    1.36  	: "=m" (features)
    1.37  	:
    1.38 -	: "%rax", "%rbx", "%rcx", "%rdx", "%rdi"
    1.39 +	: "%rax", "%rcx", "%rdx"
    1.40  	);
    1.41  #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
    1.42  	__asm {
    1.43 @@ -194,7 +194,7 @@
    1.44  	}
    1.45  #elif defined(__sun) && (defined(__i386) || defined(__amd64))
    1.46  	    __asm(
    1.47 -"        movl    %ebx,%edi\n"
    1.48 +"        pushl   %ebx\n"
    1.49  "        xorl    %eax,%eax         \n"
    1.50  "        cpuid                     \n"
    1.51  "        cmpl    $1,%eax           \n"
    1.52 @@ -208,7 +208,7 @@
    1.53  "        movl    %edx,-8(%rbp)     \n"
    1.54  #endif
    1.55  "1:                                \n"
    1.56 -"        movl    %edi,%ebx\n" );
    1.57 +"        popl    %ebx\n" );
    1.58  #endif
    1.59  	return features;
    1.60  }
    1.61 @@ -218,7 +218,7 @@
    1.62  	int features = 0;
    1.63  #if defined(__GNUC__) && defined(i386)
    1.64  	__asm__ (
    1.65 -"        movl    %%ebx,%%edi\n"
    1.66 +"        pushl   %%ebx\n"
    1.67  "        movl    $0x80000000,%%eax   # Query for extended functions    \n"
    1.68  "        cpuid                       # Get extended function limit     \n"
    1.69  "        cmpl    $0x80000001,%%eax                                     \n"
    1.70 @@ -227,14 +227,14 @@
    1.71  "        cpuid                       # and get the information         \n"
    1.72  "        movl    %%edx,%0                                              \n"
    1.73  "1:                                                                    \n"
    1.74 -"        movl    %%edi,%%ebx\n"
    1.75 +"        popl    %%ebx\n"
    1.76  	: "=m" (features)
    1.77  	:
    1.78 -	: "%eax", "%ecx", "%edx", "%edi"
    1.79 +	: "%eax", "%ecx", "%edx"
    1.80  	);
    1.81  #elif defined(__GNUC__) && defined (__x86_64__)
    1.82  	__asm__ (
    1.83 -"        movq    %%rbx,%%rdi\n"
    1.84 +"        pushq   %%rbx\n"
    1.85  "        movl    $0x80000000,%%eax   # Query for extended functions    \n"
    1.86  "        cpuid                       # Get extended function limit     \n"
    1.87  "        cmpl    $0x80000001,%%eax                                     \n"
    1.88 @@ -243,10 +243,10 @@
    1.89  "        cpuid                       # and get the information         \n"
    1.90  "        movl    %%edx,%0                                              \n"
    1.91  "1:                                                                    \n"
    1.92 -"        movq    %%rdi,%%rbx\n"
    1.93 +"        popq    %%rbx\n"
    1.94  	: "=m" (features)
    1.95  	:
    1.96 -	: "%rax", "%rbx", "%rcx", "%rdx", "%rdi"
    1.97 +	: "%rax", "%rcx", "%rdx"
    1.98  	);
    1.99  #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
   1.100  	__asm {
   1.101 @@ -261,7 +261,7 @@
   1.102  	}
   1.103  #elif defined(__sun) && ( defined(__i386) || defined(__amd64) )
   1.104  	    __asm (
   1.105 -"        movl    %ebx,%edi\n"
   1.106 +"        pushl   %ebx\n"
   1.107  "        movl    $0x80000000,%eax \n"
   1.108  "        cpuid                    \n"
   1.109  "        cmpl    $0x80000001,%eax \n"
   1.110 @@ -274,7 +274,7 @@
   1.111  "        movl    %edx,-8(%rbp)   \n"
   1.112  #endif
   1.113  "1:                               \n"
   1.114 -"        movl    %edi,%ebx\n"
   1.115 +"        popl    %ebx\n"
   1.116  	    );
   1.117  #endif
   1.118  	return features;