when
$ nasm -f elf64 -o thisfile.o thisfile.asm
it says the line of jmp
and popfd
"instruction not supported in 64-bit mode"
this is the whole code:
SELECTOR_KERNEL_CS equ 8
extern cstart
extern gdt_ptr
[SECTION .bss]
StackSpace resb 2 * 1024
StackTop:
[section .text]
global _start
_start:
mov esp, StackTop
sgdt [gdt_ptr]
call cstart
lgdt [gdt_ptr]
;lidt [idt_ptr]
jmp SELECTOR_KERNEL_CS:csinit
csinit:
push 0
popfd ; Pop top of stack into EFLAGS
hlt
Since you're in 64-bit mode, you'll need to use
popfq
instead ofpopfd
(alternatively, you can just usepopf
).As for the
jmp
, I believe you'll need to do a trick withretf
:This works because
retf
will first pop the new instruction pointer, then pop the newcs
selector.