Using inline assembler

Etienne via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Oct 9 06:29:25 PDT 2014


On 2014-10-09 8:54 AM, anonymous wrote:
> This compiles:
>
> align(16) union __m128i { ubyte[16] data; } /* note the position
> of the semicolon */
>
> void store(__m128i* src, __m128i* dst) {
>       asm
>       {
>           movdqu XMM0, [src]; /* note: [src] */
>           movdqu [dst], XMM0;
>       }
> }

Yes, this does compile, but the value from src never ends up stored in dst.

void main() {
	__m128i src;
	src.data[0] = 255;
	__m128i dst;
	writeln(src.data); // shows 255 at offset 0
	store(&src, &dst);
	writeln(dst.data); // remains set as the initial array
}

http://x86.renejeschke.de/html/file_module_x86_id_184.html

Is this how it's meant to be used?


More information about the Digitalmars-d-learn mailing list