Commit ed35d779 by malcolm

Fixed up the gdt, still crashing

parent 781eab06
Showing with 16 additions and 14 deletions
...@@ -101,7 +101,9 @@ str1 db 'Hello World', 0 ; Hello World ...@@ -101,7 +101,9 @@ str1 db 'Hello World', 0 ; Hello World
str2 db 'WHY IS THIS', 0 str2 db 'WHY IS THIS', 0
hexChars db '0123456789abcdef' ; Used for hex formatting hexChars db '0123456789abcdef' ; Used for hex formatting
gdtr: dw 48
dw 0x0
dw gdt
Main: ;main section Main: ;main section
nop nop
nop nop
...@@ -114,23 +116,22 @@ Main: ;main section ...@@ -114,23 +116,22 @@ Main: ;main section
int 0x15 int 0x15
;; now to try protected mode... ;; now to try protected mode...
cli cli
gdtr: dw 0
dd 0
setGdt: setGdt:
xor eax, eax ;xor eax, eax
mov ax, ds ;mov ax, ds
shl eax, 4 ;shl eax, 4
add eax, gdt ;add eax, gdt
;jp $ ;jp $
mov [gdtr + 2], eax ;mov [gdtr + 2], eax
;jp $ ; ;jp $ ;
mov eax, gdt_end ;mov eax, gdt_end
;jp $ ;jp $
sub eax, gdt ;sub eax, gdt
mov [gdtr], ax ;mov [gdtr], ax
lgdt [gdtr] lgdt [gdtr]
mov eax, cr0 mov eax, cr0
or al, 1 or eax, 1
mov cr0, eax mov cr0, eax
jmp 08h:PMain jmp 08h:PMain
...@@ -149,8 +150,8 @@ gdt: ...@@ -149,8 +150,8 @@ gdt:
db 0x10 ; load protected-mode kernel to 100000h db 0x10 ; load protected-mode kernel to 100000h
db 0x93 ; data access rights db 0x93 ; data access rights
dw 0 dw 0
times 16 db 0 times 15 db 0
gdt_end: gdt_end:db 0
;; .null: times 8 db 0 ;; .null: times 8 db 0
;; .code: dw 0x0400 ; limit (4MiB) ;; .code: dw 0x0400 ; limit (4MiB)
;; dw 0x0000 ; base 0-15 ;; dw 0x0000 ; base 0-15
...@@ -171,6 +172,7 @@ gdt_end: ...@@ -171,6 +172,7 @@ gdt_end:
;; db 0xC0 ;; db 0xC0
;; db 0x0C ;; db 0x0C
PMain: PMain:
[bits 32]
mov si, str1 mov si, str1
call PrintStr call PrintStr
nop nop
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment