Re: D ASM. Program fails

2016-01-22 Thread anonymous via Digitalmars-d-learn
On 22.01.2016 21:34, Iakh wrote: This code returns 0 for any input v It seems to return 5 here: http://dpaste.dzfl.pl/85fb8e5c4b6b

Re: D ASM. Program fails

2016-01-22 Thread Iakh via Digitalmars-d-learn
On Friday, 22 January 2016 at 17:27:35 UTC, userABCabc123 wrote: int pmovmskb(byte16 v) { asm { naked; push RBP; mov RBP, RSP; sub RSP, 0x10; movdqa dword ptr[RBP-0x10], XMM0; movdqa XMM0, dword ptr[RBP-0x10]; pmovmskb EAX, XMM0;

Re: D ASM. Program fails

2016-01-22 Thread Iakh via Digitalmars-d-learn
On Friday, 22 January 2016 at 12:18:53 UTC, anonymous wrote: int pmovmskb(byte16 v) { int r; asm { movdqa XMM0, v; pmovmskb EAX, XMM0; mov r, EAX; } return r; } This code returns 0 for any input v Removed the `inout` because it doesn't

Re: D ASM. Program fails

2016-01-22 Thread Iakh via Digitalmars-d-learn
On Friday, 22 January 2016 at 20:41:23 UTC, anonymous wrote: On 22.01.2016 21:34, Iakh wrote: This code returns 0 for any input v It seems to return 5 here: http://dpaste.dzfl.pl/85fb8e5c4b6b Yeah. Sorry. My bad.

Re: D ASM. Program fails

2016-01-22 Thread userABCabc123 via Digitalmars-d-learn
On Friday, 22 January 2016 at 20:54:46 UTC, Iakh wrote: On Friday, 22 January 2016 at 17:27:35 UTC, userABCabc123 wrote: [...] Thanks. It works. Buth shorter version too: asm { naked; push RBP; mov

Re: D ASM. Program fails

2016-01-22 Thread anonymous via Digitalmars-d-learn
On 22.01.2016 06:59, Iakh wrote: import std.stdio; import core.simd; int pmovmskb(inout byte16 v) { asm { movdqa XMM0, v; pmovmskb EAX, XMM0; ret; } } void main() { byte16 a = [-1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; auto i =

Re: D ASM. Program fails

2016-01-22 Thread userABCabc123 via Digitalmars-d-learn
On Friday, 22 January 2016 at 14:06:42 UTC, Adam D. Ruppe wrote: On Friday, 22 January 2016 at 12:18:53 UTC, anonymous wrote: I don't know much about these things, but it seems to be the `ret;`. Right. This is an ordinary D function so the compiler generates code to set up a stack for local

Re: D ASM. Program fails

2016-01-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 22 January 2016 at 12:18:53 UTC, anonymous wrote: I don't know much about these things, but it seems to be the `ret;`. Right. This is an ordinary D function so the compiler generates code to set up a stack for local variables. It looks like: push ebp; mov ebp, esp; sub EBP,

Re: D ASM. Program fails

2016-01-22 Thread userABCabc123 via Digitalmars-d-learn
On Friday, 22 January 2016 at 17:12:25 UTC, userABCabc123 wrote: Note that there is maybe a DMD codegen bug because the asm generated for the non naked version copy the result to the stack and then the stack to result but after pmovmskb it's already setup in EAX. 0044C580h push

D ASM. Program fails

2016-01-21 Thread Iakh via Digitalmars-d-learn
This code compiles but program exits with code -11 What's wrong? import std.stdio; import core.simd; int pmovmskb(inout byte16 v) { asm { movdqa XMM0, v; pmovmskb EAX, XMM0; ret; } } void main() { byte16 a = [-1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,