3 ms·
You can jump between 32-bit and 64-bit modes in a 64-bit Windows and Linux by switching between the 0x23 and 0x33 code segments. Like so: BITS 32 start
by pbsd 13y ago
You can jump between 32-bit and 64-bit modes in a 64-bit Windows and Linux by switching between the 0x23 and 0x33 code segments. Like so:
BITS 32
start:
call far 0x33:code64
code32:
nop ; resume
code64:
BITS 64
xor rax, rax
BITS 32
retf ; return to 0x23:code32
- 0x0 13y agoThat's interesting that the CS values are the same in windows and linux, more than a coincidence... Is this part of some x86_64 ABI spec?
- pbsd 13y agoAfter checking the docs, it seems the fast syscall instructions force the GDT to be laid out in a specific order. Since the segment values (selectors) are really offsets into the GDT, it makes sense that they end up being the same.
- userbinator 13y agoVery interesting. Is there one that lets you go into 16-bit mode too? ;)
- 0x0 13y agoProbably not; according to wikipedia you cannot go to virtual8086 mode from "long mode" (aka 64bit mode), which also explains why 64bit windows no longer ship an NTVDM or run 16bit dos and windows applications.