Week 3 - Instruction Set Architectures (Part 1) Flashcards

1
Q

What is an Instruction Set Architecture (ISA)?

A

The ISA is the part of a computer’s architecture that defines the set of instructions the processor can execute, including how instructions are formatted and how they operate on data.

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

What are the three types of instructions in MIPS architecture?

A

Operate instructions (e.g., arithmetic operations).
Data movement instructions (e.g., load and store).
Control flow instructions (e.g., branches and jumps).

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

What is the von Neumann model, and what are its five components?

A

The von Neumann model is a computer architecture that consists of:

Memory
Processing unit
Input
Output
Control unit

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

What is RISC and how does it differ from CISC?

A

RISC stands for Reduced Instruction Set Computer, which uses a small set of simple instructions. CISC (Complex Instruction Set Computer) has more complex instructions, such as the Intel x86 architecture.

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

What is a MIPS register file, and how many registers does it contain?

A

The MIPS register file contains 32 registers, each with 32 bits. Registers are used to store data temporarily during instruction execution.

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

How is an instruction represented in MIPS architecture?

A

MIPS instructions are represented as 32-bit binary words, which are encoded as machine code. The Instruction Set Architecture (ISA) defines the binary format and execution behavior.

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

What are the three instruction formats in MIPS?

A

R-format (register)
I-format (immediate)
J-format (jump)

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

What is an example of an operate instruction in MIPS, and how is it represented?

A

An example is the add instruction, which adds two registers and stores the result in a third register:

add $s0, $s1, $s2   # $s0 = $s1 + $s2
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How are variables mapped to registers in MIPS assembly?

A

Variables in high-level programming languages are mapped to specific registers in MIPS, allowing for direct manipulation in assembly code.

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

What does the R-format in MIPS represent, and what are its components?

A

The R-format is used for register-to-register operations and includes:

op (opcode)
rs (source register 1)
rt (source register 2)
rd (destination register)
shamt (shift amount)
funct (function code)

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

What is the I-format in MIPS, and when is it used?

A

The I-format is used for instructions involving immediate values (constants), such as lw (load word) and addi (add immediate).

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

What is an example of a load word (lw) instruction in MIPS?

A

The lw instruction loads data from memory into a register. For example:

lw $s3, 8($s0)   # $s3 = Memory[$s0 + 8]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How does MIPS branching work with conditional instructions?

A

MIPS uses instructions like beq (branch if equal) and bne (branch if not equal) to change control flow based on comparisons between registers.

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

How is an if-else statement implemented in MIPS assembly?

A

An if-else statement is implemented using conditional branch instructions and jumps:

bne $s3, $s4, else   # if ($s3 != $s4) go to else
add $s0, $s1, $s2    # if true, execute this
j done               # jump to done
else: sub $s0, $s0, $s3  # if false, execute this
done:
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a for loop in MIPS assembly?

A

A for loop can be implemented using conditional branches and jumps. Example for summing numbers from 0 to 9:

addi $s1, $zero, 0   # sum = 0
addi $s0, $zero, 0   # i = 0
addi $t0, $zero, 10  # end condition
for: beq $s0, $t0, done   # if i == 10, exit loop
     add $s1, $s1, $s0    # sum = sum + i
     addi $s0, $s0, 1     # i++
     j for
done:
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the jump and link (jal) instruction in MIPS, and when is it used?

A

The jal instruction is used to call a function. It stores the return address in the $ra (return address) register and jumps to the function.

17
Q

How does a function call work in MIPS?

A

A function call involves passing arguments in registers ($a0–$a3), using jal to jump to the function, and returning a value in $v0.

18
Q

What are the conventions for passing arguments and returning values in MIPS?

A

Arguments: Passed in registers $a0 to $a3.
Return value: Stored in register $v0.

19
Q

What is the purpose of the program counter (PC) in MIPS architecture?

A

The program counter (PC) holds the address of the current instruction and is automatically updated to point to the next instruction in sequence.

20
Q

What is the function of the ALU in MIPS?

A

The ALU (Arithmetic Logic Unit) performs all arithmetic and logical operations, such as addition, subtraction, and comparisons, based on the instructions received.