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
Question
Book Icon
Chapter 4.5, Problem 4.44PP

A.

Program Plan Intro

Assembly code for Conditional jump:

long absSum(long *start, long count)

start in %rdi, count in %rsi

absSum:

irmovq $8, %r8

irmovq $1, %r9

xorq %rax, %rax     

andq %rsi, %rsi

jmp test

loop:

mrmovq (%rdi),%r10

xorq %r11, %r11

subq %r10, %r11

jle pos

rrmovq %r11, %r10

pos:

addq %r10, %rax

addq %r8, %rdi

subq %r9, %rsi

test:

jne loop

ret

Assembly code for Conditional move:

long absSum(long *start, long count)

start in %rdi, count in %rsi

absSum:

irmovq $8, %r8

irmovq $1, %r9

xorq %rax, %rax

andq %rsi, %rsi

jmp test

loop:

mrmovq (%rdi),%r10

xorq %r11, %r11

subq %r10, %r11

cmovg %r11, %r10

addq %r10, %rax

addq %r8, %rdi

subq %r9, %rsi

test:

jne loop

ret

Processing stages:

  • The processing of an instruction has number of operations.
  • The operations are organized into particular sequence of stages.
  • It attempts to follow a uniform sequence for all instructions.
  • The description of stages are shown below:
    • Fetch:
      • It uses program counter “PC” as memory address to read instruction bytes from memory.
      • The 4-bit portions “icode” and “ifun” of specifier byte is extracted from instruction.
      • It fetches “valC” that denotes an 8-byte constant.
      • It computes “valP” that denotes value of “PC” plus length of fetched instruction.
    • Decode:
      • The register file is been read with two operands.
      • It gives values “valA” and “valB” for operands.
      • It reads registers with instruction fields “rA” and “rB”.
    • Execute:
      • In this stage the ALU either performs required operation or increments and decrements stack pointer.
      • The resulting value is termed as “valE”.
      • The condition codes are evaluated and destination register is updated based on condition.
      • It determines whether branch should be taken or not in a jump instruction.
    • Memory:
      • The data is been written to memory or read from memory in this stage.
      •  The value that is read is determined as “valM”.
    • Write back:
      • The results are been written to register file.
      • It can write up to two results.
    • PC update:
      • The program counter “PC” denotes memory address to read bytes of instruction from memory.
      • It is used to set next instruction’s address.

B.

Program Plan Intro

Assembly code for Conditional jump:

long absSum(long *start, long count)

start in %rdi, count in %rsi

absSum:

irmovq $8, %r8

irmovq $1, %r9

xorq %rax, %rax     

andq %rsi, %rsi

jmp test

loop:

mrmovq (%rdi),%r10

xorq %r11, %r11

subq %r10, %r11

jle pos

rrmovq %r11, %r10

pos:

addq %r10, %rax

addq %r8, %rdi

subq %r9, %rsi

test:

jne loop

ret

Assembly code for Conditional move:

long absSum(long *start, long count)

start in %rdi, count in %rsi

absSum:

irmovq $8, %r8

irmovq $1, %r9

xorq %rax, %rax     

andq %rsi, %rsi

jmp test

loop:

mrmovq (%rdi),%r10

xorq %r11, %r11

subq %r10, %r11

cmovg %r11, %r10

addq %r10, %rax

addq %r8, %rdi

subq %r9, %rsi

test:

jne loop

ret

Processing stages:

  • The processing of an instruction has number of operations.
  • The operations are organized into particular sequence of stages.
  • It attempts to follow a uniform sequence for all instructions.
  • The description of stages are shown below:
    • Fetch:
      • It uses program counter “PC” as memory address to read instruction bytes from memory.
      • The 4-bit portions “icode” and “ifun” of specifier byte is extracted from instruction.
      • It fetches “valC” that denotes an 8-byte constant.
      • It computes “valP” that denotes value of “PC” plus length of fetched instruction.
    • Decode:
      • The register file is been read with two operands.
      • It gives values “valA” and “valB” for operands.
      • It reads registers with instruction fields “rA” and “rB”.
    • Execute:
      • In this stage the ALU either performs required operation or increments and decrements stack pointer.
      • The resulting value is termed as “valE”.
      • The condition codes are evaluated and destination register is updated based on condition.
      • It determines whether branch should be taken or not in a jump instruction.
    • Memory:
      • The data is been written to memory or read from memory in this stage.
      •  The value that is read is determined as “valM”.
    • Write back:
      • The results are been written to register file.
      • It can write up to two results.
    • PC update:
      • The program counter “PC” denotes memory address to read bytes of instruction from memory.
      • It is used to set next instruction’s address.

C.

Program Plan Intro

Assembly code for Conditional jump:

long absSum(long *start, long count)

start in %rdi, count in %rsi

absSum:

irmovq $8, %r8

irmovq $1, %r9

xorq %rax, %rax     

andq %rsi, %rsi

jmp test

loop:

mrmovq (%rdi),%r10

xorq %r11, %r11

subq %r10, %r11

jle pos

rrmovq %r11, %r10

pos:

addq %r10, %rax

addq %r8, %rdi

subq %r9, %rsi

test:

jne loop

ret

Assembly code for Conditional move:

long absSum(long *start, long count)

start in %rdi, count in %rsi

absSum:

irmovq $8, %r8

irmovq $1, %r9

xorq %rax, %rax     

andq %rsi, %rsi

jmp test

loop:

mrmovq (%rdi),%r10

xorq %r11, %r11

subq %r10, %r11

cmovg %r11, %r10

addq %r10, %rax

addq %r8, %rdi

subq %r9, %rsi

test:

jne loop

ret

Processing stages:

  • The processing of an instruction has number of operations.
  • The operations are organized into particular sequence of stages.
  • It attempts to follow a uniform sequence for all instructions.
  • The description of stages are shown below:
    • Fetch:
      • It uses program counter “PC” as memory address to read instruction bytes from memory.
      • The 4-bit portions “icode” and “ifun” of specifier byte is extracted from instruction.
      • It fetches “valC” that denotes an 8-byte constant.
      • It computes “valP” that denotes value of “PC” plus length of fetched instruction.
    • Decode:
      • The register file is been read with two operands.
      • It gives values “valA” and “valB” for operands.
      • It reads registers with instruction fields “rA” and “rB”.
    • Execute:
      • In this stage the ALU either performs required operation or increments and decrements stack pointer.
      • The resulting value is termed as “valE”.
      • The condition codes are evaluated and destination register is updated based on condition.
      • It determines whether branch should be taken or not in a jump instruction.
    • Memory:
      • The data is been written to memory or read from memory in this stage.
      •  The value that is read is determined as “valM”.
    • Write back:
      • The results are been written to register file.
      • It can write up to two results.
    • PC update:
      • The program counter “PC” denotes memory address to read bytes of instruction from memory.
      • It is used to set next instruction’s address.

Blurred answer
Students have asked these similar questions
8(s+1)(s+2) Exercise 3: A transfer function is given as T(s) = (s+10) (s+3)(s+4)' a. Use MATLAB function zpk() to define the transfer function. b. Use MATLAB command zplane() to obtain the zero-pole plot of the T (s). c. Use MATLAB to plot the step and ramp response of the system. d. Think about a way to plot the ramp response of the system by still using the MATLAB function step().
f. Suppose that we are developing a new version of the AMD Barcelona processor with a 4 GHz clock rate. We have added some additional instructions to the instruction set in such a way that the number instructions has been reduced by 15%. The execution time is reduced to 700 s and the new SPECratio is 13.7. Find the new CPI. Ans. 1.37 g. This CPI value is larger than obtained in (a) as the clock rate was increased from 3 GHz to 4 GHz. Determine whether the increase in the CPI is similar to that of the clock rate. If they are dissimilar, why? Ans. 1.33, 1.45 h. By how much has the CPU time been reduced? Ans. 6.7% i. For a second benchmark, libquantum, assume an execution time of 960 ns, CPI of 1.61, and clock rate of 3 GHz. If the execution time is reduced by an additional 10% without affecting the CPI and with a clock rate of 4 GHz, determine the number of instructions. Ans. 2146 j. Determine the clock rate required to give a further 10% reduction in CPU time while maintaining the…
4. A particular piece of loop iteration requires 6 registers, 2 of which are used to track array indices / loop counters. The other 4 registers are used to hold load values, compute results and store results. If the architecture has 32 general-purpose registers, then how many times can the loop be unrolled by the compiler?

Chapter 4 Solutions

Computer Systems: A Programmer's Perspective (3rd Edition)

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education