Example of PUSH and POP examen de la stack sous gdb : x/10x $sp Here’s a simple example of pushing and popping a value in x86-64 assembly: [BITS 64] section .text global _start ; Entry point for the program _start: mov rax, 42 ; Moves the value 42 into the rax register push rax ; Pushes the value of rax onto the stack pop rbx ; Pops the top value from the stack into rbx ; Exit the program mov eax, 60 ; syscall number for exit xor edi, edi ; Exit code 0 syscall ; Invoke syscall to exit the program In this example, we first moved the value 42 into the rax register. Then we pushed the value of rax onto the stack. We then popped the top value from the stack into the rbx register. Finally, we use the syscall instruction to exit the program. Autre programme : [BITS 64] section .bss ; nada section .data prompt: db 'What is your name? ' prompt_length: equ $-prompt name: times 30 db 0 name_length: equ $-name greeting: db 'Greetings, ' greeting_length: equ $-greeting section .text global _start _start: ; Prompt the user for their name mov rax, 1 ; '1' is the ID for the sys_write call mov rdi, 1 ; '1' is the file descriptor for stdout and our first argument mov rsi, prompt ; prompt string is the second argument mov rdx, prompt_length ; prompt string length is the third argument syscall ; make the call with all arguments passed ; Get the user's name mov rax, 0 ; 0 = sys_read mov rdi, 0 ; 0 = stdin mov rsi, name mov rdx, name_length syscall push rax ; store return value (size of name) on the stack... we'll need this for later ; Print our greeting string mov rax, 1 ; 1 = sys_write mov rdi, 1 ; 1 = stdout mov rsi, greeting mov rdx, greeting_length syscall ; Print the user's name mov rax, 1 mov rdi, 1 mov rsi, name pop rdx stored on the stack syscall ; 1 = sys_write ; 1 = stdout ; length previously returned by sys_read and ; Exit the program normally mov rax, 60 ; 60 = sys_exit xor rdi, rdi ; return code 0 syscall