Data segment

from Wikipedia, the free encyclopedia

The data segment is the part of object files or a running process in which global and static variables are stored. These variables must already be present in the memory and initialized when the program is started, and their storage space requirements are already known at compilation time. A data block is therefore already created during compilation, which can later be loaded into memory as part of the program when it is started and used immediately. Sometimes data, BSS, stack , and heap areas are collectively referred to as a "data segment".

In machine language, there are then separate segments for data and executable code. For that think, for instance Intel - processors registry CS ( code segment ) and DS ( Data Segment ) ready. Individual commands then relate either to the data or code segment. The jump instruction JMP 0120, for example, designates the absolute address 0120 which is to be jumped to in the segment specified by the segment register CS . In the case of commands for data exchange such as MOV DX, [BX], on the other hand, the address in BX refers to the data segment as a pointer . Assembly languages provide their own instructions for defining segments for data, code, stack, and their order (for example .DATA , .CODE , .STACK, etc.).

In some operating systems (e.g. in z / OS ) the separation of code and data segments is not necessary. The machine instructions do not differentiate between these two types of areas, but address data and code parts with identical procedures, registers, etc. A machine program can therefore contain a mixture of data and code; for reasons of software quality ( maintainability ), however, data declarations and the command part of the program are usually implemented structurally separately .

Block started by symbol

The term Block Started by Symbol is used in many compilers and linkers for a segment that contains static variables that are initialized with zero values. The abbreviation BSS or .bss is often used. This memory area is suitable e.g. B. for fields (arrays) that are not initialized with predefined values. The zero values ​​are usually not saved in the object file, only the size of the BSS area. The loader then evaluates this information and requests a correspondingly large memory area from the operating system, ensuring that the memory area is initialized with the zero values.

Historically, Block Started by Symbol was a pseudo-operation in UA-SAP (United Aircraft Symbolic Assembly Program), an assembler developed in the mid-1950s .

See also