Commit 35ecb3ae by malcolm

GDT all fixed up, no longer crashes. Added some 32 bit setup.

parent ed35d779
Showing with 32 additions and 44 deletions
...@@ -101,9 +101,8 @@ str1 db 'Hello World', 0 ; Hello World ...@@ -101,9 +101,8 @@ 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 gdtr: dw gdt_end - gdt - 1
dw 0x0 dd gdt
dw gdt
Main: ;main section Main: ;main section
nop nop
nop nop
...@@ -133,49 +132,38 @@ setGdt: ...@@ -133,49 +132,38 @@ setGdt:
mov eax, cr0 mov eax, cr0
or eax, 1 or eax, 1
mov cr0, eax mov cr0, eax
jmp 08h:PMain jmp 08h:PMain
gdt: gdt:
times 16 db 0 dd 0
dw 0xffff ; segment limit dd 0
.src: .code:
dw 0 dw 0FFFFh ; limit
db 2 dw 0 ; base low
db 0x93 ; data access rights db 0 ; base mid
dw 0 db 10011010b ; access
dw 0xffff ; segment limit db 11001111b ; granularity
.dest: db 0 ; base high
dw 0 .data:
db 0x10 ; load protected-mode kernel to 100000h dw 0FFFFh ; limit
db 0x93 ; data access rights dw 0 ; base low
dw 0 db 0 ; base mid
times 15 db 0 db 10010010b ; access
gdt_end:db 0 db 11001111b ; granularity
;; .null: times 8 db 0 db 0 ; base high
;; .code: dw 0x0400 ; limit (4MiB) gdt_end:
;; dw 0x0000 ; base 0-15
;; db 0x00 ; base 16-23 [bits 32]
;; db 0x9A ; access byte
;; db 0xC0 ; flags/limit 16-19
;; db 0x04 ; base 24-31
;; .data: dw 0x0400
;; dw 0x0000
;; db 0x00
;; db 0x92
;; db 0xC0
;; db 0x08
;; .tss: dw 0x0400
;; dw 0x0000
;; db 0x00
;; db 0x89
;; db 0xC0
;; db 0x0C
PMain: PMain:
[bits 32]
mov si, str1 mov ax, 0x10 ; set data segments to data selector (0x10)
call PrintStr mov ds, ax
nop mov ss, ax
nop mov es, ax
hlt mov esp, 90000h
;mov si, str1
;call PrintStr
;nop
;nop
hlt
jp $ jp $
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