在分析linux中的set_base之前,我们定义
;eax is TSS0 offset address
;ebx is kernel_base address 0x10000
;ecx is gdt_address
;edi is TSS0_SEL 0x20
set_base:
addl %ebx, %eax ; eax = eax + ebx = 0x10000 + TSS0 offset address
addl %ecx, %edi ; edi = edi + ecx = gdt_address + TSS0_SEL
movw %ax, 2(%edi) ; *(shou*)((char*)edi + 2) = eax的低位
rorl $16, %eax ; 将eax的高低16位颠倒
movb %al, 4(%edi)
movb %ah, 7(%edi)
rorl $16, %eax
ret
时间: 2024-11-14 16:38:43