PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : GCC Assembler Warning (wooz?)


liquid
2004-02-01, 19:53:35
ushort check_ID_proc(CPU_info_struct& info)
{
ushort cpu_type = 0xffff;

static char vendor_id[13] = "We love AMD!";

__asm__ __volatile__(
"xorl %%eax, %%eax \n\t" // clear EAX

"cpuid \n\t"

"pushl %%eax \n\t" // save EAX

// get pointer to vendor_id buffer into EAX
"movl %3, %%eax \n\t"

// copy vendor string out of EBX, EDX and ECX
"movl %%ebx, (%%eax) \n\t"
"movl %%edx, 4(%%eax) \n\t"
"movl %%ecx, 8(%%eax) \n\t"

"popl %%eax \n\t" // restore eax

// make sure 1 is valid input for CPUID
"cmpl $1, %%eax \n\t"

"jl 1f \n\t" // jump to end IF not
"xorl %%eax, %%eax \n\t" // clear EAX
"inc %%eax \n\t" // increment EAX

// get family/model/stepping features
"cpuid \n\t"

"movb %%al, %0 \n\t" // mov stepping, al
"andb $0x0f, %0 \n\t" // and stepping 0fh

"andb $0xf0, %%al \n\t"
"shrb $4, %%al \n\t"
"movb %%al, %1 \n\t" // model ID

"andl $0x0f00, %%eax \n\t"
"shrl $8, %%eax \n\t" // isolate family
"andl $0x0f, %%eax \n\t"
"movw %%ax, %2 \n\t" // CPU type

"1: \n\t" // END_DETECTION
"movw %2, %%ax \n\t"

// outputs
: "=m" (info.stepping),
"=m" (info.model),
"+m" (cpu_type)
// inputs
: "m" (vendor_id)
// clobbers
: "%eax", "%ebx", "%ecx", "%edx", "cc"
);

info.vendor_id = vendor_id;
info.cpu_type = cpu_type;

return info.cpu_type;
}

Der GCC meldet mir da immer ein "warning: use of memory input without lvalue in asm operand 3 is deprecated" - ich frage mich schon die ganze Zeit was er mir damit sagen will. Habt ihr ne Ahnung?

cya
liquid

Xmas
2004-02-01, 21:21:02
vendor_id ist keine LValue, mit anderen Worten: Die Adresse des Arrays, die du verwenden willst, steht gar nicht im Speicher. Du verwendest aber "m".
Du musst hier also einen Pointer, kein Array verwenden.

static char vendor_id_str[] = "We love AMD!";
static char * vendor_id = vendor_id_str;


Theoretisch würde auch
static char * vendor_id = "We love AMD!";
gehen, das ist aber nicht empfehlenswert, aufgrund der Art wie der Compiler mit Stringliteralen umgeht.

liquid
2004-02-02, 20:48:44
Thx Xmas für die Antwort, den Fehler hatte ich nämlich noch in ein paar anderen Funktion. Werde das gleich mal fixen.

cya
liquid