ALIGN Directive
The ALIGN directive causes the assembler to align the next data item or instruction on an address according to a given value. The number could be 1, 2, or 4. If it equals 1, the next variable or byte is aligned on a 1-byte boundary. If number is 2, the next variable is aligned on an even-numbered address, and if number is 4, the next address is a multiple of 4.
ALIGN 1 |
ALIGN 2 |
ALIGN 4 |
.data
X BYTE 0FFh
ALIGN 1
Y DWORD 12345678h
.code
mov eax, 0
mov ebx, OFFSET X
mov ax, [ebx + 2]
call WriteHex
|
.data
X BYTE 0FFh
ALIGN 2
Y DWORD 12345678h
.code
mov eax, 0
mov ebx, OFFSET X
mov ax, [ebx + 2]
call WriteHex
|
.data
X BYTE 0FFh
ALIGN 4
Y DWORD 12345678h
.code
mov eax, 0
mov ebx, OFFSET X
mov ax, [ebx + 2]
call WriteHex
|
|
Output |
Output |
Output |
†The CPU can process data stored at even-numbered addresses more quickly than those at odd-numbered addresses.
If the offset is already at the required address, it is not advanced.
The assembler fills unused bytes with zeros for data and
NOPs for instruction.
The
NOP instruction is used to delete/insert machine code, to delay execution for purposes of timing, or to align a subsequent instruction on a word boundary.
NOP simply performs a null operation by executing “
XCHG AX, AX” .
NOP — No Operation |
Usage: NOP
|
Flag |
O
|
D
|
I
|
S
|
Z
|
A
|
P
|
C
|
|
Result |
|
|
|
|
|
|
|
|
|
|
Clocks |
|
|
Operands |
286 |
386 |
486 |
Size Bytes |
|
none |
3 |
3 |
1 |
1 |
|
|
“I’m not arguing, I’m just explaining why I’m right.”
― Unknown
|