Reputation: 2073
I thiiink I understand that
movzbl (%rdi, %rcx, 1) , %ecx
means "move zero-extended byte to long" and is saying to extend ecx into 32 bits, but I'm not entirely sure what the syntax (%rdi, %rcx, 1) refers to.
I've seen somewhere that that syntax refers to
(Base, Index, Scale)
but I can't find any resources that say what that means exactly. I'm guessing it means to move whatever info is at (%rdi, %rcx, 1) to %ecx so that
(long) %ecx = (%rdi, %rcx, 1)
but how do I figure out what location that is? is there some sort of arithmetic involved to find an address or something?
also isn't ecx implicitly 32 bits already? Why would it need to be extended into 32 bits?
edit for clarification:
I understand that the syntax (%rdi, %rcx, 1) means that I have to add those three things together, but I don't understand how that results in an answer.
What am I adding, the contents of the registers? The address of the register? If it's the address, how do I figure out what the address is and add it together?
All I'm finding online is telling me what the syntax means but not how to use it with examples.
Upvotes: 4
Views: 11499
Reputation: 58762
To quote the intel basic architecture manual:
3.7.5 Specifying an Offset The offset part of a memory address can be specified directly as a static value (called a displacement) or through an address computation made up of one or more of the following components:
- Displacement -- An 8-, 16-, or 32-bit value.
- Base -- The value in a general-purpose register.
- Index -- The value in a general-purpose register.
- Scale factor -- A value of 2, 4, or 8 that is multiplied by the index value.
The offset which results from adding these components is called an effective address.
Notice it says "the value in a general-purpose register". As registers are not part of the memory address space on x86, they don't even have an address, so the only thing you can possibly use is the value in them.
As for the movzbl
: it instructs the cpu to fetch a byte from memory, and zero extend it to 32 bits.
Upvotes: 1