neg

RISC-V neg Pseudo-Instruction Details

Assembler pseudo-instruction

neg expands to sub rd, x0, rs. SUB computes zero minus rs, ignores overflow, and writes the low XLEN result bits to rd.

What You Write
neg rd, rs
Typical Real Expansion
sub rd, x0, rs

What This Pseudo Instruction Is Saving You From Writing

A SUB spelling with its first source operand fixed to x0.

How To Read The Expansion

Step 1
sub rd, x0, rs
Step 2
SUB computes x0 minus rs.

Assembly Forms And Real Instructions

The expansion above identifies the SUB ISA semantics that apply.

Official References And Reading Order

This page treats pseudo-instructions as assembler-level aliases or macros: first read what real instructions they expand to, then use the official ISA manual for the behavior of those real instructions. ABI, relocation, and linker-relaxation details follow the psABI document.

Pitfalls / Common Confusions

SUB ignores overflow and writes the low XLEN result bits to rd.

FAQ

What is the official neg expansion?

sub rd, x0, rs