Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
RISC-V
Reminders:
- Lab 1 released today
- Lab hours begin today
- Sign up for piazza
Direct
Hardware
Microprocessor Execution
x0 Address 31 0
x1 100110....0 0
4
x2
8 Holds
32-bit “words” 12 program
...
16
20
and data
x31
32-bit “words”
ALU
Arithmetic Machine language directly
Logic Unit reflects this structure
September 10, 2019 MIT 6.004 Fall 2019 L02-3
MicroProcessor Structure /
Assembly Language
§ Each register is of fixed size, say 32 bits
§ The number of registers are small, say 32
§ ALU directly performs operations on the register
file, typically
§ xi ¬ Op( xj , xk ) where Op Î {+, AND, OR, <, >, ...}
§ Memory is large, say Giga bytes, and holds
program and data
§ Data can be moved back and forth between
Memory and Register File
§ Ld x M[addr]
§ St M[addr] x
x4 ß load(Mem[x1]) 0
x1 Addr of a[i] 4 a[0]
add x3, x3, x4 n
x2 8 a[1]
addi x1, x1, 4 x3 sum
addi x2, x2, -1 a[n-1]
bnez x2, loop x10 100
100 base
104 n
store(sum) ß x3 108 sum
Base 10 Base 2
111
5 00101
+ 3 + 00011
8 0 1 0 00
§ sll x3, x1, x2 00101
Shift x1 left 01010 Notice fixed
by x2 bits 10100 width
01000
0x0
x3 ß x1 + x2 0x4 b
0x8 c
store(Mem[a]) ß x3 0xC
0x10 a
0x14
x1 ß load(0x4)
x2 ß load(0x8) 32-bit “words”
x3 ß x1 + x2 (4 bytes)
store(0x10) ß x3
§ Assembly: § Behavior:
Main Memory
lw x1, 0x0(x10)
lw x2, 0x4(x10) Register File 31 0
sw x3, 0x8(x10)
September 10, 2019 MIT 6.004 Fall 2019 L02-20
Pseudoinstructions
§ Aliases to other actual instructions to simplify
assembly programming.
Next lecture:
Implementing Procedures in Assembly