Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ignore the given answers Question 4 Consider the following code fragment where t

ID: 3712489 • Letter: I

Question

ignore the given answers

Question 4 Consider the following code fragment where the right-hand side of the assignments in func are to be completed by answering this question (and the next question): typedef struct point f float 'p struct t float x float y struct point next; point; void func(point spi, point sp2) ( int main) point init, "final; // assume init has been initialized to some value func(init, final); return The compiler generates the following assembly code for the body of func: push %ebp mov %esp, %ebp mov ??8(%ebp), %eax lea 8x4(%eax), %edx mov oc(%ebp), %eax mov %eax, (%eax) mov 0x8 (xebp), xeax mov ex8(%eax), %eax mov exc(%ebp), %edx mov %eax,8x4(%edx) mov 8x8 (xebp), xeax nov 8x4(%eax), %eax mov exc (%ebp), %edx mov %eax,8x8(%eax) nov 6x8(%ebp), %eax mov 8xc (xebp), xedx mov %edx,6xE(%eax) mov ???(%ebp), %eax movi sexe, exc(%eax) pop %ebp ret Complete the first two assignment statements by answering the following: The value of Ais sp1->p The value of B is sp1->s.x The value of C is spi->s.y

Explanation / Answer

Value of A is sp1->p.
Since A is the part in which we are assigning value to sp2->p and to that function two points sp1 and sp2 are passed and we are copying sp1 contents to sp2.
so for sp2->p, sp1->p is the correct assignment.

Value of B is sp1->s.x. Since s is a another structure that is defined inside point so we are accessing through -> operator and x is variable inside s so sp1->s.x is the
correct assignment.

Simillarly Value of c is sp1->s,y