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.
hey,
Ive managed to compile my bootloader using NASM with no errors , but the code doesnt run beyond the GDTpointer that ive marked below...I can print a string befor the line...but not after...Any ideas as to why?
Its not like ive loaded the segment register that my string function uses with the descriptor offsett yet...
[BITS 16]
[ORG 0X7E00] ;
jmp main
main:
;****segment DS register is already set at 00000 for you by the bootloader
mov si, BootstrapLoaded ;Load into the index register the offsett of the string
call PrintMsg
Call GDT
mov si,GDTLoaded
Call PrintMsg
jmp $
;The following GDT notes are written in Notes3 file
GDT:
.Gdt_null:
Dw 0
Dw 0
Dw 0
Dw 0
.Gdt_code:
Dw 1
Dw 0
Db 0
Db 10011010
Db 11011111
Db 0
.Gdt_data:
Dw 1
Dw 0
Db 0
Db 10010010
Db 11011111
Db 0
.Gdt_end:
.Gdt_pointer:
Dw .Gdt_end - .Gdt_code -1
Dd .Gdt_code
.Gdt_load
CLI
Lgdt [.Gdt_pointer]
Ret
PrintMsg: ;The datasegment register for the bootstrap is loaded in the first stage bootsector
mov ah, 0x0e
mov bh, 0x00
mov bl, 0x07
.NextChar:
mov al, [ds:si]
inc si ;
or al, al
jz .Break
int 0x10
jmp .NextChar
.Break:
ret
BootstrapLoaded: db "The bootstrap(extended bootloader) is running", 13, 10, 0
GDTLoaded: db "GDT is loaded",13,10,0
"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 ]
"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 ]
Actually, you don't need a GDT in order to set the PE bit successfully.
"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 ]
[BITS 16]
[ORG 0X7E00]
jmp main
main:
;****segment DS register is already set at 00000 for you by the bootloader
mov si, BootstrapLoaded
call PrintMsg
mov si, MSGPmode
Call PrintMsg
Call GDT_load
jmp $
;The following GDT notes are written in Notes3 file
GDT_run:
.Gdt_null: ;Offset 0, descriptor code 0
Dw 0
Dw 0
Dw 0
Dw 0
.Gdt_code: ;Offset 8 bytes down, 0x8h
Dw 1
Dw 0
Db 0
Db 10011010
Db 11011111
Db 0
.Gdt_data: ;Offsett 16 bytes down, 0x10h
Dw 1
Dw 0
Db 0
Db 10010010
Db 11011111
Db 0
.Gdt_end:
GDT_load:
.Gdt_pointer:
Dw GDT_run.Gdt_end - GDT_run.Gdt_code -1
Dd GDT_run.Gdt_code
;*******************************Problem here....String doesnt print...*******************
mov si, OK;Load into the index register the offsett of the string
Call PrintMsg
.Gdt_load
CLI
Lgdt [.Gdt_pointer]
Ret
PrintMsg:
mov ah, 0x0e
mov bh, 0x00
mov bl, 0x07
.NextChar:
mov al, [ds:si] ;DS (segment selecter not necessar, NASM will assume current data segment)
inc si
or al, al ; if al=0 (the last character=null) then 0 flag is set
jz .Break
int 0x10
jmp .NextChar
.Break:
ret
BootstrapLoaded: db "The bootstrap(extended bootloader) is running", 13, 10, 0
MSGPmode: db "Loading Protected Mode",13,10,0
OK: db "[OK]",13,10,0
nekros, Jeremiah, Combuster...I think i figured out what youve been trying to tell me this whole time...So now in what i hope is the last example, im not running the GDT, ive only set up the pointer...But still i cant get the string to print...Any ideas as to why?
Since in the code i havent used thr LGDT instruction, or called the function that sets up the descriptors.... rather just set the limit and base adress in the pointer. Why or how is it that im running the GDT?
You're jumping to the address of the GDT pointer, where you've dw/dd'd some bytes. When the processor sees those bytes it tries to execute them as opcodes. You are trying to run data as code.