运行setup.s:
一开始利用BIOS提供的中断服务程序从设备上提取内核所需的机器系统数据至0x90000~0x901FC(覆盖bootsect)
随后关中断并将系统从0x10000移动至0x00000(即覆盖原本的BIOS中断程序):
! now we want to move to protected mode ...
cli ! no interrupts allowed !
! first we move the system to it's rightful place
mov ax,#0x0000
cld ! 'direction'=0, movs moves forward
do_move:
mov es,ax ! destination segment
add ax,#0x1000
cmp ax,#0x9000
jz end_move
mov ds,ax ! source segment
sub di,di
sub si,si
mov cx,#0x8000
rep
movsw
jmp do_move
REP
MOVSW
指令:
将cx个“字”(2字节),从DS:SI复制至ES:DI
一次复制0x10000空间,直到0x90000这个地址为止(貌似有点浪费,system没有这么大)
之后,设置中断描述符表和全局描述符表:
end_move:
mov ax,#SETUPSEG ! right, forgot this at first. didn't work :-)
mov ds,ax
lidt idt_48 ! l