View Questions Only
View Questions with Strategies
(Instruction formats) Write a sequence of instructions that will compute the value of y = x2 + 2x + 3 for a given x using
Mult z, x, x
Mult y, 2, x
Add y, y, z
Add y, y, 3
Move z, x
Mult z, x
Move y, 3
Add y, z
Move z, x
Mult z, 2
Add y, z
Move x
Mult x
Store z
Move x
Mult 2
Add z
Add 3
Store y
(Addressing modes) Write procedures for reading from and writing to a FIFO queue, using a two-address format, in comjunction with:
Reading: Loadindirect R3, R1
Inc R1
Writing: Storeindirect R2, Data
Inc R2
Reading: Move temp, BR
Move BR, R1
Loadrel R4, offset
Inc R1
Move BR, temp
Writing: Move temp, BR
Move BR, R2
Storerel offset, Data
Inc R2
Move BR, temp
(Addressing modes) Write a sequence of instructions that will compute aixi where A = [a1, a2, ..., a100] and X = [x1, x2, ..., x100] represent arrays that are stored in the main memory. Use two-address instructions, in conjunction with:
Move Sum, 0
Load Temp1, 1000
Load Temp2, 2000
Mult Temp1, Temp2
Add Sum, Temp1
...
Load Temp1, 1099
Load Temp2, 2099
Mult Temp1, Temp2
Add Sum, Temp1
Move Sum, 0
Loadrel Temp1, 0
Loadrel Temp2, 100
Mult Temp1, Temp2
Add Sum, Temp1
...
Loadrel Temp1, 99
Loadrel Temp2, 199
Mult Temp1, Temp2
Add Sum, Temp1
Move Sum, 0
Move IR, 0
L1: Loadindex Temp1, 1000
Loadindex Temp2, 2000
Mult Temp1, Temp2
Add Sum, Temp1
Cmp IR, 100
Bne L1
(Instruction set) Add a dedicated base register ( BR ) to the 16-bit processor shown in Figure 9.9, and then show the changes this requires in the instruction set and the processor schematic.
Add one instruction to load the base:
Lbase Address : BR <-- Address
Change relative addressing:
Lrel Dest, Base : RF[Dest] <-- Mem[BR + Offset]
Srel Srcl, Base : Mem[BR + Offset] <-- RF[Srcl]
The processor would need to be modified in the following manner:
(Reduced instruction set) Using the instruction set presented in Figure 9.11, propose the changes that enable it so to accommodate a register file with:
(IS flowchart) Develop an IS flowchart for the reduced instruction set presented in Figure 9.11.
(Branch prediction) Write a program that will compute absolute value for the RISC processor shown in Figure 9.12. Develop a timing diagram for this processor,
To realize this algorithm using our RISC instructions on the processor without branch prediction, we could program it as follows:
Address | Instruction |
---|---|
100 | Bgeq a, 0, +9 |
101 | N o - op |
102 | N o - op |
103 | N o - op |
104 | sub val, 0, a |
105 | jump + 5 |
106 | N o - op |
107 | N o - op |
108 | N o - op |
109 | N o - op |
110 | ... |
Timing diagram when branch is not taken ( a < 0 )
Timing diagram when branch is taken ( a >= 0)
The program would change slightly when tuned for the processor with branch prediction
Address | Instruction |
---|---|
100 | Bgeq a, 0, +3 |
101 | sub val, 0, a |
102 | jump + 2 |
103 | mov val, a |
104 | ... |
Timing diagram when branch is not taken ( a < 0 )
Timing diagram when branch is taken ( a >= 0 )