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
illustrate how a link list looks like at the end of each instruction when the following instructions are executed sequentially. show the head and tail pointers in each case. Question 1 slst = new(singly linked list) addToHead(slst, 11) addToHead(slst, 22) addToTail(slst, 33) addToTail(slst, 44) addToHead(slst, 55) deleteFromTail(slst) deleteFromHead(slst) delete(slst, 11) Link List_Example output
Explain the Memory stack organization of 16 locations of stack( 0 to 15). take the initial value of thestack pointer is SP = 0E in Hex. Explain the following push and pop instructions through the Memorystack organization diagram.(1) PUSH R5 WHERE R5 = XX in Hex(2) POP R4 WHERE R4 = (XX + 3 ) Hex for example roll no 64 is having the data in R5 = 64Hex and R4 is ( 64+3 = 67 Hex)
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.

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