www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/01/06:03:30

From: anakin AT pobox DOT com (Simon Tatham)
Newsgroups: comp.lang.asm.x86,alt.lang.asm,comp.os.msdos.djgpp
Subject: Re: NASM
Date: 1 Feb 1997 09:21:01 GMT
Organization: Trinity College, Cambridge
Lines: 35
Message-ID: <5cv1tt$ke3@lyra.csx.cam.ac.uk>
References: <Pine DOT GSO DOT 3 DOT 95 DOT 970117233047 DOT 15969A-100000 AT nontri DOT ku DOT ac DOT th> <5boris$t6v AT lyra DOT csx DOT cam DOT ac DOT uk> <Pine DOT GSO DOT 3 DOT 95 DOT 970201081138 DOT 1000A-100000 AT std DOT cpc DOT ku DOT ac DOT th>
NNTP-Posting-Host: anakin.trin.cam.ac.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019