For example, I have this code within BITS 64 section:
Code: Select all
mov rdi, gdtr
lgdt [rdi]
mov ax, SEG_DATA64_0
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov rsp, kstack_end
push qword 2
popf
mov rcx, qword .reloadcs
; jmp rcx
push qword SEG_CODE64_0
push rcx
db 0x48
retf