Computer Systems: A Programmer's Perspective (3rd Edition)
3rd Edition
ISBN: 9780134092669
Author: Bryant, Randal E. Bryant, David R. O'Hallaron, David R., Randal E.; O'Hallaron, Bryant/O'hallaron
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 4, Problem 4.48HW
Program Plan Intro
Given Y86-64 code:
.pos 0
irmovq stack, %rsp
call main
halt
.align 8
data:
.quad 0x0000000000000004
.quad 0x0000000000000003
.quad 0x0000000000000002
data_end:
.quad 0x0000000000000001
main:
irmovq data,%rdi
irmovq data_end,%rsi
call ysBubbleP
ret
ysBubbleP:
jmp L2
L4:
mrmovq 8(%rax), %r9
mrmovq (%rax), %r10
rrmovq %r9, %r8
subq %r10, %r8
jge L3
rmmovq %r10, 8(%rax)
rmmovq %r9, (%rax)
L3:
irmovq $8, %r8
addq %r8, %rax
jmp L5
L6:
rrmovq %rdi, %rax
L5:
rrmovq %rsi, %r8
subq %rax, %r8
jg L4
irmovq $8, %r8
subq %r8, %rsi
L2:
rrmovq %rsi, %r8
subq %rdi, %r8
jg L6
ret
.pos 0x200
stack:
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:
Unary and Binary Operations:
- The details of unary operations includes:
- The single operand functions as both source as well as destination.
- It can either be a memory location or a register.
- 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.
- The details of binary operations includes:
- The first operand denotes the source.
- The second operand works as both source as well as destination.
- The first operand can either be an immediate value, memory location or register.
- The second operand can either be a register or a memory location.
Jump Instruction:
- The “jump” instruction causes execution to switch to an entirely new position in program.
- The “label” indicates jump destinations in assembly code.
- The “je” instruction denotes “jump if equal” or “jump if zero”.
- The comparison operation is performed.
- If result of comparison is either equal or zero, then jump operation takes place.
- The “ja” instruction denotes “jump if above”.
- The comparison operation is performed.
- If result of comparison is greater, then jump operation takes place.
- The “pop” instruction resumes execution of jump instruction.
- The “jmpq” instruction jumps to given address. It denotes a direct jump.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Going missing
Some calculations involving blank values may give different results to what you might expect. For example, when you pass a blank value into the AND() function, it is treated as TRUE. This is often unhelpful. To make blanks behave in a sensible way in calculations, you must first convert them to be "not available" using NA(). This function takes no inputs, and returns a missing value. To convert a blank value to a missing value, use this pattern.
=IF(ISBLANK(cell), NA(), cell)
Instruction
In column H, use AND() to find women who have kids and get benefits.
In column I, convert the blanks in column G to missing values.
In column J, again find women who have kids and get benefits, this time using column I rather than G.
please show the formula used to "has kids and gets benefits" , "gets benefits with missing values", has kids and gets benefits". Thank you
Is non-white
Has over 12 years of school?
Is married?
Has kids?
Has young kids?
Is head of household?
Gets…
Modify the below program that the input values representingfractions are stored with denominators that are positive integers. You cannot require the user to only enter a positive denominator value; the user should not be inconvenienced by such a restriction. For example, whilst values of 1 / -2 are acceptable inputs for a fraction, the output representation should be -1 / 2. Your solution should check the denominator input; if it is negative, swap the sign of both numerator and denominator instance variables.
//Import the essential package
import java.util.ArrayList;
import java.util.Scanner;
//Define the class Fraction
class Fraction
{
private int n, d;
public Fraction()
{
//Initialize the values
this.n = this.d = 0;
}
public Fraction(int n, int d)
{
//Initialize the variables
this.n = n;
this.d = d;
}
//Define the getter function getNum() that returns the numerator
public int getNum()
{…
Experiment 1: IMPLEMENTATION OF CAESAR CIPHER
Objective:
To implement the simple substitution technique named Caesar cipher using C+ language.
Theory:
To enerypt a message with a Caesar cipher, each letter in the message is changed using a
simple rule: shift by three. Each letter of the message is shifted a fixed distance (3 for
example) down the alphabet, A becomes D, B becomes E, and so on. For the last letters,
we can think of alphabet as a circle and "wrap around", W becomes Z. X becomes A, Y
becomes B, and Z becomes C. To change a message back, cach letter is replaced by the
one three before it.
Example
ABCDEFGHIJKLMNOPQRSTUVWXYZ
t t t t t t t t ttt t t t t t t tt t t t t t t ft
DEFGHIJKLMNOPQRSTUVW XY Z ABc)
digorithm
STEP-1: Read the plain text from the user.
STEP-2: Read the key value from the user.
STEP-3: If the key is positive then encrypt the text by adding the key with each character
in the plain text.
STEP-4: Else subtract the key from the plain text.
STEP-5: Display the…
Chapter 4 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Ch. 4.1 - Prob. 4.1PPCh. 4.1 - Prob. 4.2PPCh. 4.1 - Prob. 4.3PPCh. 4.1 - Prob. 4.4PPCh. 4.1 - Prob. 4.5PPCh. 4.1 - Prob. 4.6PPCh. 4.1 - Prob. 4.7PPCh. 4.1 - Prob. 4.8PPCh. 4.2 - Practice Problem 4.9 (solution page 484) Write an...Ch. 4.2 - Prob. 4.10PP
Ch. 4.2 - Prob. 4.11PPCh. 4.2 - Prob. 4.12PPCh. 4.3 - Prob. 4.13PPCh. 4.3 - Prob. 4.14PPCh. 4.3 - Prob. 4.15PPCh. 4.3 - Prob. 4.16PPCh. 4.3 - Prob. 4.17PPCh. 4.3 - Prob. 4.18PPCh. 4.3 - Prob. 4.19PPCh. 4.3 - Prob. 4.20PPCh. 4.3 - Prob. 4.21PPCh. 4.3 - Prob. 4.22PPCh. 4.3 - Prob. 4.23PPCh. 4.3 - Prob. 4.24PPCh. 4.3 - Prob. 4.25PPCh. 4.3 - Prob. 4.26PPCh. 4.3 - Prob. 4.27PPCh. 4.4 - Prob. 4.28PPCh. 4.4 - Prob. 4.29PPCh. 4.5 - Prob. 4.30PPCh. 4.5 - Prob. 4.31PPCh. 4.5 - Prob. 4.32PPCh. 4.5 - Prob. 4.33PPCh. 4.5 - Prob. 4.34PPCh. 4.5 - Prob. 4.35PPCh. 4.5 - Prob. 4.36PPCh. 4.5 - Prob. 4.37PPCh. 4.5 - Prob. 4.38PPCh. 4.5 - Prob. 4.39PPCh. 4.5 - Prob. 4.40PPCh. 4.5 - Prob. 4.41PPCh. 4.5 - Prob. 4.42PPCh. 4.5 - Prob. 4.43PPCh. 4.5 - Prob. 4.44PPCh. 4 - Prob. 4.45HWCh. 4 - Prob. 4.46HWCh. 4 - Prob. 4.47HWCh. 4 - Prob. 4.48HWCh. 4 - Modify the code you wrote for Problem 4.47 to...Ch. 4 - In Section 3.6.8, we saw that a common way to...Ch. 4 - Prob. 4.51HWCh. 4 - The file seq-full.hcl contains the HCL description...Ch. 4 - Prob. 4.53HWCh. 4 - The file pie=full. hcl contains a copy of the PIPE...Ch. 4 - Prob. 4.55HWCh. 4 - Prob. 4.56HWCh. 4 - Prob. 4.57HWCh. 4 - Our pipelined design is a bit unrealistic in that...Ch. 4 - Prob. 4.59HW
Knowledge Booster
Similar questions
- please write the python code to implement without error for this problem. I am stuck.arrow_forwardI am working on a block of code and cannot figure out how to count the number of times a loop is proccessed within the stated parameters, but when the output is 0 that value is not counted in the iteration. Here is the problem and my codearrow_forwardFOR C++ In this assignment, we are going to implement a couple of sorting algorithms and test their performances. So the idea is as follows: You should write a program to sort an array. For this purpose, you will implement two sorting algorithms: Insertion Sort and Merge Sort. For each algorithm, you are supposed to have a counter and count how many times a comparison is made to sort the array. Once this logic is implemented, create integer arrays of 1000 and 10000 elements with random values inside (you can implement a random number generator for this purpose and randomize their elements). Then go ahead and run your application. The output should show us how many comparisons it made for each algorithm for 1000 and 10000 elements. //header file#include<iostream>#include<time.h>//using namespaceusing namespace std; // Insertion sort sorting function it will take array and its size an argumentvoid insertionSort(int nums[], int m, int& comparisonsCount){ int j, val,…arrow_forward
- FOR C++ In this assignment, we are going to implement a couple of sorting algorithms and test their performances. So the idea is as follows: You should write a program to sort an array. For this purpose, you will implement two sorting algorithms: Insertion Sort and Merge Sort. For each algorithm, you are supposed to have a counter and count how many times a comparison is made to sort the array. Once this logic is implemented, create integer arrays of 1000 and 10000 elements with random values inside (you can implement a random number generator for this purpose and randomize their elements). Then go ahead and run your application. The output should show us how many comparisons it made for each algorithm for 1000 and 10000 elements.arrow_forwardUsing C++ How would I generate a random value for a random location in a multiplication table (printing the random value at a random row and column). Then you ask and read a row and column from the user and compare them with the generated row and column and tell if it’s right. We haven't learned functions. Just nested Loops Assignment: Write a program that prints the multiplication table but inserts a randomly generated incorrect value between 1 and 50 into a cell whose row and column are randomly selected. Make sure the program does insert an incorrect value. For example, if row and column of 3 and 4 are randomly selected, keep generating a random number to print for that location until it's not the right value of 12. Then, ask the user to tell where in the table the incorrect number is located by entering the row and column of the incorrect number. Print whether the user was right or not. If he or she was right, ask for and read the correct value; if not, the program must give the…arrow_forwardRun my function on {(1,4),(0,6),(3,5),(2,9),(7,8)}. Is the output what you expect? Find the problem and fix it, writing a correct version of the function. Again, use the same function name, i.e., count_crossings_and_nestings. Demonstrate that the new version works by testing it on the example provided. Now write a well-documented version of your function count_crossings_and_nestings. Add a document string and plenty of comments.arrow_forward
- The Fibonacci sequence begins with 0 and then 1 follows. All subsequent values are the sum of the previous two, ex: 0, 1, 1, 2, 3, 5, 8, 13. Complete the fibonacci() function, which has an index n as parameter and returns the nth value in the sequence. Any negative index values should return -1. Ex: If the input is: 7 the output is: fibonacci(7) is 13 Note: Use a for loop and DO NOT use recursion. python def fibonacci(n): # Type your code here. if __name__ == '__main__': start_num = int(input()) print('fibonacci({}) is {}'.format(start_num, fibonacci(start_num)))arrow_forwardThe Fibonacci sequence begins with 0 and then 1 follows. All subsequent values are the sum of the previous two, ex: 0, 1, 1, 2, 3, 5, 8, 13. Complete the fibonacci() function, which has an index n as parameter and returns the nth value in the sequence. Any negative index values should return -1. Ex: If the input is: 7 the output is: fibonacci (7) is 13 Note: Use a for loop and DO NOT use recursion.arrow_forwardThe Fibonacci sequence begins with 0 and then 1 follows. All subsequent values are the sum of the previous two, ex: 0, 1, 1, 2, 3, 5, 8, 13. Complete the fibonacci() function, which has an index n as parameter and returns the nth value in the sequence. Any negative index values should return -1. Ex: If the input is: 7 the output is: fibonacci (7) is 13 Note: Use a for loop and DO NOT use recursion. 461710.3116374.qx3zqy7 LAB ACTIVITY 1 def fibonacci(n): 1234567 4 7.34.1: LAB: Fibonacci sequence 6 #Type your code here. 5 if __name__ start_num = '__main__': int(input()) main.py print(f'fibonacci ({start_num}) is {fibonacci (start_num)}') 0/10 Load default template...arrow_forward
- Suppose you are given a vector x. Write first a pseudo-code or algorithm that would print out the sum of all the entries in x. You will probably want to use a some kind of for loop construction to achieve this. 1: for i = start : finish do 2: statements 3: end for Now use the start:increment:finish notation, and modify your procedure slightly, to print out the sum of the odd elements in the array (that is, the elements in entries 1, 3, 5, and so on). Implement and test your algorithm with an arbitrary array of real numbers using Python.arrow_forwardlanguage is c++ sample output included with user input in boldarrow_forwardPlease help with creating the code as follows: Task 2(a): Implement the FFT algorithm using the above pseudocode as the function FFT(). Notethat we have introduced a sign parameter in the FFT pseudocode to specify the sign of the exponent in ωn.If sign is 1, ωn = e2πi/n. If sign is -1, ωn = e−2πi/n.Task 2(b): Then implement the inverse FFT as the function IFFT() that calls the FFT function youwrote with the appropriate inputs, and then normalizes the output by n. Example Task 2(a): Fast Fourier Transform FFT <input_file.txt> <output_file.txt>where input_file.txt contains the coefficients of the polynomial, this query should read thenumbers from input_file.txt, compute the FFT, and output the result to output_file.txt.Note: This FFT query has the same name as the FFT function in the pseudocode. It should beclear from the context which one we are referring to.Example 1:task2a_input1.txt1.0002.0003.000FFT task2a_input1.txt…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning