Help needed on inline assembly

downs default_357-line at yahoo.de
Wed Jan 30 04:35:42 PST 2008


> 
> #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.

 --downs


More information about the Digitalmars-d-learn mailing list