-
Notifications
You must be signed in to change notification settings - Fork 0
/
u256.sx
98 lines (41 loc) · 1.01 KB
/
u256.sx
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
.text
.include "aliases"
.include "commonmacros"
.include "u256macros"
/**
The C-compatible function mul512
multiplies two 256-bit scalars.
The result is a 512-bit product split into two scalars
hi and lo
(lo, hi) = a*b
This function is used for testing the macro u256mul.
Input:
io0: pointer to Scalar a
io1: pointer to Scalar b
io2: pointer to Scalar lo
io3: pointer to Scalar hi
*/
BEGIN_C_FUNCTION mul512
LOAD_A_B
MUL_U256
STORE_R_LO io2
STORE_R_HI io3
END_C_FUNCTION mul512
/**
The C-compatible function square512
squares a 256-bit scalar.
The result is a 512-bit product split into two scalars
hi and lo
(lo, hi) = a*a
This function is used for testing the macro SQUARE_U256.
Input:
io0: pointer to scalar a
io1: pointer to scalar lo
io2: pointer to scalar hi
*/
BEGIN_C_FUNCTION square512
LOAD_A
SQUARE_U256
STORE_R_LO io1
STORE_R_HI io2
END_C_FUNCTION square512