There is an additional possible value or value for "pointer-based array access":
You may have a pointer to an array, not an array at a fixed address. In fact, in C / C ++, an "array pointer" is usually just a pointer to the first element of an array. Basically, you have an array that is a parameter of a function, or a pointer to an array that is a member of a structure or class:
void Foo(char a[]);
void Foo(char *a);
struct Bar { int offset4bytes; char* a; };
, , .
, ,
char tmp = a[i];
, r1 . ( , , , , . , .)
, r2.
, , tmp r3.
, . Intel x86, ,
MOV r3, (r2,r1)4
. ( , ).
, , :
MOV r3, (r2*2,r1)4
,
r3 := load( Memory[r2<<1+r1+4]
MIPS, , base + _index * + . MIPS + . MIPS
ADDU r10, r1,r1 ; dest on left. r10 = 2*r1
ADDU r11, r2,r10
LB r3,(r11)4
. RISC , x86 CISC . , canm.
, MIPS. x86 32- , . MIPS 16- . MIPS , 32 . , , .
- MIPS , LUXC1, reg + reg . , .
- , lop,
for(int i=0;i<N;i++) {
this->a[i] = 0;
}
, .
,
for(char *p=this->a;p<&(this->a[N]);p++) {
*p=0;
}
,
for(char *p=this->a;p<this->a+N;p++) {
*p;
}
for(i=-N,*p=this->a;i<0;i++,p++) {
*p=0;
}
, , , . (, , , .
, , . .