Questions tagged [protected-mode]

x86 protected mode allows system software to support virtual memory, paging and preemptive multi-tasking.

x86 protected mode allows system software to support virtual memory, paging and preemptive multi-tasking.

  • Protected mode was first added to the x86 architecture in 1982, with the release of Intel's 80286 processor, and later extended with the release of the 80386 processor in 1985.
  • To maintain backward compatibility, x86 processors begins executing instructions in real mode.

To enter protected mode:

  • The Global Descriptor Table (GDT) must first be created with a minimum of three entries: a null descriptor, a code segment descriptor and data segment descriptor.
  • In an IBM-compatible machine, the A20 line (21st address line) also must be enabled to allow the use of all the address lines so that the CPU can access beyond 1 megabyte of memory.
  • Then the PE bit must be set in the CR0 register and a far jump must be made to clear the prefetch input queue:
; 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.
214 questions
1
vote
1 answer

Problem understanding far jump after entering protected mode

In my bootloader code there is a section in which we switch the cpu to protected mode by loading the GDT and enabling the control register bit. This is the portion of bootloader code: init_pm: ... cli lgdt [GDT_descriptor] mov eax,…
alireza
  • 33
  • 6
1
vote
1 answer

Can't get into protected mode

I'm attempting to make a simple OS and can't seem to get into protected mode. My code assembles fine and runs but it's in like a loop or something: the screen just flashes the booting message. I'm pretty sure the problem is when I set cr0 in…
1
vote
1 answer

Changing to protected mode causes triple fault

I have been having an issue whereby after long jumping to protected mode, seemingly when setting up the ss register, a triple fault is caused. My code: switch-to-32bit.asm [org 0x7c00] [bits 16] switch_to_32bit: cli lgdt [gdt_descriptor] …
Alice F
  • 435
  • 5
  • 13
1
vote
1 answer

In x86 32 bit protected mode, can we still use SP rather than ESP register when use PUSH/POP instructions?

I don't know when use SP register and when use ESP register, besides, I want to know when use ESP register, does it always decrease 4 and can't decrease 2?
1
vote
1 answer

How to delay execution for a specified amount of milliseconds when in protected mode?

I have a C program that runs on bare x86 (without an OS) in protected mode. I need to delay the program's execution for a certain amount of time. Currently, I'm doing this: for(p=0; p<1000000; ++p) asm("pause"); But this looks very very wrong (I do…
user500944
1
vote
1 answer

problem running a bootloader using nasm and qemu

I have an assembly language code where I switch to protected mode and print "Hello World " on the screen afterwards. I have saved this code in a file named boot2.asm. I need help in running and testing the code as I am unable to do so by the command…
1
vote
0 answers

Far jump to 32 bit segment after enabling protected mode fails

This is a followup to my previous question about relocating my x86 bootloader. It seems I still don't understand x86 addressing schemes correctly, my code is now the following (after preprocessing): .code16 .global _start jmp…
Peter
  • 2,919
  • 1
  • 16
  • 35
1
vote
1 answer

32-bit assembly bootloader works in VM/qemu but not on a real PC

I coded this small bootloader that prints a single character to the screen in 32-bit protected mode: bits 16 org 0x7c00 jmp boot times 3-($-$$) db 0x90 ; Support 2 or 3 byte encoded JMPs before BPB. ; Dos 4.0 EBPB 1.44MB floppy OEMname: …
1
vote
0 answers

Reboot After LGDT Instruction And Far Jump To Protected Mode

So I have ran into a problem which I've been stuck on now for what seems like eternity, about 3 days without sleep trying to solve the issue on my own now, and it's kinda depressing to me as I feel as if it should honestly be a relatively simple…
GodDamn
  • 161
  • 1
  • 8
1
vote
1 answer

Disable Internet Explorer prompt 'the program will open outside of protected mode' when running application through BHO

I have written a BHO that will start a console application as soon as the BHO got instantiated. The console application is a simple helper application developed in C# and is placed in local disk C. When I deployed the BHO on my development machine…
1
vote
1 answer

What will happen if the GDT is changed as the program is executing?

What will happen if the GDT is changed as the program is executing? Is there any physical register or anything else that monitors whether the GDT is changed when executing program?
Jack Smith
  • 13
  • 2
1
vote
0 answers

Switch from Protected Mode to Real Mode

After some months of investigation, I have accomplished my goal to switch to 32-bit mode, now I was wondering if I could go back, following the: OSDevWiki Real Mode Page I need a 16-bit Protected Mode data selector but I don't know how to make one.…
JeffLee
  • 111
  • 1
  • 10
1
vote
1 answer

Does internet explorer running in protected mode allows full read access to the user's "My Documents" folder?

I'm currently developing an IE add-on that needs to read some existing files under the "My Documents" from the current user's profile. If IE is running in protected mode: what care should be taken to always be able to read those files? does the…
nick2083
  • 1,953
  • 13
  • 16
1
vote
2 answers

Is there a way to automate Internet Explorer which is not affected by different protected mode settings?

I'm trying to automate the Internet explorer using C# in Visual Studio. Unfortunately the protected mode settings are not set to the same value for each zone and I don't have the necessary rights to change that. I tried Selenium Webdriver and…
1
vote
0 answers

Screen Flickering when enabling Protected Mode

I am writing a small demo kernel for a school project and, in my kernel I enable the A20 line, load the GDT and then enable protected mode. when I comment out the protected mode part, everything works fine, the A20 line gets enabled and the GDT is…
Klaus Maria
  • 107
  • 1
  • 9