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
Expert Solution & Answer
Chapter 3, Problem 3.74HW
Explanation of Solution
Given assembly code:
x in %xmm0
find_range:
vxorps %xmm1, %xmm1, %xmm1
vucomiss %xmm1, %xmm0
ja .L5
vucomiss %xmm1, %xmm0
jp .L8
movl $1, %eax
je .L3
.L8:
vucomiss %xmm1, %xmm0
setbe %al
movzbl %al, %eax
addl $2, %eax
ret
.L5:
movl $0, %eax
.L3:
Rep;ret
Explanation:
- The assembly function “find_range” illustrates conditional branching in floating point.
- It compares a value “x” with 0.
- If value is less than 0, then result is negative.
- If value is greater than 0, then result is positive.
- If value equals 0, then result is zero.
- The instruction “vxorps %xmm1, %xmm1, %xmm1” sets value of “%xmm1” to 0.
- The instruction “vucomiss %xmm1, %xmm0” compares values.
- The instruction “jp .L8” jumps to label “.L8”.
- The instruction “ja .L5” jumps to label “.L5” if first value is greater than second.
- The instruction “movl $0, %eax” moves immediate value to register “%eax”.
- The instruction “movl $1, %eax” moves immediate value to register “%eax”...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Sea t (k) a function that denotes the number of times that the instruction sum + = i + j will be executed in the code that follows. k is assumed to be a positive integer.
Find the exact formula for t (k). Find a simple function A (k) such that t (k) = Θ (A (k)). Justify the answer with the corresponding theorems. (Note: you are not asking what the value is end of the sum variable)
please answer with proper explanation and step by step solution.
Question:
Write a C program that allows input for an integer, where it is passed to a ConvertDecimaltoBinary function that bit shifts the number 8 times, stores each of those values in an int array, then reads is backwards if the number in the array is even store character '0' in an array or if it is odd store character '1' in a character array. Ultimately, converting decimal to Binary in the way I have explained, in C.
Consider the following C function:
void f(int **, int a, int b) {
if (x != 0) {
*x += a;
}
return;
}
Write a translation of this function into assembly following the C convention for subprograms. It's ok for this
function to destroy the values of registers EAX and EBX, and the function's code can only reference registers
EAX, EBX, EBP, and ESP.
Chapter 3 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
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 code a C program and declare one pointer type variables, and demonstrate if this pointer can point to it's own address by using printf function. Please make sure your code(program) is well documented, meaning is full of comments for each line. If your code failed for a valid reason, means you are not allowed to do this, then explain why!arrow_forwardNotice that this problem includes escape sequences as well as math functions. Remember that C++ does not have a predefined constant for PI. Create your own and initialize it by calling the function acos(-1.0). use C++ to make code output in picarrow_forward(Practice) State whether the following are valid function names and if so, whether they’re mnemonic names that convey some idea of the function’s purpose. If they are invalid names, state why. powerdensity m1234 newamp 1234 abcd total tangent absval computed b34a 34ab volts$ a2B3 while minVal sine $sine cosine speed netdistance sum return stackarrow_forward
- IN asmly language please Pretty please with successful build screen shot and output 1.Using the AddTwo program from Section 3.2 as a reference, write a program that calculates the following expression, using registers: A = (A + B) − (C + D). Assign integer values to the EAX, EBX, ECX, and EDX registers. Note: you can hard code integer literal onto the registers, e.g. mov eax,55 ; AddTwo.asm - adds two 32-bit integers.; Chapter 3 example .386.model flat,stdcall.stack 4096ExitProcess proto,dwExitCode:dword .codemain proc mov eax,5 add eax,6 invoke ExitProcess,0main endpend main 2. Listing File for AddTwoSum Generate a listing file for AddTwoSum.asm(in 3.4.3 of the text) and write a description of the machine code bytes generated for each instruction. You can write your descriptions directly over the .lst file. You might have to guess at some of the meanings of the byte values. Submit the .lst file with your description over it.…arrow_forward2-Write a C++ program to input elements in an array and reverse the array using pointers.How to reverse an array using pointers in C++programming. Logic to reverse an arrayusing pointers in C++.ExampleInputInput array elements: 10 20 30 40 50 60 70 80 90 100OutputReversed array: 100 90 80 70 60 50 40 30 20 10arrow_forwardI was given to write a parallel computing problem in which a sequential c++ code is to be written and should be made to work as a parallel program by adding simple parallel computing constructs like "pragma omp parallel". it should be run on a ccr which I have access to and check the speed up of the parallelly running problem. All the skeleton of the program is given and I should complete the specific function.arrow_forward
- For each of the following C functions (given as function prototypes), which register is used to pass each of the parameters? Which register(s) is used to pass the return value? Note: uint64_t is unsigned 64-bit integer. a-short add2(short a, short b); b-uint16_t add3(uint8_t a, uint8_t b, uint8_t c); c-unsigned fibonacci(unsigned n); d-char* mystrcmp(char *dst, char *src) e-uint64_t sumOfArray(uint32_t X[], int N);arrow_forward1. Solving the coin-row problem by dynamic programming for the coin row (5, 1, 2, 10, 6, 2). 2. Write the used function for solving this problem, and clarify your steps in detail.arrow_forwardConvert the following function in Python code into MIPS code. Note that 2 integers a and b are passed as arguments to the function and result is returned back to the calling execution unit. 1. def Problem3 (a, b): # Initialize sum sum = 0 for i in range(a, b): sum = sum+ 2 return (sum)arrow_forward
- Using the C Programming language, write two versions of a function that contains a loop. Eachthe function should accept two numbers and calculate the sum of all numbers between the first numberand last number (inclusive of the first and last number). Once each function is writtenand tested for correct output, generate an assembly language version of the function. Write a version of the function using a while loop Write a version of the function using a goto loop Is the assembly language version of each loop function the same or different? (hint: Number of registers used Number of jumps (iterations), Total number of operations).arrow_forwardCreate a function block that works so that the output from the block changes state (0 to 1 or 1 to 0) each time the input goes from 0 to 1 (rising edge). - Realize the function block in Structured Text (ST). - Realize the function block in the Function Block Diagram (FBD) - Realize the function block in Ladder (LD)arrow_forwardBelow C-code has a for loop which will repeat 1000 times of the operation. This code will be running on very simple machine. Change the code to reduce the number of branch instructions. You can have up to 5 lines (statements) within the for loop. What is the number of branch operations before and after? for (i=0; i<1000; i++){ y[i] = w * x[i] + b[i]; }arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr