(a) Load value at index address of 1 into R.
Load value at index address of 1 into S.
Load value at index address of (k-3) into T(based on the value of k).
Add R and S and store them into AC.
Load value from S into R.
Load value from AC into S.
Decrement T.
Loop until T reaches 0 value and if the accumulator reaches 0 pc(program counter) will be set to given address 4.
Store AC into memory location M.
(b) Unless the processor can give effect to the branch in a single time cycle, the pipeline will continue fetching instructions sequentially. Such instructions cannot be allowed to take effect because the programmer has diverted control to another part of the program. So a branch out of the normal sequence often involves a hazard.
The processor in a conditional branch may or may not branch, depending upon a calculation that has not yet occurred which makes it even more problematic. Many different processors may begin to execute 2 different program sequences, both assuming the branch is and is not taken, discarding all work that pertains to incorrect guess.
A processor with the implementation of branch prediction that usually makes correct predictions can minimize the performance penalty from branching. However, if branches are predicted poorly, it may create more work for the processor such as flushing from the pipeline the incorrect code path.
Programs that are written for the pipelined processor deliberately avoid branching to minimize possible loss of speed.
(c) Branch delay slots are one of the features of RISC architectures. The RISC is known to be pipelined, so while the current instruction is in execution, the following instructions will be in pipeline already. If there is, for example, a conditional branch in the instruction stream, the CPU cannot know whether the next instruction is the one following the branch or the instruction at the target location until it has evaluated the branch. This would cause a bubble in the pipeline; therefore some RISC architectures have a branch delay slot. The instruction after the branch will always be executed, no matter whether the branch is taken or not.
Consider the following assembly code. 1. 1, LOAD R, #1 2, LOADS, #1 3, LOAD T, #(k-3) 4. ADD AC, R, S 5. LOAD R, S 6. LOAD S, AC 8. BRP 4, T 9. STOR AC, M where R, S, T, AC are is addressing and...
Op-code Operand Description 1 RXY LOAD register R from cell XY 2 RXY LOAD register R with value XY 3 RXY STORE register R in cell XY 4 0RS MOVE R to S 5 RST ADD S and T into R (2’s comp.) 6 RST ADD S and T into R (floating pt.) 7 RST OR S and T into R 8 RST AND S and T into R 9 RST XOR S and T into R A R0X ROTATE...
Consider the following code segment. int[]arr={1, 2, 3, 4, 5, 6, 7, 8}; for(int k=3; k<arr.length-1; R++ arr[k]-arr[k+1]; What are the contents of arr as a result of executing the code segment? a. {1, 2, 3, 5, 6, 7, 8, 8) b. {2, 2, 4, 5, 6, 7, 8, 8} C. {2, 4, 6, 5, 6, 7, 8,8} d. {4, 2, 4, 4, 6, 7, 8, 8) e. {6, 6, 4, 5, 6, 7, 8, 8} int) arr={7, 2.5, 3.0,...
Question 8 (Chapters 6-7) 12+2+2+3+2+4+4-19 marks] Let 0メS C Rn and fix E S. For a E R consider the following optimization problem: (Pa) min a r, and define the set K(S,x*) := {a E Rn : x. is a solution of (PJ) (a) Prove that K(S,'). Hint: Check 0 (b) Prove that K(S, r*) is a cone. (c) Prove that K(S,) is convex d) Let S C S2 and fix eS. Prove that K(S2, ) cK(S, (e) Ifx. E...
Questions1. The function L is defined as L(1) = 2,L(2) = 1,L(3) = 3,L(4) = 4 and for n ≥ 4,L(n + 1) = L(n) + L(n − 1) + L(n − 2)L(n − 3)i.e., the (n + 1)-th value is given by the sum of the n-th, n − 1-th and n − 2-th values divided by the n − 3-th value.(a) Write an assembly program for computing the k-th value L(k), where k is an integer bigger than...
Question 2 Consider the system shown in Figure Q2, where Wis a unit step disturbance and R is a unit step input. 0.4 s+ 1 10 Figure Q2 (5 marks) (3 marks) (c) Find the value for K so that the steady state error due to w(t) is less than 0.01; 6 marks) (d) In order to eliminate the steady state error, show whether a PI controller can be successful 6 marks) (a) Find the expression of E(s)-R(s)-Y(s) in terms...
Question 2 Consider the system shown in Figure Q2, where Wis a unit step disturbance and R is a unit step input. 0.4 s+ 1 10 Figure Q2 (5 marks) (3 marks) (c) Find the value for K so that the steady state error due to w(t) is less than 0.01; 6 marks) (d) In order to eliminate the steady state error, show whether a PI controller can be successful 6 marks) (a) Find the expression of E(s)-R(s)-Y(s) in terms...
7 [24 marks] Consider the following MIPS code segment that is executed on a 5-stage pipeline architecture that does not implement forwarding or stalling in hardware. (1) add $4, $1, $1 (2) add $7, $4, $9 (3) lw $2, 40($8) (4) sub $8, $1, $2 (5) sw $8, 80(S2) (6) sub $2, $8, $4 (7) lw S8, 2($1) (8) add $8, $4, S2 Identify the data dependences that cause hazards. You are to use the following format to inform each...
Consider the following operations: A B- C The corresponding assembly code instruction list generated by a compiler are 1 load [%r0 +4], %r1 2 load [%r0 + 8], %r2 3 sub %r1, %r2,%r3 4 load [ZrO + 12], %r4 5 add %r3, %r4 , %r5 6 store %r3, [%r0 + 16] 7 store %r5, [%r0 + 20] a) Identify the potential pipeline hazards. (10 points) b) State if the found hazards can be eliminated and if so propose a scheme...
QUESTION 8 The velocity of a particle is v-1 9 i + (3-2) j m/s, where t is in seconds. If r:0 when particle in the y direction during the interval t 1 sto t 4 s 0, determine the displacement of the QUESTION 8 The velocity of a particle is v-1 9 i + (3-2) j m/s, where t is in seconds. If r:0 when particle in the y direction during the interval t 1 sto t 4 s...
Accumulation Pattern Problem 2 Consider the code below. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 labs = ['lab1', 'lab2', 'lab3', 'lab4', 'lab5', 'lab6', 'lab7', 'lab8', 'lab9'] graded = '' for lab in labs: lab_num = int(lab[3]) if lab_num < 4: graded = graded + lab + ' is simple\n' elif lab_num < 7: graded = graded + lab + ' is ok\n' else: graded = graded + lab + ' is complex\n' ...