Help needed on inline assembly

Hendrik Renken funsheep at -[no-spam]-gmx.net
Wed Jan 30 04:52:38 PST 2008


downs schrieb:
>> #float[4] array = [ 1f, 2f, 3f, 4f ];
>> #
>> #void main()
>> #{
>> #	float* a = &array[0];
>> #
>> #	asm
>> #	{
>> #		mov EAX, [a];
>> #		movaps XMM1, [EAX];		
>> #	}
>> #}
>>
>>
>> But i get a secfault. Why? I would interpret the code like this: a holds
>> the address to the first arrayelement. moc EAX, [a]; copies the address
>> to the first arrayelement to EAX. 
> 
> 
> Nope :)
> Remember, [] dereferences. mov EAX, [a] copies the value, i.e. "a dereferenced", to EAX.
> So EAX now contains the first value in array, 1f.
> Trying to dereference that floating point number leads understandably to a segfault.

ok. yeah. didnt posted the right example (i have a bunch of
asm-test-files). But this doesnt work either:

float[4] array = [ 1f, 2f, 3f, 4f ];

void main()
{
	float* a = &array[0];

	asm
	{
		mov EAX, a;
		movaps XMM1, [EAX];
	}
}


More information about the Digitalmars-d-learn mailing list