12

The expression is:

times 512-($-$$) db 0

I know what the dollar sign means but I don't know what it means when it's double.

What does the double dollar sign mean?

Paul R
  • 208,748
  • 37
  • 389
  • 560
Grevak
  • 533
  • 5
  • 17
  • 4
    Future readers: for `$`, see https://stackoverflow.com/questions/10361231/what-does-the-dollar-sign-mean-in-x86-assembly-when-calculating-string-lengt. (One of the answers there mentions `$$` too.) – Peter Cordes Oct 14 '17 at 04:07

2 Answers2

26

When all else fails, Read The Fine Manual (section 3.5 "Expressions"):

NASM supports two special tokens in expressions, allowing calculations to involve the current assembly position: the $ and $$ tokens. $ evaluates to the assembly position at the beginning of the line containing the expression; so you can code an infinite loop using JMP $. $$ evaluates to the beginning of the current section; so you can tell how far into the section you are by using ($−$$).

So the example in your question is just padding the current section to a size of 512 with zeroes.

Paul R
  • 208,748
  • 37
  • 389
  • 560
  • Are you aware of how this could be done in GAS? -- Looks like you can. See [this](https://stackoverflow.com/questions/47859273/calculating-padding-length-with-gas-att-directives-for-a-boot-sector) question. – sherrellbc Feb 23 '18 at 12:11
0

$$ evaluates to the beginning of the current section. you could find it in nasm documentation here : https://nasm.us/doc/nasmdoc3.html#section-3.5