The Character Segment. 4tH 4tH Forth compiler
Anuncio
Anuncio
Chapter 9
Character Segment
9.1
The Character Segment
Wonder where all these strings are created? I bet you do. Well, when you define a string, memory is allocated in the Character Segment. When you define another one, space is allocated after the first string. That means that if you go beyond the boundaries of the first string, you’ll end up in the space allocated to the second string.
After the second string there is a void. If you end up there your program will end with an error-message. And what about the space before the first string? Well, take a look at figure
9.1.
The lower memory is at the bottom. Yes, before your strings there are two other areas, the TIB and the PAD.
We’ll elaborate on that in the next section.
The Character Segment is created at run-time. That means that it isn’t there when you compile a program. The compiler just keeps track of how much memory would be needed to create such a Character Segment and stores that information in the header.
When you run the program the header is read first. Then the Character Segment is created, so it is already there when your program starts executing. When you exit the program, the Character Segment is destroyed and all information stored there is lost (unless you save it first).
User strings
Figure 9.1: ment
PAD
TIB
Character seg-
9.2
What is the TIB?
The TIB stands for "Terminal Input Buffer" and is used by one single, but very important word called ’REFILL’. In essence, ’REFILL’ does the same thing as ’ACCEPT’, except that it has a dedicated area to store its data and sets up everything for parsing. Whatever you type when you call ’REFILL’, it is stored in the TIB.
94
Descargar
Anuncio