Copyright (C) 2000-2012 |
GNU Info (nasm.info)Section 10.1.410.1.4. `TIMES' Doesn't Work ---------------------------- The other common problem with the above code is people who write the `TIMES' line as TIMES 510-$ DB 0 by reasoning that `$' should be a pure number, just like 510, so the difference between them is also a pure number and can happily be fed to `TIMES'. NASM is a _modular_ assembler: the various component parts are designed to be easily separable for re-use, so they don't exchange information unnecessarily. In consequence, the `bin' output format, even though it has been told by the `ORG' directive that the `.text' section should start at 0, does not pass that information back to the expression evaluator. So from the evaluator's point of view, `$' isn't a pure number: it's an offset from a section base. Therefore the difference between `$' and 510 is also not a pure number, but involves a section base. Values involving section bases cannot be passed as arguments to `TIMES'. The solution, as in the previous section, is to code the `TIMES' line in the form TIMES 510-($-$$) DB 0 in which `$' and `$$' are offsets from the same section base, and so their difference is a pure number. This will solve the problem and generate sensible code. automatically generated by info2www version 1.2.2.9 |