3DNow! on Intel processors

Hello, All!

While getting CPU info on my P3 and P4, I’ve found that 3DNow extension flag
is setted up on both intel processors. I think need to add a CPU vendor
identification before testing CPU features. Or I missed smth ? :slight_smile:

With best regards, Mike Gorchak. E-mail: @Mike_Gorchak

Hello, All!

While getting CPU info on my P3 and P4, I’ve found that 3DNow extension flag
is setted up on both intel processors. I think need to add a CPU vendor
identification before testing CPU features. Or I missed smth ? :slight_smile:

Yep. SDL in CVS has an API to detect CPU features like this.
Check out SDL_Has3DNow() and friends in SDL_cpuinfo.h

See ya!
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Hello, Sam!

??>> While getting CPU info on my P3 and P4, I’ve found that 3DNow
??>> extension flag is setted up on both intel processors. I think need to
??>> add a CPU vendor identification before testing CPU features. Or I
??>> missed smth ? :slight_smile:

SL> Yep. SDL in CVS has an API to detect CPU features like this.
SL> Check out SDL_Has3DNow() and friends in SDL_cpuinfo.h

Heh, no. You missunderstood me. Is it correct, that 3DNow is detected on
Intel processors ? And yes - I’m using the latest CVS version.

With best regards, Mike Gorchak. E-mail: @Mike_Gorchak

Heh, no. You missunderstood me. Is it correct, that 3DNow is detected on
Intel processors ?

Oh, probably not. I’ll look into it.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Sam Lantinga wrote:

Heh, no. You missunderstood me. Is it correct, that 3DNow is detected on
Intel processors ?

Oh, probably not. I’ll look into it.

Sorry, I couldn’t resist looking at some assy stuff… :slight_smile:

Stephane

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed…
Name: cpufix.patch
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040115/3c171457/attachment.asc

Sorry, I couldn’t resist looking at some assy stuff… :slight_smile:

So why doesn’t the C code initializing the variable to zero do the trick?

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Sorry, I couldn’t resist looking at some assy stuff… :slight_smile:

So why doesn’t the C code initializing the variable to zero do the trick?

Because you use the variable only as an output of the assembly routine (using “=r”). If you want to use it as input, add “r” (variable name) to the input list, i.e. do something like this :
: “=r” (has_3DNow)
: “r” (has_3DNow)

Stephane

Sorry, I couldn’t resist looking at some assy stuff… :slight_smile:

So why doesn’t the C code initializing the variable to zero do the trick?

Because you use the variable only as an output of the assembly routine (using “=r”). If you want to use it as input, add “r” (variable name) to the input list, i.e. do something like this :
: “=r” (has_3DNow)
: “r” (has_3DNow)

Except I don’t want to use it as an input. I want to write to it with C
code, initializing it to zero, and then I want to write to it with asm.

What am I missing?

-Sam Lantinga, Software Engineer, Blizzard Entertainment

Sam Lantinga wrote:

Except I don’t want to use it as an input. I want to write to it with C
code, initializing it to zero, and then I want to write to it with asm.

What am I missing?

That’s because you’re using registers operands ("=r") as output
parameters. For example, if gcc allocates eax for your output register :
“movl $1,%0” translates to “mov $1,%%eax” and “=r” translates to “mov
%%eax, has_CPUID”, so that if eax wasn’t initialized before gcc puts a
garbage value into has_CPUID.

Now, if you use a memory operand as output parameter ("=m"), “movl
$1,%0” translates to “mov $1,has_CPUID” and “=m” translates to nothing
(because it’s already stored in memory).

So I guess what you really want is to use a memory operand and change
all “=r” to “=m”. If you are used to VC++ inline assembly, gcc’s memory
operands are similar to using variables inside VC++ assembly.

Btw register operands and the input/ouput/modified sets are a
gcc-specific feature, and exist solely for better optimization by the
compiler (by letting it do register allocation). You can even have gcc
do the register allocation for your asm procedures that way !

Stephane

That’s because you’re using registers operands ("=r") as output
parameters. For example, if gcc allocates eax for your output register :
“movl $1,%0” translates to “mov $1,%%eax” and “=r” translates to “mov
%%eax, has_CPUID”, so that if eax wasn’t initialized before gcc puts a
garbage value into has_CPUID.

Okay, thanks.

Mike, can you update from CVS and see if the problem is fixed?

Thanks!
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Hello, Sam!

??>> That’s because you’re using registers operands ("=r") as output
??>> parameters. For example, if gcc allocates eax for your output register
??>> : “movl $1,%0” translates to “mov $1,%%eax” and “=r” translates to
??>> “mov %%eax, has_CPUID”, so that if eax wasn’t initialized before gcc
??>> puts a garbage value into has_CPUID.

SL> Okay, thanks.
SL> Mike, can you update from CVS and see if the problem is fixed?

Yep, completely fixed :slight_smile: thanks.

With best regards, Mike Gorchak. E-mail: mike at malva.ua

Hello, Sam!

??>> That’s because you’re using registers operands ("=r") as output
??>> parameters. For example, if gcc allocates eax for your output register
??>> : “movl $1,%0” translates to “mov $1,%%eax” and “=r” translates to
??>> “mov %%eax, has_CPUID”, so that if eax wasn’t initialized before gcc
??>> puts a garbage value into has_CPUID.

SL> Okay, thanks.
SL> Mike, can you update from CVS and see if the problem is fixed?

Yep, completely fixed :slight_smile: thanks.

Heheh, can you update again and see if it’s still fixed?

Thanks!
-Sam Lantinga, Software Engineer, Blizzard Entertainment