FSUB.H

RISC-V FSUB.H Instruction Details

Instruction ManualR-type

Half-precision floating-point subtraction, OP-FP fmt=H(10).

Instruction Syntax

fsub.h rd, rs1, rs2, rm
Operand Breakdown
rd: destination floating-point register receiving the formatted result.
rs1/rs2: source floating-point registers; arithmetic/rounding forms with rm use rm or dynamic frm for rounding mode.
ZfhFloating-Point Arithmetic

Instruction Behavior

FSUB.H performs half-precision floating-point subtraction on two FP source operands, rounds according to the rm field or dynamic frm, writes the result to FP register rd, and records fflags according to RISC-V floating-point rules.

FSUB.H Decode And Execute Animation

Shows the Zfh-extension half-precision OP-FP flow: decode fields, read FP operands, perform FSUB semantics, then write rd.

rd
rs1
rs2
rm
fsub.h
,
,
,
Execution Context
FLEN=>=32 / fmt=H (10)
rounding: RNE nearest-even
fflags: example fflags remains 0
31..27
26..25
24..20
19..15
14..12
11..7
6..0
00001
FSUB
10
fmt=H
01100
rs2
01011
rs1
000
rm
01010
rd
1010011
OP-FP
Execution Data Path
instruction
0x0CC58553
opcode
1010011 -> OP-FP
funct5/fmt
00001 + H(10) -> FSUB.H
rm
000 -> RNE nearest-even
rd/rs
fa0(f10) / fa1(f11) / fa2(f12)
read
3.5, 1.25
FP op
3.5 - 1.25 = 2.25
write
fa0(f10) = 2.25; example fflags remains 0
Current Step

Fetch: show the 32-bit OP-FP encoding

The word is split as an R-type OP-FP instruction; half-precision OP-FP instructions use opcode 1010011.

encoding: 0x0CC58553
syntax : fsub.h fa0(f10), fa1(f11), fa2(f12), rne
result : fa0(f10) = 2.25; example fflags remains 0

The H/Q animation accepts only finite whitelisted examples whose inputs and result are exactly checkable; this example needs no rounding and sets no FP exception flags. NaN, infinity, overflow, underflow, and inexact paths are covered in static text.

Half-precision Calculation
rs1
fa1(f11) = 3.5
rs2
fa2(f12) = 1.25
result
3.5 - 1.25 = 2.25

The H/Q animation accepts only finite whitelisted examples whose inputs and result are exactly checkable; this example needs no rounding and sets no FP exception flags. NaN, infinity, overflow, underflow, and inexact paths are covered in static text.

This animation shows only Zfh-extension ISA-visible OP-FP encoding, example numeric results, and fflags relationship; it does not model FPU pipelines, latency, every IEEE 754 corner case, or microarchitecture.

Quick Understanding & Search Notes

FSUB.H is a Zfh-extension half-precision OP-FP arithmetic instruction. It decodes funct5=00001 with fmt=H(10), reads f[rs1] and f[rs2], performs subtraction, rounds by rm/frm, and writes f[rd].

fmt=H(10) selects the half-precision floating-point format; the opcode remains OP-FP 1010011.
The rm field selects a static rounding mode, while rm=111 uses dynamic frm; exact examples keep the same numeric value but the field is still encoded.
Applicable inexact, overflow, underflow, invalid-operation, and related cases are accrued in fflags; this is not integer arithmetic or condition-code update.
Zfh H-format values in wider FLEN floating-point registers follow NaN-boxing rules.

Common Usage Scenarios

Floating-point arithmetic

Understand this scenario with real code like «fsub.h f10, f11, f12, rne ; f10 = f11 - f12».

Pre-Use Checklist

Syntax Check
  • rd: destination floating-point register receiving the formatted result.
  • rs1/rs2: source floating-point registers; arithmetic/rounding forms with rm use rm or dynamic frm for rounding mode.
Semantic Check
  • Confirm the floating-point format suffix (.H/.S/.D/.Q) matches the data width.
  • Decide whether software must inspect fflags for NV, DZ, OF, UF, or NX.

Pitfalls / Common Confusions

Rounding comes from the rm field; rm=111 uses the dynamic frm rounding mode.
Floating-point exceptions are recorded in fflags, not as integer branch conditions or integer traps.
NaNs, infinities, overflow, underflow, and inexact results are reported through floating-point exception flags.

FAQ

What does rm do for FSUB.H?

rm selects the floating-point rounding mode; rm=111 uses dynamic frm. If the result is exactly representable, rounding does not change the example value, but the encoded field still matters.

Does FSUB.H write integer registers or condition codes?

FSUB.H writes FP register f[rd]. RISC-V floating-point exceptions are accrued in fflags, not reported through integer condition codes.