|
Segments
The architecture of the x86 processors forces to the use of memory segments to manage the information, the size of these segments is of 64kb.
The reason of being of these segments is that, considering that the maximum size of a number that the processor can manage is given by a word of 16 bits or register, it would not be possible to access more than 65536 localities of memory using only one of these registers, but now, if the memory is divided into groups or segments, each one of 65536 localities, and we use an address on an exclusive register to find each segment, and then we make each address of a specific slot with two registers, and it is possible for us to access a quantity of 4294967296 bytes of memory.
In order for the assembler to be able to manage the data, it is necessary that each piece of information or Instruction be found in the area that corresponds to its respective segments. The assembler accesses this information taking into account the localization of the segment, given by the DS, ES, SS and CS registers and inside the register the address of the specified piece of information. It is because of this that when we create a program using the Debug on each line that we assemble, something like this appears:
1CB0:0102 MOV AX,BX
Where the first number, 1CB0, corresponds to the memory segment being used, the second one refers to the address inside this segment, and the Instructions which will be stored from that address follow.
The assembler adjusts the size of the segments taking as a base the number of bytes each assembled Instruction needs, since it would be a waste of memory to use the whole segments. For example, if a program only needs 10kb to store data, the data segment will only be of 10kb and not the 64kb it can handle.
|
|