Page 1 of 1

Memory-align the first variable when Structure Align is used

Posted: Fri Oct 07, 2016 1:36 pm
by Keya
Tonight i needed an aligned variable but there doesnt seem to be any direct way. I was able to come up with a workaround using pointers and CopyMemory but its not pretty.

At the moment you might have something like this:

Code: Select all

Structure Bytes Align 16
 Byte1.a
 Byte2.a
EndStructure
and Byte2 will be 16 bytes after Byte1, BUT the address for Byte1 won't necessarily be a 16-aligned address... but that's what's often needed now with a lot of these new x64 instructions as i keep finding out!

basically my problem would been solved if the "Align n" parameter of the Structure command also ensured that the first element is aligned. It'd be great to be able to align all variables, like "Protected myvar.i Align 16" as well, but at least if Structures have that ability with the first element i guess it would be sufficient?

Thankyou very much for your consideration

Re: Memory-align the first variable when Structure Align is

Posted: Fri Oct 07, 2016 2:24 pm
by wilbert
Keya wrote:that's what's often needed now with a lot of these new x64 instructions as i keep finding out!
It's also needed with a lot of SSE instructions.
It would be great to have this ability you are requesting for 16 byte aligned variables.

Re: Memory-align the first variable when Structure Align is

Posted: Fri Oct 07, 2016 9:57 pm
by Keya
please also add alignment to function calls to ensure the stack is correctly aligned! perhaps ...

Code: Select all

Import ""
  SomeAlignedFunction.i() Align 16
EndImport