90 likes | 341 Views
IA32 addressing modes. Immediate Direct memory Register Register indirect Indexed Based-indexed. addressing. Opcode indicates what operation is to be performed. Operands specify the location of data. Example of addressing modes that we have already used: A = 12 B dword 52
E N D
IA32 addressing modes • Immediate • Direct memory • Register • Register indirect • Indexed • Based-indexed
addressing • Opcode indicates what operation is to be performed. • Operands specify the location of data. • Example of addressing modes that we have already used: A = 12 B dword 52 mov eax, 1 ; immediate mov ebx, eax ; register mov ecx, A ; immediate mov edx, B ; direct memory
Register indirect • Say B is located at memory location (address) 400. We load the address of B into a register. movebx, 400 ;load the address of B moveax, ebx ;eax is now 400 moveax, [ebx] ;eax now equals 52 • This is the register indirect addressing mode. The register does not contain the value but contains a reference to (pointer to/location of) the value in memory.
Indexed Used to: • reference memory at a constant offset from a register • when register points to object and data member is a know offset from start of object • reference memory using a register as an additional offset • when register is used as an offset to an array element
Indexed A dword 592h, 50h, 60h, 70h, 80h, 90h mov eax, 4 mov ebx, A[eax] ;what’s in ebx? mov ecx, [A+eax] ;what’s in ecx?
Indexed A dword 592h, 50h, 60h, 70h, 80h, 90h moveax, 4 movebx, A[eax] ;what’s in ebx? movecx, [A+eax] ;what’s in ecx?