movl $1,%eax
movl $data1,%ecx
.datadata1 10,11,22,33,44,55,66,77,88,99..._start:movl $0,%edi ; direct addressing here. Index registermovl data(,%edi,4),%eax; movl addr_or_offset(%base_or_offset,%index,multiplier); index : index location; multiplier : space taken by each block of memory; eg: long takes 4 blocks; IF %edi was some other value, that location would be; extracted and the content be saved into eax
Base Pointer Addressing Mode
pushl $7pushl $8pushl $77pushl %ebp ; save value of base ptr to stack, now can overwritemovl %esp,%ebp ; over-write base ptr with stack ptrmovl 4(%ebp),%eax ; save 4+esp (77) to eax registermovl 8(%ebp),%eax ;movl 12(%ebp),%eax ; base pointer addressing
Consider having an operation: ADD X,Y [opcode | source operand | destionation operand] [opcode | (mode,register) | (mode,register) ] (mode : ~16 codes) (register : ~8 registers)
We need a way to address the data points X and Y
Indirect (Deffered) Addressing Mode
The register holds the address of a location that then holds the address of another location which contains payload
Consider Register in CPU to have address "1000"
In the Memory, let us have locations numbers 1000 to 1200
Let value in address "1000" be the address "1010"
Here, register points to 1000 in memory which points to 1010 in memory, which in turn contains the final payload.
(Needs 2 machine cycles)