title: nasm: how to pad the beginning of the string such that it ends right at an alignment boundary
body: <p>I cannot figure out how to pad the beginning of the string such that it ends right at an alignment boundary:</p>
  <pre><code>%macro string 1
  _unaligned:
  ; some preprocesor expression comes here
      db %1
  _aligned:
  %endmacro
  </code></pre>
  <p>After several hours of trying different solutions, I still don't have any. Can anybody help, please?</p>
  <p>EDIT:</p>
  <p>This is the real example how it should work (for 32bit code):</p>
  <pre><code>%define LAST 0
  
  %macro xword 2
  %strlen len %1
                  ; pad - some preprocassor magic comes here
                  db %1
  NAME__%2        db len
  LINK__%2        dd LAST ; must be aligned !!!
  CODE__%2        dd code
  PAR__%2
  %define LAST PAR__%2
  %endmacro
  </code></pre>
  <p>Usage:</p>
  <p>xword 'TEST',test01</p>
  <p>creates structure (for example $ = 0x0001):</p>
  <pre><code>0x0001  
  0x0002  
  0x0003  db 'T'
  0x0004  db 'E'
  0x0005  db 'S'
  0x0006  db 'T'
  0x0007  db 4
  0x0008  dd 0    ; LAST (must be ALIGNED)
  0x000C  dd code
  </code></pre>
  <p>There must be no more padding than necessary, as it is necessary to save as much memory as possible.</p>