Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
org 0x8000
start:
mov ax, 0x800
mov ds, ax
mov es, ax
cli;
lgdt [toc]
mov bx, [toc]
mov ebx, [toc+2]
sti;
cli;
mov eax, cr0
or eax, 1
mov cr0, eax
jmp 0x8:pmode
BITS 32
pmode:
; code......
hlt;
gdt_start:
dd 0
dd 0
dw 0FFFFh
dw 0
db 0
db 10011010b
db 11001111b
db 0
dw 0FFFFh
dw 0
db 0
db 10010010b
db 11001111b
db 0
toc:
dw toc - gdt_start - 1
dd gdt_start
But jmp is still going to 0xfffffff0. Does anybody know where can be the problem now? EDIT:
Finally works! I think I won't ever use org directive. I have removed ORG, and added 0x8000 to jump and "toc" of GDT. Now it works... mostly... But still thanks for navigating mi to the right way.
I can't understand why you try to use "org 8000h" and segment base 8000h (800h*10h) at same time. org directive is used to set up current offset within the segment, not segment base. Yes, this combination allows you to use same starting linear address 10000h, but in this case you should calculate linear addresses/FLAT offsets as I mentioned above: 8000h+gdt, 8000h+pmode, 8000h+$, and so on.
If you have seen bad English in my words, tell me what's wrong, please.
I also found out that it wasn't fully the ORG fault.... I think that lgdt instruction also depends on DI/SI, not only on segment registers. Few days ago I had same problem again. I cleaned di and si.... Then, everything went perfectly.
Last edited by HugeCode on Sun May 12, 2013 6:01 am, edited 1 time in total.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]