C8 Computer organization · Practice
Problem set 1: the instruction cycle, instructions and memory
Problems dealt one at a time, with new numbers every time. The kinds you miss come back more often, and you can keep going as long as you like.
0 solved
0 in a row
0 of 16 kinds solid
Check
A program runs 5 million instructions at an average of 1.4 cycles each on a 400 MHz clock.
(a)
How long does it take?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
(b)
How many million instructions does it run per second?
Check
A program's first instruction is at 2000, and it runs straight through with no branches.
(a)
At what address is instruction number 3 (counting the first as 0)?
(b)
How many bytes do instructions 0 to 3 take?
Check
Consider addi x6, x0, 1.
(a)
What is its 32-bit encoding?
(b)
What does x6 hold after it runs?
Check
Encode the R-type instructions below (opcode 0x33, funct3 = 0).
(a)
add x7, x1, x30
(b)
sub x7, x1, x30
Check
An instruction word reads 00203693.
(a)
What register number is in its rs1 field (bits 19:15)?
(b)
What is its funct3 (bits 14:12)?
Check
A program builds a constant with lui t0, 74565 then addi t0, t0, 291.
(a)
What value does t0 hold?
(b)
What did t0 hold after the lui alone?
Check
An array of 4-byte elements starts at 1000.
(a)
What is the address of element 2?
(b)
How far apart are neighboring elements?
Check
The word AABBCCDD is stored at 0x1000 on this little-endian machine.
(a)
What byte is at 0x1000?
(b)
What does lbu from 0x1001 give?
Check
The byte AD is in memory.
(a)
What does lb load?
(b)
What does lbu load?
Check
A region of memory is addressed by the low 16 bits of the address.
(a)
How many bytes does it cover?
(b)
How many 32-bit words is that?
Check
A load uses the address 1004.
(a)
How many bytes past the start of its word is it? (0 means it's aligned for lw.)
(b)
At what address does the word containing it start?
Check
The stack pointer starts at 10000 and a function makes a frame of 4 words.
(a)
What does sp hold inside the function?
(b)
How many bytes is the frame?
Check
t0 = 25 and t1 = 3 when the instructions below run, in order.
(a)
sub t2, t0, t1 puts what in t2?
(b)
slli t3, t2, 2 then puts what in t3?
Check
Two 64-bit numbers are held as high and low words: (17, 4 × 10⁹) and (9, 8 × 10⁸).
(a)
What does add leave in the low word of the sum?
(b)
What is the high word of the sum?
Check
A branch instruction is 00628863. (B-type: bit 31 is imm[12], bits 30:25 imm[10:5], bits 11:8 imm[4:1], bit 7 imm[11].)
(a)
What byte offset does it encode?
(b)
What is its funct3?
Check
A CISC design runs 1 billion instructions at CPI 1.6; a RISC design needs 1.4 times as many at CPI 1.2. Both run at 2 GHz.
(a)
How long does the CISC design take?
Write units the way you normally would: 1.5 s and 1500 ms are the same answer.
(b)
And the RISC design?
A kind of problem counts as solid once you've got it right on the first try twice in a row. Back to the lesson · Practice every topic in C8