Assembler
To calculate the address are used two components of address - offset and section. When for addressing are used address of variables or tags, then it is known, in which segment they are defined. Address of the segment begining and offset of a variable with this name or labels in relation to the segment beginning are used to calculate the address. This offset is called executive address, and it is calculated according to the addressing mode. In this case, required value should be loaded to the appropriate register segment, otherwise the data will be transferred completely into another memory cells. When it needed, in command there is an ability to override the appropriate segment. It is possible to use two methods for this purpose:
- You can use pseudo operator "assume", in order to specify which segment will be used by default when accessing memory.
- Directly in the command, you can specify: relative to which segment offset will be applied.
The physical address - is a twenty-bits unsigned integer, which identifies the location of byte in memory space. The logical address - is a two sixteen-bits unsigned integers: base (source) address of the segment and the effective address (offset), which determines the distance in bytes from the addressed cell to the beginning of the segment.
Programs operates logical address, not physical, hence, when accessing memory for data writing and reading or instruction fetch - occurs hardware transformation of the logical address into a physical address. Microprocessor expands segmental register by four zero bits and adds the offset, which is obtained when calculating the address. Rules of transformation depend on the operating mode of the microprocessor - protected and real. In normal mode of the microprocessor operation - logical address is directly served into the address bus, in other words - coincides with the physical address. In protected mode of the microprocessor operation, the rules for obtaining the logical addresses are different from the real mode, and when applying page memory organization - logical addresses may significantly differ from physical addresses.