In RISC-V, the register named zero always reads as 0.
5 Assembly Concepts Online Quiz Questions
Use this free practice quiz with 20 questions to review 5 Assembly Concepts, test your knowledge, and prepare for your next test or exam.
A RISC-V register t0 contains 8. After executing addi t0, t0, 3, what value does t0 contain?
- A
8
- B
11
- C
3
- D
0
A names a location in a program so a branch can refer to that destination symbolically.
In the RISC-V examples, li is a pseudoinstruction provided as assembler shorthand.
- A
True
- B
False
Consider beq t0, t1, equal. If t0 and t1 contain the same value when this instruction executes, what happens next?
- A
Execution always continues with the next instruction.
- B
Execution transfers to
equal. - C
Execution transfers to
equalonly when the register values differ. - D
The instruction changes
t0andt1but does not affect control flow.
When a called procedure returns normally, control resumes at the instruction after the caller's call.
- A
True
- B
False
Select all statements that describe the standard RISC-V register conventions presented for procedures.
- A
a0is used for the first argument and the return value. - B
raholds the return address. - C
spis the stack pointer. - D
t0–t6are temporary registers. - E
a1is the stack pointer. - F
x0holds the return address.
A procedure that calls another procedure may need to save its own before making the call, because the new call updates ra.
A program uses RISC-V registers such as a0 and the bge instruction. Which conclusion about using that program on a different processor architecture is best supported?
- A
Assembly instructions use the same registers and names on every processor.
- B
Assembly programs may need changes for another processor architecture, including changes to registers or instruction names.
- C
An assembler automatically makes every program architecture-independent.
- D
Only labels, not instructions or registers, depend on the processor architecture.
The sum_to_n procedure accumulates the integers from 1 through its positive input. What result does it return when n=6?
Consider this portion of sum_to_n. Select all statements that correctly describe its behavior.
- A
t0is initialized as the counter andt1as the accumulator. - B
The counter is incremented before the branch decides whether to repeat.
- C
The branch repeats while
t1is less than or equal toa0. - D
The branch repeats when
a0is greater than or equal tot0. - E
The accumulator is initialized with the value in
a0.
A procedure initializes its sum register to 0, then executes bge zero, a0, done before its loop. If a0 contains a negative input, what does this branch cause the procedure to do?
- A
The loop runs once and returns 1.
- B
The branch goes to
done, so the procedure returns 0. - C
The procedure increments
a0until it becomes positive. - D
The branch goes to
loopand repeats untila0is zero.
Describe how you could translate a loop that accumulates a running total into assembly. Explain how you would represent its changing values, repeated work, loop condition, and final result, without writing a complete program.
What does the RISC-V instruction addi t0, t0, 1 do?
- A
It adds the values in
t0andt1and stores the result int0. - B
It adds 1 to the value in
t0and stores the result int0. - C
It copies the value in
t0intot1. - D
It loads the value 1 into
t0, replacing its previous value.
In assembly code, what role does a label such as equal play when used as the destination in a branch instruction?
- A
A register reserved for storing branch conditions.
- B
A constant that an instruction adds to a register.
- C
A name for a location in the program that can be used as a branch or jump destination.
- D
A directive that changes the processor architecture.
In RISC-V assembly, what is the role of li in an instruction such as li t0, 1?
- A
It is a pseudoinstruction that loads an immediate value.
- B
It is a branch that runs only when two registers are equal.
- C
It is a register name for the return address.
- D
It is a label that marks the end of a procedure.
What happens when the processor executes beq t0, t1, equal and the values in t0 and t1 are not equal?
- A
It always transfers control to the destination.
- B
It transfers control if the first register is less than the second.
- C
It transfers control if the two registers are different.
- D
It transfers control if the two registers are equal; otherwise, execution continues with the next instruction.
For the sum_to_n procedure shown, if the caller places 5 in a0, what integer result is returned in a0?
In RISC-V, t4 contains −7 and t5 contains 12. What value does this instruction write to t3?
In RISC-V, t0 contains −3 and t1 contains 2. Is the branch taken?