![]() See also Referencing the contents of a memory location. That's why compilers choose addressing modes like 8(%ebp) to access stack memory, not 8(,%ebp). An index requires a SIB byte to encode, making the instruction longer. If you have the choice, use just a base instead of an index with a scale of 1. foo is a symbol address that the linker will fill in and subtract 0x10 from (because of the -0x10 assemble-time offset). foo and -0x10 are both part of the displacement, both link-time constants. EDX is the index register, with scale-factor 2. For example: movzwl foo-0x10(,%edx,2), %eaxĭoes a zero-extending 16-bit ("word") load into EAX, from the address foo-0x10 + edx*2. But AT&T syntax is rigid every component of the addressing mode can only go in its proper place. Some Intel-syntax assemblers also allow syntax like 1234, others don't. In AT&T syntax, it's disp(base, index, scale) - constants go outside the parens. And yes, *1 (shift count = 0) is the default if you write (%edi, %edx) that's equivalent to (%edi, %edx, 1) The scale-factor is encoded as a 2-bit shift count (0,1,2,3), for scale factors of 1, 2, 4, or 8. The offset which results from adding these components is called an effective address. Scale factor - A value of 2, 4, or 8 that is multiplied by the index value.Index - The value in a general-purpose register.Base - The value in a general-purpose register.Displacement - An 8-, 16-, or 32-bit value.The offset part of a memory address can be specified directly as a static value (called a displacement) or throughĪn address computation made up of one or more of the following components:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |