11 ms·
The article says `lea` helps calculate the array relative address on AMD64. Why does the article say the problem would be tricky on 32-bit? `lea` is an old ins
by orra 3y ago
The article says `lea` helps calculate the array relative address on AMD64.
Why does the article say the problem would be tricky on 32-bit? `lea` is an old instruction. Thanks.
- astrange 3y agox86-32 doesn't have PC-relative addressing (`%eip`). Btw, his code is wrong, it assumes pointers fit into 32 bits.
- comex 3y agoIt’s not `lea` itself that’s new in AMD64 but rather RIP-relative addressing; this can be used as a memory operand for any instruction but it’s especially useful with `lea`. If you’re wondering where the reference to RIP is, the assembly in the post uses %eip instead of the usual %rip. [Edit: And doing so is wrong, contrary to what I wrote before editing; see sibling comment.]