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.72HW

A.

Explanation of Solution

Given Assembly code:

# long aframe(long n, long idx, long *q)

# n in %rdi, idx in %rsi, q in %rdx

aframe:

  pushq %rbp

  movq %rsp, %rbp

  subq $16, %rsp

  leaq 30(,%rdi,8), %rax

  andq $-16, %rax

  subq %rax, %rsp

  leaq 15(%rsp), %r8

  andq $-16, %r8

Explanation:

  • The instruction “pushq %rbp” creates a stack element and pushes stack pointer.
  • The instruction “movq %rsp, %rbp” stores stack pointer into “%rbp”.
  • The instruction “subq $16, %rsp” allocates space for “i”.
    • It sets “s1” in “%rsp”.
  • The instruction “leaq 30(,%rdi,8), %rax” loads value at offset “8*%rdi+30 ” into register “%rax”.
  • The instruction “andq $-16, %rax” performs “AND” operation between given immediate value and value in register “%rax”.
  • The instruction “subq %rax, %rsp” allocates space for array “p”.
    • It sets “s2” in “%rsp”.
  • The instruction “leaq 15(%rsp), %r8” loads value at offset “%rsp+15 ” into register “%r8”

B.

Explanation of Solution

Logic in computation of p:

  • The expression for “p” is shown below:

    p=(s2 +15)&0

C.

Explanation of Solution

Values of n and s1:

  • The details of values are shown below:
whiche1ns1
Minimum1evenn%16==1
Maximum24oddn%16==0
  • The details of minimum case are shown below:
    • The “e1” cannot be 0, if “e1” equals 0, “p” should be equal to “s2”.
    • When “n” is even, “e1+e2==16”, if “e2” is 15, “e1” will be minimum value.
    • Hence, “s1==n” and “n%16==1

D.

Explanation of Solution

Alignment properties:

  • The value “p” is been aligned by 16.
  • The value “s2” denotes least multiple of 16...

Blurred answer
Students have asked these similar questions
It is known that when an information system processes data, a Linked Stack is used, and the name of the indicator pointing to the top of the stack is Top. When the input data enters the system, it needs to be stored in the stack first, and then the information system will extract the data from the stack to perform operations as required. it is known that the sequence of a set of integer data entering the aforementioned information system is as follows; 27, 98, 24, 9, 83 In the initial stage of the aforementioned information system, the Stack is in an empty state, and in the process of entering the above-mentioned integer data string into the information system, the operation sequence of the Stack is as follows; Push, Push, Pop, Push, Push, Push, Pop Please diagrammatically depict the Linked Stack of the information system at each stage of operation
Hi there, any help with the following would be greatly appreciated. Context in the image:Assume a register-based protocol for the function call. Show how this is achieved. You can assume– call-by-value;– variable v is stored in register $s0;– variable f is stored in register $s1.Explain if a stack frame is required, and justify your answer.
Consider the following generic C comparison function and its assembly language representation: C: byte comp (byte a, byte b); // a in rdi, b in rei Assembly: cmpb set_inst ret Srdi, trsi Bal Now show how the condition flags will be set with the corresponding SET instruction and the given values of a and b.. View Available Hint(s) 0 set_inst setne setb setge seta a14x49 10 375 49 46 Oxaa b -101 0x53 -46 CF 0 0 1 N ZF 0 0 0 SF 0 1 0 OF 0 0 0 Reset al 1 1 Help

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
    Systems Architecture
    Computer Science
    ISBN:9781305080195
    Author:Stephen D. Burd
    Publisher:Cengage Learning
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning