User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Assembly section within the Software Development category of DaniWeb, a massive community of 455,985 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,795 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Assembly advertiser: Programming Forums
Views: 1449 | Replies: 6
Reply
Join Date: Oct 2007
Posts: 19
Reputation: sgk26p10p07 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
sgk26p10p07 sgk26p10p07 is offline Offline
Newbie Poster

Question protected mode

  #1  
Dec 2nd, 2007
Now i have been able to create the gdt's and when i change to pmode, will a short JMP flush the instruciton prefetch queue? here is a sample of my code and the gdt and gdtr content,
mov ax,07c00h
mov ds,ax
lgdt [ds:descr]
;switch to pmode by setting bit 0 of CR0
;after switching to pmode
jmp pmode; when i use JMP 0:7c00h+pmode ir reboots, the 1st 0 is code gdt
pmode:
;here when i try to write to RAM, it will reboot
mov ax,8h;the data segment
mov ds,ax;it reboots here
mov ax,0f44h
mov [0h],ax

descr:
db 0ffh,0ffh,00h,00h,07ch,gdt
gdt:
db 0ffh,0ffh,0,0,0,8a,0cfh,0;code segment
db 0ff,0ffh,0,0,0,82,0cfh,9;data segment
whta am i suppose to do to make my pmode correct, i mean be able to use the descriptors without rebooting? writing to the RAM? pleeeeeeeeeeeeeeeeaaaaaaaaaaaase help. Sam
Last edited by Ancient Dragon : Dec 2nd, 2007 at 10:04 am. Reason: add code tags
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2007
Posts: 3
Reputation: dan63043 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
dan63043 dan63043 is offline Offline
Newbie Poster

Re: protected mode

  #2  
Dec 3rd, 2007
As I recall, we sometimes needed to specify the jump to protected mode in a DB statement. Google for John Fine, he has something to get you over that problem, I think.
Reply With Quote  
Join Date: Dec 2007
Posts: 3
Reputation: dan63043 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
dan63043 dan63043 is offline Offline
Newbie Poster

Re: protected mode

  #3  
Dec 3rd, 2007
Looked at Fine's stuff, good in itself, doesn't help you, though.

Here's from http://en.wikipedia.org/wiki/Protected_mode

; set PE bit
mov eax, cr0
or eax, 1
mov cr0, eax

; far jump (cs = selector of code segment)
jmp cs:@pm

@pm:
  ; Now we are in PM.

The point here is to force the assembler to use a far jump. For some assemblers, unfortunately, this requires:
db 0eah ;far jump

For the Pentium and later processors, clearing the prefetch queue is no longer necessary.
Reply With Quote  
Join Date: Oct 2007
Posts: 19
Reputation: sgk26p10p07 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
sgk26p10p07 sgk26p10p07 is offline Offline
Newbie Poster

Re: protected mode

  #4  
Dec 4th, 2007
i know cs is for the selector but it doesnt select the right selector at all, what memory should i put at GDTR 00007c00h+gdtr or what?
Reply With Quote  
Join Date: Dec 2007
Posts: 3
Reputation: dan63043 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
dan63043 dan63043 is offline Offline
Newbie Poster

Re: protected mode

  #5  
Dec 4th, 2007
My first thought was "Well, you're probably rebooting because of a triple-fault. Have you defined your interrupt descriptor table (IDT)?"

But now I really see the 7c00, and suppose you're writing a bootloader. It's a lot easier, nowadays, to let grub do the bootloader stuff, but if you insist, there's a lot to go wrong.

What's the nature of your project? Are you just experimenting to learn a lot?
Reply With Quote  
Join Date: Oct 2007
Posts: 19
Reputation: sgk26p10p07 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
sgk26p10p07 sgk26p10p07 is offline Offline
Newbie Poster

Re: protected mode

  #6  
Dec 5th, 2007
i got it all, will post it later, now the only thig is interrrupts
Reply With Quote  
Join Date: Mar 2008
Posts: 2
Reputation: koyi is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
koyi koyi is offline Offline
Newbie Poster

Re: protected mode

  #7  
Mar 8th, 2008
Originally Posted by dan63043 View Post
; far jump (cs = selector of code segment)
jmp cs:@pm

@pm:
  ; Now we are in PM.

The point here is to force the assembler to use a far jump. For some assemblers, unfortunately, this requires:


Hi, I can't make it out how the far jump works out.
Sorry that I've posted a similar question on another thread here. I found this thread after I posted that.

So, how can "jmp cs: @pm" jumps to "@pm"? Isn't it supposed to jump to the physical address "cs * 16 + @pm"?
Last edited by koyi : Mar 8th, 2008 at 1:37 am.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Assembly Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Assembly Forum

All times are GMT -4. The time now is 9:27 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC