[
sums two words (signed or unsigned)
]

sum_words{
    = `A0 A1 A2 A3 | 0 0 | B0 B1 B2 B3 | 0 0 | 0 0 0 0
    >>>[>>>>>>>>>+<<<<<<<<<-]
    = A0 A1 A2 `0 | 0 0 | B0 B1 B2 B3 | 0 0 | A3 0 0 0
    >>>>>>[>>>>+<<<<-]>>>
    = A0 A1 A2 0 | 0 0 | B0 B1 B2 0 | 0 0 | `A3 B3 0 0
    carry_sum{
        sums D Z and carry; carry should only be 1 or zero; leaves carry 1 if overflow happened
        = `D Z 0 carry
        >>>
        = D Z 0 `carry
        first increment D if carry is 1 (must set carry if this causes overflow)
        [
            carry is 1
            = D Z 0 `!0
            <<<+
            = `Dinc Z 0 !0
            [
                Dinc is non zero
                = `Dinc Z 0 !0
                [>>+<<-]>>>[-]<<<
                = `0 Z Dinc 0
            ]
            = `0 Z Dinc carry
            >>[<<+>>-]>[<+>-]
            = Dinc Z carry `0
        ]
        = Dinc Z carry `0
        <[>+<-]<
        = Dinc `Z 0 carry
        next add Z to D (must set carry if this causes overflow)
        [
            = Dinc `Z 0 carry
            >>+<<<+
            = `R Z 0 carry_inc
            [
                [>>+<<-]
                = `0 Z R carry_inc
                >>>-<<<
                = `0 Z R carry
            ]
            = `0 Z R carry
            >>[<<+>>-]<
            = R `Z 0 carry
            -
            = R `Zdec 0 carry
        ]<
        R now holds result
        = `R 0 0 carry
    }
    = A0 A1 A2 0 | 0 0 | B0 B1 B2 0 | 0 0 | `C3 0 0 carry3
    [<<<<<<<<<+>>>>>>>>>-]<<<<<<<<<<
    = A0 A1 `A2 C3 | 0 0 | B0 B1 B2 0 | 0 0 | 0 0 0 carry3
    [>>>>>>>>>>+<<<<<<<<<<-]>>>>>>
    = A0 A1 0 C3 | 0 0 | B0 B1 `B2 0 | 0 0 | A2 0 0 carry3
    [>>>>>+<<<<<-]>>>>
    = A0 A1 0 C3 | 0 0 | B0 B1 0 0 | 0 0 | `A2 B2 0 carry3
    carry_sum{
        >>>[<<<+[[>>+<<-]>>>[-]<<<]>>[<<+>>-]>[<+>-]]<[>+<-]<[>>+<<<+[[>>+<<-]>>>-<<<]>>
        [<<+>>-]<-]<
    }
    = A0 A1 0 C3 | 0 0 | B0 B1 0 0 | 0 0 | `C2 0 0 carry2
    [<<<<<<<<<<+>>>>>>>>>>-]<<<<<<<<<<<
    = A0 `A1 C2 C3 | 0 0 | B0 B1 0 0 | 0 0 | 0 0 0 carry2
    [>>>>>>>>>>>+<<<<<<<<<<<-]>>>>>>
    = A0 0 C2 C3 | 0 0 | B0 `B1 0 0 | 0 0 | A1 0 0 carry2
    [>>>>>>+<<<<<<-]>>>>>
    = A0 0 C2 C3 | 0 0 | B0 0 0 0 | 0 0 | `A1 B1 0 carry2
    carry_sum{
        >>>[<<<+[[>>+<<-]>>>[-]<<<]>>[<<+>>-]>[<+>-]]<[>+<-]<[>>+<<<+[[>>+<<-]>>>-<<<]>>
        [<<+>>-]<-]<
    }
    = A0 0 C2 C3 | 0 0 | B0 0 0 0 | 0 0 | `C1 0 0 carry3
    [<<<<<<<<<<<+>>>>>>>>>>>-]<<<<<<<<<<<<
    = `A0 C1 C2 C3 | 0 0 | B0 0 0 0 | 0 0 | 0 0 0 carry2
    [>>>>>>>>>>>>+<<<<<<<<<<<<-]>>>>>>
    = 0 C1 C2 C3 | 0 0 | `B0 0 0 0 | 0 0 | A0 0 0 carry2
    [>>>>>>>+<<<<<<<-]>>>>>>
    = 0 C1 C2 C3 | 0 0 | 0 0 0 0 | 0 0 | `A0 B0 0 carry2
    carry_sum{
        >>>[<<<+[[>>+<<-]>>>[-]<<<]>>[<<+>>-]>[<+>-]]<[>+<-]<[>>+<<<+[[>>+<<-]>>>-<<<]>>
        [<<+>>-]<-]<
    }
    = 0 C1 C2 C3 | 0 0 | 0 0 0 0 | 0 0 | `C0 0 0 carry4
    >>>[-]<<<
    = 0 C1 C2 C3 | 0 0 | 0 0 0 0 | 0 0 | `C0 0 0 0
    [<<<<<<<<<<<<+>>>>>>>>>>>>-]<<<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