Page 1 of 1

OSdev

Posted: Thu Dec 09, 2004 7:25 am
by Solar_worm
I want create my OS. I do a bootloader byt i dont known how enter protected mode?
Can help me?

Re:OSdev

Posted: Thu Dec 09, 2004 7:32 am
by Solar_worm
I jump to 16 bit kernel at 0x8000
[BITS 16]
[ORG 0x7C00]

jmp 0x8000

times 510-($-$$) db 0
dw 0xAA55
But it doesn't work :(

Re:OSdev

Posted: Thu Dec 09, 2004 7:36 am
by Pype.Clicker
you're assuming that CS will be 0 instead of enforcing it. If your kernel is indeed loaded at 0x8000, just do

Code: Select all

jmp 0000:0x8000
and it'll be fine.

As for protected mode setup, i suggest you get a look at BonaFide and OSRC tutorials, as suggested in the FAQ and .:QuickLinkz:.

Re:OSdev

Posted: Thu Dec 09, 2004 7:38 am
by Solar
Please tell me your nick has some SF background and wasn't meant as offense. :)

Re:OSdev

Posted: Thu Dec 09, 2004 7:43 am
by Solar_worm
MegaTokyo FAQ doesn't work. And My bootloader work's.
Greets from Lituania :)

Re:OSdev

Posted: Thu Dec 09, 2004 7:49 am
by Pype.Clicker
Solar_worm wrote: MegaTokyo FAQ doesn't work.
Can you be more specific ? (e.g. post the error code/msg you get in the "working on the FAQ" thread ...)

Re:OSdev

Posted: Thu Dec 09, 2004 7:50 am
by Solar_worm
How I can with debug option write to 2nd sector
debug stage2
-w 100 0 0 2
-q
?

Re:OSdev

Posted: Thu Dec 09, 2004 8:27 am
by Pype.Clicker
haven't toyed with msdebug for ages. i guess it should have some help somewhere (try out "help debug" or "h" in debug)

people around here use tools like rawrite or winimage for floppy management ...

Re:OSdev

Posted: Thu Dec 09, 2004 10:01 am
by ASHLEY4
This is the smalist code for geting into pmode.

Code: Select all

;************************************
; \\|//
; (@ @)
; ASHLEY4.
; Put test.bin on boot sector
; with rawrite.
; Assemble with fasm
; c:\fasm test.asm test.bin
;************************************
org 0x7C00

use16
;****************************
; Realmode startup code.
;****************************

start:
        xor   ax,ax
        mov   ds,ax
        mov   es,ax
        mov   ss,ax
        mov   sp,0x7C00

;*****************************
; Setting up, to enter pmode.
;*****************************
        cli 
        lgdt  [gdtr]
        
        mov   eax, cr0
        or    al,0x1 
        mov   cr0,eax
 
        jmp   0x10: protected

;*****************************
; Pmode. ;-)
;*****************************

use32
protected:
        mov   ax,0x8
        mov   ds,ax
        mov   es,ax
        mov   ss,ax
        mov   esp,0x7C00
;*****************************
; Turn floppy off (if space).
;*****************************

        mov   dx,3F2h
        mov   al,0
        out   dx,al

        lea esi,[msg0]                 
   mov edi,0xB8000 + (80 * 3 + 4) * 2     
   mov   ecx,28
   cld
   rep movsb

        jmp   $
;*************************************
; GDT. 
;*************************************

gdt:        dw    0x0000, 0x0000, 0x0000, 0x0000
sys_data:   dw    0xFFFF, 0x0000, 0x9200, 0x00CF
sys_code:   dw    0xFFFF, 0x0000, 0x9800, 0x00CF
gdt_end:

gdtr:       dw gdt_end - gdt - 1                                     
       dd gdt

;*************************************
; Data. 
;*************************************

msg0        db "  H E L L O   W O R L D !   " 

;*************************************
; Make program 510 byte's + 0xaa55
;*************************************
            
times 510- ($-start)  db 0
dw 0xaa55 
Assemble with fasm.

PS: The space in the text, must be the same as above.

\\\\||////
(@@)
ASHLEY4.

Batteries not included, Some assembly required.

Re:OSdev

Posted: Fri Dec 10, 2004 5:51 am
by Solar_worm
Thx,
Why i cant assembly it with nasm?

Re:OSdev

Posted: Fri Dec 10, 2004 6:50 am
by bubach
change "use16" to "[bits 16]" and it should work in nasm aswell.

Re:OSdev

Posted: Fri Dec 10, 2004 8:29 am
by Solar_worm
And I must change
times 510- ($-start) db 0
dw 0xaa55

to:
times 510- ($-$$) db 0
dw 0xAA55
???

Re:OSdev

Posted: Fri Dec 10, 2004 3:51 pm
by DennisCGc
Solar_worm wrote: And I must change
times 510- ($-start) db 0
dw 0xaa55

to:
times 510- ($-$$) db 0
dw 0xAA55
???
correct.
change "use16" to "[bits 16]" and it should work in nasm aswell.
Not neccesarily needed, you can use "use16" and still it should work.

HTH,

DennisCGc.

PS:

Code: Select all

        lea esi,[msg0]
You can also use:

Code: Select all

        mov  esi,msg0
It depends on what you think it's easier to do.