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

ahodder picture ahodder · Jun 8, 2012 · Viewed 16.1k times · Source

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?

Answer

Brian Knoblauch picture Brian Knoblauch · Jun 8, 2012

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