Where did the text segment get its name?

Viewed 4072

Traditional assembler, and higher level compilers work with several memory segments, according to intended use. Hence, there is a data segment, a stack segment, a bss, and text segment. The text segment is also called the code segment.

Text segment? For machine code?

I have asked all the old-timers I could find, how something as unreadable as machine code came to be know as the "text segment". Every one of them agreed that, that was really what it was called, but none of them seemed to be surprised by it. And no one could offer an explanation.

Here's your chance to show off your geek history knowledge by enlightening us.

8 Answers

It might have something to do with the fact that the code section was usually read-only, and it could also contain strings of characters for the text messages the program could display to the user as messages. Hence the "text" section. This is in contrast to the "data" section which contains pieces of data that can be modified.

I've always imagined it comes form the analogy with human-readable text.

You write in english language a piece of text. It is a string of letters, punctuations, etc. and adheres to certain rules defined by the language (i.e. syntactical, grammatical, etc.). It can be understood by people that know the language.

Similarly, you write (i.e. build) in machine language a "text". It is a string of binary data (digits) and adheres to certain rules defined by the language (i.e. the instruction set architecture). It can be understood (i.e. executed) by processors that know that machine language (i.e. implement the ISA).

IMO the term "code" is less logical. "code" means a piece of information that has been converted (encoded) from it's original form into some alternative representation (for whatever purpose). But with the executable "code", it is not clear which was its the "original" form.

The name segment comes from the memory management techniques used in older times, which is now replaced by paging. I believe the name text comes from the analogy with the novel. Like the text in the novel, the code can be thought of as a piece of text in a novel. The text section of the code tells describes the code or it tells the story of what the program does.

I agree with kdgregory's answer, but I think the the binary text notation came from this fact.

I would say "text" implied reading. Because the text segment is read-only, I think it comes from the idea of a text book, which is also read-only in the most literal sense.

Either that, or it's some kind of abbreviation that was internally used back in the day, which could have meant something like "To EXecuTe." Though, the etymology would have been lost to time.

Related