# `neg`

[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/neg

**Negate** · Pseudo-instruction

Category: Arithmetic

Sets the first register to the arithmetic negation of the second.

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

Used in: [The RISC-V instruction set](https://asm-editor.specy.app/learn/courses/risc-v/introduction/the-risc-v-instruction-set.md) (RISC-V assembly), [A bouncing ball](https://asm-editor.specy.app/learn/courses/risc-v/examples/bouncing-ball.md) (RISC-V assembly)

## Forms

- `neg t1, t2`
  - `neg t1,t2` → `sub t1, zero, t2`

## Operands

- `t1`: Any integer register, `x0` to `x31`, or its named alias, such as `zero`, `t0` or `t6`.
- `t2`: An integer register. It may be the same register as `t1`.

## Example

```riscv
.text
li t0, 13
# t0=13; neg writes -13 (0xFFFFFFF3) to t2.
neg t2, t0
```
