by klodolph · 3y ago · 0 comments
You could, in one single instruction,
struct B {
int x, y, z;
};
struct A {
int a, b, c;
struct B *ptr;
};
void func(struct A *array, int i) {
array[i].ptr->z = 3;
}
Unless I am remembering how it works incorrectly.This is a little closer: https://godbolt.org/z/5K4MEYe31
and IIRC there was also the "LEA" instruction ("Load Effective Address") which stored the computed memory address instead of fetching/storing to that address. And I believe some compilers would (ab)use that to do math as well (though this was complicated by the aX/dX register split)
EDIT: Yeah, so if I'm not misreading MC68020UM the memory indirect mode is slower
move.l #3,([6,a0,d0.l*8],4) ; 9 cycles best case
vs. move.l 6(a0,d0.l*8),a0 ;4
move.l #3,4(a0) ; 3