I created a simple assembly program. A few Qs:
- each instruction below starts with 0x48. However, I dont see that as a part of the instruction from this references:
http://ref.x86asm.net/coder64.html#x89
E.g., x05 is the add instruction that adds immediate to a register, but not 0x0548. Similar for other instructions below.
How are rax, rbx encoded in the binary? E.g. Why using rbx is a byte more than rax?
401000: 48 05 34 12 00 00 add rax,0x1234
40100c: 48 81 c3 34 12 00 00 add rbx,0x1234
Same questions as bove, but a diff example. Why changing the source register to rbx, causes a change from c0 to d8?
401006: 48 01 c0 add rax,rax
401009: 48 01 d8 add rax,rbx
$ objdump -d assembly_test
assembly_test: file format elf64-x86-64
Disassembly of section .text:
0000000000401000 <_start>:
401000: 48 05 34 12 00 00 add rax,0x1234
401006: 48 01 c0 add rax,rax
401009: 48 01 d8 add rax,rbx
40100c: 48 81 c3 34 12 00 00 add rbx,0x1234
401013: 48 c7 c0 34 12 00 00 mov rax,0x1234
40101a: 48 89 c0 mov rax,rax
40101d: 48 89 d8 mov rax,rbx
question from:
https://stackoverflow.com/questions/65874396/how-to-interpret-x86-64-instruction-bytes-based-on-the-assembly-instructions 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…