github.com/emmansun/gmsm@v0.29.1/sm9/bn256/gfp_macros_amd64.s (about)

     1  #define res_ptr DI
     2  #define x_ptr SI
     3  #define y_ptr CX
     4  
     5  #define acc0 R8
     6  #define acc1 R9
     7  #define acc2 R10
     8  #define acc3 R11
     9  #define acc4 R12
    10  #define acc5 R13
    11  #define t0 R14
    12  
    13  #define storeBlock(a0,a1,a2,a3, r) \
    14  	MOVQ a0,  0+r \
    15  	MOVQ a1,  8+r \
    16  	MOVQ a2, 16+r \
    17  	MOVQ a3, 24+r
    18  
    19  #define loadBlock(r, a0,a1,a2,a3) \
    20  	MOVQ  0+r, a0 \
    21  	MOVQ  8+r, a1 \
    22  	MOVQ 16+r, a2 \
    23  	MOVQ 24+r, a3
    24  
    25  #define gfpCarry(a0,a1,a2,a3, b0,b1,b2,b3,b4) \
    26  	\ // b = a-p
    27  	MOVQ a0, b0 \
    28  	MOVQ a1, b1 \
    29  	MOVQ a2, b2 \
    30  	MOVQ a3, b3 \
    31  	\
    32  	SUBQ ·p2+0(SB), b0 \
    33  	SBBQ ·p2+8(SB), b1 \
    34  	SBBQ ·p2+16(SB), b2 \
    35  	SBBQ ·p2+24(SB), b3 \
    36  	SBBQ $0, b4 \
    37  	\
    38  	\ // if b is negative then return a
    39  	\ // else return b
    40  	CMOVQCC b0, a0 \
    41  	CMOVQCC b1, a1 \
    42  	CMOVQCC b2, a2 \
    43  	CMOVQCC b3, a3
    44  
    45  #define gfpCarryWithoutCarry(a0,a1,a2,a3, b0,b1,b2,b3) \
    46  	\ // b = a-p
    47  	MOVQ a0, b0 \
    48  	MOVQ a1, b1 \
    49  	MOVQ a2, b2 \
    50  	MOVQ a3, b3 \
    51  	\
    52  	SUBQ ·p2+0(SB), b0 \
    53  	SBBQ ·p2+8(SB), b1 \
    54  	SBBQ ·p2+16(SB), b2 \
    55  	SBBQ ·p2+24(SB), b3 \
    56  	\
    57  	\ // if b is negative then return a
    58  	\ // else return b
    59  	CMOVQCC b0, a0 \
    60  	CMOVQCC b1, a1 \
    61  	CMOVQCC b2, a2 \
    62  	CMOVQCC b3, a3