
Practice Problem 3.18 (solution page 332)
Starting with C code of the form
long test (long x, long y, long z) {
long val = ______;
if (______) {
if (______)
val = ______;
else
val = ______;
} else if (______)
val = ______;
return val;
}
GCC generates the following assembly code:
long test(long x, long y, long z)
x in %rdi, y in %rsi, z In %rdx
test:
leaq | (%rdi, %rsi), %rax |
addq | %rdx, %rax |
cmpq | $-3, %rdi |
jge | .L2 |
cmpq | %rdx, %rsi |
jge | .L3 |
movq | %rdi, %rax |
imulq | %rai, %rax |
ret
.L3:
Movq | %rsi, %rax |
imulq | %rdx, %rax |
ret
.L2:
cmpq | $2, %rdi |
jle | .L4 |
movq | %rdi, %rax |
imulq | %rdx, %rax |
.L4:
rep; ret
Fill in the missing expressions in the C code.

Want to see the full answer?
Check out a sample textbook solution
Chapter 3 Solutions
EBK COMPUTER SYSTEMS
Additional Engineering Textbook Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Degarmo's Materials And Processes In Manufacturing
Mechanics of Materials (10th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
- 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

