Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

intel

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?

like image 894
ahodder Avatar asked Jun 08 '12 17:06

ahodder


People also ask

What is the function of the push pop instructions used on registers in 8086 assembly?

The PUSH/POP instructions POP retrieves the value from the top of the stack and stores it into the destination, then increments the SP register (by 2). PUSH and POP can be used to save and restore the values of registers when the register needs to be used for some other function temporarily.

What is pop in assembly language?

The pop instruction removes the 4-byte data element from the top of the hardware-supported stack into the specified operand (i.e. register or memory location). It first moves the 4 bytes located at memory location [SP] into the specified register or memory location, and then increments SP by 4. Syntax. pop <reg32>

What is push and pop Instruction give example?

You can use push and pop to save registers at the start and end of your function. For example, "rbp" is a preserved register, so you need to save its value before you can use it: push rbp ; save old copy of this register. mov rbp,23. mov rax,rbp. pop rbp ; restore main's copy from the stack.

Where does push and pop used?

Stack is amount of program (RAM) memory normally allocated at the top of CPU memory heap and grow (at PUSH instruction the stack pointer is decreased) in opposite direction. A standard term for inserting into stack is PUSH and for remove from stack is POP.


1 Answers

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

like image 129
Brian Knoblauch Avatar answered Oct 01 '22 11:10

Brian Knoblauch