Optional C-preprocessor directive that defines a named constant.
25
New cards
Comment styles to use in .S files
// for single-line comments and /* ... */ for multi-line comments. AVOID the native MIPS # comment.
26
New cards
Label
A name followed by a colon (e.g. string:) that represents an address. Used for variables, constants, and branch/jump targets.
27
New cards
Assembler directive
A keyword starting with "." that gives the assembler instructions (e.g. .word, .data). It is not a CPU instruction.
28
New cards
.word
Reserves one 32-bit word (4 bytes) per value, initialized to the given value. Example: .word 3456
29
New cards
.byte
Reserves 1 byte per value. You can list more than one value per line. Example: .byte 0x41, 'B'
30
New cards
.space
Reserves the given number of bytes (uninitialized). Example: .space 24
31
New cards
.data
Segment directive. Allocates data storage. Variables go here.
32
New cards
.text
Segment directive. Allocates instruction code. Instructions (and constants, at the end) go here.
33
New cards
.global main
Makes the label main visible to other files. Used for any label referenced in another file.
34
New cards
.set noreorder
Tells the assembler NOT to rearrange instructions or fill delay slots. You must handle the delay slots yourself.
35
New cards
What decides whether a label is a variable or a constant?
Its segment: .data = variable, .text = constant.
36
New cards
Variable (in assembly terms)
A memory location. The name is a label (= an address), and the value is the contents of that memory location.
37
New cards
Address vs. value
Address = WHERE something is in memory (the drawer number). Value = WHAT is stored there (the drawer's contents).
38
New cards
Sequential execution
Instructions run one after another, in order, unless a jump or branch changes the flow.
39
New cards
Control transfer
Jumps and branches change which instruction runs next. A label marks the target.
40
New cards
if/else flow in assembly
A branch skips forward past instructions to a label.
41
New cards
for/while loop flow in assembly
A branch goes backward to a label at the top of the loop.
42
New cards
Function call flow in assembly
A jump to the function's label, then a return back.
43
New cards
Do register and memory values reset on their own?
No. They persist until an instruction explicitly changes them.
44
New cards
la
Load Address. Puts a label's address into a register. It is a macro instruction.
45
New cards
li
Load Immediate. Puts a constant value into a register. It is a macro instruction.
46
New cards
lw
Load Word. Copies a 32-bit word from memory into a register. It is a real machine instruction.
47
New cards
sw
Store Word. Copies a 32-bit word from a register into memory. It is a real machine instruction.
48
New cards
Machine instruction vs. macro instruction
Machine instruction = a real CPU instruction (lw, sw). Macro instruction = assembler shorthand that expands into one or more machine instructions (la, li).
49
New cards
Why does li t9, 0x1234abcd need two instructions?
Each instruction is 32 bits, but only 16 bits are left for a constant. A 32-bit constant is split into an upper half (lui) and a lower half (ori).
50
New cards
What li t9, 0x1234abcd expands to
lui at, 0x1234 | ori t9, at, 0xabcd
51
New cards
Offset in lw t1, 8(t0)
The 8. Address used = offset + address in register (8 + t0).
52
New cards
Byte addressing
Each memory address holds 1 byte. A word (4 bytes) takes up 4 addresses.
53
New cards
Size of a MIPS word
32 bits = 4 bytes
54
New cards
Offset of an array element (word array)
offset = index × 4
55
New cards
Which register gets changed in lw t1, 0(t0)?
t1 (the left/destination register). t0 only supplies the address.
56
New cards
MIPS / PIC32 environment challenges
I/O limitations, managing a complex environment, virtual vs. physical addresses, no explicit stack instructions, and a verbose function-calling structure.