github.com/emmansun/gmsm@v0.29.1/internal/subtle/xor_riscv64.s (about)

     1  // Copyright 2024 Sun Yimin. All rights reserved.
     2  // Use of this source code is governed by a MIT-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build !purego
     6  
     7  #include "textflag.h"
     8  
     9  // func xorBytes(dst, a, b *byte, n int)
    10  TEXT ·xorBytes(SB), NOSPLIT|NOFRAME, $0
    11  	MOV	dst+0(FP), X5
    12  	MOV	a+8(FP), X6
    13  	MOV	b+16(FP), X7
    14  	MOV	n+24(FP), X8
    15  
    16  	MOV 	$8, X9
    17  	BLTU	X8, X9, tail
    18  
    19  loop:
    20  	MOV (X6), X10
    21  	MOV (X7), X11
    22  	XOR X10, X11, X10
    23  	MOV X10, (X5)
    24  	ADD $8, X5
    25  	ADD $8, X6
    26  	ADD $8, X7
    27  	SUB $8, X8
    28  	BGEU X8, X9, loop
    29  
    30  tail:
    31  	BEQZ	X8, done
    32  	MOV $4, X9
    33  	BLTU X8, X9, less_than4
    34  	MOVWU (X6), X10
    35  	MOVWU (X7), X11
    36  	XOR X10, X11, X10
    37  	MOVW X10, (X5)
    38  	ADD $4, X5
    39  	ADD $4, X6
    40  	ADD $4, X7
    41  	SUB $4, X8
    42  
    43  less_than4:
    44  	MOV $2, X9
    45  	BLTU X8, X9, less_than2
    46  	MOVHU (X6), X10
    47  	MOVHU (X7), X11
    48  	XOR X10, X11, X10
    49  	MOVH X10, (X5)
    50  	ADD $2, X5
    51  	ADD $2, X6
    52  	ADD $2, X7
    53  	SUB $2, X8
    54  
    55  less_than2:
    56  	BEQZ	X8, done
    57  	MOVBU (X6), X10
    58  	MOVBU (X7), X11
    59  	XOR X10, X11, X10
    60  	MOVB X10, (X5)
    61  
    62  done:
    63  	RET