I don\'t know how to do the missing expressions in the code, please let me know
ID: 3602699 • Letter: I
Question
I don't know how to do the missing expressions in the code, please let me know to do it
Consider the following union declaration 1 union ele struct t long *p; long y; 4 h e1; struct [ long x; union ele *next; 10 This declaration illustrates that structures can be embedded within unions The following procedure (with some expressions omitted) operates on a linked list having these unions as list elements void proc (union ele up A. What are the offsets (in bytes) of the following fields e2.x e2.next B. How many total bytes would the structure require? C. The compiler generates the following assembly code for the body of proc: void proc (union ele *up) up in %rdi proc: 1 movq movq movq subq movq ret 8(%rdi), %rax (%rax), %rdx (%rax), %rdx 8(%rax) ,%rax %rdx ,(%rdi ) 6 On the basis of this information, fill in the missing expressions in the code for proc Hint: Some union references can have ambiguous interpretations. These ambiguities get resolved as you see where the references lead. There is only one answer that does not perform any casting and does not violate any type constraintsExplanation / Answer
A.
(As one element (i.e e1 or e2) can be accessed at a time in union)
e1.p=0 bytes (OFFSET)
e1.y=8 bytes (OFFSET)
e2.x=0 bytes (OFFSET)
w2.next = 8 bytes (OFFSET)
B.
total bytes the union structure require is largest of the elements in the union i.e in this case sizeof e2
sizeof(e2) = 8 + pointer size (8) = 16 bytes (answer)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.