i tried to post it with the file uploaded, but it told me that a file with the same name was already uploaded, so i'm pasting into here.
Code: Select all
init:
;segment descriptor
struc segment_descriptor
.seg_length0_15 resw 0 ;low word of segment length
.base_addr0_15 resw 0 ;low word of base address
.base_addr16_23 resb 0 ;low byte of high word of base address
.flags resb 0 ;segment type and misc. flags
.access resb 0 ;highest nibble of segment length and access flags
.base_addr24_31 resb 0 ;highest byte of base address
endstruc
;interrupt descriptor
struc interrupt_descriptor
.offset0_15 resw 0 ;low word of handler offset
.selector0_15 resw 0 ;segment selector
.zero_byte resb 0 ;unused
.flags resb 0 ;flags
.offset16_31 resw 0 ;high word of handler offset
endstruc
;gdt data
gdt_reg dw gdt_size,0,0
dummy_dscr:
istruc segment_descriptor
resw 0
resw 0
resb 0
resb 0
resb 0
iend
code32_dscr:
istruc segment_descriptor
resw 0ffffh
resw 0
resw 0
resb 9ah
resb 0cfh
resb 0
iend
data32_dscr:
istruc segment_descriptor
resw 0ffffh
resw 0
resw 0
resb 92h
resb 0cfh
resb 0
iend
core32_dscr:
istruc segment_descriptor
resw 0ffffh
resw 0
resw 0
resb 9ah
resb 0
resb 0
iend
data16_dscr:
istruc segment_descriptor
resw 0ffffh
resw 0
resw 0
resb 92h
resb 0
resb 0
iend
gdt_size=-$(dummy_dscr)
;task selector
taskselector:
task_backlink resw 0,0
task_esp0 resd 0
task_ss0 resw 0,0
task_esp1 resd 0
task_ss1 resw 0,0
task_esp2 resd 0
tasl_ss2 resw 0,0
task_cr3 resd 0
task_eip resd 0
task_eflags resd 0
task_eax resd 0
task_ecx resd 0
task_edx resd 0
task_ebx resd 0
task_esp resd 0
task_ebp resd 0
task_esi resd 0
task_edi resd 0
task_es resw 0,0
task_cs resw 0,0
task_ss resw 0,0
task_ds resw 0,0
task_fs resw 0,0
task_gs resw 0,0
task_idt resw 0,0
task_trap resw 0
task_iomapbase resw 0
task_iobitmap times 128 resb 0
endtaskselector1:
systemtaskselector equ $-gdt_reg
systemtaskdescriptor:
resw 103 ;limit/length
resb 0 ;base 0
resb 0 ;base 0
resb 10001001b ;p=1, dpl=00, dt=0, available (1,0,0,0,1001)
resb 01000000b ;g=1, d=1, 0, avl=0, 1111=f: limit/length (1,1,0,0,1111)
resb 0 ;base 0
endsystaskdesc:
lgdt [fword ds:gdt_reg]
cli
mov eax,cr0
or al,1
mov cr0,eax
jmp start32
start32:
mov ax, systemtaskselector
ltr ax
ret