Help needed on inline assembly
Hendrik Renken
funsheep at -[no-spam]-gmx.net
Wed Jan 30 10:16:01 PST 2008
Jarrett Billingsley schrieb:
> "Hendrik Renken" <funsheep at -[no-spam]-gmx.net> wrote in message
> news:fnprum$6oh$1 at digitalmars.com...
>> float[4] array = [ 1f, 2f, 3f, 4f ];
>>
>> void main()
>> {
>> float* a = &array[0];
>>
>> asm
>> {
>> mov EAX, a;
>> movaps XMM1, [EAX];
>> }
>> }
>
> If you're using the newest DMD, this should work, it does for me.
Now i've updated to 1.026. And the above example doesnt work (still not
aligned) movups works.
> If you're
> using anything older than 1.023 (like, hm, 1.015? GRRGH), this will
> probably fail.
Yeah. I used 1.015 before...
> 1.023 made anything in the static data segment >= 16 bytes
> paragraph aligned, so that data is already aligned properly.
Doesnt seem to work for me (using DMD 1.026 on linux). Or the aligment
is in 1.026 broken again...
> I don't know what GDC does in this case.
>
> Another way to get an aligned allocation is to use a struct with the
> float[4] in it.
>
> struct vec
> {
> float[4] array;
> }
>
> void main()
> {
> vec* v = new vec;
>
> // ptr will get you the pointer to the 0th element too
> float* a = v.array.ptr;
>
> asm
> {
> mov EAX, a;
> movaps XMM1, [EAX];
> }
> }
>
> This also doesn't rely on any standard library stuff.
>
>
More information about the Digitalmars-d-learn
mailing list