Quelltext /~heha/hs/switch_mode.zip/Linux/switch_cs.S

	.intel_syntax noprefix
	.code64
	.text
	.globl switch_cs
switch_cs:
	push	rbx
	push	rbp
	mov	rbp, rsp
	sub	rsp, 0x18

	mov	rbx, rsp
	movq	[rbx], offset .L1
	mov	[rbx+4], edi

	// Before the lcall, switch to a stack below 4GB.
	// This assumes that the data segment is below 4GB.
	mov	rsp, offset stack+0xf0
	lcall	[rbx]

	// restore rsp to the original stack
	leave
	pop	rbx
	ret

	.code32
.L1:
	call	esi
	lret


	.code64
	.globl check_mode
// returns false for 32-bit mode; true for 64-bit mode
check_mode:
	xor	eax, eax
	// In 32-bit mode, this instruction is executed as
	// inc eax; test eax, eax
	test	rax, rax
	setz	al
	ret

	.data
	.align	16
stack:  .space	0x100
Vorgefundene Kodierung: UTF-80