Professional Documents
Culture Documents
1
Registers
❑ Built-in memory locations in the processor
❑ Fastest memory location
❑ Can hold an instruction, a memory location, or data
2
RAM and Processor on Motherboard
3
Registers
❑ MIPS has 32 registers
❑ X86 has 8 registers
Why not add more?
❑ Each register is 32-bit wide
▪ Referred to as 32-bit architecture
▪ This means that you can have addresses that are 32-bit in size!
4
How many addresses a 32-bit register can refer?
32-bit Address
1 Byte
4 billion
232 Different values 1 Byte
unique
addresses 1 Byte
1 Byte
230 × 22 Different values 1 Byte
1 Byte
Giga 1 Byte
4Giga Different values 1 Byte
5
How many addresses a 32-bit register can refer?
32-bit Address
4 Byte
4 billion
232 Different values 4 Byte
unique
addresses 4 Byte
4 Byte
230 × 22 Different values 4 Byte
4 Byte
Giga 4 Byte
4Giga Different values 4 Byte
6
How many addresses a 32-bit register can refer?
4 Bytes chunk is known
32-bit Address as “word” in memory
4 Byte
4 billion
232 Different values 4 Byte
unique
addresses 4 Byte
4 Byte
230 × 22 Different values 4 Byte
4 Byte
Giga 4 Byte
4Giga Different values 4 Byte
7
Possible Word Sizes
❑ 8, 16, 24, 32, or 64 bits
How many Bytes?
8
Register Files
❑ Consists of a set of registers that can be read and written by supplying a register
number to be accessed.
❑ Values must be fetched from memory before performing any operation on them
10
Recall from Assembly Language…
11
Example of an instruction
14
Memory Address
a b c a=b+c
Memory
a 0
lw R1, 4(R0) Load is performed with offset
Base Address from base address
b 4 lw R2, 8(R0)
(Lets say
stored in R0) c 8
add R3, R1, R2
sw R3, 0(R0)
15
Base Address in Arrays: Example
D[2]
a b c D[0]
D[1]
d = [100, 200, 300]
d[2] = d[0] + d[1]
Memory
a 0
lw R1, 12(R0)
Base Address
b 4 lw R2, 16(R0)
(Lets say
stored in R0) c 8
d[0] 12 add R3, R1, R2
d[1] 16
sw R3, 20(R0)
d[2] 20
16
Immediate Operands
❑ An immediate instruction uses a constant number as one of the inputs
(instead of a register operand)
R-Type
Instructions add R3, R1, R2
I-Type
Instructions add R3, R1, 1000 What if we want
to store a
constant value in
a register?
17
Immediate Operands
❑ Putting a constant in a register requires addition to register $zero
▪ A special register that always has a zero in it
18
Text Book Study
❑ T1: 1.6
❑ T2: 1.8, B.8
19