Author Topic: Align attribute specification  (Read 2180 times)

Offline AndrewF

  • Jr. Member
  • *
  • Posts: 15
Align attribute specification
« 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

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2358
  • Country: us
Re: Align attribute specification
« Reply #1 on: June 24, 2014, 10:46:48 PM »
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


Offline AndrewF

  • Jr. Member
  • *
  • Posts: 15
Re: Align attribute specification
« Reply #2 on: June 24, 2014, 11:25:17 PM »
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

Quote
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

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2358
  • Country: us
Re: Align attribute specification
« Reply #3 on: June 25, 2014, 06:35:10 AM »
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