DUP is a specific operand specifier to the
DW/etc psuedo-instructions, telling them to repeat a specific value. It can only be used in these data instructions.
TIMES is a generic instruction prefix, telling the assembler to produce multiple copies of the instruction (or psuedo-instruction), whatever it may be.
TIMES is specific to NASM, whereas
DUP is widely supported. The reason why
TIMES is used in NASM is that one of the primary design goals of NASM was to simplify the use of directives and provide more logical, rational ways of doing things.
TIMES can be used in the way you show to fill a space with zeroes, but there are other applications (e.g. aligning loops by generating a sequence of
NOP or similar instructions), and this way a single directive can handle multiple jobs. I actually wasn't aware that
DUP was supported in NASM at all. I guess
DUP was added in a later version for compatibility with MASM-style syntax; I'm not quite sure when; certainly it was quite late, with the result that the documentation doesn't report that it's available), but
TIMES is preferred (at least by the original authors of NASM) as being a more generally useful directive.
As to the meaning of
$, the reason for different sites having different descriptions is probably again due to the NASM/MASM distinction. In NASM,
$ is a variable that contains the address at which the current instruction will be assembled. Note that as it is an address, it may be subject to relocation or otherwise changed during linking. It therefore cannot be used in the
TIMES instruction, whose value must be determinable at the point of assembly (it is a critical expression).
$$ is the address of the start of the section, so
$ - $$ is an offset, which is not subject to relocation and can therefore always be turned into a number. In MASM,
$ has the same meaning, but there is no equivalent
$$ variable (I believe you would achieve the same things using the
WRT operator, but it has been a while since I used MASM so I'm not sure about that).
This should allow you to work out the answer to your third question:
TIMES 510-($-$$) db 0 does nothing if
$-$$ is equal to
510 because the number of repetitions becomes 0, so if you know that your code is already 512 bytes long you do not need it.