logical address translating

logical address translating

逻辑地址 #

逻辑地址由两部分组成: 16位的段选择符(segment selector)和32位的位移(offset)。

进程可访问的地址空间称为线性地址空间(linear address space), Segmentation将线性地址空间划分为多个段(Segment)。

下面是节选自 Linux 的 bootsect 中的代码:

BOOTSEG   = 0x7c0
_start:
  jmpl $BOOTSEG, $start2
start2:
  movw $BOOTSEG, %ax
  movw %ax, %ds
  ...

跳转的目标地址就是 0x7c0 << 4 + OFFSET(start2)。跳转成功以后,cs 段寄存器中的值就是段基址 0x7c0,start2 的偏移值是 8,所以记录当前执行指令地址的 ip 寄存器中的值就是实际地址 0x7c08。

Viewpoint #

From #

02|聊聊x86体系架构中的实模式和保护模式