# `lb`

[RISC-V Documentation](https://asm-editor.specy.app/documentation/risc-v.md) › [Instructions](https://asm-editor.specy.app/documentation/risc-v/instruction.md)

Web page: https://asm-editor.specy.app/documentation/risc-v/instruction/lb

**Load byte**

Category: Load and store

Loads the byte at the address in the second register plus an offset into the first, sign-extended to the register width.

[RISC-V manual: lb](https://docs.riscv.org/reference/isa/v20260120/unpriv/rv32.html#norm:lb_lbu_op)

Used in: [Arrays and strings](https://asm-editor.specy.app/learn/courses/risc-v/think-in-assembly/arrays-and-strings.md) (RISC-V assembly), [Length of a string](https://asm-editor.specy.app/learn/courses/risc-v/examples/string-length.md) (RISC-V assembly), [Reverse a string in place](https://asm-editor.specy.app/learn/courses/risc-v/examples/reverse-a-string.md) (RISC-V assembly), [Data in memory](https://asm-editor.specy.app/learn/courses/assembly-basics/think-in-assembly/data-in-memory.md) (Assembly basics)

## Forms

- `lb t1, imm12(t2)`

## Pseudo-instructions

The processor does not have these forms. The assembler replaces each of them with one or more real instructions. Open a row to see them.

- `lb t1, (t2)`
  - `lb t1,(t2)` → `lb t1, 0(t2)`
- `lb t1, imm`
  - `lb t1,-100`: Set $1 to sign-extended 8-bit value from effective memory byte address → `lb t1, imm(zero)`
  - `lb t1,10000000`: Set $t1 to sign-extended 8-bit value from effective memory byte address → `lui t1, hi(imm)`; `lb t1, lo(imm)(t1)`

- `lb t1, label` · Set $t1 to sign-extended 8-bit value from effective memory byte address
  - `lb t1,label` → `auipc t1, pcrel_hi(label)`; `lb t1, pcrel_lo(label)(t1)`

- `lb t1, %lo(label)(t2)` · Load from Address
  - `lb t1,%lo(label)(t2)` → `lb t1, lo(label)(t2)`

## Operands

- `t1`: Any integer register, `x0` to `x31`, or its named alias, such as `zero`, `t0` or `t6`.
- `imm12`: A signed 12-bit immediate, `-2048` to `2047`.
- `t2`: An integer register. It may be the same register as `t1`.
- `imm`: An immediate value: a signed 12-bit value (`-2048` to `2047`) or a 32-bit value (`-2147483648` to `4294967295`). The size your value needs decides which real instructions the assembler uses. Open the row to see them for each size.
- `label`: A named address in the program, such as the start of a loop or a variable in `.data`.

## Example

```riscv
# value is initialized and naturally aligned for this operation.
.data
value: .word 0x017fff80
.text
la t0, value
# The first byte is 0x80; lb writes −128 (0xFFFFFF80) to t2.
lb t2, 0(t0)
```
