retnw
Near return, 16-bit
Requests the 16-bit near-return encoding, with an optional unsigned cleanup byte count.
8086 and later
CFPFAFZFSFDFOF –––––––
- Changes no flag
Forms
retnwretnw
Operands
imm16- An unsigned 16-bit byte count,
0to65535, added to the stack pointer after the return address is popped.
NASM also accepts it in 64-bit source, with an operand-size prefix, but there it removes only 2 bytes from the stack and jumps to that value zero-extended, an address below 64 KiB: it cannot return to a 64-bit caller, and ordinary 64-bit functions return with ret. The optional sole immediate operand is an unsigned 16-bit additional cleanup count, not a signed stack adjustment.
global _start
section .text
_start:
mov rax, 12
mov rbx, 5
mov rcx, 3
mov rsi, 9
retnw 5
mov rax, 60 ; syscall 60: exit
xor rdi, rdi
syscall