| ▲ | hota_mazi an hour ago | |||||||
I think OP was just making a comment on the asymmetry of the syntax. Brackets [] are usually used to dereference. Why is this written
instead of just | ||||||||
| ▲ | jcranmer 26 minutes ago | parent | next [-] | |||||||
When you encode an x86 instruction, your operands amount to either a register name, a memory operand, or an immediate (of several slightly different flavors). I'm no great connoisseur of ISAs, but I believe this basic trichotomy is fairly universal for ISAs. The operands of an LEA instruction are the destination register and a memory operand [1]. LEA happens to be the unique instruction where the memory operand is not dereferenced in some fashion in the course of execution; it doesn't make a lot of sense to create an entirely new syntax that works only for a single instruction. [1] On a hardware level, the ModR/M encoding of most x86 instructions allows you to specify a register operand and either a memory or a register operand. The LEA instruction only allows a register and a memory operand to be specified; if you try to use a register and register operand, it is instead decoded as an illegal instruction. | ||||||||
| ▲ | Y_Y 32 minutes ago | parent | prev | next [-] | |||||||
The way I rationalize it is that you're getting the address of something. A raw address isn't what you want the address of, so you're doing something like &(*(rdi+rsi)). | ||||||||
| ▲ | secondcoming an hour ago | parent | prev [-] | |||||||
Yes, that’s what I meant | ||||||||
| ||||||||