Professional Documents
Culture Documents
• Today’s topics:
MIPS instructions
Code examples
1
Instruction Set
2
Example
C code a = b + c + d + e;
translates into the following assembly code:
add a, b, c add a, b, c
add a, a, d or add f, d, e
add a, a, e add a, a, f
C code f = (g + h) – (i + j);
4
Subtract Example
C code f = (g + h) – (i + j);
translates into the following assembly code:
5
Operands
7
Binary Stuff
• 1 word = 32 bits = 4B
int a, b, c, d[10]
…
Memory
Base address
10
Memory Organization
Stack
11
Memory Instruction Format
destination register
source address
lw $t0, 8($t3)
any register
a constant that is added to the register in brackets
12
Memory Instruction Format
source register
destination address
sw $t0, 8($t3)
any register
a constant that is added to the register in brackets
13
Example
int a, b, c, d[10];
14
Example
Convert to assembly:
15
Example
Convert to assembly:
Stack
Text (instructions)
17
Recap – Numeric Representations
• Binary 001000112 = 1 x 25 + 1 x 21 + 1 x 20
21