Practice Problem 2.43 (solution page 157)
In the following code, we have omitted the definitions of constants M and N:
#define M /* Mystery number 1 */
#define N /* Mystery number 2 */
int arith(int x, int y) {
int result = 0;
result = x*M + y/N; /* M and N are mystery numbers. */
return result;
}
We compiled this code for particular values of M and N. The compiler optimized the multiplication and division using the methods we have discussed. The following is a translation of the generated machine code back into C:
/* Translation of assembly code for axith */
int optarith(int x, int y) {
int t = x;
x <<= 5;
x -= t;
if (y < 0) y + = 7;
y >> 3; /* Arithmetic shift */
return x+y;
}
What are the values of M and N?
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
EBK COMPUTER SYSTEMS
Additional Engineering Textbook Solutions
Starting Out With Visual Basic (7th Edition)
C How to Program (8th Edition)
Digital Fundamentals (11th Edition)
Starting Out with C++ from Control Structures to Objects (8th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY