i have simple .asm
file:
bits 64 section .text global main main: mov rax, 0x2a ; 42
the mov
statement compiles machine code using following command line:
nasm.exe -o load_rax.bin -f bin load_rax.asm
...and resulting binary output is:
0xb8 0x2a 0x00 0x00 0x00
when compile same mov
instruction through this online x86 / x64 assembler , disassembler, different:
0x48 0xc7 0xc0 0x2a 0x00 0x00 0x00
am doing wrong compiling via nasm? understand there op-code compression going on , if case i'd prefer able handle need know if instructions have been compressed, how tell , algorithm used.
i working in 64-bit.
any ideas on why these binaries different extremely helpful.
b8 2a 00 00 00
instance of mov r32, imm32
,
48 c7 c0 2a 00 00 00
instance of mov r/m64, imm32
there is, suppose, argument made longer encoding "what asked for", because explicitly writes 64bit version of register told to. on other hand, useless encode way since writes 32bit registers zero-extended anyway, nasms encoding isn't wrong, it's taking code less literally.
Comments
Post a Comment