Function Items Flashcards

1
Q

What is a function in programming

A

a stored subroutine that performs a specific task based on the parameters with which it is provided

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

How do we name and label a function in MIPS

A

same way as a reg label and there is no different between that and other labels.

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

How do we call a function in MIPS

A

jal function_name

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

How do we return from function in MIPS?

A

jr $ra

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

Where do we return from the function? In other words, what will be the next instruction executed after the function return?

A

the next instruction executed is the one immediately following the jal

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

What is caller?

A

the program that instigates a procedure and provides the necessary parameter values

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

Callee

A

a procedure that executes a series of store instructions based on parameters provided by the caller and then returns control to the caller

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

Stack pointer

A

a value denoting the most recently allocated address in a stack that shows where registers should be spilled or where old register values can be found. In MIPS, it is register $sp. The top of the stack

The stack pointer is adjusted by one word for each register that is saved or restored.

The stack grows from a higher address to a lower address

You push values onto the stack by subtracting from the stack pointer. Adding to the stack pointer shrinks the stack, and thereby pops values off of it.

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

What are MIPS function calling conventions regarding s-registers.

A

$s0 - $s7: saved registers that must be preserved on a procedure call (if used, the callee saves and restores them)

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

t-registers

A

$t0 - $t9: temporary registers that are not preserved by the callee on a procedure call

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

Where do we save the value of the register?

A

On stack

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