MIPS Assembly Language Elements Concepts

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/55

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 4:08 AM on 10/3/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

56 Terms

1
New cards
Machine code
The binary instructions a CPU actually executes. Each CPU architecture has its own machine code.
2
New cards
Why can't a CPU run C++ directly?
C++ is a universal, high-level language. It has to be compiled into the CPU's own machine code (binary) first.
3
New cards
Assembly language
Text mnemonics that stand for binary machine code, so humans can read and write it.
4
New cards
Mnemonic
A short text name for an instruction or operand, e.g. lw, add, t0.
5
New cards
Assembler
The tool that translates assembly language into machine code.
6
New cards
Assembling vs. disassembling
Assembling: assembly text → machine code (binary). Disassembling: machine code → assembly text.
7
New cards
4 things assembly language defines
1) Operation mnemonics (instructions) 2) Operand mnemonics (data) 3) Number/type of operands 4) Operand ordering (source/destination)
8
New cards
RISC
Reduced Instruction Set Computer. Fewer instructions, fixed instruction size. MIPS is RISC.
9
New cards
CISC
Complex Instruction Set Computer. Many instructions of varying size. Example: Intel architecture.
10
New cards
MIPS instruction size
Fixed: every instruction is exactly 32 bits.
11
New cards
Load/store architecture
Data must be loaded into registers before it can be processed and stored back to memory afterward. MIPS cannot operate directly on data in memory.
12
New cards
Load vs. Store
Load = memory (or a constant/address) → register. Store = register → memory.
13
New cards
Pipelined architecture
The CPU works on several instructions at once, each in a different stage. In MIPS this causes the delayed branch.
14
New cards
Delayed branch / branch delay slot
The instruction right after a branch or jump always executes, even when the branch is taken.
15
New cards
nop
'No operation.' An instruction that does nothing. A safe filler for a branch delay slot.
16
New cards
How many general-purpose registers does MIPS have?
32
17
New cards
Register zero ($0)
Always holds the value 0 and cannot be changed.
18
New cards
Register t0
Temporary register 0. It is register number 8, NOT register 0.
19
New cards
Register at
Assembler temporary. The assembler uses it when expanding macro instructions (e.g. lui at, 0x1234).
20
New cards
Register names in MPLAB
Leave off the $. Write t0, not $t0.
21
New cards
MPLAB X IDE
Microchip's development environment, used with the PIC32 microcontroller (a MIPS variant).
22
New cards
Required file extension in MPLAB X
".S" (dot capital S). It allows C-preprocessor directives.
23
New cards
#include <xc.h>
Required C-preprocessor directive. Defines built-in labels.
24
New cards
#define century 100
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.