github.com/cloudflare/circl@v1.5.0/ecc/fourq/fp_amd64.s (about)

     1  // +build amd64,!purego
     2  
     3  #include "textflag.h"
     4  #include "fp_amd64.h"
     5  
     6  // fpModp sets e to zero if it is equal to p. This is the only case where c
     7  // will not naturally be reduced to canonical form.
     8  // func fpMod(c *fp)
     9  TEXT ·fpMod(SB),0,$0-8
    10      MOVQ c+0(FP), DI
    11      _fpMod(0(DI))
    12      RET
    13  
    14  // func fpAdd(c, a, b *fp)
    15  TEXT ·fpAdd(SB),0,$0-24
    16      MOVQ c+0(FP), DI
    17      MOVQ a+8(FP), SI
    18      MOVQ b+16(FP), BX
    19      _fpAdd(0(DI), 0(SI), 0(BX))
    20      RET
    21  
    22  // func fpSub(c, a, b *fp)
    23  TEXT ·fpSub(SB),0,$0-24
    24      MOVQ c+0(FP), DI
    25      MOVQ a+8(FP), SI
    26      MOVQ b+16(FP), BX
    27      _fpSub(0(DI), 0(SI), 0(BX))
    28      RET
    29  
    30  // func fpHlf(c, a *fp)
    31  TEXT ·fpHlf(SB),0,$0-16
    32  	MOVQ a+8(FP), DI
    33      MOVQ 0(DI), AX
    34      MOVQ 8(DI), BX
    35  
    36  	SHLQ $1, BX
    37  	SHRQ $1, AX, BX
    38  	SHRQ $1, BX, AX
    39  	SHRQ $1, BX
    40  
    41  	MOVQ c+0(FP), DI
    42      MOVQ AX, 0(DI)
    43      MOVQ BX, 8(DI)
    44  	RET
    45  
    46  // func fpMul(c, a, b *fp)
    47  TEXT ·fpMul(SB),0,$0-24
    48      MOVQ a+8(FP), DI
    49      MOVQ b+16(FP), SI
    50      _fpMulLeg(R10, R9, R8, 0(DI), 0(SI))
    51      SHLQ $1, R10
    52      BTRQ $63, R9
    53      ADCQ R10, R8
    54      ADCQ  $0, R9
    55      _fpReduce(R8, R9)
    56  
    57      MOVQ c+0(FP), DI
    58      MOVQ R8, 0(DI)
    59      MOVQ R9, 8(DI)
    60      RET
    61  
    62  // func fpSqr(c, a *fp)
    63  TEXT ·fpSqr(SB),0,$0-16
    64      MOVQ a+8(FP), DI
    65      MOVQ $0, CX
    66  
    67      MOVQ 0(DI), AX
    68      MULQ 0(DI)
    69      MOVQ AX, R8
    70      MOVQ DX, R9
    71  
    72      MOVQ 0(DI), AX
    73      MULQ 8(DI)
    74      SHLQ $1, DX
    75      ADDQ DX, R8
    76      ADCQ AX, R9
    77      ADCQ $0, CX
    78      ADDQ DX, R8
    79      ADCQ AX, R9
    80      ADCQ $0, CX
    81  
    82      MOVQ 8(DI), AX
    83      MULQ 8(DI)
    84      SHLQ $1, DX
    85      SHLQ $1, AX
    86      ADCQ $0, DX
    87      ADDQ AX, R8
    88      ADCQ DX, R9
    89      ADCQ $0, CX
    90  
    91      SHLQ $1, CX
    92      BTRQ $63, R9
    93      ADCQ CX, R8
    94      ADCQ $0, R9
    95      _fpReduce(R8, R9)
    96  
    97      MOVQ c+0(FP), DI
    98      MOVQ R8, 0(DI)
    99      MOVQ R9, 8(DI)
   100      RET