943,832 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 2841
  • Assembly RSS
Dec 2nd, 2007
0

protected mode

Expand Post »
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,
Assembly Syntax (Toggle Plain Text)
  1. mov ax,07c00h
  2. mov ds,ax
  3. lgdt [ds:descr]
  4. ;switch to pmode by setting bit 0 of CR0
  5. ;after switching to pmode
  6. jmp pmode; when i use JMP 0:7c00h+pmode ir reboots, the 1st 0 is code gdt
  7. pmode:
  8. ;here when i try to write to RAM, it will reboot
  9. mov ax,8h;the data segment
  10. mov ds,ax;it reboots here
  11. mov ax,0f44h
  12. mov [0h],ax
  13.  
  14. descr:
  15. db 0ffh,0ffh,00h,00h,07ch,gdt
  16. gdt:
  17. db 0ffh,0ffh,0,0,0,8a,0cfh,0;code segment
  18. 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
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
sgk26p10p07 is offline Offline
19 posts
since Oct 2007
Dec 3rd, 2007
0

Re: protected mode

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.
Reputation Points: 12
Solved Threads: 5
Light Poster
dan63043 is offline Offline
36 posts
since Dec 2007
Dec 3rd, 2007
0

Re: protected mode

Looked at Fine's stuff, good in itself, doesn't help you, though.

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

Assembly Syntax (Toggle Plain Text)
  1. ; set PE bit
  2. mov eax, cr0
  3. or eax, 1
  4. mov cr0, eax
  5.  
  6. ; far jump (cs = selector of code segment)
  7. jmp cs:@pm
  8.  
  9. @pm:
  10. ; Now we are in PM.

The point here is to force the assembler to use a far jump. For some assemblers, unfortunately, this requires:
Assembly Syntax (Toggle Plain Text)
  1. db 0eah ;far jump

For the Pentium and later processors, clearing the prefetch queue is no longer necessary.
Reputation Points: 12
Solved Threads: 5
Light Poster
dan63043 is offline Offline
36 posts
since Dec 2007
Dec 4th, 2007
0

Re: protected mode

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?
Reputation Points: 10
Solved Threads: 1
Newbie Poster
sgk26p10p07 is offline Offline
19 posts
since Oct 2007
Dec 4th, 2007
0

Re: protected mode

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?
Reputation Points: 12
Solved Threads: 5
Light Poster
dan63043 is offline Offline
36 posts
since Dec 2007
Dec 5th, 2007
0

Re: protected mode

i got it all, will post it later, now the only thig is interrrupts
Reputation Points: 10
Solved Threads: 1
Newbie Poster
sgk26p10p07 is offline Offline
19 posts
since Oct 2007
Mar 8th, 2008
0

Re: protected mode

Click to Expand / Collapse  Quote originally posted by dan63043 ...
Assembly Syntax (Toggle Plain Text)
  1. ; far jump (cs = selector of code segment)
  2. jmp cs:@pm
  3.  
  4. @pm:
  5. ; 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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
koyi is offline Offline
2 posts
since Mar 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: Far jump to a label?
Next Thread in Assembly Forum Timeline: Converting this code to support Windows 98





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC