bswap
Byte swap
Reverses the byte order of a 32-bit or 64-bit register, so the lowest byte swaps places with the highest.
486 and later
CFPFAFZFSFDFOF –––––––
- Changes no flag
Forms
bswap ax8086 and laterbswap cx8086 and laterbswap dx8086 and laterbswap bx8086 and later
Operands
reg- A general-purpose register matching the operation’s size, for example
al,ax,eaxorrax. The byte registersah,bh,chanddhcannot be used with a REX prefix, which is required byspl,bpl,sil,dilandr8–r15.
For example, bswap rax exchanges byte 0 with byte 7, byte 1 with byte 6, and so on. A 32-bit result also clears the register's upper 32 bits. There is no defined 16-bit form; xchg al, ah swaps the bytes of ax.
global _start
section .text
_start:
mov rax, 12
mov rbx, 5
mov rcx, 3
mov rsi, 9
bswap rax
mov rax, 60 ; syscall 60: exit
xor rdi, rdi
syscall