
EBK COMPUTER SYSTEMS
3rd Edition
ISBN: 8220101459107
Author: O'HALLARON
Publisher: YUZU
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 3.6, Problem 3.21PP
Explanation of Solution
Given assembly code:
long test(long x, long y)
x in %rdi, y in %rsi
test:
leaq 0(,%rdi,8), %rax
testq %rsi, %rsi
jle .L2
movq %rsi, %rax
subq %rdi, %rax
movq %rdi, %rdx
andq %rsi, %rdx
cmpq %rsi, %rdi
cmovge %rdx, %rax
ret
.L2:
addq %rsi, %rdi
cmpq $-2, %rsi
cmovle %rdi, %rax
ret
Load Effective Address:
- The load effective address instruction “leaq” is a variant of “movq” instruction.
- The instruction form reads memory to a register, but memory is not been referenced at all.
- The first operand of instruction is a memory reference; it copies effective address to destination.
- The pointers could be generated for later references of memory.
- The common arithmetic operations could be described compactly using this instruction.
- The operand in destination should be a register.
Data movement instructions:
- The different instructions are been grouped as “instruction classes”.
- The instructions in a class performs same operation but with different sizes of operand.
- The “Mov” class denotes data movement instructions that copy data from a source location to a destination.
- The class has 4 instructions that includes:
- movb:
- It copies data from a source location to a destination.
- It denotes an instruction that operates on 1 byte data size.
- movw:
- It copies data from a source location to a destination.
- It denotes an instruction that operates on 2 bytes data size.
- movl:
- It copies data from a source location to a destination.
- It denotes an instruction that operates on 4 bytes data size.
- movq:
- It copies data from a source location to a destination.
- It denotes an instruction that operates on 8 bytes data size.
- movb:
Comparison Instruction:
- The “CMP” instruction sets condition code according to differences of their two operands.
- The working pattern is same as “SUB” instruction but it sets condition code without updating destinations.
- The zero flag is been set if two operands are equal.
- The ordering relations between operands could be determined using other flags.
- The “cmpl” instruction compares values that are double word.
Unary and Binary Operations:
- The details of unary operations includes:
- The single operand serves as both source as well as destination.
- It can either be a register or a memory location.
- The instruction “incq” causes 8 byte element on stack top to be incremented.
- The instruction “decq” causes 8 byte element on stack top to be decremented...
Expert Solution & Answer

Want to see the full answer?
Check out a sample textbook solution
Students have asked these similar questions
"Please, the answer must be documented from a
book, experience, or accurate information without
using artificial intelligence."
Write a program to read the distance from ultrasonic sensor
connected to pin No. A3 and urn ON a RED
pin No. 12 when the distance rises from 100cm.
"Please, the answer must be documented from a
book, experience, or accurate information without
using artificial intelligence."
Write an Arduino program to blink (flash) 8- LED's connected
to pins (6-13) according to the following sequence:
array with delay of 0.1s).
(Note: Use
Pin 6
Pin 7
Pin 8
Pin 9 Pin 10 Pin 11
Pin 12
Pin 13
0
0
0
0
0
1
0
0
0
0
0
0
1
1
0
0
0
0
1
1
1
0
0
0
0
0
1
1
11100
0
1
1
1
1
1
1
1
1
1
1
1
1
177
1
1
1
1
1
1
1
1
"Please, the answer must be documented from a
book, experience, or accurate information without
using artificial intelligence."
Suppose you have two push buttons connected to pins 7 & 8
and two LED's connected to pins 9 & 10 of an Arduino. Write a
program to turn ON the LED's if the two push buttons are
pressed according to the following scenario.
push buttons
push buttons
LED (pin9)
LED (pin10)
Delay
(pin7)
(pin8)
open
open
HIGH
HIGH
2s
closed
open
LOW
HIGH
1s
open
closed
HIGH
LOW
1s
closed
closed
LOW
LOW
3s
Chapter 3 Solutions
EBK COMPUTER SYSTEMS
Ch. 3.4 - Prob. 3.1PPCh. 3.4 - Prob. 3.2PPCh. 3.4 - Prob. 3.3PPCh. 3.4 - Prob. 3.4PPCh. 3.4 - Prob. 3.5PPCh. 3.5 - Prob. 3.6PPCh. 3.5 - Prob. 3.7PPCh. 3.5 - Prob. 3.8PPCh. 3.5 - Prob. 3.9PPCh. 3.5 - Prob. 3.10PP
Ch. 3.5 - Prob. 3.11PPCh. 3.5 - Prob. 3.12PPCh. 3.6 - Prob. 3.13PPCh. 3.6 - Prob. 3.14PPCh. 3.6 - Prob. 3.15PPCh. 3.6 - Prob. 3.16PPCh. 3.6 - Practice Problem 3.17 (solution page 331) An...Ch. 3.6 - Practice Problem 3.18 (solution page 332) Starting...Ch. 3.6 - Prob. 3.19PPCh. 3.6 - Prob. 3.20PPCh. 3.6 - Prob. 3.21PPCh. 3.6 - Prob. 3.22PPCh. 3.6 - Prob. 3.23PPCh. 3.6 - Practice Problem 3.24 (solution page 335) For C...Ch. 3.6 - Prob. 3.25PPCh. 3.6 - Prob. 3.26PPCh. 3.6 - Practice Problem 3.27 (solution page 336) Write...Ch. 3.6 - Prob. 3.28PPCh. 3.6 - Prob. 3.29PPCh. 3.6 - Practice Problem 3.30 (solution page 338) In the C...Ch. 3.6 - Prob. 3.31PPCh. 3.7 - Prob. 3.32PPCh. 3.7 - Prob. 3.33PPCh. 3.7 - Prob. 3.34PPCh. 3.7 - Prob. 3.35PPCh. 3.8 - Prob. 3.36PPCh. 3.8 - Prob. 3.37PPCh. 3.8 - Prob. 3.38PPCh. 3.8 - Prob. 3.39PPCh. 3.8 - Prob. 3.40PPCh. 3.9 - Prob. 3.41PPCh. 3.9 - Prob. 3.42PPCh. 3.9 - Practice Problem 3.43 (solution page 344) Suppose...Ch. 3.9 - Prob. 3.44PPCh. 3.9 - Prob. 3.45PPCh. 3.10 - Prob. 3.46PPCh. 3.10 - Prob. 3.47PPCh. 3.10 - Prob. 3.48PPCh. 3.10 - Prob. 3.49PPCh. 3.11 - Practice Problem 3.50 (solution page 347) For the...Ch. 3.11 - Prob. 3.51PPCh. 3.11 - Prob. 3.52PPCh. 3.11 - Practice Problem 3.52 (solution page 348) For the...Ch. 3.11 - Practice Problem 3.54 (solution page 349) Function...Ch. 3.11 - Prob. 3.55PPCh. 3.11 - Prob. 3.56PPCh. 3.11 - Practice Problem 3.57 (solution page 350) Function...Ch. 3 - For a function with prototype long decoda2(long x,...Ch. 3 - The following code computes the 128-bit product of...Ch. 3 - Prob. 3.60HWCh. 3 - In Section 3.6.6, we examined the following code...Ch. 3 - The code that follows shows an example of...Ch. 3 - This problem will give you a chance to reverb...Ch. 3 - Consider the following source code, where R, S,...Ch. 3 - The following code transposes the elements of an M...Ch. 3 - Prob. 3.66HWCh. 3 - For this exercise, we will examine the code...Ch. 3 - Prob. 3.68HWCh. 3 - Prob. 3.69HWCh. 3 - Consider the following union declaration: This...Ch. 3 - Prob. 3.71HWCh. 3 - Prob. 3.72HWCh. 3 - Prob. 3.73HWCh. 3 - Prob. 3.74HWCh. 3 - Prob. 3.75HW
Knowledge Booster
Similar questions
- "Please, the answer must be documented from a book, experience, or accurate information without using artificial intelligence." OF ENG Connect 8 LED's and one push button to an Arduino, write a program to glow the LED's in series one by one when the button is pressed. When the button is released it should stop and restart again when the button is pressed hold. And when the LED's sequence is complete it should stop and shouldn't restart unless the button is released and repressed.arrow_forward"Please, the answer must be documented from a book, experience, or accurate information without using artificial intelligence." Write an Arduino program to read the status of two push buttons COLED's connected to pins 2&3 respectively and flash ON two connected to pins 12&13 respectively according to the following scenario: If pin 2 is HIGH let LED 12 flash with delay of 400ms, and if pin 3 HIGH, let LED 13 flash ON with delay of 300ms.arrow_forward"Please, the answer must be documented from a book, experience, or accurate information without using artificial intelligence." Write an Arduino program to obtain the complement following input sequence (1011) by using switch connected to pin11 and one LED connected to pin12. one push of the buttonarrow_forward
- "Please, the answer must be documented from a book, experience, or accurate information without using artificial intelligence." Suppose you have two push buttons connected to pins 7,8 and two LED's connected to pins 9,10 of an Arduino. Write a program to turn ON/OFF the LED's if the two push buttons are pressed according to the following scenarios: S7 S$ L9 L10 Delay 0 0 1 1 2s 1 0 0 1 1s 1 1 0 1s 0 0 3s EERINGarrow_forward"Please, the answer must be documented from a book, experience, or accurate information without using artificial intelligence." Write an Arduino program to read the status of two push buttons connected to pins 2&3 respectively and flash ON two LED's connected to pins 12&13 respectively according to the following scenario: If pin 2 is HIGH let LED 12 flash with delay of 400ms, and if pin 3 HIGH, let LED 13 flash ON with delay of 300ms.arrow_forward"Please, the answer must be documented from a book, experience, or accurate information without using artificial intelligence." Suppose you have 4-LED's connected to pins (10,11,12,13) and 2-Switches connected to pins (4,5) of an Arduino, write program to turn ON 10&12 while turning OFF 11&13 for 350ms by pressing the switch connected to pin 4. Then turn ON 10&11 while turning OFF 12&13 for 400ms when pressing the switch connected to pin 5.arrow_forward
- Can you write the following C program into ARMv8 Assembly Language?long long int f(long long int n, long long int k) { long long int b; b=k+2; if (n==0) b = 8; else b = b + 4 * n + f(n-1,k+1); return b + k; }Can you make sure to properly save and restor registers across prodcedure calls, and assume that the procedure starts at address 0x00400100. Additionally, can you keep variable b at X19, and assume n and k are passed in X0 and X1. The result is returned in X0arrow_forwardNo Ai, find the correct answer to this question. Because all the rest ive found or tried are wrong. Show the steps.arrow_forwardCould you use pencil and paper, NO AI. Make it the correct answer, Dont use ai to solve this. I keep getting different answer. When ever I try it. Use this: Make a database with multiple tables from attributes as shown above that are in 3NF, showing PK, non-key attributes, and FK for each table? Assume the tables are already in 1NF. [Hint: 3 tables will result after deducing 1NF -> 2NF -> 3NF]arrow_forward
- Please answer the JAVA OOP Programming Assignment 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…arrow_forward23 } 24 ain.cpp // Tasks: C tot Shore Run Task 1: Create a class "Student" with attributes name, age, and grade. Add methods to set and get these values. Task 2: Implement a class "BankAccount" with deposit and withdraw methods, ensuring balance does not go negative. Task 3: Develop a class "Circle" that calculates its area and circumference given the radius. Task 4: Implement a class "Book" that stores title, author, and price, and allows updating and displaying book detailsarrow_forward42 व 2 = 16 25 32-5 Subnetting = 27 Problem 8 Number of needed subnets 5 Network Address 172.50.0.0/27 Address class B Default subnet mask 255.255.0. . Custom subnet mask 255.255.255.229 Total number of subnets Total number of host addresses Number of usable addresses Number of bits borrowed 3 8122 8120 What is the 4th subnet range? What is the subnet number for the 5th subnet? What is the subnet broadcast address for the 6th subnet? What are the assignable addresses for the 3rd subnet?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY