Module 7 - Procedures in Assembly Flashcards

1
Q
What register stores a temporary value that the caller procedure must save before calling a nested procedure?
  $sp
  $t0
  $ra
  $s0
  $at
  $v0
  $a0
A

$t0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
What register does the “jal” instruction automatically update?
  $at
  $ra
  $a0
  $sp
  $v0
  $s0
  $t0
A

$ra

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What register stores a temporary value that the callee procedure must save before performing it’s task?

  $s0
  $t0
  $ra
  $sp
  $at
  $a0
  $v0
A

$s0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the main reasons for writing procedures in assembly programs? Select all that apply.

Easier to understand and to debug
Avoiding use the jump table
Higher performance in terms of execution time
Easier to reuse the code

A

Easier to understand and to debug

Easier to reuse the code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
What register stores a parameter value of a procedure?
  $s0
  $v0
  $at
  $a0
  $sp
  $ra
  $t0
A

$a0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

A procedure does not call another procedure. How does it differ from a procedure that does call another procedure?

Register $ra does not need to be saved to stack
It does not need any arguments (no inputs
It does not return any values (no outputs)
Its return address does not need to be saved in $ra

A

Register $ra does not need to be saved to stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

In MIPS, the stack pointer is manipulated using the instruction

addiu $sp, $sp, XX
where “XX” is a number that may be positive or negative.

If we need to reserve enough room on the stack for 6 integers in addition to the $ra register, what is the value of XX?

A

-28

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
In a procedure call, the $ra register is used for what purpose?
  Temporary scratch storage.
  Storing the return address
  Passing Parameters
  Storing return values
A

Storing the return address

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
A set of registers are reserved for procedure calls. How do we preserve all values when a procedure calls another procedure?
  Use floating point registers
  Use temporary registers
  Use heap memory
  Use stack memory
A

Use stack memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
In a procedure call, what is responsible for saving the $ra registers?
  Operating System
  Caller Procedure
  Stack
  Callee Procedure
A

Caller Procedure

How well did you know this?
1
Not at all
2
3
4
5
Perfectly