Help needed on inline assembly

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


Hi,

i'd like to work with the SSE-commands in assembly. I wrote some
testroutines (with my limited knowledge). Some of them work, others
dont. I'd like to know, why's that so. Can someone of you guys help me out?


First thing:
#void main()
#{
#	float[4] array = [ 1f, 2f, 3f, 4f ];
#	float* a = &array[0];
#//	float t;
#
#	asm
#	{
#		mov EBX, a;
#		movaps XMM1, [EBX];
#	}
#}

doesnt work. uncomment the line
//	float t;

and it works. Why? Does the assembler code need to be aligned to
something? When yes, how can i do this without the need of allocating
another float on the stack?


Second thing: I dont know how to address a public const variable, with
my limited knowledge i would do something like this:

#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. Which is then used to access the array.

Im using DMD 1.024 (since later versions broke derelict on my platform)


More information about the Digitalmars-d-learn mailing list