NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: AndrewF on June 24, 2014, 09:20:11 PM
-
I have read in NASM manual that align specify how many low bits of the segment start address must be forced to zero.
If not specified what is its default value 0 or 1?
thanks
-
Default specification for alignment depends on output format and section.
Parameter to "align=" (the section directive attribute) and to "align" (the macro) must both be a power of two. What happens if you try 0? What would it mean to force 0 bits to 0?
Best,
Frank
-
Default specification for alignment depends on output format and section.
Parameter to "align=" (the section directive attribute) and to "align" (the macro) must both be a power of two. What happens if you try 0? What would it mean to force 0 bits to 0?
Best,
Frank
Thanks I haven't see this
The defaults assumed by NASM if you do not specify the above qualifiers are:
section .text progbits alloc exec nowrite align=16
section .rodata progbits alloc noexec nowrite align=4
section .data progbits alloc noexec write align=4
section .bss nobits alloc noexec write align=4
section other progbits alloc noexec nowrite align=1
-
It occurs to me that something in the manual may be ambiguous. It says that the parameter to "align=" is the number of bits forced to 0. If you say "align=16", it isn't going to clear 16 bits, of course. The power to which 2 must be raised to get the parameter (it must be a power of 2) is the number of bits forced to 0. I'm sure you've figured that out, but... it might be clearer...
Best,
Frank