Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;originally found at http://a.michelizza.free.fr
- [BITS 16]
- [ORG 0x0]
- jmp start
- %include "GDT.INC"
- start:
- ; init of segments registers to 0x07C0
- mov ax, 0x07C0
- mov ds, ax
- ; load kernel into RAM
- xor ax, ax
- int 0x13
- mov ax, 0x100
- mov es, ax
- mov bx, 0
- mov ah, 2
- mov al, 1 ; 1 sector
- mov ch, 0
- mov cl, 2
- mov dh, 0
- int 0x13
- ; init GDT cf GDT.INC
- ;code and data segments just differs from one bit.
- ; base and limit are the same for code and data segment (0 to 4Gio)
- descInit 0, 0xFFFFF, 10011011b, 1101b, gdt_cs
- descInit 0, 0xFFFFF, 10010011b, 1101b, gdt_ds
- mov ax, gdtend ; compute GTD limit
- mov bx, gdt
- sub ax, bx
- mov word [gdtptr], ax
- xor eax, eax ; compute linear @ of GDT
- mov ax, ds
- mov bx, gdt
- call calcadr
- mov dword [gdtptr+2], ecx
- ; switching to protected mode
- cli
- lgdt [gdtptr] ; load gdt
- mov eax, cr0
- or ax, 1
- mov cr0, eax ; active Proected mode
- jmp next
- next:
- mov ax, 0x10 ; data segment in GDT
- mov ds, ax
- jmp dword 0x8:0x1000
- ;end:
- ; jmp end
- ;---data-----------------------------------------------------------------
- gdt:
- gdt_null:
- dw 0, 0, 0, 0
- gdt_cs:
- dw 0, 0, 0, 0
- gdt_ds:
- dw 0, 0, 0, 0
- gdtend:
- gdtptr:
- dw 0x0000 ; limite
- dd 0 ; base
- bootdrv: db 0
- ;--------------------------------------------------------------------
- ;; NOP jusqu'a 510
- times 510-($-$$) db 144
- dw 0xAA55
- 87,0-1 Bas
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement