C8 Computer organization · Practice
RISC-V instructions and assembly
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.
Check
RV32I has no multiply instruction. With n in a0, put 5 × n in a1 using shifts and adds.
RISC-V RV32IM (base integer plus multiply and divide). End your program with ebreak. Tab indents; press Esc and then Tab to move on.
Check
With n in a0, put n with its lowest 4 bits cleared into a1. Use one instruction before the ebreak.
RISC-V RV32IM (base integer plus multiply and divide). End your program with ebreak. Tab indents; press Esc and then Tab to move on.
Check
Encode addi x12, x0, 217 as a 32-bit word in hex.
Check
The assembler splits li a0, 0x066228D8 into lui and addi. What 20-bit value does lui load?
Check
What's the largest value a signed 8-bit immediate can hold?
Check
a0 holds a negative number and a1 a shift amount. Put a0 shifted right arithmetically by a1 into a2.
RISC-V RV32IM (base integer plus multiply and divide). End your program with ebreak. Tab indents; press Esc and then Tab to move on.
Check
t0 holds −99 and is shifted right by 1.
(a)
What does srai give?
(b)
What does srli give, as an unsigned number?
Check
With n in a0, put 9 × n in a1 using shifts and adds.
RISC-V RV32IM (base integer plus multiply and divide). End your program with ebreak. Tab indents; press Esc and then Tab to move on.
Check
Smallest value of a signed 10-bit field?
Check
addi x12, x0, 217 in hex?
Check
t0 holds 36. What does slli t1, t0, 1 put in t1?
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