Win32 compilation [11]: pseudo commands related to data align, even, and org)

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.