P
Paul
Most of the assemblers I have used do have such directives:[...]
.data and .text are both directives to the assembler.
Which assembler? Most of the assemblers I've used didn't have
such directives.
GNU Assembler, .section .text
The directive here is .section. The .text is simply a symbol; you
can,
at least in principle, use anything you want (and a really good
compiler
will use more than just .text and .data).
NASM, SECTION .text
Ditto. The directive is SECTION; the .text is just a user defined
symbol.
MASM, .CODE
TASM, CODESEG
Worked what way? You generally want to put data into the data segment
and code into the text aka. code segment. These directives allow the
programmer to do this, what's the problem?
The directives allow the programmer to divide the program up into one
or
more segments. Other directives tell the linker where to put these
segments. There may be defaults for some symbols, but they're
certainly
not universal, and they don't mean that you cannot use other segments,
or other names.
I can write assembler compiler that can compile this:
"jesus .text", that doesn't prove anything. A text segment is
generally where the assembler puts code. A fact. Come on, what are you
smoking?
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
If you mean by "generally" that this is most often the case then I would
agree. Because, in general, the term TEXT segment as we use it today is a
PC program format, also this represents the memory layout.
But it is not true to say that this is the *only* type of memory model. A
true flat model(not wintel .flat model) has one segment of memory it doesn't
need to have any segment name, ofc you can name it anything_you_want but it
doesn't do anything. It's no more a text segment than it's an
anything_you_want segment.