Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Requests and Feedback

#align

A community discussion post from the original code:zIRON forum.

0CodErr member
Posts
201
Threads
37
Location
Unknown

#align

#align; - align current code to 2,4,8 boundary (dependant on architecture)

Looks like only 2,4,8 byte alignment available.

What if we need 16 byte alignment? For example, instructions:

MOVAPS — Move Aligned Packed Single-Precision Floating-Point MOVAPD — Move Aligned Packed Double-Precision Floating-Point
The MOVAPx instructions copy a vector of four single-precision floating-point values (MOVAPS) or a vector of two double-precision floating-point values (MOVAPD) from the second operand to the first operand — i.e., from an XMMregister or 128-bit memory location or to another XMMregister, or vice versa. A general-protection exception occurs if a memory operand is not aligned on a 16-byte boundary.

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

The #align directive is for code only, I will be adding other alignment options for variables and other data such as blocks hopefully for the next release. :)

e.g.

push eax
push ecx
push edx
#align;            // aligned on 4 byte boundary
call MyProcedure

For data, I may add several options such as

#set align 16;
DWord myVariable;
#set align 4;
Dword myVariable2;

In fact, maybe I should rename #align; to #aligncode;

and then use #align as you say... #align 16; etc... What do you think?

0CodErr member
Posts
201
Threads
37
Location
Unknown

I think that there is many ways to implement this.

#align <value>; -- seems useable, also we can to allow #align sysword;

What about #aligncode; then

we can make all procedures/functions autoaligned by #procalign <value>;

Also we can add #loopalign <value>; for align of while\repeat loops.

May be also should use some alignment by default.

In any way it should be completely explained in our documentation of Ziron.

Colin admin
Posts
928
Threads
49
Location
Bulgaria

ok that's a good idea, maybe i will change it and add some directives.

#set code_align <x>;
#set loop_align <x>;
#set data_align <x>;
#set proc_align <x>;

etc... I will look into this, seems there is a big issue with latest release, something is broken, i guess from one of the procedure rewrites for memory operands.

Edit: This issue i have fixed, so i will take a look at this after i finish 1 new emacro feature.