as: i386-Memory

1 
1 9.15.7 Memory References
1 ------------------------
1 
1 An Intel syntax indirect memory reference of the form
1 
1      SECTION:[BASE + INDEX*SCALE + DISP]
1 
1 is translated into the AT&T syntax
1 
1      SECTION:DISP(BASE, INDEX, SCALE)
1 
1 where BASE and INDEX are the optional 32-bit base and index registers,
1 DISP is the optional displacement, and SCALE, taking the values 1, 2, 4,
1 and 8, multiplies INDEX to calculate the address of the operand.  If no
1 SCALE is specified, SCALE is taken to be 1.  SECTION specifies the
1 optional section register for the memory operand, and may override the
1 default section register (see a 80386 manual for section register
1 defaults).  Note that section overrides in AT&T syntax _must_ be
1 preceded by a '%'.  If you specify a section override which coincides
1 with the default section register, 'as' does _not_ output any section
1 register override prefixes to assemble the given instruction.  Thus,
1 section overrides can be specified to emphasize which section register
1 is used for a given memory operand.
1 
1    Here are some examples of Intel and AT&T style memory references:
1 
1 AT&T: '-4(%ebp)', Intel: '[ebp - 4]'
1      BASE is '%ebp'; DISP is '-4'.  SECTION is missing, and the default
1      section is used ('%ss' for addressing with '%ebp' as the base
1      register).  INDEX, SCALE are both missing.
1 
1 AT&T: 'foo(,%eax,4)', Intel: '[foo + eax*4]'
1      INDEX is '%eax' (scaled by a SCALE 4); DISP is 'foo'.  All other
1      fields are missing.  The section register here defaults to '%ds'.
1 
1 AT&T: 'foo(,1)'; Intel '[foo]'
1      This uses the value pointed to by 'foo' as a memory operand.  Note
1      that BASE and INDEX are both missing, but there is only _one_ ','.
1      This is a syntactic exception.
1 
1 AT&T: '%gs:foo'; Intel 'gs:foo'
1      This selects the contents of the variable 'foo' with section
1      register SECTION being '%gs'.
1 
1    Absolute (as opposed to PC relative) call and jump operands must be
1 prefixed with '*'.  If no '*' is specified, 'as' always chooses PC
1 relative addressing for jump/call labels.
1 
1    Any instruction that has a memory operand, but no register operand,
1 _must_ specify its size (byte, word, long, or quadruple) with an
1 instruction mnemonic suffix ('b', 'w', 'l' or 'q', respectively).
1 
1    The x86-64 architecture adds an RIP (instruction pointer relative)
1 addressing.  This addressing mode is specified by using 'rip' as a base
1 register.  Only constant offsets are valid.  For example:
1 
1 AT&T: '1234(%rip)', Intel: '[rip + 1234]'
1      Points to the address 1234 bytes past the end of the current
1      instruction.
1 
1 AT&T: 'symbol(%rip)', Intel: '[rip + symbol]'
1      Points to the 'symbol' in RIP relative way, this is shorter than
1      the default absolute addressing.
1 
1    Other addressing modes remain unchanged in x86-64 architecture,
1 except registers used are 64-bit instead of 32-bit.
1