C8 Computer organization · Practice
Arrays and strings in 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
An array of 8-byte elements starts at 1000. What is the address of element 3?
Check
The byte AD is loaded with lb. What signed value does the register hold?
Check
Add the five words of the array vals and leave the sum in a0.
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 10 × n in a1 using shifts and adds (no multiply).
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
The array vals holds the words 1, 2, 3, and so on. With its address in a0 and a count n in a1, put the sum of the first n words 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
A string of 12 characters is measured by a loop of four instructions per character, plus two for the terminating zero.
(a)
How many instructions run?
(b)
And with the test moved to the bottom (load, increment, branch back), plus 3 instructions around it?
Check
How many bytes does a 12-character C string occupy?
Check
The byte 2E is loaded with lb. What value results?
Check
How many bytes past the start does the end pointer of a 50-word array sit?
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