Question: Suppose you are given the job of checking that a C compiler generates the proper code for structure and union access. You write the following
Suppose you are given the job of checking that a C compiler generates the proper code for structure and union access. You write the following structure declaration:
![typedef union { struct { long u; short v; char W; } t1; struct { } int a [2]; char *p: } t2; } u_type; You](https://dsd5zvtm8ll6.cloudfront.net/images/question_images/1698/1/4/4/4416537a0b9d0e1e1698144439823.jpg)
with different access expressions expr and with destination data type type set according to type associated with expr. You then examine the code generated when compiling the functions to see if they match your expectations.
Suppose in these functions that up and dest are loaded into registers %rdi and %rsi, respectively. Fill in the following table with data type type and sequences of one to three instructions to compute the expression and store the result at dest.
![expr up->t1.u up->t1.v &up->t1.w up->t2.a up->t2.a [up->t1.u] *up->t2.p type long Code movq (%rdi), %rax movq](https://dsd5zvtm8ll6.cloudfront.net/images/question_images/1698/1/4/4/4986537a0f2344af1698144496261.jpg)
typedef union { struct { long u; short v; char W; } t1; struct { } int a [2]; char *p: } t2; } u_type; You write a series of functions of the form void get (u_type *up, type *dest) { *dest = expr;
Step by Step Solution
3.37 Rating (150 Votes )
There are 3 Steps involved in it
Structures and unions involve a simple set of concepts but it takes practice to be c... View full answer
Get step-by-step solutions from verified subject matter experts
