Practice Problem 3.43 (solution page 344)
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 uniun {
struct {
long u;
short v;
char w;
} t1;
struct {
int a [2];
char *p;
} t2;
} u_type;
You write a scries of functions or the form
void get (u_type *up, type *dest) {
*dest = expr;
}
with different access expressions expr and with destination data type type set according to type associated with expr. You then examine tire 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.
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Computer Systems: A Programmer's Perspective Plus Mastering Engineering With Pearson Etext -- Access Card Package (3rd Edition)
Additional Engineering Textbook Solutions
Starting Out With Visual Basic (7th Edition)
Starting Out with Java: Early Objects (6th Edition)
Starting Out with Python (3rd Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Digital Fundamentals (11th Edition)
Java How To Program (Early Objects)
- General math) a. Write a C++ program to calculate and display the midpoint coordinates of the line segment connecting the two endpoints given in Exercise 1a. Use the fact that the coordinates of the midpoint between two points with the coordinates x1,y1)and(x2,y2)are((x1+x2)/2,(y1+y2)/2). Your program should produce the following display (replacing the underscores with values your program calculates): ThexmidpointcoordinateisTheymidpointcoordinateis b. How do you know the midpoint values your program calculates are correct? c. After verifying the output your program produces, modify it to determine the midpoint coordinates of the line connecting the points (2,10) and (12,6). d. If your program doesn’t already do so, change its output to this: The x coordinate of the midpoint is xxx.xx The y coordinate of the midpoint is xxx.xx The xxx.xx denotes placing the calculated value in a field wide enough for three places to the left of the decimal point and two places to the right of it.arrow_forward(Practice) Run Program 7.10 to determine the average and standard deviation of the following list of 15 grades: 68, 72, 78, 69, 85, 98, 95, 75, 77, 82, 84, 91, 89, 65, and 74.arrow_forwardPlease solve and show steps, work, and information related to this problem. Thank you. The following C++ code performs a set of various arithmetic operations using both pointers and references: Fill in a memory table that shows the final values for both function a and function b. Indicate the final values of each parameter, passed in variable(s), and the return value of the function. Provide a separate copy of this memory table for each function.arrow_forward
- C++ programming problem: During the tax season, every Friday, the J&J accounting firm provides assitance to people who prepare their own tax returns. Their charges are as follows: a. If a person has low income (<=25,000) and the consulting time is less than or equal to 30 minutes, there are no charges; otherwise, the service charges are 40% of the regular hourly rate for the time over 30 minutes. b. For others, if the consulting time is less than or equal to 20 minutes, there are no service charges; otherwise, service charges are 70% of the regularly hourly rate for the time over 20 minutes. Write a program that prompts the user to enter the hourly rate, the total consulting time, and whether the person has low income. The program should output the billing amount. Your program must contain a function that takes as input the hourly rate, the total consulting time, and a value indicating whether the person has low income. The function should return the billing amount. Your…arrow_forward(Practice) For the following function headers, determine the number, type, and order(sequence) of the values that must be passed to the function: a. void factorial(int n) b. void volts(int res, double induct, double cap) c. void power(int type, double induct, double cap) d. void flag(char type, double current, double time) e. void total(double amount, double rate) f. void roi(int a, int b, char c, char d, double e, double f) g. void getVal(int item, int iter, char decflag, char delim)arrow_forwardState whether each of the following is true or false. If false, explain why g) Definitions can appear anywhere in the body of a function.arrow_forward
- Need help with this c++ function problemarrow_forwardWrite a program to solve quadratic equations for real roots. No need to use imaginary numbers. ax^2 +bx +c= 0 Requirements:-Define an array of type double with size 3 in main() to store the 3 coefficients.-Read the 3 coefficients from user input.-Create the function prototype and definition for the function getRootCount(discriminant, coefficients) Parameters: discriminant: output to be calculated by the function coefficients: input array of 3 coefficients Return: number of roots: 0, 1, or 2 -Create the function prototype and definition for a function to determine the numbers of roots: getRootCount(discriminant, coefficients); Parameters: discriminant: output value to be calculated by the function (reference parameter) coefficients: input array of 3 coefficients Return: number of roots: 0, 1, or 2 (int) -Create the function prototype and definition for a function to solve equations and get the root(s): solveEquation(discriminant,…arrow_forward1. Question : Simplify the following functions using Boolean algebra rules: F1 = a.b+c’+c(a’+b’) F2 = (x.y’+z)(x+y’)z 2. Question : Convert the following function to POS standard form F3 = (? + ?) (?̅+ ? + ?) • Convert the following function to SOP standard form F4 = (? + ?) (?̅+ ? + ?) 3. Question : • Use K-maps to minimize the following functions F5 = a’b’d+a’bc’d+a’bcd F6 = ∑(0,2,5, 9,10 11,12,13)arrow_forward
- (General math) a. Write a C++ program to calculate and display the value of the slope of the line connecting two points with the coordinates (3,7) and (8,12). Use the fact that the slope between two points with the coordinates (x1,y1)and(x2,y2)is(y2y1)/(x2x1). b. How do you know the result your program produced is correct? c. After verifying the output your program produces, modify it to determine the slope of the line connecting the points (2,10) and (12,6). d. What do you think will happen if you use the points (2,3) and (2,4), which results in a division by zero? How do you think this situation can be handled? e. If your program doesn’t already do so, change its output to this: The value of the slope is xxx.xx The xxx.xx denotes placing the calculated value in a field wide enough for three places to the left of the decimal point and two places to the right of it.arrow_forwardI need help in coding the following practice problem using the fundamentals of C Programming Language without using arrays. The New Telephone Company has the following rate structure for long-distance calls:a) Any call started after 6:00 P.M. gets a 50% discount.b) Any call started after 8:00 A.M. is charged full price.c) All calls are subject to a 4% tax.d) The regular rate for a call is /P5.00 per minute.e) Any call longer than 60 minutes receives a 15% discount on its cost(after anyother discount is taken but before tax is added).Write a program that processes several calls by reading the start time for each call andthe length of each call. The gross cost (before any discounts or tax) should be printedfollowed by the net cost (after discounts are deducted and tax is added).arrow_forwardSuppose we have the following function. f(x) = { x2 , |x| <= 1 2|x| - 1 , |x| >= 1 Solve the R programming question attached given this information above. Show all work and the R code.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning