0.00-050613_boot.s

 1 !    boot.s
 2 !
 3 ! It then loads the system at 0x10000, using BIOS interrupts. Thereafter
 4 ! it disables all interrupts, changes to protected mode, and calls the 
 5 
 6 BOOTSEG = 0x07c0
 7 SYSSEG  = 0x1000            ! system loaded at 0x10000 (65536).
 8 SYSLEN  = 17                ! sectors occupied.
 9 
10 entry start
11 start:
12     jmpi    go,#BOOTSEG
13 go:    mov    ax,cs
14     mov    ds,ax
15     mov    ss,ax
16     mov    sp,#0x400        ! arbitrary value >>512
17 
18 ! ok, we've written the message, now
19 load_system:
20     mov    dx,#0x0000
21     mov    cx,#0x0002
22     mov    ax,#SYSSEG
23     mov    es,ax
24     xor    bx,bx
25     mov    ax,#0x200+SYSLEN
26     int     0x13
27     jnc    ok_load
28 die:    jmp    die
29 
30 ! now we want to move to protected mode ...
31 ok_load:
32     cli            ! no interrupts allowed !
33     mov    ax, #SYSSEG
34     mov    ds, ax
35     xor    ax, ax
36     mov    es, ax
37     mov    cx, #0x2000
38     sub    si,si
39     sub    di,di
40     rep
41     movw
42     mov    ax, #BOOTSEG
43     mov    ds, ax
44     lidt    idt_48        ! load idt with 0,0
45     lgdt    gdt_48        ! load gdt with whatever appropriate
46 
47 ! absolute address 0x00000, in 32-bit protected mode.
48     mov    ax,#0x0001    ! protected mode (PE) bit
49     lmsw    ax        ! This is it!
50     jmpi    0,8        ! jmp offset 0 of segment 8 (cs)
51 
52 gdt:    .word    0,0,0,0        ! dummy
53 
54     .word    0x07FF        ! 8Mb - limit=2047 (2048*4096=8Mb)
55     .word    0x0000        ! base address=0x00000
56     .word    0x9A00        ! code read/exec
57     .word    0x00C0        ! granularity=4096, 386
58 
59     .word    0x07FF        ! 8Mb - limit=2047 (2048*4096=8Mb)
60     .word    0x0000        ! base address=0x00000
61     .word    0x9200        ! data read/write
62     .word    0x00C0        ! granularity=4096, 386
63 
64 idt_48: .word    0        ! idt limit=0
65     .word    0,0        ! idt base=0L
66 gdt_48: .word    0x7ff        ! gdt limit=2048, 256 GDT entries
67     .word    0x7c00+gdt,0    ! gdt base = 07xxx
68 .org 510
69     .word   0xAA55

C

原文地址:https://www.cnblogs.com/CodeSkill/p/5086046.html