
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)
- Can you help me solve it through matlabarrow_forwardI need help with this problem and an explanation of the solution for the image described below. (Introduction to Signals and Systems)arrow_forwardI need help with this problem and an explanation of the solution for the image described below. (Introduction to Signals and Systems)arrow_forward
- DO NOT USE AI, THEY WILL MESS UParrow_forwardDesign an ER diagram for a Hospital Management System. Include weak and strong entity sets, attributes, and relationships.arrow_forwardI need help with this problem and an explanation of the solution for the image described below. (Introduction to Signals and Systems)arrow_forward
- How to create a java code with the scenario below? Patriot Ships is a new cruise line company which has a fleet of 10 cruise ships, each with a capacity of 300 passengers. To manage its operations efficiently, the company is looking for a program that can help track its fleet, manage bookings, and calculate revenue for each cruise. Each cruise is tracked by a Cruise Identifier (must be 5 characters long), cruise route (e.g. Miami to Nassau), and ticket price. The program should also track how many tickets have been sold for each cruise. Create an object-oriented solution with a menu that allows a user to select one of the following options: 1. Create Cruise – This option allows a user to create a new cruise by entering all necessary details (Cruise ID, route, ticket price). If the maximum number of cruises has already been created, display an error message. 2. Search Cruise – This option allows to search a cruise by the user provided cruise ID. 3. Remove Cruise – This op on allows a…arrow_forwardI need help with this problem and an explanation of the solution for the image described below. (Introduction to Signals and Systems)arrow_forwardI need help with this problem and an explanation of the solution for the image described below. (Introduction to Signals and Systems)arrow_forward
- Assignment Q1: LC-3 Instruction Execution Instruction LD R1, VALUE Binary Encoding (16-bit) Bit Breakdown IR Loaded Value (Hex) 0010 001 000000101 Opcode 0010 (LD), DR=001 (R1), PCOffset9-000000101 ? ? ? ? ? ? x1241 ? x3206 ? 1001 011 001 111111 ? ? Tasks You are required to: 1. Decode each instruction based on the LC-3 instruction set and complete the last column in the table above. Provide a clear description of the function of each instruction. LC-3 Table is included in the slides. 2. Update register (any register invovled) values step by step after executing each instruction. Hints Use the LC-3 instruction set reference (Lecture X) to decode instructions accurately. ⚫ Keep track of register dependencies some instructions modify registers that are used later. Consider the effects of instructions like AND R1, RO, #0, which effectively clears the destination register. For the STR instruction, remember that the effective address is calculated as Base Register + Offset (sign-extended).…arrow_forwardhttps://personalpages.bradley.edu/~olekmali/class_notes/ece-x72/homework/4_code.tar.gz https://personalpages.bradley.edu/~olekmali/class_notes/ece-x72/homework/4_http_multi.cpp.HTML http://localhost:8081/arrow_forwardAssignment cution nderstanding ruction Exe- In the LC-3 architecture, memory accesses occur through the Memory Address Register (MAR) and the Memory Data Register (MDR). These registers facilitate LOAD (LD) and STORE (ST) instructions by temporarily holding addresses and data during memory operations. Given Information ⚫ The system has a 16-bit address bus and a 16-bit data bus. ⚫ The MAR is 16 bits wide and holds the memory address for read/write operations. • The MDR is 16 bits wide and temporarily stores data being read from or written to memory. At the beginning, memory and registers are initialized as follows: Initial Register Values: • R1 = x4000 • R2 = x4001 ⚫ R3 = x0000 (used as the destination register for load) • MAR = x0000 • MDR = x0000 Initial Memory Contents: M[x4000]=x1234, M[24001] = x5678 The following LC-3 instructions are executed sequentially: LD R3, x4000 ST R3, x4001 ; Load value from memory address x4000 into R3 ; Store value from R3 into memory address x4001…arrow_forward
- 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





