gmsm/internal/subtle/xor_s390x.s

48 lines
801 B
ArmAsm
Raw Normal View History

2024-08-28 09:42:12 +08:00
// The original code (non-vector) is ported from Golang
// https://github.com/golang/go/blob/master/src/crypto/aes/ctr_s390x.go
2024-08-19 17:46:47 +08:00
//go:build !purego
#include "textflag.h"
// func xorBytes(dst, a, b *byte, n int)
TEXT ·xorBytes(SB),NOSPLIT,$0-32
MOVD dst+0(FP), R1
MOVD a+8(FP), R2
MOVD b+16(FP), R3
MOVD n+24(FP), R4
MOVD $0, R5
2024-08-28 08:38:36 +08:00
CMPBLT R4, $16, less_than16
2024-08-28 09:59:52 +08:00
loop16b:
2024-08-20 10:02:42 +08:00
VL 0(R2)(R5*1), V0
VL 0(R3)(R5*1), V1
VX V0, V1, V2
VST V2, 0(R1)(R5*1)
LAY 16(R5), R5
SUB $16, R4
2024-08-28 09:59:52 +08:00
CMPBGE R4, $16, loop16b
2024-08-20 10:02:42 +08:00
less_than16:
2024-08-19 17:46:47 +08:00
CMPBLT R4, $8, tail
MOVD 0(R2)(R5*1), R7
MOVD 0(R3)(R5*1), R8
XOR R7, R8
MOVD R8, 0(R1)(R5*1)
LAY 8(R5), R5
SUB $8, R4
2024-08-20 10:02:42 +08:00
2024-08-19 17:46:47 +08:00
tail:
CMPBEQ R4, $0, done
MOVB 0(R2)(R5*1), R7
MOVB 0(R3)(R5*1), R8
XOR R7, R8
MOVB R8, 0(R1)(R5*1)
LAY 1(R5), R5
SUB $1, R4
BR tail
2024-08-20 10:02:42 +08:00
2024-08-19 17:46:47 +08:00
done:
RET