Some questions about x86-64 modes

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
ComputerMail
Posts: 11
Joined: Fri Jan 20, 2017 4:35 pm

Some questions about x86-64 modes

Post by ComputerMail »

Hi,

i am following that tutorial http://wiki.osdev.org/Setting_Up_Long_Mode and am blocked at some points, first "The Switch from Real Mode" so we are in real mode here so why do we use ecx and others 32 bits elements ? Other question, at "Entering the 64-bit Submode" what is the difference between IA32e mode and 64-bit long mode ? I understand the first allows us to execute 32bits code but does it allows us to execute 64bits code also ? And the second, i understand it allows us to execute 64 bits code, what are avantages to use one or other ? Last question, at same point as the previous, there is writed "Our GDT (see chapter 4.8.1 and 4.8.2 of the AMD64 Architecture Programmer's Manual Volume 2) should look like this:", here is specified amd processor does x86-64 intel has the same working ?
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: Some questions about x86-64 modes

Post by Octocontrabass »

ComputerMail wrote:first "The Switch from Real Mode" so we are in real mode here so why do we use ecx and others 32 bits elements ?
Because 32-bit operations are convenient, even in real mode.
ComputerMail wrote:Other question, at "Entering the 64-bit Submode" what is the difference between IA32e mode and 64-bit long mode ?
The wiki page was wrong, it's supposed to say "compatibility mode" instead of "IA-32e". (IA-32e is Intel's name for AMD64.) I've corrected the wiki page.
ComputerMail wrote:I understand the first allows us to execute 32bits code but does it allows us to execute 64bits code also ?
You can't execute 64-bit code in compatibility mode.
ComputerMail wrote:And the second, i understand it allows us to execute 64 bits code, what are avantages to use one or other ?
That question has been answered many times. Have you already tried asking Google?
ComputerMail wrote:here is specified amd processor does x86-64 intel has the same working ?
Yes. (There are a few small differences between AMD64 and IA-32e, but the GDT is not one of them.)
Korona
Member
Member
Posts: 1000
Joined: Thu May 17, 2007 1:27 pm
Contact:

Re: Some questions about x86-64 modes

Post by Korona »

This should be posted in OS Development and not in this subforum.

The difference between real mode and protected mode is not their operand size but the way that segment registers are handled. Real mode only allows accessing 1 MiB of memory but it does not prevent execution of 32-bit instructions. In 16-bit modes (= real mode and 16-bit protected mode) 32-bit instructions need an operand size override prefix. Likewise in 32-bit modes 16-bit instructions need such a prefix.

IA32e is Intel's term for 64-bit long mode. Intel's and AMD's implementations of x86_64 are almost binary compatible (except for things like VT-x/SVM, Machine Check, Performance Monitoring, ...).
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].
Post Reply