Add more comment in mbr

This commit is contained in:
Mathieu Maret 2018-07-10 14:04:51 +02:00
parent 35c0fb8f86
commit 0d43780f35

28
mbr.asm
View File

@ -94,26 +94,26 @@ main:
mov bx, copy_target;target pointer
int 0x13
cli ; clear interruption flag
cli ; disable interruption when setting GDT
; switch in 32 bits
lgdt [gdt_pointer] ; switch in 32bits here
mov eax, cr0
or eax,0x1; set the protected mode bit on special CPU reg cr0
mov cr0, eax
jmp CODE_SEG:boot2
jmp CODE_SEG:boot2 ; In protected mode we need to add the segment selector
; GDT table desciption could be found http://wiki.osdev.org/Global_Descriptor_Table
; here we define the 3 64bits segment needed: null segment, code segment and data segment
gdt_start: ;null segment
dq 0x0
gdt_code: ;code segment
dw 0xFFFF
dw 0x0
db 0x0
db 10011010b
db 11001111b
db 0x0
dw 0xFFFF ; limit [0:15]
dw 0x0 ; base [0:15]
db 0x0 ; base [16:23]
db 10011010b ; access byte: Present(1)| Priv(2) 0 ->kernel 3->userspace | 1 | Executable(1) | Direction/Conformity (1) | RW(1) | Accessed(1)
db 11001111b ; Granularity(1) | Size (1) 0-> 16bit mode 1->32protected mode | 0 | 0 | Limit [16:19]
db 0x0 ; base [24:31]
gdt_data:
dw 0xFFFF
dw 0x0
@ -135,12 +135,12 @@ dw 0xaa55
copy_target:
bits 32
boot2:
mov ax, DATA_SEG
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov ax, DATA_SEG ; set all segments to point to DATA_SEG https://en.wikipedia.org/wiki/X86_memory_segmentation
mov ds, ax ; Data segment
mov es, ax ; Extra Segment (for string operation)
mov fs, ax ; No Specific use
mov gs, ax ; No Specific use
mov ss, ax ; stack segment
mov esi,hello32
mov ebx,0xb8000 ; Cannot use BIOS anymore, use VGA Text buffer instead