aboutsummaryrefslogtreecommitdiff
path: root/softfloat/s_add192.c
blob: 06a4a93963d3110ffa0daa8bfd91bea33e17fde7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// See LICENSE.SoftFloat for license details.


#include <stdint.h>
#include "platform.h"
#include "primitives.h"

struct uint192
 softfloat_add192(
     uint64_t a128,
     uint64_t a64,
     uint64_t a0,
     uint64_t b128,
     uint64_t b64,
     uint64_t b0
 )
{
    struct uint192 z;
    unsigned int carry64, carry128;

    z.v0 = a0 + b0;
    carry64 = ( z.v0 < a0 );
    z.v64 = a64 + b64;
    carry128 = ( z.v64 < a64 );
    z.v128 = a128 + b128;
    z.v64 += carry64;
    carry128 += ( z.v64 < carry64 );
    z.v128 += carry128;
    return z;

}