CS计算机代考程序代写 Java assembly Instance Variables:

Instance Variables:
Structs in C:
 Similar to objects in Java, fields are stored contiguously in memory. BUT:
 Similar to arrays, structs can be allocated statically or dynamically.  To access an instance variable:
Breakout Question. Given the declaration.
Write out the assembly code for i = s->hope;
struct { int emo;
int ji;
int hope;
} *s;
int i;
Allocation and Access . notation:
-> notation:
Dynamic:
Struct D* d1
void foo2() {
d1 = malloc(sizeof(struct D));
d1->e = 3;
d1->f = 2;
}
Memory Addressing Modes
Assign a[3] = 5; using base+offset
ld $a, r0
ld $3, r1
ld $5, r2
st r2, (r0, r1, 4)
Address 0x1000 0x1004

Address 0x2000 … 0x5000 0x5004
Value
d0
Value
d1
What is the difference between the following structs
Draw out a memory representation:
Why?
Declaration and Alignment
What are the offsets to j?
Static:
Struct D d0;
void foo1() {
d0.e = 4;
d0.f = 6;
}
Assign d0.f = 7; using indexed
ld $d0, r0
ld $7, r1
st r1, 4(r0)