Week 3 - Instruction Set Architectures (Part 1) Flashcards
What is an Instruction Set Architecture (ISA)?
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.
What are the three types of instructions in MIPS architecture?
Operate instructions (e.g., arithmetic operations).
Data movement instructions (e.g., load and store).
Control flow instructions (e.g., branches and jumps).
What is the von Neumann model, and what are its five components?
The von Neumann model is a computer architecture that consists of:
Memory
Processing unit
Input
Output
Control unit
What is RISC and how does it differ from CISC?
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.
What is a MIPS register file, and how many registers does it contain?
The MIPS register file contains 32 registers, each with 32 bits. Registers are used to store data temporarily during instruction execution.
How is an instruction represented in MIPS architecture?
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.
What are the three instruction formats in MIPS?
R-format (register)
I-format (immediate)
J-format (jump)
What is an example of an operate instruction in MIPS, and how is it represented?
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 are variables mapped to registers in MIPS assembly?
Variables in high-level programming languages are mapped to specific registers in MIPS, allowing for direct manipulation in assembly code.
What does the R-format in MIPS represent, and what are its components?
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)
What is the I-format in MIPS, and when is it used?
The I-format is used for instructions involving immediate values (constants), such as lw (load word) and addi (add immediate).
What is an example of a load word (lw) instruction in MIPS?
The lw instruction loads data from memory into a register. For example:
lw $s3, 8($s0) # $s3 = Memory[$s0 + 8]
How does MIPS branching work with conditional instructions?
MIPS uses instructions like beq (branch if equal) and bne (branch if not equal) to change control flow based on comparisons between registers.
How is an if-else statement implemented in MIPS assembly?
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:
What is a for loop in MIPS assembly?
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:
What is the jump and link (jal) instruction in MIPS, and when is it used?
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.
How does a function call work in MIPS?
A function call involves passing arguments in registers ($a0–$a3), using jal to jump to the function, and returning a value in $v0.
What are the conventions for passing arguments and returning values in MIPS?
Arguments: Passed in registers $a0 to $a3.
Return value: Stored in register $v0.
What is the purpose of the program counter (PC) in MIPS architecture?
The program counter (PC) holds the address of the current instruction and is automatically updated to point to the next instruction in sequence.
What is the function of the ALU in MIPS?
The ALU (Arithmetic Logic Unit) performs all arithmetic and logical operations, such as addition, subtraction, and comparisons, based on the instructions received.