Skip to main content

add

Function add 

Source
pub const fn add(
    op1: u32,
    op2: u32,
    carry_in: bool,
    prior: Flags,
) -> (u32, Flags)
Expand description

ARM ADD-family: op1 + op2 + carry_in.

Uses the exact overflow/carry formulas the ARM ARM specifies (Mesen2 Add) — NOT reimplemented from first principles, since the signed-overflow and carry-out derivations below are the well-known highest-bug-density spot in a from-scratch ARM core. Returns (result, flags_if_update_requested); the caller decides whether to commit the returned flags (mirrors the updateFlags/S-bit gate every ARM ALU instruction carries).