02_riscv
02_riscv
CIS 5710
Computer Organization & Design
ISAs & RISC-V
App App App • ISA recap
System software
• RISC-V ISA overview
Mem CPU I/O • RISC-V assembly
Address Value
0 A
lb x1,0(x0)
1 B
opcode 2 C
destination register
3 D
immediate
source register 4 E
load address = source + immediate 5 F
6 G
7 H
struct foo {
char c;
int i;
}
address 0 1 2 3
big-endian 00000000 00000000 00000001 00000011 256 + 3 = 259
little-endian 00000011 00000001 00000000 00000000 3 + 256 = 259
loop:
lw a4, 0(a1) # load element
add a3, a3, a4 # add to sum
addi a1, a1, 4 # increment pointer
addi a2, a2, -1 # decrement index
bnez a2, loop # all done?