Skip to main content
gamedev.net
🔒 Locked

gnu assembly pointer access

Started by 666_1337 1 reply 450+ views
Original Post
666_1337
666_1337
hi, i''m writing a makefile-generator that uses the cpuid-instruction to get information on which extentions are supported on the platform executing it. i''ve got a struct with all the features in the there-written order in the memory, so getting through the struct with an incrementing pointer (and an incrementing bitmask) would do it.
  
struct _pfeautures
   {
    int fpu,
	vme,
        de,
	pse,
	tsc,
	msr,
	pae,
	mce,
	cx8,
	apic,
	nothing_1,
	sep,
	mtrr,
	pge,
	mca,
	cmov,
	pat,
	pse36,
	psn,
	clfsh,
	nothing_2,
	ds,
	acpi,
	mmx,
	fxsr,
	sse,
	sse2,
	ss,
	htt,
	tm,
	nothing_3,
	sbf;
   };
  
however, the problem is that i cannot access a memory location with anything like "mov %%eax, %%ecx+%0". somebody knows a solution? how can i access the memory address of "%0"? ... in gnu''s assembly syntax
our new version has many new and good features. sadly, the good nes are not new and the new nes are not good oo
George2
George2
It''s called AT&T assembly syntax and a quick search on google found this

from the link :
Intex Syntax

mov eax,[ebx]
mov eax,[ebx+3]

AT&T Syntax

movl (%ebx),%eax
movl 3(%ebx),%eax


"THE INFORMATION CONTAINED IN THIS REPORT IS CLASSIFIED; DO NOT GO TO FOX NEWS TO READ OR OBTAIN A COPY." , the pentagon
666_1337
666_1337
i think you misunderstood me.


    
asm("mov $0x01, %%eax\n"
"cpuid\n"
... //analyze %eax

"mov $0x01, %%eax\n" //store the bitmask that will be shifted in %eax

"mov $0x20, %%ecx\n" //nothing important in %ecx. i'll use it as counter.

"movd %%ebx, %%mm0\n" //make a backup of %ebx in the mmx register

"start: movd %%mm0, %%ebx\n" //restore %ebx

"and %%eax, %%ebx\n" //apply the bitmask on %ebx

"shl $0x01, %%eax\n" //shift the bitmask

"mov %%eax, %12\n" //%12 is the variable "fpu"

increment_pointer_to_%12 //this is what i need

"dec %%ecx\n" // and

"jnz start\n" // loop

:..., cpu_info.cpu_features.fpu; //this is the lowest address

:...
);


i need to be able to determine the memory address of the 12th parameter for incrementing.

[edited by - 666_1337 on March 16, 2003 8:33:23 AM]
our new version has many new and good features. sadly, the good nes are not new and the new nes are not good oo

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.