I was originally trying to generate the bytes for an immediate move into a 64 bit register.The specific operation I wanted was
mov rdi, 0x1337
Using https://www.felixcloutier.com/x86/mov, the only non-sign extended instructions I saw was
REX.W + B8+ rd io
This confused me so I created a small assembly program to see what the assembler would generate
global _start
section .text
_start:
mov rdi, 0x1337
syscall
mov rax, 60
xor rdi, rdi
syscall
I had to turn off optimizations so that there would be a move into a 64-bit register. So I compiled with nasm -felf64 -O0 main.asm && ld main.o
and generated a a.out
. I look at the objdump -M intel -d ./a.out
and this line
48 bf 37 13 00 00 00 movabs rdi,0x1337
That line looks nothing like
REX.W + B8+ rd io
to me? Additionally, after some research, I saw that the command is suppose to be 10 bytes. How do you get that from REX.W + B8+ rd io
?