Why do segments begin with paragraph boundaries?

In a real-time segmented memory model, a segment always starts with a paragraph border. The paragraph is 16 bytes in size, so the segment address is always divided by 16. What is the reason / benefit of having segments at the border of the paragraph?

+4
source share
3 answers

This is not so much an advantage as an axiom - the segmentation model 8086 of the real mode is designed at the hardware level, so the segment register determines the border of the paragraph.

The segment register set the base address of the upper 16 bits of the 8086-bit address space 8086, the lower 4 bits of this base address were essentially forced to zero.

Segmented architecture was one way that the 1686-bit register architecture could address the full megabyte (!) Of the address space (which requires 20 bits of addressing).

For a bit more history, the next step Intel took in the x86 architecture was to abstract segment registers from directly defining the base address. This was protected mode 286, in which the segment register held a “selector”, which, instead of defining bits for the physical base address, was an index into a set of descriptor tables containing information about the physical address, permissions to access the physical memory address, etc.

Segment registers in modern 32-bit or larger x86 processors still do this. But when address offsets can indicate full 32-bit addressing (or 64-bit on x64 processors) and page tables capable of providing semantics of virtual memory in a segment defined by a selector, the programming model essentially eliminates the need to manipulate segment registers at the application level. For the most part, the OS sets up the segment registers once, and nothing else they need to solve. Therefore, programmers usually do not even need to know that they exist.

+4
source

In 8086 there were 20 address lines. The segment was mapped to the top 16, leaving the offset of the bottom 4 lines or 16 addresses.

+2
source

The segment register stores the address of the memory cell where this segment begins . But segment registers store 16-bit information. This 16 bit is converted to 20 bit, adding 4 bits 0 to the right end of the address. If the segment register contains 1000H, it moves to the left to get 10000H. Now it's 20 bits.

When converting, we added 4 bits 0 to the end of the address. Therefore, each segment in memory should start at the memory location , where the last 4 bits are 0.

For ex:

If a segment starts at memory location 10001H, we cannot access it because the last 4 bits are not equal to 0. Any address in the segment register will be added with 4 bits at the right end to convert to 20 bits. Thus, there is no access to such an address.

0
source

Source: https://habr.com/ru/post/1302606/


All Articles