Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can use no-ops as well to fix data hazards and the jump instruction must be moved up with delay slots added. Problem 1. Using the

Can use no-ops as well to fix data hazards and the jump instruction must be moved up with delay slots added.

image text in transcribed

Problem 1. Using the following psudo-code and a assuming a 4 stage pipeline (Instruction fetch, instruction decode, execute, write back) show how instruction reordering, loop unrolling and branch delay slots could be used to fix data and control hazards. The ; character denote the start of a comment. ; increment all the values in an array by 1. Ox00000100: mov ri, Oxffffffff ; load -1 into ri. Ox00000104: mov r2, Ox0000fff8 ; load start of array. Ox00000108: mov r3, 0x00000200 ; load size of array, 1024 items. Ox0000010c: mov r4, 0x00000001 ; load constant to increment values by. Ox00000110: add r5, r2, r3 ; save the max index. Ox00000114: mov r6, [r2] ; start of loop. load array value to be worked on. Ox00000118: add r6, r6, r4 ; perform the increment. Ox0000011c: add r2, r2, r4 ; update the array pointer. Ox00000120: cmp r7, r5, r2 ; have we hit the max index? 1 means no. Ox00000124: jp [0x00000114], r7 ; if we have more to do, jump to start of loop. Ox00000128: hlt ; we have finished updating the array. Intructions are: mov DST, SRC: Moves the value held in the SRC register to the DST register. mov DST, OxImm: Stores the value of Imm in the DST register. Imm is a 4 byte value. mov DST, (SRC): Moves the value held in memory at the location pointed to by the SRC register to the DST register. mov DST, [OxImm]: Moves the value held in memory at the location pointed to by the value Imm in the DST register. Imm is a 4 byte value. mov [OxImm], SRC: Moves the value held in the SRC register to the memory location pointed to by the value Imm. mov [DST], SRC: Moves the value held in the SRC register to the memory location pointed to by the DST register. add DST, SRC, TRG: Stores the result of SRC + TRG in DST. neg DST: Negates the result of DST and stores it in DST. cmp DST, SRC, TRG: Stores a 1 in DST if, and only if, SRC - TRG is a positive number, greater than 0. jp [Addr], SRC: If the register SRC contains a positive number, load the instruction pointer to by Addr instruction buffer and update the instruction pointer to Addr + 1. Problem 1. Using the following psudo-code and a assuming a 4 stage pipeline (Instruction fetch, instruction decode, execute, write back) show how instruction reordering, loop unrolling and branch delay slots could be used to fix data and control hazards. The ; character denote the start of a comment. ; increment all the values in an array by 1. Ox00000100: mov ri, Oxffffffff ; load -1 into ri. Ox00000104: mov r2, Ox0000fff8 ; load start of array. Ox00000108: mov r3, 0x00000200 ; load size of array, 1024 items. Ox0000010c: mov r4, 0x00000001 ; load constant to increment values by. Ox00000110: add r5, r2, r3 ; save the max index. Ox00000114: mov r6, [r2] ; start of loop. load array value to be worked on. Ox00000118: add r6, r6, r4 ; perform the increment. Ox0000011c: add r2, r2, r4 ; update the array pointer. Ox00000120: cmp r7, r5, r2 ; have we hit the max index? 1 means no. Ox00000124: jp [0x00000114], r7 ; if we have more to do, jump to start of loop. Ox00000128: hlt ; we have finished updating the array. Intructions are: mov DST, SRC: Moves the value held in the SRC register to the DST register. mov DST, OxImm: Stores the value of Imm in the DST register. Imm is a 4 byte value. mov DST, (SRC): Moves the value held in memory at the location pointed to by the SRC register to the DST register. mov DST, [OxImm]: Moves the value held in memory at the location pointed to by the value Imm in the DST register. Imm is a 4 byte value. mov [OxImm], SRC: Moves the value held in the SRC register to the memory location pointed to by the value Imm. mov [DST], SRC: Moves the value held in the SRC register to the memory location pointed to by the DST register. add DST, SRC, TRG: Stores the result of SRC + TRG in DST. neg DST: Negates the result of DST and stores it in DST. cmp DST, SRC, TRG: Stores a 1 in DST if, and only if, SRC - TRG is a positive number, greater than 0. jp [Addr], SRC: If the register SRC contains a positive number, load the instruction pointer to by Addr instruction buffer and update the instruction pointer to Addr + 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Life Audit

Authors: Michelle Moroney

1st Edition

978-0717184736

More Books

Students also viewed these Accounting questions