Mail Archives: djgpp/1997/02/01/06:03:30
Sugree Phatanapherom <ioisgp AT std DOT cpc DOT ku DOT ac DOT th> wrote:
> times 512-$ db 0
That's what the $$ token is for.
In a generic relocated object file, that statement has very little
meaning, since `$' may end up anywhere at link time and the
assembler can't predict it; so in general, that statement is
incorrect. Therefore NASM flags the statement as incorrect in all
cases, and so it won't work even in the `bin' case with an explicit
ORG, when you might expect NASM to `know' where the segment begins.
The trouble is that it's only the `bin' output module that takes any
notice at all of the `org' directive: the main code in the assembler
doesn't. This could possibly be fixed, but huge hacks would be
required; and in any case, it still wouldn't work in the `.data' and
`.bss' segments.
The $$ token references the start of the given section, and so
that's the canonical one to use:
> buffer:
> times 512-$+buffer db 0
That's a way to get round it, but
times 512-$+$$ db 0
will make absolutely sure, by definition, that you end up 512 bytes
from the start of your section.
Hope that helps,
--
<^ I /\/\ O /\/ Simon Tatham <sgt20 AT cam DOT ac DOT uk> <anakin AT pobox DOT com>
_> ------------ Trinity College, Cambridge, CB2 1TQ, England.
- Raw text -