C8 Computer organization · Practice
Assembly functions lab
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
a0 points to an array of a1 signed words (here 5). Return the largest 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
a0 points to the string "hello, world" (ending in a zero byte), and a1 holds a character code. Return in a0 how many times that character appears.
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
Count the 1 bits in a0 and return the count in a1.
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
Copy a2 words from the address in a0 to the address in a1 (here 4 words, from src to dst).
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
Return in a0 the greatest common divisor of a0 and a1, using Euclid's algorithm with remu.
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
square (provided) returns a0² and clobbers t0 and t1. With n in a0, call it for each i from 1 to n and return the sum of the squares 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
Write sum recursively: sum(0) = 0 and sum(n) = n + sum(n − 1). Main calls it with n in a0. Each level must save what it needs on the stack, and sp must end where it started.
RISC-V RV32IM (base integer plus multiply and divide). End your program with ebreak. Tab indents; press Esc and then Tab to move on.
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