Hacker News new | past | comments | ask | show | jobs | submit login

X86_64 is also bizarre, with mode switch as partt of jump, register aliasing, etc.



There is nothing bizarre about implementing mode switching as part of a jump instruction. Every CPU I know of with more than one mode implements switching with some kind of jump instruction.


I agree it isn't bizarre. But...

> Every CPU I know of with more than one mode implements switching with some kind of jump instruction.

So you don't know x86? You enter protected mode by manipulating the cr0 register.


But after entering 386-style protected mode or amd64's long mode you can switch between different modes by far jumps to specially crafted descriptors / selectors (and at least in 32 bit protected mode you can trigger various documented semi-magical behavior by that). So it's consistent.


So what jwatte said is wrong? I don't know such details about x86. I was thinking mainly of ARM and MIPS.


No, he was referring to the 32-bit to 64-bit mode switch. I was talking about entering 32-bit protected mode from real mode for the first time, typically right after boot-up. As another posted mentioned, once you're in protected mode, you can go back to "fake" real mode (e.g. an MS DOS program running on Windows) with a segment descriptor based jump, which is consistent with the manner of x64's mode switching.


My least favorite part when reading and writing x64 code has to be the calling conventions.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: