ahodder
ahodder

Reputation: 11439

pop Instruction not supported in 64-bit mode using NASM?

I'm working on a more indepth hello world using NASM following this tutorial (section 4). This tutorial essentially teaches you how to handle command line input.
This is the snippet of the code in question:

section .text
        global _start

_start:
        pop     ebx     ; arg count
        pop     ebx     ; arg[0] the program name
        pop     ebx     ; arg[1-n] the remainder of the args
                        ; must each be indiviually popped

The code errors out during compilation with error: instruction not supported in 64-bit mode referring to the 3 pop instructions above. Upon viewing the docs it seems that this code only works for 32-bit systems.

Is there a 64-bit pop instruction? Does anyone have a 64 bit tutorial using pop that I can look at?

Upvotes: 22

Views: 25393

Answers (2)

Niyas Ali
Niyas Ali

Reputation: 273

basically you can convert it into 64bit by replacing eax to rax (same goes for all other registers)

Upvotes: 1

Brian Knoblauch
Brian Knoblauch

Reputation: 21369

Yes, the 64-bit pop instruction is... POP. :-) You need to use it against 64-bit registers though (like rbx).

Upvotes: 26

Related Questions