;r8-r15寄存器,低32位r8d-r15d,低16位r8w-r15w,低8位r8b-r15b
mov rax, rcx ;save dst address
cpystart256:
cmp r8, 256
jnbe loop256 ;if(r8 > 256)cb
cpystart128:
cmp r8, 128
jnbe loop128 ;if(r8 > 128)cb
cpystart64:
cmp r8, 64
jnbe loop64 ;if(r8 > 64)cb
cpystart32:
cmp r8, 16
jbe loop8_16 ;if(r8 < 16) cb
loop32_64:
movdqu xmm0, [rdx]
movdqu xmm1, -16[rdx + r8] ;save 16 to 32 bytes src
cmp r8, 32
jbe loop16_32 ;if(r8 < 32 )cb
movdqu xmm2, 16[rdx] ;save 32 to 64 bytes src
movdqu xmm3, -32[rdx + r8]
movdqu 16[rcx], xmm2
movdqu -32[rcx + r8], xmm3
loop16_32: movdqu [rcx], xmm0
movdqu -16[rcx + r8], xmm1
ret
loop8_16:
cmp r8, 8 ; save 8 to 16 bytes src
jb loop4_7
mov r9, [rdx]
mov r10, -8[rdx+r8]
mov [rcx], r9
mov -8[rcx+r8], r10
ret
loop4_7:
cmp r8, 4 ;save 4 to 7 bytes src
jb loop1_3
mov r9d, [rdx]
mov r10d, -4[rdx + r8]
mov [rcx], r9d
mov -4[rcx + r8], r10d
ret
loop1_3:
or r8, r8 ;save 1 to 4 bytes src
jz loop_end
mov r9b, [rdx] ;save the first byte
or r8b, 2 ;save the two byte
jz loop0_1
mov r10w, -2[rdx + r8]
mov -2[rcx + r8], r10w
loop0_1:
mov [rcx], r9b
loop_end:
ret
loop256:
mov r9, r8
shr r9, 8
loop256_start:
movdqu xmm0, [rdx]
movdqu xmm1, [rdx+16]
movdqu xmm2, [rdx+32]
movdqu xmm3, [rdx+48]
movdqu xmm4, [rdx+64]
movdqu xmm5, [rdx+80]
movdqu xmm6, [rdx+96]
movdqu xmm7, [rdx+112]
movdqu xmm8, [rdx+128]
movdqu xmm9, [rdx+144]
movdqu xmm10, [rdx+160]
movdqu xmm11, [rdx+176]
movdqu xmm12, [rdx+192]
movdqu xmm13, [rdx+208]
movdqu xmm14, [rdx+224]
movdqu xmm15, [rdx+240]
movdqu [rcx], xmm0
movdqu [rcx+16], xmm1
movdqu [rcx+32], xmm2
movdqu [rcx+48], xmm3
movdqu [rcx+64], xmm4
movdqu [rcx+80], xmm5
movdqu [rcx+96], xmm6
movdqu [rcx+112], xmm7
movdqu [rcx+128], xmm8
movdqu [rcx+144], xmm9
movdqu [rcx+160], xmm10
movdqu [rcx+176], xmm11
movdqu [rcx+192], xmm12
movdqu [rcx+208], xmm13
movdqu [rcx+224], xmm14
movdqu [rcx+240], xmm15
add rdx, 256
add rcx, 256
dec r9
jnz loop256_start
and r8, 0ffh
jmp cpystart128
loop128:
mov r9, r8
shr r9, 7
loop128_start:
movdqu xmm0, [rdx]
movdqu xmm1, [rdx+16]
movdqu xmm2, [rdx+32]
movdqu xmm3, [rdx+48]
movdqu xmm4, [rdx+64]
movdqu xmm5, [rdx+80]
movdqu xmm6, [rdx+96]
movdqu xmm7, [rdx+112]
movdqu [rcx], xmm0
movdqu [rcx+16], xmm1
movdqu [rcx+32], xmm2
movdqu [rcx+48], xmm3
movdqu [rcx+64], xmm4
movdqu [rcx+80], xmm5
movdqu [rcx+96], xmm6
movdqu [rcx+112], xmm7
add rdx, 128
add rcx, 128
;dec r9
;jnz loop128_start
and r8, 07fh
jmp cpystart64
loop64: mov r9, r8
shr r9, 6
loop64_start:
movdqu xmm0, [rdx]
movdqu xmm1, [rdx+16]
movdqu xmm2, [rdx+32]
movdqu xmm3, [rdx+48]
movdqu [rcx], xmm0
movdqu [rcx+16], xmm1
movdqu [rcx+32], xmm2
movdqu [rcx+48], xmm3
add rdx, 64
add rcx, 64
;dec r9
;jnz loop64_start
and r8, 03fh
jmp cpystart32
mov rax, rcx ;save dst address
cpystart256:
cmp r8, 256
jnbe loop256 ;if(r8 > 256)cb
cpystart128:
cmp r8, 128
jnbe loop128 ;if(r8 > 128)cb
cpystart64:
cmp r8, 64
jnbe loop64 ;if(r8 > 64)cb
cpystart32:
cmp r8, 16
jbe loop8_16 ;if(r8 < 16) cb
loop32_64:
movdqu xmm0, [rdx]
movdqu xmm1, -16[rdx + r8] ;save 16 to 32 bytes src
cmp r8, 32
jbe loop16_32 ;if(r8 < 32 )cb
movdqu xmm2, 16[rdx] ;save 32 to 64 bytes src
movdqu xmm3, -32[rdx + r8]
movdqu 16[rcx], xmm2
movdqu -32[rcx + r8], xmm3
loop16_32: movdqu [rcx], xmm0
movdqu -16[rcx + r8], xmm1
ret
loop8_16:
cmp r8, 8 ; save 8 to 16 bytes src
jb loop4_7
mov r9, [rdx]
mov r10, -8[rdx+r8]
mov [rcx], r9
mov -8[rcx+r8], r10
ret
loop4_7:
cmp r8, 4 ;save 4 to 7 bytes src
jb loop1_3
mov r9d, [rdx]
mov r10d, -4[rdx + r8]
mov [rcx], r9d
mov -4[rcx + r8], r10d
ret
loop1_3:
or r8, r8 ;save 1 to 4 bytes src
jz loop_end
mov r9b, [rdx] ;save the first byte
or r8b, 2 ;save the two byte
jz loop0_1
mov r10w, -2[rdx + r8]
mov -2[rcx + r8], r10w
loop0_1:
mov [rcx], r9b
loop_end:
ret
loop256:
mov r9, r8
shr r9, 8
loop256_start:
movdqu xmm0, [rdx]
movdqu xmm1, [rdx+16]
movdqu xmm2, [rdx+32]
movdqu xmm3, [rdx+48]
movdqu xmm4, [rdx+64]
movdqu xmm5, [rdx+80]
movdqu xmm6, [rdx+96]
movdqu xmm7, [rdx+112]
movdqu xmm8, [rdx+128]
movdqu xmm9, [rdx+144]
movdqu xmm10, [rdx+160]
movdqu xmm11, [rdx+176]
movdqu xmm12, [rdx+192]
movdqu xmm13, [rdx+208]
movdqu xmm14, [rdx+224]
movdqu xmm15, [rdx+240]
movdqu [rcx], xmm0
movdqu [rcx+16], xmm1
movdqu [rcx+32], xmm2
movdqu [rcx+48], xmm3
movdqu [rcx+64], xmm4
movdqu [rcx+80], xmm5
movdqu [rcx+96], xmm6
movdqu [rcx+112], xmm7
movdqu [rcx+128], xmm8
movdqu [rcx+144], xmm9
movdqu [rcx+160], xmm10
movdqu [rcx+176], xmm11
movdqu [rcx+192], xmm12
movdqu [rcx+208], xmm13
movdqu [rcx+224], xmm14
movdqu [rcx+240], xmm15
add rdx, 256
add rcx, 256
dec r9
jnz loop256_start
and r8, 0ffh
jmp cpystart128
loop128:
mov r9, r8
shr r9, 7
loop128_start:
movdqu xmm0, [rdx]
movdqu xmm1, [rdx+16]
movdqu xmm2, [rdx+32]
movdqu xmm3, [rdx+48]
movdqu xmm4, [rdx+64]
movdqu xmm5, [rdx+80]
movdqu xmm6, [rdx+96]
movdqu xmm7, [rdx+112]
movdqu [rcx], xmm0
movdqu [rcx+16], xmm1
movdqu [rcx+32], xmm2
movdqu [rcx+48], xmm3
movdqu [rcx+64], xmm4
movdqu [rcx+80], xmm5
movdqu [rcx+96], xmm6
movdqu [rcx+112], xmm7
add rdx, 128
add rcx, 128
;dec r9
;jnz loop128_start
and r8, 07fh
jmp cpystart64
loop64: mov r9, r8
shr r9, 6
loop64_start:
movdqu xmm0, [rdx]
movdqu xmm1, [rdx+16]
movdqu xmm2, [rdx+32]
movdqu xmm3, [rdx+48]
movdqu [rcx], xmm0
movdqu [rcx+16], xmm1
movdqu [rcx+32], xmm2
movdqu [rcx+48], xmm3
add rdx, 64
add rcx, 64
;dec r9
;jnz loop64_start
and r8, 03fh
jmp cpystart32