Assembly language ALIGN directives: a variable alignment

ALIGN directive to align a variable byte boundaries, word boundaries, or double word boundary paragraph boundary.

 

The syntax is as follows:

ALIGN bound

Bound possible values ​​are: 1,2,4,8,16. When the value is 1, the next 1 byte boundary aligned with the variable (the default). When a value of 2, the next variable is aligned with an even address. When the value is 4, then the next address variable is a multiple of 4. When the value is 16, then the next address variable is a multiple of 16, i.e., the boundary of a paragraph.

In order to meet the alignment requirement, the assembler inserts a null byte or more before the variable. Why should align data? Because the data stored on an even and odd addresses is, CPU speed processing even address data much faster.

In the following examples, bVal in any position, but with an offset of 00,404,000. Insert ALIGN 2 directive before wVal, which makes wVal aligned on an even offset:

  bVal BYTE ?           ;00404000h  ALIGN 2   wVal WORD ?           ;00404002h  bVal2 BYTE ?          ;00404004h  ALIGN 4   dVal DWORD ?          ;00404008h  dVal2 DWORD ?         ;0040400Ch

Note that, originally offset dVal, 00404005, but it ALIGN 4 directive offset becomes 00,404,008.

4.1  Operand Type
4.2  MOV instructions
4.3  MOVZX to doing it and instructions MOVSX
4.4  LAHF SAHF instruction and
4.5 of 5  XCHG instructions
4.6  immediate offset operands
4.7  assembly language data transfer Example
4.8  addition and subtraction Detailed
4.9  the OFFSET operator
4.10  the ALIGN directive
4.11  the PTR operator
4.12  the TYPE operator
4.13  lengthof operator
4.14  the LABEL directive
4.15  indirect addressing
4.16  the JMP and LOOP instruction
4.17  64 MOV instruction
4.18  64-bit addition and subtraction

Guess you like

Origin blog.csdn.net/Javaxuxuexi/article/details/93401674