Code: Select all
DESCRIPTOR struct
segment_limit_0_15 dw ?
base_addr_0_15 dw ?
base_addr_16_23 db ?
segment_properties db ?
seg_limit_16_19_gran db ?
base_addr_24_31 db ?
DESCRIPTOR ends
gstart label qword
nullDescriptor DESCRIPTOR <0,0,0,0,0,0>
code16Descriptor DESCRIPTOR <0ffffh,0000,00,9Fh,00h,00>
code32Descriptor DESCRIPTOR <0ffffh,0000,00,9Fh,08Fh,00>
data16Descriptor DESCRIPTOR <0ffffh,0000,00,93h,00h,00>
Stack16Descriptor DESCRIPTOR <0ffffh,0000,00,93h,00h,00>
bigData16Descriptor DESCRIPTOR <0ffffh,0000,00,92h,0CFh,00>
gend label qword
gbase label fword
limit dw gend-gstart-1 ;limit
addr dd ?
org_gdt label fword
orig_gdt_limit dw 0000h
orig_gdt_addr dd 00000000h
unrealmode proc
push eax
push ebx
push ds
push es
push fs
push gs
db 66h
sgdt fword ptr cs:org_gdt
xor eax, eax
mov ax, cs
shl eax, 4
add eax, offset gstart
mov dword ptr cs:[addr], eax
pushf
cli
mov bx, bigData16Descriptor - gstart
lgdt fword ptr cs:[gbase]
mov eax, cr0
or al, 1
mov cr0,eax
mov ds, bx
mov es, bx
mov eax, cr0
and al, 0FEh
mov cr0, eax
nop
db 66h
lgdt cs:orig_gdt
popf
pop gs
pop fs
pop es
pop ds
pop ebx
pop eax
ret
unrealmode endp
Can anyone help me in this.?