Integers are 4 byles word 32bits
are 1 byte 8bits
Characters
doubles an 8
bytes 2words 64bits
Nullterminatingstring Asequenceof
characters endingwith 0 NULL
Topic V0E
Strings of Characters
1
, Instructions to Manipulate Characters Bytes
(Bytes)
AEfkBd
t.TT
RISC-V byte load/store instead of a word
String processing is a common case
lb t0, 0(s0)
lb t1, 1(s0)
lb rd, offset(rs1) Register Value
lbu t2, 0(s0)
s0 0x10001010
Sign-extend to 32 bits in rd lbu t3, 1(s0)
t0 0x00000009
t1 0xFFFFFF80
lbu rd, offset(rs1) t2 0x00000009
t3 0x00000080
Zero-extend to 32 bits in rd Address Value
unsigned 0x10001015 0x00
0x10001014 0x0B
sb rs2, offset(rs1)
0x10001013 0x00
Store just the rightmost byte 0x10001012 0x00
least significant 0x10001011
0x10001010
0x80
0x09
2
, Instructions to Manipulate Half words
In RISC-V a halfword is 16 bits
lh rd, offset(rs1)
Sign-extend to 32 bits in rd
lhu rd, offset(rs1)
Zero-extend to 32 bits in rd
sh rs2, offset(rs1)
Store just the rightmost halfword
least significant
3
are 1 byte 8bits
Characters
doubles an 8
bytes 2words 64bits
Nullterminatingstring Asequenceof
characters endingwith 0 NULL
Topic V0E
Strings of Characters
1
, Instructions to Manipulate Characters Bytes
(Bytes)
AEfkBd
t.TT
RISC-V byte load/store instead of a word
String processing is a common case
lb t0, 0(s0)
lb t1, 1(s0)
lb rd, offset(rs1) Register Value
lbu t2, 0(s0)
s0 0x10001010
Sign-extend to 32 bits in rd lbu t3, 1(s0)
t0 0x00000009
t1 0xFFFFFF80
lbu rd, offset(rs1) t2 0x00000009
t3 0x00000080
Zero-extend to 32 bits in rd Address Value
unsigned 0x10001015 0x00
0x10001014 0x0B
sb rs2, offset(rs1)
0x10001013 0x00
Store just the rightmost byte 0x10001012 0x00
least significant 0x10001011
0x10001010
0x80
0x09
2
, Instructions to Manipulate Half words
In RISC-V a halfword is 16 bits
lh rd, offset(rs1)
Sign-extend to 32 bits in rd
lhu rd, offset(rs1)
Zero-extend to 32 bits in rd
sh rs2, offset(rs1)
Store just the rightmost halfword
least significant
3