flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Switch to protected mode

Author
Thread Post new topic Reply to topic
Enko



Joined: 03 Apr 2007
Posts: 678
Location: Mar del Plata
Enko
Hello, I have a little o a big problem settingup the protected mode.
First I run my bootloeader that make a raw read of the 2nd sector of the floppy, write's it to 0x1000:0000 and then jumps to this address, the main kernel.
The problem is than I can't switch to protected mode from my kernel, I've spend aboute 3 days reading stuff but I still can't get it. The examples in this forum are some way different because in on, the bootloeader switch to the protected mode, and in other, it is a .com file.

This is the code, its located at 0x1000:0000

Code:
jmp       real_mode      
global_descriptor_table:
null_descriptor:        db      0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00
system_code:  db      0xFF,0xFF, 0x00,0x00, 0x01,0x9A, 0x00,0xCF
system_data:  db      0xFF,0xFF, 0x00,0x00, 0x01,0x92, 0x00,0xCF
system_linear:        db      0xFF,0xFF, 0x00,0x00, 0x00,0x92, 0x00,0xCF
global_descriptor_end:
gdtr:
       dw      global_descriptor_end - global_descriptor_table -1
  dd      global_descriptor_table
real_mode:
   mov     ax, cs
      mov     ds, ax
      mov     es, ax
      
    cli
 lgdt    [gdtr]
      mov     eax, cr0
    inc     ax
  mov     cr0, eax
    jmp     0x8:protected_mode
use32
protected_mode:
      mov   ax,0x10 
      mov   ds,ax
 mov   ss,ax
 mov   ax,0x18
       mov   es,ax
 mov   byte [es:0xB8010], "!"
forever:
  jmp     forever
    

Any kind of tip will be very apritiated. Thanks. Wink
Post 30 May 2007, 19:19
View user's profile Send private message Reply with quote
mikegonta



Joined: 20 Nov 2005
Posts: 99
mikegonta
[ Post removed by author. ]


Last edited by mikegonta on 27 Jan 2009, 21:58; edited 2 times in total
Post 31 May 2007, 02:30
View user's profile Send private message Reply with quote
Enko



Joined: 03 Apr 2007
Posts: 678
Location: Mar del Plata
Enko
Thanks for tips.
I modified the code, now its turn the protected mode in the boot loeader and works
Post 31 May 2007, 19:20
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.