The 32-bit register capacity is 4 bytes. If the data in the memory is 4 * n Bytes aligned, the throughput will be accelerated;
However, this is not the case. Data of different sizes may make the registers undo with awkwardly, thus reducing the running speed!
If alignment is used, some memory space will be wasted. In fact, this is a problem that needs to weigh the gains and losses of "Speed" and "Memory.
Test files to be used:
; Test11_1.asm.586.model flat, stdcallinclude windows. incinclude kernel32.incinclude masm32.incinclude debug. incincludelib kernel32.libincludelib masm32.libincludelib debug. lib. data; declare the Three-Byte variable V1 db 0 V2 db 0 V3 db 0. codemain proc; default offset addresses of the three byte variables are as follows (each occupies one byte without alignment constraints): printdec offset V1; 4206592 printdec offset V2; 4206593 printdec offset V3; 4206594 retmain endpend main
Align: Specifies the alignment boundary.
; Test11_2.asm.586.model flat, stdcallinclude windows. incinclude kernel32.incinclude masm32.incinclude debug. incincludelib kernel32.libincludelib masm32.libincludelib debug. lib. data V1 db 0 align 4; ensure that the starting address of the next variable is a multiple of 4 V2 db 0 V3 db 0. codemain proc printdec offset V1; 4206592 printdec offset V2; 4206596 (!) Printdec offset V3; 4206597 retmain endpend main; the parameter after align is 2n. It can also be tested as follows: 1, 2, 8, 16
The even is an even align 2
; Cmdflat, stdcallinclude windows. incinclude kernel32.incinclude masm32.incinclude Debug. incincludelib kernel32.libincludelib masm32.libincludelib Debug. Lib. Data V1 db 0 even ;(!) V2 db 0 V3 db 0. codemain proc printdec offset V1; 4206592 printdec offset V2; 4206594 (!) Printdec offset V3; 4206595 retmain endpend main
Org can specify to span the target bytes of a specified book from the current position and then arrange the next data:
; ‑Flat, stdcallinclude windows. incinclude kernel32.incinclude masm32.incinclude Debug. incincludelib kernel32.libincludelib masm32.libincludelib Debug. Lib. Data V1 db 0 org 100 ;(!) V2 db 0 V3 db 0. codemain proc printdec offset V1; 4206592 printdec offset V2; 4206692 (!) Printdec offset V3; 4206693 retmain endpend main
These pseudo commands do not affect local variables, because these pseudo commands are used before compilation, and the local variables use the memoryProgramAfter running.
In addition to compilation, we should also consider the issue of "alignment" When arranging variable types and sequences.