Commit 0a7e2777 by malcolm

Testing switch to protected mode for execution of C code. Does not work. At all.

parent 69500cf3
Showing with 29 additions and 3 deletions
...@@ -41,13 +41,14 @@ read_fail db 'Failure to read from disk.', 13, 10, 0 ...@@ -41,13 +41,14 @@ read_fail db 'Failure to read from disk.', 13, 10, 0
times 510 - ($ - $$) db 0 times 510 - ($ - $$) db 0
; Fill last two bytes (a word) with the MBR signature 0xAA55 ; Fill last two bytes (a word) with the MBR signature 0xAA55
dw 0xaa55 dw 0xaa55
;---------------- BOOTLOADER CODE ----------------;
ls: mov si, str1 ; pointer to string in si ls: mov si, str1 ; pointer to string in si
call PrintStr ; print string call PrintStr ; print string
jmp Main ; jmp Main ;
hlt hlt
;---------------- SCREEN FUNCTIONS ---------------;
PrintStr: ; print string at SI PrintStr: ; print string at SI
nextChar: nextChar:
mov al, [si] ; grab next char mov al, [si] ; grab next char
...@@ -95,7 +96,7 @@ PrintHexChar: ...@@ -95,7 +96,7 @@ PrintHexChar:
call PrintChar call PrintChar
ret ret
;------------------ DATA BLOCK ------------------;
str1 db 'Hello World', 0 ; Hello World str1 db 'Hello World', 0 ; Hello World
str2 db 'WHY IS THIS', 0 str2 db 'WHY IS THIS', 0
...@@ -109,3 +110,28 @@ Main: ;main section ...@@ -109,3 +110,28 @@ Main: ;main section
mov si, str1 mov si, str1
mov ax, 10 mov ax, 10
call PrintHexStr ; print string call PrintHexStr ; print string
mov ax, 0x2401
int 0x15
;; now to try protected mode...
cli
lgdt [gdtinfo]
mov eax, cr0
or al, 1
mov cr0, eax
jmp 08h:PMain
gdtinfo:
dw gdt_end - gdt - 1 ;last byte in table
dd gdt ;start of table
gdt dd 0, 0
flatdesc db 0xff, 0xff, 0, 0, 0, 10010010b, 11001111b, 0
gdt_end:
db 0x55
db 0xAA
PMain:
nop
nop
hlt
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