Switch to and from 16-bit Real Mode and 32-bit Pro

2019-07-26 23:04发布

问题:

I'm interested in writing my own microkernel with graphics support. However, as far as I know there is no way to change the graphics mode without interrupt 0x10, which requires Real Mode. How can I switch between Real and Protected Mode during the application's runtime? I have seen an article on osdev.org, but since I am new to assembly I cannot work out how to implement this.

Technical details:

  • Ubuntu 16.04.4 LTS
  • GCC 7.3.0 cross-compiler (i686-elf)
  • NASM 2.11.08 assembler, but inline GAS-style syntax is fine

回答1:

The very page you reference has a section that describes what needs to be done to transfer CPU from protected back to real mode. It even has an assembler snippet for that.

To get from real mode to protected mode, use Intel's recommendations given in the Intel SDM volume 3A, chapter 9. Section 9.10.2 given an example of assembly code that is meant to transfer CPU to protected mode.

That said, you are in fact not bound to use INT 10h in real mode. See comments for your question.