Computer Systems: A Programmer's Perspective (3rd Edition)
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
Expert Solution & Answer
Book Icon
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”...

Blurred answer
Students 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.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
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr