www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Equivalent in D for .p2align 4,,15 ?

reply Etienne <etcimon gmail.com> writes:
I'm looking for the D inline assembler equivalent of the .p2align 4,,15 
directive to optimize a loop.

Here's more information:
http://stackoverflow.com/questions/21546946/what-p2align-does-in-asm-code

I tried searching through a turbo assembler tutorial (because D's is 
based on it) and found nothing except a few hints here: 
http://www.csn.ul.ie/~darkstar/assembler/manual/a10.txt

There might be a way through segments, directives, but I'm not sure at 
all if D supports it.

Does anyone have any idea if/how I can align my code this way or if the 
compiler handles it?
Oct 29 2014
parent reply "anonymous" <anonymous example.com> writes:
On Wednesday, 29 October 2014 at 17:16:23 UTC, Etienne wrote:
 I'm looking for the D inline assembler equivalent of the 
 .p2align 4,,15 directive to optimize a loop.

 Here's more information:
 http://stackoverflow.com/questions/21546946/what-p2align-does-in-asm-code

 I tried searching through a turbo assembler tutorial (because 
 D's is based on it) and found nothing except a few hints here: 
 http://www.csn.ul.ie/~darkstar/assembler/manual/a10.txt

 There might be a way through segments, directives, but I'm not 
 sure at all if D supports it.

 Does anyone have any idea if/how I can align my code this way 
 or if the compiler handles it?
As far as I understand, `.p2align 4,,15` aligns to a 16 byte boundary, and the third argument could be left out, because more than 15 bytes wouldn't ever be skipped anyway. D inline assembler has an 'align' directive [1]. Aligning to a 16 byte boundary in D: `align 16;`. [1] http://dlang.org/iasm.html -- "align IntegerExpression", near the top
Oct 29 2014
parent Etienne <etcimon gmail.com> writes:
On 2014-10-29 1:44 PM, anonymous wrote:
 D inline assembler has an 'align' directive [1]. Aligning to a 16
 byte boundary in D: `align 16;`.

 [1] http://dlang.org/iasm.html -- "align IntegerExpression", near
 the top
Of course, align directive works on instructions in asm. Thanks anonymous, that was a very simple explanation.
Oct 29 2014