What does the bracket in `movl (%eax), %eax` mean?
%eax is register EAX; (%eax) is the memory location whose address is contained in the register EAX; 8(%eax) is the memory location whose address is the value of EAX plus 8.
%eax is register EAX; (%eax) is the memory location whose address is contained in the register EAX; 8(%eax) is the memory location whose address is the value of EAX plus 8.
Assembling (note GAS uses % instead of $ to denote registers) the following: vpblendvb %xmm4, %xmm3, %xmm2, %xmm1 with the GNU assembler (version 2.21.0.20110327 on x86_64 2.6.38 linux) and then disassembling yields: $ objdump -d a.out 0: c4 e3 69 4c cb 40 vpblendvb %xmm4,%xmm3,%xmm2,%xmm1 in intel syntax (as the manual shows): $ objdump -d … Read more
1, 2, 3 and 5: the notation is somewhat redundant, but I find it to be a good thing when developing in assembly. Redundancy helps reading. The point about “let the assembler figure it out” easily turns into “let the programmer who reads the code figure it out”, and I do not like it when … Read more
The difference is that with $ it’s the numeric value while without $ it’s the contents of memory at that address If argument of instruction is without any special marker (such as % for register or $ for numeric constant), then it is memory access. So following: movl 10, %eax movl foo, %eax Corresponds to … Read more
Normally, Gnu tools use AT&T syntax. You can tell that it is AT&T syntax by the presence of little symbols, like the $ preceding literals, and the % preceding registers. For example, this instruction: sub $16, %rax is obviously using AT&T syntax. It subtracts 16 from the value in the rax register, and stores the … Read more
A RIP-relative addressing mode is the only good option for addressing static data on MacOS; the image base address is above 2^32 so 32-bit absolute addresses aren’t usable even in position-dependent code (unlike x86-64 Linux). RIP-relative addressing of static data is position-independent, so it works even in position-independent executables (ASLR) and libraries. movl x(%rip), %eax … Read more
AT&T syntax splits the movzx Intel instruction mnemonic into different mnemonics for different source sizes (movzb vs. movzw). In Intel syntax, it’s: movzx eax, byte ptr [eax+ecx+1] i.e. load a byte from memory at eax+ecx+1 and zero-extend to full register. BTW, most GNU tools now have a switch or a config option to prefer Intel … Read more