CS350 Intro Computer Systems Homework

Homework 9 on Issues in Pipelining

While it increases the throughput of a computer system, pipelining presents challenges in data hazards, branch misprediction and return among others as we discussed in class. Fill the yellow cells of the spreadsheet with values when the three sets of instructions shown below are executed on the pipepline.

  1. data hazards: page 27 of lecture note 04-pipeline-a.pptx:
    0x000: irmovq $10,%rdx
    0x00a: irmovq $3,%rax
    0x014: addq %rdx,%rax
    0x016: halt
    
  2. branch misprediction: page 28 of lecture note 04-pipeline-a.pptx:
    0x000:    xorq %rax,%rax 
    0x002:    jne  t             # Not taken
    0x00b:    irmovq $1, %rax    # Fall through
    0x015:    nop
    0x016:    nop
    0x017:    nop
    0x018:    halt
    0x019: t: irmovq $3, %rdx    # Target (Should not execute)
    0x023:    irmovq $4, %rcx    # Should not execute
    0x02d:    irmovq $5, %rdx    # Should not execute
    
  3. return: page 30 of lecture note 04-pipeline-a.pptx:
    0x000:    irmovq Stack,%rsp  # Intialize stack pointer
    0x00a:    nop                  # Avoid hazard on %rsp
    0x00b:    nop
    0x00c:    nop
    0x00d:    call p               # Procedure call
    0x016:    irmovq $5,%rsi       # Return point
    0x020:    halt
    0x020: .pos 0x20
    0x020: p: nop                   # procedure
    0x021:    nop
    0x022:    nop
    0x023:    ret
    0x024:    irmovq $1,%rax        # Should not be executed
    0x02e:    irmovq $2,%rcx        # Should not be executed
    0x038:    irmovq $3,%rdx        # Should not be executed
    0x042:    irmovq $4,%rbx        # Should not be executed
    0x100: .pos 0x100
    0x100: Stack:                   # Initial stack pointer