[bits 64]
LoadGDT:
	; rdi is the first argument passed to the LoadGDT function by C
	lgdt [rdi]

	; update the data segment registers
	mov ax, 0x10
	mov ds, ax
	mov es, ax
	mov fs, ax
	mov gs, ax
	mov ss, ax

	; update the code segment
	pop rdi ; store return address in rdi
	mov rax, 0x08 ; code segment offset
	push rax ; we push 0x08 because it will be used by the far return instruction
	push rdi ; push return address because it will be used by far return

	; far return
	retfq
	
GLOBAL LoadGDT