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.73HW
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”.
Function find_range:
#Define function
range_t find_range(float x) {
__asm__(
"vxorps %xmm1, %xmm1, %xmm1\n\t"
"vucomiss %xmm1, %xmm0\n\t"
"jp .P\n\t"
"ja .A\n\t"
"jb .B\n\t"
"je .E\n\t"
"...
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)
Explain the pointer soting with help of pseudo code?
Example:
The Problem
Input File
Using C programming language write a program that simulates a variant of the Tiny Machine
Architecture. In this implementation memory (RAM) is split into Instruction Memory (IM) and Data
Memory (DM). Your code must implement the basic instruction set architecture (ISA) of the Tiny
Machine Architecture:
//IN 5
//OUT 7
//STORE O
//IN 5
//OUT 7
//STORE 1
//LOAD O
//SUB 1
55
67
30
55
67
1 LOAD
2- ADD
3> STORE
4> SUB
5> IN
6> OUT
7> END
8> JMP
9> SKIPZ
31
10
41
30
//STORE O
67
//OUT 7
11
/LOAD 1
//OUT 7
//END
67
70
Output Specifications
Each piece of the architecture must be accurately represented in your code (Instruction Register, Program
Counter, Memory Address Registers, Instruction Memory, Data Memory, Memory Data Registers, and
Accumulator). Data Memory will be represented by an integer array. Your Program Counter will begin
pointing to the first instruction of the program.
Your simulator should provide output according to the input file. Along with…
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
- Define the term " pointer offset " .arrow_forwardDefine the function: int power (int base, int exp) {/*It accepts the arguments for base and exponent and returns power. The algorithm is to repeatedly multiply the value of the base to how many times the value of exponent. Test the function inside main(). Write the complete C program. */} For example: Intput. Result 2 32 5arrow_forwardDefine a problem with user input, user output, Pointers, and Pointer Arithmetic. If no output explain the reason why and what you are going to do make sure it does not happen again aka learning from your mistakes.Problem:Design:Code:Output:arrow_forward
- INSTRUCTION: Read and study the assignment below. Solve the problem using C++ programming language, compile, run and screen shot the correct output. Copy and paste the source code or program code and the required sample output (screen shot) in the format below. Write a program using RETURNING VALUES FROM FUNCTION that will display the sum, product, difference, quotient and modules of two numbers. Note: Create function name for sum, product, difference,quotient and modulus. Complete the program codes below to finished the problem requirements. SAMPLE OUTPUT:Enter first number: 7Enter second number: 2The sum is 9The product is 14The difference is 5The quotient is 3The modulus is 1 SOURCE CODE: Update the source code below include<iostream> using namespace std; int addTwoNumbers(int , int); // function name for sum // Create function name for product // Create function name…arrow_forwardCoding Hacks In C Program, given an integer, write a detailed algorithm/code to find the square of the given integer without using a multiplication or division operator. Also, the use of the pow() [power] function is not allowed.arrow_forwardAIM- Write an 8085 sequence to check whether the first set of reading is higher than the second one or not. PROBLEM STATEMENT- The pressure of two boilers is monitored and controlled by a microcomputer works based on microprocessor programming. A set of 6 readings of first boiler, recorded by six pressure sensors, which are stored in the memory location starting from 2050H. A corresponding set of 6 reading from the second boiler is stored at the memory location starting from 2060H. Each reading from the first set is expected to be higher than the corresponding position in the second set of readings. Write an 8085 sequence to check whether the first set of reading is higher than the second one or not. If all the readings of first set is higher than the second set, store 00 in the 'D' register. If any one of the readings is lower than the corresponding reading of second set, stop the process and store FF in the register 'D'. Data (H): First set: 78, 89, 6A, 80, 90, 85 Second Set:71, 78,…arrow_forward
- Create 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_forwardPlease 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_forwardNOTE: (what your answer will contain) 1. Use C PROGRAMMING LANGUAGE ONLY 2. Use RECURSION type of program 3. Copy and paste your code(no need screenshot) 4. Screenshot the output 5. It should be USER-DEPENDENT 3. Writa a C program containing a recusive function that will get the whole number quotient res of dividing wo Integers n and m. (Example if n- and m= 3, 4/3-1. Output )arrow_forward
- Question: Write three address code and quadruple for following expression :(a + b ) * (a + b - c) Subject: Compiler Design. Note: write in own words. copy from internet will unhelpful for mearrow_forwardPlease Write a code in C programming to ARM64 Assembly Programming Loops (1) Write a program that adds the digits of your CWID number and prints the result.arrow_forwarduestion 1 Give the following declaration: int value(int x); Write an assembly function equivalent to the following C function: int sum() return value(10) + value(20); Notes: This is a non-leaf function. For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac). BIUS Paragraph Arialarrow_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