title: How to do the equivalent of "times 512-($-$$) db 0" (nasm) in gas (gnu assembler)
body: <p>In nasm (Netwide Assembler), it is possible to find the address of the current instruction with <em>$</em>, and the address of the current section with <em>$$</em>.  By using <em>($-$$)</em> we therefore get the length of the section so far, and with the full instruction:</p>
  
  <pre><code>times 512-($-$$) db 0
  </code></pre>
  
  <p>we pad the remainder of a sector with zeros.
  This is typically used in small hello-world programs for OS development.</p>
  
  <p>I have seen that GNU assembler supports constructs like <em>rept</em> to make repetions, and <em>.</em> (dot) can be used to get the current address. But I have not yet figured out exactly how to do the whole <em>thing</em> in gas.</p>
  
  <p>So how can it be done?</p>